01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Vadim L. Bogdanov
19: * @version $Revision$
20: */package javax.swing.plaf.basic;
21:
22: import java.awt.Dimension;
23: import javax.swing.JToolBar;
24: import javax.swing.SwingTestCase;
25: import javax.swing.UIManager;
26: import javax.swing.plaf.ComponentUI;
27:
28: public class BasicToolBarSeparatorUITest extends SwingTestCase {
29: private JToolBar.Separator separator;
30:
31: private BasicToolBarSeparatorUI ui;
32:
33: @Override
34: protected void setUp() throws Exception {
35: super .setUp();
36: separator = new JToolBar.Separator();
37: ui = new BasicToolBarSeparatorUI();
38: separator.setUI(ui);
39: }
40:
41: @Override
42: protected void tearDown() throws Exception {
43: super .tearDown();
44: }
45:
46: public BasicToolBarSeparatorUITest(final String name) {
47: super (name);
48: }
49:
50: public void testPaint() {
51: // Note: painting code, cannot test
52: }
53:
54: public void testGetPreferredSize() {
55: assertEquals(UIManager.getDimension("ToolBar.separatorSize"),
56: ui.getPreferredSize(separator));
57: ui = new BasicToolBarSeparatorUI();
58: assertEquals(UIManager.getDimension("ToolBar.separatorSize"),
59: ui.getPreferredSize(separator));
60: }
61:
62: public void testCreateUI() {
63: ComponentUI ui1 = BasicToolBarSeparatorUI.createUI(separator);
64: assertTrue(ui1 instanceof BasicToolBarSeparatorUI);
65: ComponentUI ui2 = BasicToolBarSeparatorUI.createUI(separator);
66: assertNotSame(ui1, ui2);
67: }
68:
69: public void testInstallDefaults() {
70: ui.installDefaults(separator);
71: assertNull(separator.getBackground());
72: assertNull(separator.getForeground());
73: assertEquals(UIManager.getDimension("ToolBar.separatorSize"),
74: separator.getSeparatorSize());
75: Dimension size = new Dimension(1, 2);
76: separator.setSeparatorSize(size);
77: ui.installDefaults(separator);
78: assertEquals(size, separator.getSeparatorSize());
79: }
80:
81: public void testBasicToolBarSeparatorUI() {
82: // nothing to test
83: }
84: }
|