001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Alexander T. Simbirtsev
019: * @version $Revision$
020: * Created on 21.12.2004
021:
022: */package javax.swing;
023:
024: import java.awt.Component;
025: import java.awt.Dimension;
026: import javax.accessibility.AccessibleContext;
027:
028: public class Box_FillerTest extends SwingTestCase {
029: public static void main(final String[] args) {
030: junit.textui.TestRunner.run(Box_FillerTest.class);
031: }
032:
033: /*
034: * @see TestCase#setUp()
035: */
036: @Override
037: protected void setUp() throws Exception {
038: super .setUp();
039: }
040:
041: public void testFiller() {
042: Dimension minimumSize = new Dimension(100, 100);
043: Dimension preferredSize = new Dimension(200, 200);
044: Dimension maximumSize = new Dimension(300, 300);
045: Box.Filler filler = new Box.Filler(minimumSize, preferredSize,
046: maximumSize);
047: assertEquals("Minimum size initialized correctly ",
048: minimumSize, filler.getMinimumSize());
049: assertEquals("Preferred size initialized correctly ",
050: preferredSize, filler.getPreferredSize());
051: assertEquals("Maximum size initialized correctly ",
052: maximumSize, filler.getMaximumSize());
053: assertFalse("Opaqueness initialized correctly", filler
054: .isOpaque());
055: filler = new Box.Filler(null, null, null);
056: assertNull("Minimum size initialized correctly ", filler
057: .getMinimumSize());
058: assertNull("Preferred size initialized correctly ", filler
059: .getPreferredSize());
060: assertNull("Maximum size initialized correctly ", filler
061: .getMaximumSize());
062: assertFalse("Opaqueness initialized correctly", filler
063: .isOpaque());
064: }
065:
066: /*
067: * Class under test for Dimension getMinimumSize()
068: */
069: public void testGetMinimumSize() {
070: Dimension initMinimumSize = new Dimension(100, 100);
071: Dimension initPreferredSize = new Dimension(200, 200);
072: Dimension initMaximumSize = new Dimension(300, 300);
073: Box.Filler filler = new Box.Filler(initMinimumSize,
074: initPreferredSize, initMaximumSize);
075: assertEquals("Minimum size initialized correctly ",
076: initMinimumSize, filler.getMinimumSize());
077: Dimension minimumSize = new Dimension(1000, 1000);
078: filler.setMinimumSize(minimumSize);
079: assertEquals("Minimum size is unchangeable", initMinimumSize,
080: filler.getMinimumSize());
081: filler.setMinimumSize(null);
082: assertEquals("Minimum size is unchangeable ", initMinimumSize,
083: filler.getMinimumSize());
084: }
085:
086: /*
087: * Class under test for Dimension getMaximumSize()
088: */
089: public void testGetMaximumSize() {
090: Dimension initMinimumSize = new Dimension(100, 100);
091: Dimension initPreferredSize = new Dimension(200, 200);
092: Dimension initMaximumSize = new Dimension(300, 300);
093: Box.Filler filler = new Box.Filler(initMinimumSize,
094: initPreferredSize, initMaximumSize);
095: assertEquals("Maximum size initialized correctly ",
096: initMaximumSize, filler.getMaximumSize());
097: Dimension maximumSize = new Dimension(1000, 1000);
098: filler.setMaximumSize(maximumSize);
099: assertEquals("Minimum size is unchangeable", initMaximumSize,
100: filler.getMaximumSize());
101: filler.setMaximumSize(null);
102: assertEquals("Minimum size is unchangeable ", initMaximumSize,
103: filler.getMaximumSize());
104: }
105:
106: /*
107: * Class under test for Dimension getPreferredSize()
108: */
109: public void testGetPreferredSize() {
110: Dimension initMinimumSize = new Dimension(100, 100);
111: Dimension initPreferredSize = new Dimension(200, 200);
112: Dimension initMaximumSize = new Dimension(300, 300);
113: Box.Filler filler = new Box.Filler(initMinimumSize,
114: initPreferredSize, initMaximumSize);
115: assertEquals("Preferred size initialized correctly ",
116: initPreferredSize, filler.getPreferredSize());
117: Dimension preferredSize = new Dimension(1000, 1000);
118: filler.setPreferredSize(preferredSize);
119: assertEquals("Minimum size is unchangeable", initPreferredSize,
120: filler.getPreferredSize());
121: filler.setPreferredSize(null);
122: assertEquals("Minimum size is unchangeable ",
123: initPreferredSize, filler.getPreferredSize());
124: }
125:
126: /*
127: * Class under test for AccessibleContext getAccessibleContext()
128: */
129: public void testGetAccessibleContext() {
130: Component filler = Box.createVerticalGlue();
131: AccessibleContext accessible = filler.getAccessibleContext();
132: assertEquals("Accessible context is correct ",
133: Box.Filler.AccessibleBoxFiller.class, accessible
134: .getClass());
135: }
136:
137: public void testChangeShape() {
138: Dimension minimumSize = new Dimension(100, 100);
139: Dimension preferredSize = new Dimension(200, 200);
140: Dimension maximumSize = new Dimension(300, 300);
141: Box.Filler filler = new Box.Filler(minimumSize, preferredSize,
142: maximumSize);
143: assertEquals("Minimum size initialized correctly ",
144: minimumSize, filler.getMinimumSize());
145: assertEquals("Preferred size initialized correctly ",
146: preferredSize, filler.getPreferredSize());
147: assertEquals("Maximum size initialized correctly ",
148: maximumSize, filler.getMaximumSize());
149: minimumSize = new Dimension(110, 110);
150: preferredSize = new Dimension(220, 220);
151: maximumSize = new Dimension(330, 330);
152: filler.changeShape(minimumSize, preferredSize, maximumSize);
153: assertEquals("Minimum size's changed correctly ", minimumSize,
154: filler.getMinimumSize());
155: assertEquals("Preferred size's changed correctly ",
156: preferredSize, filler.getPreferredSize());
157: assertEquals("Maximum size's changed correctly ", maximumSize,
158: filler.getMaximumSize());
159: }
160: }
|