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 Dmitry A. Durnev
019: * @version $Revision$
020: */package java.awt;
021:
022: import junit.framework.TestCase;
023:
024: public class BorderLayoutRTest extends TestCase {
025: Container emptyContainer;
026: Dimension defSize;
027: BorderLayout layout;
028: private Dimension maxSize;
029:
030: @Override
031: protected void setUp() throws Exception {
032: super .setUp();
033: emptyContainer = new Container();
034: defSize = new Dimension();
035: maxSize = new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
036: layout = new BorderLayout();
037: }
038:
039: public final void testGetLayoutAlignmentX1() {
040: layout.getLayoutAlignmentX(null);
041: }
042:
043: public final void testGetLayoutAlignmentX2() {
044: layout.getLayoutAlignmentX(emptyContainer);
045: }
046:
047: public final void testGetLayoutAlignmentY1() {
048: layout.getLayoutAlignmentY(null);
049: }
050:
051: public final void testGetLayoutAlignmentY2() {
052: layout.getLayoutAlignmentY(emptyContainer);
053: }
054:
055: public final void testInvalidateLayout1() {
056: layout.invalidateLayout(null);
057: }
058:
059: public final void testInvalidateLayout2() {
060: layout.invalidateLayout(emptyContainer);
061: }
062:
063: public final void testMaximumLayoutSize1() {
064: assertEquals(maxSize, layout.maximumLayoutSize(null));
065: }
066:
067: public final void testMaximumLayoutSize2() {
068: assertEquals(maxSize, layout.maximumLayoutSize(emptyContainer));
069: }
070:
071: public final void testMinimumLayoutSize() {
072: assertEquals(defSize, layout.minimumLayoutSize(emptyContainer));
073: }
074:
075: public final void testPreferredLayoutSize() {
076: assertEquals(defSize, layout
077: .preferredLayoutSize(emptyContainer));
078: }
079:
080: /**
081: * Regression for HARMONY-4085
082: */
083: public final void testHarmony4085() {
084: final Frame f = new Frame();
085: final boolean[] isInvoked = new boolean[4];
086:
087: f.add(new Component() {
088: @Override
089: public void setSize(int width, int height) {
090: isInvoked[0] = true;
091: super .setSize(width, height);
092: }
093: }, BorderLayout.EAST);
094: f.add(new Component() {
095: @Override
096: public void setSize(int width, int height) {
097: isInvoked[1] = true;
098: super .setSize(width, height);
099: }
100: }, BorderLayout.WEST);
101: f.add(new Component() {
102: @Override
103: public void setSize(int width, int height) {
104: isInvoked[2] = true;
105: super .setSize(width, height);
106: }
107: }, BorderLayout.NORTH);
108: f.add(new Component() {
109: @Override
110: public void setSize(int width, int height) {
111: isInvoked[3] = true;
112: super .setSize(width, height);
113: }
114: }, BorderLayout.SOUTH);
115:
116: f.setSize(100, 100);
117: f.setVisible(true);
118: f.dispose();
119:
120: assertTrue(isInvoked[0]);
121: assertTrue(isInvoked[1]);
122: assertTrue(isInvoked[2]);
123: assertTrue(isInvoked[3]);
124: }
125: }
|