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 Sergey Burlak
19: * @version $Revision$
20: */package javax.swing.plaf.metal;
21:
22: import java.awt.Dimension;
23: import javax.swing.JScrollBar;
24: import javax.swing.SwingConstants;
25: import javax.swing.SwingTestCase;
26:
27: public class MetalScrollBarUITest extends SwingTestCase {
28: private MetalScrollBarUI barUI;
29:
30: private JScrollBar bar;
31:
32: @Override
33: protected void setUp() throws Exception {
34: bar = new JScrollBar();
35: barUI = new MetalScrollBarUI();
36: bar.setUI(barUI);
37: }
38:
39: @Override
40: protected void tearDown() throws Exception {
41: barUI = null;
42: bar = null;
43: }
44:
45: public void testGetPreferredSize() throws Exception {
46: bar.getLayout().layoutContainer(bar);
47: assertEquals(new Dimension(17, 34), barUI
48: .getPreferredSize(null));
49: assertEquals(new Dimension(17, 16), barUI.increaseButton
50: .getPreferredSize());
51: assertEquals(new Dimension(17, 16), barUI.decreaseButton
52: .getPreferredSize());
53: }
54:
55: public void testCreateButtons() throws Exception {
56: assertNotNull(barUI.increaseButton);
57: assertNotNull(barUI.decreaseButton);
58: assertFalse(barUI.increaseButton == barUI
59: .createIncreaseButton(SwingConstants.HORIZONTAL));
60: assertFalse(barUI.decreaseButton == barUI
61: .createDecreaseButton(SwingConstants.HORIZONTAL));
62: }
63:
64: public void testCreateUI() throws Exception {
65: assertFalse(MetalScrollBarUI.createUI(bar) == MetalScrollBarUI
66: .createUI(bar));
67: }
68:
69: public void testCreatePropertyChangeListener() throws Exception {
70: assertNotNull(barUI.createPropertyChangeListener());
71: assertFalse(barUI.createPropertyChangeListener() == barUI
72: .createPropertyChangeListener());
73: }
74: }
|