You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/11/26 01:04:16 UTC
svn commit: r479240 [4/28] -
/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BorderFactoryTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BorderFactoryTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BorderFactoryTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BorderFactoryTest.java Sat Nov 25 16:04:10 2006
@@ -26,7 +26,6 @@
import java.awt.Font;
import java.awt.Insets;
import java.awt.image.BufferedImage;
-
import javax.swing.border.BevelBorder;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
@@ -37,49 +36,45 @@
import javax.swing.border.TitledBorder;
public class BorderFactoryTest extends SwingTestCase {
-
- public static void main(final String[] args) {
- junit.textui.TestRunner.run(BorderFactoryTest.class);
- }
-
- /*
- */
public void testStaticVariablesInitialization() {
assertTrue("Shared values are initialized", BorderFactory.emptyBorder != null);
assertTrue("Shared values are initialized", BorderFactory.sharedEtchedBorder != null);
assertTrue("Shared values are initialized", BorderFactory.sharedLoweredBevel != null);
assertTrue("Shared values are initialized", BorderFactory.sharedRaisedBevel != null);
-
- EmptyBorder emptyBorder = (EmptyBorder)BorderFactory.emptyBorder;
+ EmptyBorder emptyBorder = (EmptyBorder) BorderFactory.emptyBorder;
Insets insets = emptyBorder.getBorderInsets();
assertEquals(insets, new Insets(0, 0, 0, 0));
-
int etchType = EtchedBorder.LOWERED;
Color shadowColor = null;
Color highlightedColor = null;
-
- Border border = (EtchedBorder)BorderFactory.sharedEtchedBorder;
- assertEquals("Shadow color coinsides", shadowColor, ((EtchedBorder)border).getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, ((EtchedBorder)border).getHighlightColor());
- assertEquals("Etch type coinsides", etchType, ((EtchedBorder)border).getEtchType());
-
+ Border border = BorderFactory.sharedEtchedBorder;
+ assertEquals("Shadow color coinsides", shadowColor, ((EtchedBorder) border)
+ .getShadowColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, ((EtchedBorder) border)
+ .getHighlightColor());
+ assertEquals("Etch type coinsides", etchType, ((EtchedBorder) border).getEtchType());
int bevelType = BevelBorder.LOWERED;
-
- border = (BevelBorder)BorderFactory.sharedLoweredBevel;
- assertEquals("highlightOuterColor coinsides", highlightedColor, ((BevelBorder)border).getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightedColor, ((BevelBorder)border).getHighlightInnerColor());
- assertEquals("shadowOuterColor coinsides", shadowColor, ((BevelBorder)border).getShadowOuterColor());
- assertEquals("shadowInnerColor coinsides", shadowColor, ((BevelBorder)border).getShadowInnerColor());
- assertEquals("Bevel type coinsides", bevelType, ((BevelBorder)border).getBevelType());
-
+ border = BorderFactory.sharedLoweredBevel;
+ assertEquals("highlightOuterColor coinsides", highlightedColor, ((BevelBorder) border)
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightedColor, ((BevelBorder) border)
+ .getHighlightInnerColor());
+ assertEquals("shadowOuterColor coinsides", shadowColor, ((BevelBorder) border)
+ .getShadowOuterColor());
+ assertEquals("shadowInnerColor coinsides", shadowColor, ((BevelBorder) border)
+ .getShadowInnerColor());
+ assertEquals("Bevel type coinsides", bevelType, ((BevelBorder) border).getBevelType());
bevelType = BevelBorder.RAISED;
-
- border = (BevelBorder)BorderFactory.sharedRaisedBevel;
- assertEquals("highlightOuterColor coinsides", highlightedColor, ((BevelBorder)border).getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightedColor, ((BevelBorder)border).getHighlightInnerColor());
- assertEquals("shadowOuterColor coinsides", shadowColor, ((BevelBorder)border).getShadowOuterColor());
- assertEquals("shadowInnerColor coinsides", shadowColor, ((BevelBorder)border).getShadowInnerColor());
- assertEquals("Bevel type coinsides", bevelType, ((BevelBorder)border).getBevelType());
+ border = BorderFactory.sharedRaisedBevel;
+ assertEquals("highlightOuterColor coinsides", highlightedColor, ((BevelBorder) border)
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightedColor, ((BevelBorder) border)
+ .getHighlightInnerColor());
+ assertEquals("shadowOuterColor coinsides", shadowColor, ((BevelBorder) border)
+ .getShadowOuterColor());
+ assertEquals("shadowInnerColor coinsides", shadowColor, ((BevelBorder) border)
+ .getShadowInnerColor());
+ assertEquals("Bevel type coinsides", bevelType, ((BevelBorder) border).getBevelType());
}
/*
@@ -98,35 +93,27 @@
int just2 = 2;
int pos1 = 1;
int pos2 = 2;
-
- TitledBorder border1 = (TitledBorder)BorderFactory.createTitledBorder(border3, string1, just1, pos1, font1, color1);
- TitledBorder border2 = (TitledBorder)BorderFactory.createTitledBorder(border4, string2, just2, pos2, font2, color2);
-
+ TitledBorder border1 = BorderFactory.createTitledBorder(border3, string1, just1, pos1,
+ font1, color1);
+ TitledBorder border2 = BorderFactory.createTitledBorder(border4, string2, just2, pos2,
+ font2, color2);
assertEquals("title field initialized correctly ", string1, border1.getTitle());
- assertEquals("border field initialized correctly ",
- border3,
- border1.getBorder());
- assertEquals("color field initialized correctly ",
- color1,
- border1.getTitleColor());
- assertEquals("font field initialized correctly ",
- font1,
- border1.getTitleFont());
+ assertEquals("border field initialized correctly ", border3, border1.getBorder());
+ assertEquals("color field initialized correctly ", color1, border1.getTitleColor());
+ assertEquals("font field initialized correctly ", font1, border1.getTitleFont());
assertEquals("position field initialized correctly ", pos1, border1.getTitlePosition());
- assertEquals("justification field initialized correctly ", just1, border1.getTitleJustification());
-
+ assertEquals("justification field initialized correctly ", just1, border1
+ .getTitleJustification());
assertEquals("title field initialized correctly ", string2, border2.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border2.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border2.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border2.getTitleFont());
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border2.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border2.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border2.getTitleFont());
assertEquals("position field initialized correctly ", pos2, border2.getTitlePosition());
- assertEquals("justification field initialized correctly ", just2, border2.getTitleJustification());
+ assertEquals("justification field initialized correctly ", just2, border2
+ .getTitleJustification());
}
/*
@@ -143,35 +130,28 @@
int just2 = 2;
int pos1 = 1;
int pos2 = 2;
-
- TitledBorder border1 = (TitledBorder)BorderFactory.createTitledBorder(border3, string1, just1, pos1, font1);
- TitledBorder border2 = (TitledBorder)BorderFactory.createTitledBorder(border4, string2, just2, pos2, font2);
-
+ TitledBorder border1 = BorderFactory.createTitledBorder(border3, string1, just1, pos1,
+ font1);
+ TitledBorder border2 = BorderFactory.createTitledBorder(border4, string2, just2, pos2,
+ font2);
assertEquals("title field initialized correctly ", string1, border1.getTitle());
- assertEquals("border field initialized correctly ",
- border3,
- border1.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border1.getTitleColor());
- assertEquals("font field initialized correctly ",
- font1,
- border1.getTitleFont());
+ assertEquals("border field initialized correctly ", border3, border1.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border1.getTitleColor());
+ assertEquals("font field initialized correctly ", font1, border1.getTitleFont());
assertEquals("position field initialized correctly ", pos1, border1.getTitlePosition());
- assertEquals("justification field initialized correctly ", just1, border1.getTitleJustification());
-
+ assertEquals("justification field initialized correctly ", just1, border1
+ .getTitleJustification());
assertEquals("title field initialized correctly ", string2, border2.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border2.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border2.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border2.getTitleFont());
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border2.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border2.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border2.getTitleFont());
assertEquals("position field initialized correctly ", pos2, border2.getTitlePosition());
- assertEquals("justification field initialized correctly ", just2, border2.getTitleJustification());
+ assertEquals("justification field initialized correctly ", just2, border2
+ .getTitleJustification());
}
/*
@@ -186,35 +166,27 @@
int just2 = 2;
int pos1 = 1;
int pos2 = 2;
-
- TitledBorder border1 = (TitledBorder)BorderFactory.createTitledBorder(border3, string1, just1, pos1);
- TitledBorder border2 = (TitledBorder)BorderFactory.createTitledBorder(border4, string2, just2, pos2);
-
+ TitledBorder border1 = BorderFactory.createTitledBorder(border3, string1, just1, pos1);
+ TitledBorder border2 = BorderFactory.createTitledBorder(border4, string2, just2, pos2);
assertEquals("title field initialized correctly ", string1, border1.getTitle());
- assertEquals("border field initialized correctly ",
- border3,
- border1.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border1.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border1.getTitleFont());
+ assertEquals("border field initialized correctly ", border3, border1.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border1.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border1.getTitleFont());
assertEquals("position field initialized correctly ", pos1, border1.getTitlePosition());
- assertEquals("justification field initialized correctly ", just1, border1.getTitleJustification());
-
+ assertEquals("justification field initialized correctly ", just1, border1
+ .getTitleJustification());
assertEquals("title field initialized correctly ", string2, border2.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border2.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border2.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border2.getTitleFont());
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border2.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border2.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border2.getTitleFont());
assertEquals("position field initialized correctly ", pos2, border2.getTitlePosition());
- assertEquals("justification field initialized correctly ", just2, border2.getTitleJustification());
+ assertEquals("justification field initialized correctly ", just2, border2
+ .getTitleJustification());
}
/*
@@ -225,34 +197,29 @@
String string2 = null;
Border border3 = new EmptyBorder(1, 1, 1, 1);
Border border4 = null;
- TitledBorder border1 = (TitledBorder)BorderFactory.createTitledBorder(border3, string1);
- TitledBorder border2 = (TitledBorder)BorderFactory.createTitledBorder(border4, string2);
-
+ TitledBorder border1 = BorderFactory.createTitledBorder(border3, string1);
+ TitledBorder border2 = BorderFactory.createTitledBorder(border4, string2);
assertEquals("title field initialized correctly ", string1, border1.getTitle());
- assertEquals("border field initialized correctly ",
- border3,
- border1.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border1.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border1.getTitleFont());
- assertEquals("position field initialized correctly ", TitledBorder.TOP, border1.getTitlePosition());
- assertEquals("justification field initialized correctly ", TitledBorder.LEADING, border1.getTitleJustification());
-
+ assertEquals("border field initialized correctly ", border3, border1.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border1.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border1.getTitleFont());
+ assertEquals("position field initialized correctly ", TitledBorder.TOP, border1
+ .getTitlePosition());
+ assertEquals("justification field initialized correctly ", TitledBorder.LEADING,
+ border1.getTitleJustification());
assertEquals("title field initialized correctly ", string2, border2.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border2.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border2.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border2.getTitleFont());
- assertEquals("position field initialized correctly ", TitledBorder.TOP, border2.getTitlePosition());
- assertEquals("justification field initialized correctly ", TitledBorder.LEADING, border2.getTitleJustification());
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border2.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border2.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border2.getTitleFont());
+ assertEquals("position field initialized correctly ", TitledBorder.TOP, border2
+ .getTitlePosition());
+ assertEquals("justification field initialized correctly ", TitledBorder.LEADING,
+ border2.getTitleJustification());
}
/*
@@ -262,30 +229,18 @@
LineBorder border1 = new LineBorder(Color.red, 33, false);
LineBorder border2 = new LineBorder(Color.red, 33, true);
EmptyBorder border3 = new EmptyBorder(1, 1, 1, 1);
-
- CompoundBorder border4 = (CompoundBorder)BorderFactory.createCompoundBorder(border1, border2);
- CompoundBorder border5 = (CompoundBorder)BorderFactory.createCompoundBorder(border2, border3);
- CompoundBorder border7 = (CompoundBorder)BorderFactory.createCompoundBorder(border2, null);
- CompoundBorder border8 = (CompoundBorder)BorderFactory.createCompoundBorder(null, border3);
-
- assertEquals("border fields coinsides", border1,
- border4.getOutsideBorder());
- assertEquals("border fields coinsides", border2,
- border4.getInsideBorder());
-
- assertEquals("border fields coinsides", border2,
- border5.getOutsideBorder());
- assertEquals("border fields coinsides", border3,
- border5.getInsideBorder());
-
- assertEquals("border fields coinsides", border2,
- border7.getOutsideBorder());
+ CompoundBorder border4 = BorderFactory.createCompoundBorder(border1, border2);
+ CompoundBorder border5 = BorderFactory.createCompoundBorder(border2, border3);
+ CompoundBorder border7 = BorderFactory.createCompoundBorder(border2, null);
+ CompoundBorder border8 = BorderFactory.createCompoundBorder(null, border3);
+ assertEquals("border fields coinsides", border1, border4.getOutsideBorder());
+ assertEquals("border fields coinsides", border2, border4.getInsideBorder());
+ assertEquals("border fields coinsides", border2, border5.getOutsideBorder());
+ assertEquals("border fields coinsides", border3, border5.getInsideBorder());
+ assertEquals("border fields coinsides", border2, border7.getOutsideBorder());
assertNull("border fields coinsides", border7.getInsideBorder());
-
assertNull("border fields coinsides", border8.getOutsideBorder());
-
- assertEquals("border fields coinsides", border3,
- border8.getInsideBorder());
+ assertEquals("border fields coinsides", border3, border8.getInsideBorder());
}
/*
@@ -294,34 +249,29 @@
public void testCreateTitledBorderBorder() {
Border border3 = new EmptyBorder(1, 1, 1, 1);
Border border4 = null;
- TitledBorder border1 = (TitledBorder)BorderFactory.createTitledBorder(border3);
- TitledBorder border2 = (TitledBorder)BorderFactory.createTitledBorder(border4);
-
+ TitledBorder border1 = BorderFactory.createTitledBorder(border3);
+ TitledBorder border2 = BorderFactory.createTitledBorder(border4);
assertEquals("title field initialized correctly ", "", border1.getTitle());
- assertEquals("border field initialized correctly ",
- border3,
- border1.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border1.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border1.getTitleFont());
- assertEquals("position field initialized correctly ", TitledBorder.TOP, border1.getTitlePosition());
- assertEquals("justification field initialized correctly ", TitledBorder.LEADING, border1.getTitleJustification());
-
+ assertEquals("border field initialized correctly ", border3, border1.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border1.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border1.getTitleFont());
+ assertEquals("position field initialized correctly ", TitledBorder.TOP, border1
+ .getTitlePosition());
+ assertEquals("justification field initialized correctly ", TitledBorder.LEADING,
+ border1.getTitleJustification());
assertEquals("title field initialized correctly ", "", border2.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border2.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border2.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border2.getTitleFont());
- assertEquals("position field initialized correctly ", TitledBorder.TOP, border2.getTitlePosition());
- assertEquals("justification field initialized correctly ", TitledBorder.LEADING, border2.getTitleJustification());
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border2.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border2.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border2.getTitleFont());
+ assertEquals("position field initialized correctly ", TitledBorder.TOP, border2
+ .getTitlePosition());
+ assertEquals("justification field initialized correctly ", TitledBorder.LEADING,
+ border2.getTitleJustification());
}
/*
@@ -330,34 +280,30 @@
public void testCreateTitledBorderString() {
String string1 = "string1";
String string2 = null;
- TitledBorder border1 = (TitledBorder)BorderFactory.createTitledBorder(string1);
- TitledBorder border2 = (TitledBorder)BorderFactory.createTitledBorder(string2);
-
+ TitledBorder border1 = BorderFactory.createTitledBorder(string1);
+ TitledBorder border2 = BorderFactory.createTitledBorder(string2);
assertEquals("title field initialized correctly ", string1, border1.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border1.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border1.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border1.getTitleFont());
- assertEquals("position field initialized correctly ", TitledBorder.TOP, border1.getTitlePosition());
- assertEquals("justification field initialized correctly ", TitledBorder.LEADING, border1.getTitleJustification());
-
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border1.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border1.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border1.getTitleFont());
+ assertEquals("position field initialized correctly ", TitledBorder.TOP, border1
+ .getTitlePosition());
+ assertEquals("justification field initialized correctly ", TitledBorder.LEADING,
+ border1.getTitleJustification());
assertEquals("title field initialized correctly ", string2, border2.getTitle());
- assertEquals("border field initialized correctly ",
- UIManager.getDefaults().getBorder("TitledBorder.border"),
- border2.getBorder());
- assertEquals("color field initialized correctly ",
- UIManager.getDefaults().getColor("TitledBorder.titleColor"),
- border2.getTitleColor());
- assertEquals("font field initialized correctly ",
- UIManager.getDefaults().getFont("TitledBorder.font"),
- border2.getTitleFont());
- assertEquals("position field initialized correctly ", TitledBorder.TOP, border2.getTitlePosition());
- assertEquals("justification field initialized correctly ", TitledBorder.LEADING, border2.getTitleJustification());
+ assertEquals("border field initialized correctly ", UIManager.getDefaults().getBorder(
+ "TitledBorder.border"), border2.getBorder());
+ assertEquals("color field initialized correctly ", UIManager.getDefaults().getColor(
+ "TitledBorder.titleColor"), border2.getTitleColor());
+ assertEquals("font field initialized correctly ", UIManager.getDefaults().getFont(
+ "TitledBorder.font"), border2.getTitleFont());
+ assertEquals("position field initialized correctly ", TitledBorder.TOP, border2
+ .getTitlePosition());
+ assertEquals("justification field initialized correctly ", TitledBorder.LEADING,
+ border2.getTitleJustification());
}
/*
@@ -369,18 +315,15 @@
int left = 200;
int right = 300;
int bottom = 400;
- MatteBorder border = (MatteBorder)BorderFactory.createMatteBorder(top, left, bottom, right, icon);
-
+ MatteBorder border = BorderFactory.createMatteBorder(top, left, bottom, right, icon);
Insets insets = border.getBorderInsets(null);
assertEquals(insets, new Insets(top, left, bottom, right));
-
icon = new ImageIcon(new BufferedImage(30, 40, BufferedImage.TYPE_4BYTE_ABGR));
top = 200;
left = 300;
right = 200;
bottom = 300;
- border = (MatteBorder)BorderFactory.createMatteBorder(top, left, bottom, right, icon);
-
+ border = BorderFactory.createMatteBorder(top, left, bottom, right, icon);
Insets insets2 = border.getBorderInsets(null);
assertEquals(insets2, new Insets(top, left, bottom, right));
}
@@ -394,18 +337,15 @@
int left = 200;
int right = 300;
int bottom = 400;
- MatteBorder border = (MatteBorder)BorderFactory.createMatteBorder(top, left, bottom, right, color);
-
+ MatteBorder border = BorderFactory.createMatteBorder(top, left, bottom, right, color);
Insets insets = border.getBorderInsets(null);
assertEquals(insets, new Insets(top, left, bottom, right));
-
color = Color.YELLOW;
top = 200;
left = 300;
right = 200;
bottom = 300;
- border = (MatteBorder)BorderFactory.createMatteBorder(top, left, bottom, right, color);
-
+ border = BorderFactory.createMatteBorder(top, left, bottom, right, color);
Insets insets2 = border.getBorderInsets(null);
assertEquals(insets2, new Insets(top, left, bottom, right));
}
@@ -416,8 +356,7 @@
public void testCreateLineBorderColorint() {
int thickness = 11;
Color color = Color.yellow;
-
- LineBorder border = (LineBorder)BorderFactory.createLineBorder(color, thickness);
+ LineBorder border = (LineBorder) BorderFactory.createLineBorder(color, thickness);
assertEquals("Thickness coinsides", thickness, border.getThickness());
assertFalse("RoundedCorners coinsides", border.getRoundedCorners());
assertEquals("Colors coinsides", color, border.getLineColor());
@@ -430,8 +369,7 @@
int thickness = 1;
boolean roundedCorners = false;
Color color = Color.yellow;
-
- LineBorder border = (LineBorder)BorderFactory.createLineBorder(color);
+ LineBorder border = (LineBorder) BorderFactory.createLineBorder(color);
assertEquals("Thickness coinsides", thickness, border.getThickness());
assertEquals("RoundedCorners coinsides", roundedCorners, border.getRoundedCorners());
assertEquals("Colors coinsides", color, border.getLineColor());
@@ -441,7 +379,7 @@
* Class under test for CompoundBorder createCompoundBorder()
*/
public void testCreateCompoundBorder() {
- CompoundBorder border = (CompoundBorder)BorderFactory.createCompoundBorder();
+ CompoundBorder border = BorderFactory.createCompoundBorder();
assertNull(border.getInsideBorder());
assertNull(border.getOutsideBorder());
}
@@ -454,7 +392,8 @@
int left = 200;
int right = 300;
int bottom = 400;
- EmptyBorder border = (EmptyBorder)BorderFactory.createEmptyBorder(top, left, bottom, right);
+ EmptyBorder border = (EmptyBorder) BorderFactory.createEmptyBorder(top, left, bottom,
+ right);
Insets insets = border.getBorderInsets(null);
assertEquals(insets, new Insets(top, left, bottom, right));
}
@@ -466,18 +405,18 @@
int etchType = EtchedBorder.LOWERED;
Color shadowColor = Color.YELLOW;
Color highlightedColor = Color.RED;
-
- EtchedBorder border = (EtchedBorder)BorderFactory.createEtchedBorder(highlightedColor, shadowColor);
+ EtchedBorder border = (EtchedBorder) BorderFactory.createEtchedBorder(highlightedColor,
+ shadowColor);
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
-
shadowColor = Color.GREEN;
highlightedColor = Color.WHITE;
-
- border = (EtchedBorder)BorderFactory.createEtchedBorder(highlightedColor, shadowColor);
+ border = (EtchedBorder) BorderFactory.createEtchedBorder(highlightedColor, shadowColor);
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
}
@@ -488,19 +427,20 @@
int etchType = EtchedBorder.LOWERED;
Color shadowColor = Color.YELLOW;
Color highlightedColor = Color.RED;
-
- EtchedBorder border = (EtchedBorder)BorderFactory.createEtchedBorder(etchType, highlightedColor, shadowColor);
+ EtchedBorder border = (EtchedBorder) BorderFactory.createEtchedBorder(etchType,
+ highlightedColor, shadowColor);
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
-
etchType = EtchedBorder.RAISED;
shadowColor = Color.GREEN;
highlightedColor = Color.WHITE;
-
- border = (EtchedBorder)BorderFactory.createEtchedBorder(etchType, highlightedColor, shadowColor);
+ border = (EtchedBorder) BorderFactory.createEtchedBorder(etchType, highlightedColor,
+ shadowColor);
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
}
@@ -511,17 +451,16 @@
int etchType = EtchedBorder.LOWERED;
Color shadowColor = null;
Color highlightedColor = null;
-
- EtchedBorder border = (EtchedBorder)BorderFactory.createEtchedBorder(etchType);
+ EtchedBorder border = (EtchedBorder) BorderFactory.createEtchedBorder(etchType);
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
-
etchType = EtchedBorder.RAISED;
-
- border = (EtchedBorder)BorderFactory.createEtchedBorder(etchType);
+ border = (EtchedBorder) BorderFactory.createEtchedBorder(etchType);
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
}
@@ -532,10 +471,10 @@
int etchType = EtchedBorder.LOWERED;
Color shadowColor = null;
Color highlightedColor = null;
-
- EtchedBorder border = (EtchedBorder)BorderFactory.createEtchedBorder();
+ EtchedBorder border = (EtchedBorder) BorderFactory.createEtchedBorder();
assertEquals("Shadow color coinsides", shadowColor, border.getShadowColor());
- assertEquals("Highlighted color coinsides", highlightedColor, border.getHighlightColor());
+ assertEquals("Highlighted color coinsides", highlightedColor, border
+ .getHighlightColor());
assertEquals("Etch type coinsides", etchType, border.getEtchType());
}
@@ -548,25 +487,32 @@
Color highlightInnerColor = Color.YELLOW;
Color shadowOuterColor = Color.GREEN;
Color shadowInnerColor = Color.BLACK;
-
- BevelBorder border = (BevelBorder)BorderFactory.createBevelBorder(bevelType, highlightOuterColor, highlightInnerColor, shadowOuterColor, shadowInnerColor);
- assertEquals("highlightOuterColor coinsides", highlightOuterColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightInnerColor, border.getHighlightInnerColor());
- assertEquals("shadowOuterColor coinsides", shadowOuterColor, border.getShadowOuterColor());
- assertEquals("shadowInnerColor coinsides", shadowInnerColor, border.getShadowInnerColor());
+ BevelBorder border = (BevelBorder) BorderFactory.createBevelBorder(bevelType,
+ highlightOuterColor, highlightInnerColor, shadowOuterColor, shadowInnerColor);
+ assertEquals("highlightOuterColor coinsides", highlightOuterColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightInnerColor, border
+ .getHighlightInnerColor());
+ assertEquals("shadowOuterColor coinsides", shadowOuterColor, border
+ .getShadowOuterColor());
+ assertEquals("shadowInnerColor coinsides", shadowInnerColor, border
+ .getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
-
bevelType = BevelBorder.RAISED;
highlightOuterColor = Color.YELLOW;
highlightInnerColor = Color.RED;
shadowOuterColor = Color.WHITE;
shadowInnerColor = Color.BLUE;
-
- border = (BevelBorder)BorderFactory.createBevelBorder(bevelType, highlightOuterColor, highlightInnerColor, shadowOuterColor, shadowInnerColor);
- assertEquals("highlightOuterColor coinsides", highlightOuterColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightInnerColor, border.getHighlightInnerColor());
- assertEquals("shadowOuterColor coinsides", shadowOuterColor, border.getShadowOuterColor());
- assertEquals("shadowInnerColor coinsides", shadowInnerColor, border.getShadowInnerColor());
+ border = (BevelBorder) BorderFactory.createBevelBorder(bevelType, highlightOuterColor,
+ highlightInnerColor, shadowOuterColor, shadowInnerColor);
+ assertEquals("highlightOuterColor coinsides", highlightOuterColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightInnerColor, border
+ .getHighlightInnerColor());
+ assertEquals("shadowOuterColor coinsides", shadowOuterColor, border
+ .getShadowOuterColor());
+ assertEquals("shadowInnerColor coinsides", shadowInnerColor, border
+ .getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
}
@@ -577,21 +523,24 @@
int bevelType = BevelBorder.LOWERED;
Color highlightColor = Color.RED;
Color shadowColor = Color.GREEN;
-
- BevelBorder border = (BevelBorder)BorderFactory.createBevelBorder(bevelType, highlightColor, shadowColor);
- assertEquals("highlightOuterColor coinsides", highlightColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightColor, border.getHighlightInnerColor());
+ BevelBorder border = (BevelBorder) BorderFactory.createBevelBorder(bevelType,
+ highlightColor, shadowColor);
+ assertEquals("highlightOuterColor coinsides", highlightColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightColor, border
+ .getHighlightInnerColor());
assertEquals("shadowOuterColor coinsides", shadowColor, border.getShadowOuterColor());
assertEquals("shadowInnerColor coinsides", shadowColor, border.getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
-
bevelType = BevelBorder.RAISED;
highlightColor = Color.YELLOW;
shadowColor = Color.WHITE;
-
- border = (BevelBorder)BorderFactory.createBevelBorder(bevelType, highlightColor, shadowColor);
- assertEquals("highlightOuterColor coinsides", highlightColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightColor, border.getHighlightInnerColor());
+ border = (BevelBorder) BorderFactory.createBevelBorder(bevelType, highlightColor,
+ shadowColor);
+ assertEquals("highlightOuterColor coinsides", highlightColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightColor, border
+ .getHighlightInnerColor());
assertEquals("shadowOuterColor coinsides", shadowColor, border.getShadowOuterColor());
assertEquals("shadowInnerColor coinsides", shadowColor, border.getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
@@ -604,19 +553,20 @@
int bevelType = BevelBorder.LOWERED;
Color highlightColor = null;
Color shadowColor = null;
-
- BevelBorder border = (BevelBorder)BorderFactory.createBevelBorder(bevelType);
- assertEquals("highlightOuterColor coinsides", highlightColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightColor, border.getHighlightInnerColor());
+ BevelBorder border = (BevelBorder) BorderFactory.createBevelBorder(bevelType);
+ assertEquals("highlightOuterColor coinsides", highlightColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightColor, border
+ .getHighlightInnerColor());
assertEquals("shadowOuterColor coinsides", shadowColor, border.getShadowOuterColor());
assertEquals("shadowInnerColor coinsides", shadowColor, border.getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
-
bevelType = BevelBorder.RAISED;
-
- border = (BevelBorder)BorderFactory.createBevelBorder(bevelType);
- assertEquals("highlightOuterColor coinsides", highlightColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightColor, border.getHighlightInnerColor());
+ border = (BevelBorder) BorderFactory.createBevelBorder(bevelType);
+ assertEquals("highlightOuterColor coinsides", highlightColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightColor, border
+ .getHighlightInnerColor());
assertEquals("shadowOuterColor coinsides", shadowColor, border.getShadowOuterColor());
assertEquals("shadowInnerColor coinsides", shadowColor, border.getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
@@ -626,10 +576,11 @@
int bevelType = BevelBorder.RAISED;
Color highlightColor = null;
Color shadowColor = null;
-
- BevelBorder border = (BevelBorder)BorderFactory.createRaisedBevelBorder();
- assertEquals("highlightOuterColor coinsides", highlightColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightColor, border.getHighlightInnerColor());
+ BevelBorder border = (BevelBorder) BorderFactory.createRaisedBevelBorder();
+ assertEquals("highlightOuterColor coinsides", highlightColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightColor, border
+ .getHighlightInnerColor());
assertEquals("shadowOuterColor coinsides", shadowColor, border.getShadowOuterColor());
assertEquals("shadowInnerColor coinsides", shadowColor, border.getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
@@ -639,10 +590,11 @@
int bevelType = BevelBorder.LOWERED;
Color highlightColor = null;
Color shadowColor = null;
-
- BevelBorder border = (BevelBorder)BorderFactory.createLoweredBevelBorder();
- assertEquals("highlightOuterColor coinsides", highlightColor, border.getHighlightOuterColor());
- assertEquals("highlightInnerColor coinsides", highlightColor, border.getHighlightInnerColor());
+ BevelBorder border = (BevelBorder) BorderFactory.createLoweredBevelBorder();
+ assertEquals("highlightOuterColor coinsides", highlightColor, border
+ .getHighlightOuterColor());
+ assertEquals("highlightInnerColor coinsides", highlightColor, border
+ .getHighlightInnerColor());
assertEquals("shadowOuterColor coinsides", shadowColor, border.getShadowOuterColor());
assertEquals("shadowInnerColor coinsides", shadowColor, border.getShadowInnerColor());
assertEquals("Bevel type coinsides", bevelType, border.getBevelType());
@@ -656,5 +608,4 @@
Insets insets = border.getBorderInsets(null);
assertEquals(insets, new Insets(0, 0, 0, 0));
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutRTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutRTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutRTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutRTest.java Sat Nov 25 16:04:10 2006
@@ -21,17 +21,16 @@
package javax.swing;
import java.awt.Dimension;
-
import javax.swing.border.EmptyBorder;
public class BoxLayoutRTest extends SwingTestCase {
-
public void testLayoutContainer() {
- final JPanel panel1 = new JPanel();
+ final JPanel panel1 = new JPanel();
panel1.setBorder(new EmptyBorder(5, 5, 5, 5));
panel1.setLayout(new BoxLayout(panel1, BoxLayout.X_AXIS));
panel1.add(new JPanel());
panel1.add(new JTextField("AAAAAAAAA"));
- assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), panel1.getMaximumSize());
+ assertEquals(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE), panel1
+ .getMaximumSize());
}
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxLayoutTest.java Sat Nov 25 16:04:10 2006
@@ -31,11 +31,9 @@
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-
import javax.swing.border.EmptyBorder;
public class BoxLayoutTest extends SwingTestCase {
-
protected BoxLayout layout = null;
public void testBoxLayout() {
@@ -43,27 +41,25 @@
boolean thrown = false;
String text = null;
try {
- layout = new BoxLayout(container, BoxLayout.LINE_AXIS);
+ layout = new BoxLayout(container, BoxLayout.LINE_AXIS);
} catch (AWTError e) {
thrown = true;
}
assertFalse("No exception thrown", thrown);
-
thrown = false;
text = null;
try {
- layout = new BoxLayout(container, 300);
+ layout = new BoxLayout(container, 300);
} catch (AWTError e) {
thrown = true;
text = e.getMessage();
}
assertTrue("AWTError exception thrown", thrown);
assertEquals(text, "Invalid axis");
-
thrown = false;
text = null;
try {
- layout = new BoxLayout(null, BoxLayout.Y_AXIS);
+ layout = new BoxLayout(null, BoxLayout.Y_AXIS);
} catch (AWTError e) {
thrown = true;
}
@@ -95,17 +91,16 @@
component32.setPreferredSize(new Dimension(48, 26));
JComponent component42 = new JPanel();
component42.setPreferredSize(new Dimension(41, 26));
-
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component12);
container2.add(component22);
-
- assertEquals("1 Sizes coinside:", new Dimension(89, 26), layout1.preferredLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(62, 52), layout2.preferredLayoutSize(container2));
-
+ assertEquals("1 Sizes coinside:", new Dimension(89, 26), layout1
+ .preferredLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(62, 52), layout2
+ .preferredLayoutSize(container2));
component11.setPreferredSize(new Dimension(50, 50));
component21.setPreferredSize(new Dimension(70, 150));
component31.setPreferredSize(new Dimension(90, 120));
@@ -114,27 +109,30 @@
component22.setPreferredSize(new Dimension(70, 150));
component32.setPreferredSize(new Dimension(90, 120));
component42.setPreferredSize(new Dimension(80, 90));
-
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(120, 150), layout1.preferredLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(70, 200), layout2.preferredLayoutSize(container2));
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(120, 150), layout1
+ .preferredLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(70, 200), layout2
+ .preferredLayoutSize(container2));
container1.add(component31);
container2.add(component32);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(210, 150), layout1.preferredLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(90, 320), layout2.preferredLayoutSize(container2));
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(210, 150), layout1
+ .preferredLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(90, 320), layout2
+ .preferredLayoutSize(container2));
container1.add(component41);
container2.add(component42);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.setBorder(new EmptyBorder(20, 20, 20, 20));
container2.setBorder(new EmptyBorder(20, 20, 20, 20));
- assertEquals("1 Sizes coinside:", new Dimension(330, 190), layout1.preferredLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(130, 450), layout2.preferredLayoutSize(container2));
+ assertEquals("1 Sizes coinside:", new Dimension(330, 190), layout1
+ .preferredLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(130, 450), layout2
+ .preferredLayoutSize(container2));
}
public void testLayoutInvisibleChild() {
@@ -143,7 +141,7 @@
component1.setPreferredSize(new Dimension(41, 26));
component1.setVisible(false);
container1.add(component1);
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
assertEquals(new Dimension(), layout1.preferredLayoutSize(container1));
}
@@ -166,16 +164,16 @@
component32.setMinimumSize(new Dimension(48, 26));
JComponent component42 = new JPanel();
component42.setMinimumSize(new Dimension(41, 26));
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component12);
container2.add(component22);
-
- assertEquals("1 Sizes coinside:", new Dimension(89, 26), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(62, 52), layout2.minimumLayoutSize(container2));
-
+ assertEquals("1 Sizes coinside:", new Dimension(89, 26), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(62, 52), layout2
+ .minimumLayoutSize(container2));
component11.setMinimumSize(new Dimension(50, 50));
component21.setMinimumSize(new Dimension(70, 150));
component31.setMinimumSize(new Dimension(90, 120));
@@ -184,27 +182,30 @@
component22.setMinimumSize(new Dimension(70, 150));
component32.setMinimumSize(new Dimension(90, 120));
component42.setMinimumSize(new Dimension(80, 90));
-
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(120, 150), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(70, 200), layout2.minimumLayoutSize(container2));
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(120, 150), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(70, 200), layout2
+ .minimumLayoutSize(container2));
container1.add(component31);
container2.add(component32);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(210, 150), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(90, 320), layout2.minimumLayoutSize(container2));
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(210, 150), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(90, 320), layout2
+ .minimumLayoutSize(container2));
container1.add(component41);
container2.add(component42);
container1.setBorder(new EmptyBorder(20, 20, 20, 20));
container2.setBorder(new EmptyBorder(20, 20, 20, 20));
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(330, 190), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(130, 450), layout2.minimumLayoutSize(container2));
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(330, 190), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(130, 450), layout2
+ .minimumLayoutSize(container2));
}
public void testMaximumLayoutSize1() {
@@ -226,16 +227,16 @@
component32.setMaximumSize(new Dimension(48, 26));
JComponent component42 = new JPanel();
component42.setMaximumSize(new Dimension(41, 26));
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component12);
container2.add(component22);
-
- assertEquals("1 Sizes coinside:", new Dimension(89, 26), layout1.maximumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(62, 52), layout2.maximumLayoutSize(container2));
-
+ assertEquals("1 Sizes coinside:", new Dimension(89, 26), layout1
+ .maximumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(62, 52), layout2
+ .maximumLayoutSize(container2));
component11.setMaximumSize(new Dimension(50, 50));
component21.setMaximumSize(new Dimension(70, 150));
component31.setMaximumSize(new Dimension(90, 120));
@@ -244,27 +245,30 @@
component22.setMaximumSize(new Dimension(70, 150));
component32.setMaximumSize(new Dimension(90, 120));
component42.setMaximumSize(new Dimension(80, 90));
-
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(120, 150), layout1.maximumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(70, 200), layout2.maximumLayoutSize(container2));
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(120, 150), layout1
+ .maximumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(70, 200), layout2
+ .maximumLayoutSize(container2));
container1.add(component31);
container2.add(component32);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("1 Sizes coinside:", new Dimension(210, 150), layout1.maximumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(90, 320), layout2.maximumLayoutSize(container2));
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("1 Sizes coinside:", new Dimension(210, 150), layout1
+ .maximumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(90, 320), layout2
+ .maximumLayoutSize(container2));
container1.add(component41);
container2.add(component42);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.setBorder(new EmptyBorder(20, 20, 20, 20));
container2.setBorder(new EmptyBorder(20, 20, 20, 20));
- assertEquals("1 Sizes coinside:", new Dimension(330, 190), layout1.maximumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(130, 450), layout2.maximumLayoutSize(container2));
+ assertEquals("1 Sizes coinside:", new Dimension(330, 190), layout1
+ .maximumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(130, 450), layout2
+ .maximumLayoutSize(container2));
}
public void testMaximumLayoutSize2() {
@@ -274,15 +278,16 @@
JComponent component21 = new JPanel();
JComponent component12 = new JPanel();
JComponent component22 = new JPanel();
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component12);
container2.add(component22);
-
- assertEquals("Maximum size 1: ", new Dimension(2*Short.MAX_VALUE, Short.MAX_VALUE), layout1.maximumLayoutSize(container1));
- assertEquals("Maximum size 2: ", new Dimension(Short.MAX_VALUE, 2*Short.MAX_VALUE), layout2.maximumLayoutSize(container2));
+ assertEquals("Maximum size 1: ", new Dimension(2 * Short.MAX_VALUE, Short.MAX_VALUE),
+ layout1.maximumLayoutSize(container1));
+ assertEquals("Maximum size 2: ", new Dimension(Short.MAX_VALUE, 2 * Short.MAX_VALUE),
+ layout2.maximumLayoutSize(container2));
}
/*
@@ -309,28 +314,26 @@
component4.setMinimumSize(new Dimension(41, 26));
component4.setPreferredSize(new Dimension(41, 26));
component4.setMaximumSize(new Dimension(41, 26));
-
- BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
+ BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
container.setLayout(layout);
container.setBorder(new EmptyBorder(20, 20, 20, 20));
container.add(component1);
container.add(component2);
container.add(component3);
container.add(component4);
-
component1.setAlignmentX(0);
component2.setAlignmentX(0.2f);
component3.setAlignmentX(0.3f);
component4.setAlignmentX(1);
-
JFrame window2 = new JFrame();
window2.getContentPane().add(container);
window2.pack();
-
- assertEquals("Container's minimum requirements", new Dimension(143, 144), layout.minimumLayoutSize(container));
- assertEquals("Container's preferred requirements", new Dimension(143, 144), layout.preferredLayoutSize(container));
- assertEquals("Container's maximum requirements", new Dimension(143, 144), layout.maximumLayoutSize(container));
-
+ assertEquals("Container's minimum requirements", new Dimension(143, 144), layout
+ .minimumLayoutSize(container));
+ assertEquals("Container's preferred requirements", new Dimension(143, 144), layout
+ .preferredLayoutSize(container));
+ assertEquals("Container's maximum requirements", new Dimension(143, 144), layout
+ .maximumLayoutSize(container));
assertEquals("Component1 location ", new Point(61, 20), component1.getLocation());
assertEquals("Component2 location ", new Point(50, 46), component2.getLocation());
assertEquals("Component3 location ", new Point(47, 72), component3.getLocation());
@@ -356,7 +359,7 @@
component4.setMinimumSize(new Dimension(62, 26));
component4.setPreferredSize(new Dimension(62, 26));
component4.setMaximumSize(new Dimension(62, 26));
- BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+ BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
container.setLayout(layout);
container.setBorder(new EmptyBorder(20, 20, 20, 20));
container.add(component1);
@@ -371,19 +374,23 @@
component2.setAlignmentY(0.2f);
component3.setAlignmentY(0.3f);
component4.setAlignmentY(1);
-
JFrame window = new JFrame();
window.getContentPane().add(container);
window.pack();
-
- assertEquals("Container's minimum requirements", new Dimension(246, 92), layout.minimumLayoutSize(container));
- assertEquals("Container's preferred requirements", new Dimension(350, 280), layout.preferredLayoutSize(container));
- assertEquals("Container's maximum requirements", new Dimension(246, 92), layout.maximumLayoutSize(container));
-
- assertEquals("Component1 - Locations coinside:", new Point(20, 140), component1.getLocation());
- assertEquals("Component2 - Locations coinside:", new Point(61, 135), component2.getLocation());
- assertEquals("Component3 - Locations coinside:", new Point(109, 133), component3.getLocation());
- assertEquals("Component4 - Locations coinside:", new Point(164, 114), component4.getLocation());
+ assertEquals("Container's minimum requirements", new Dimension(246, 92), layout
+ .minimumLayoutSize(container));
+ assertEquals("Container's preferred requirements", new Dimension(350, 280), layout
+ .preferredLayoutSize(container));
+ assertEquals("Container's maximum requirements", new Dimension(246, 92), layout
+ .maximumLayoutSize(container));
+ assertEquals("Component1 - Locations coinside:", new Point(20, 140), component1
+ .getLocation());
+ assertEquals("Component2 - Locations coinside:", new Point(61, 135), component2
+ .getLocation());
+ assertEquals("Component3 - Locations coinside:", new Point(109, 133), component3
+ .getLocation());
+ assertEquals("Component4 - Locations coinside:", new Point(164, 114), component4
+ .getLocation());
window.dispose();
}
@@ -398,8 +405,8 @@
JComponent component22 = new JPanel();
JComponent component32 = new JPanel();
JComponent component42 = new JPanel();
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component21);
@@ -412,65 +419,61 @@
component22.setMinimumSize(new Dimension(70, 150));
component32.setMinimumSize(new Dimension(90, 120));
component42.setMinimumSize(new Dimension(80, 90));
-
- assertEquals("1 Sizes coinside:", new Dimension(50, 50), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(70, 300), layout2.minimumLayoutSize(container2));
-
+ assertEquals("1 Sizes coinside:", new Dimension(50, 50), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(70, 300), layout2
+ .minimumLayoutSize(container2));
container1.add(component31);
container2.add(component32);
layout1.invalidateLayout(container1);
layout2.invalidateLayout(container2);
- assertEquals("1 Sizes coinside:", new Dimension(140, 120), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(90, 420), layout2.minimumLayoutSize(container2));
-
+ assertEquals("1 Sizes coinside:", new Dimension(140, 120), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(90, 420), layout2
+ .minimumLayoutSize(container2));
container1.add(component41);
container2.add(component42);
layout1.invalidateLayout(container1);
layout2.invalidateLayout(container2);
- assertEquals("1 Sizes coinside:", new Dimension(220, 120), layout1.minimumLayoutSize(container1));
- assertEquals("2 Sizes coinside:", new Dimension(90, 510), layout2.minimumLayoutSize(container2));
+ assertEquals("1 Sizes coinside:", new Dimension(220, 120), layout1
+ .minimumLayoutSize(container1));
+ assertEquals("2 Sizes coinside:", new Dimension(90, 510), layout2
+ .minimumLayoutSize(container2));
}
// Layout sharing testcases and so on
public void testSharingLayout() {
- layout = new BoxLayout(new JPanel(), BoxLayout.LINE_AXIS);
-
+ layout = new BoxLayout(new JPanel(), BoxLayout.LINE_AXIS);
try {
layout.getLayoutAlignmentY(new JPanel());
fail("Exception must be thrown");
} catch (AWTError e) {
}
-
try {
layout.getLayoutAlignmentX(new JPanel());
fail("Exception must be thrown");
} catch (AWTError e) {
}
-
try {
layout.invalidateLayout(new JPanel());
fail("Exception must be thrown");
} catch (AWTError e) {
}
-
try {
layout.maximumLayoutSize(new JPanel());
fail("Exception must be thrown");
} catch (AWTError e) {
}
-
try {
layout.layoutContainer(new JPanel());
fail("Exception must be thrown");
} catch (AWTError e) {
}
-
try {
layout.preferredLayoutSize(new JPanel());
fail("Exception must be thrown");
} catch (AWTError e) {
}
-
try {
layout.minimumLayoutSize(new JPanel());
fail("Exception must be thrown");
@@ -479,6 +482,8 @@
}
class MyPanel extends JPanel {
+ private static final long serialVersionUID = 1L;
+
MyPanel() {
setPreferredSize(new Dimension(10, 10));
setMinimumSize(new Dimension(10, 10));
@@ -497,15 +502,12 @@
JComponent component22 = new MyPanel();
JComponent component32 = new MyPanel();
JComponent component42 = new MyPanel();
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.Y_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.X_AXIS);
-
-
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.Y_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.X_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component12);
container2.add(component22);
-
float value1 = 0.02f;
float value2 = 0.47f;
float value3 = 0.51f;
@@ -519,23 +521,26 @@
component22.setAlignmentY(value2);
component32.setAlignmentY(value3);
component42.setAlignmentY(value4);
-
- assertEquals("Alignments coinside:", 0.2857143, layout2.getLayoutAlignmentY(container2), 1e-5f);
- assertEquals("Alignments coinside:", defaultValue, layout1.getLayoutAlignmentY(container1), 1e-5f);
-
+ assertEquals("Alignments coinside:", 0.2857143,
+ layout2.getLayoutAlignmentY(container2), 1e-5f);
+ assertEquals("Alignments coinside:", defaultValue, layout1
+ .getLayoutAlignmentY(container1), 1e-5f);
container1.add(component31);
container2.add(component32);
- layout1 = new BoxLayout(container1, BoxLayout.Y_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.X_AXIS);
- assertEquals("Alignments coinside:", 0.33333334, layout2.getLayoutAlignmentY(container2), 1e-5f);
- assertEquals("Alignments coinside:", defaultValue, layout1.getLayoutAlignmentY(container1), 1e-5f);
-
+ layout1 = new BoxLayout(container1, BoxLayout.Y_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.X_AXIS);
+ assertEquals("Alignments coinside:", 0.33333334, layout2
+ .getLayoutAlignmentY(container2), 1e-5f);
+ assertEquals("Alignments coinside:", defaultValue, layout1
+ .getLayoutAlignmentY(container1), 1e-5f);
container1.add(component41);
container2.add(component42);
- layout1 = new BoxLayout(container1, BoxLayout.Y_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.X_AXIS);
- assertEquals("Alignments coinside:", 0.47368422, layout2.getLayoutAlignmentY(container2), 1e-5f);
- assertEquals("Alignments coinside:", defaultValue, layout1.getLayoutAlignmentY(container1), 1e-5f);
+ layout1 = new BoxLayout(container1, BoxLayout.Y_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.X_AXIS);
+ assertEquals("Alignments coinside:", 0.47368422, layout2
+ .getLayoutAlignmentY(container2), 1e-5f);
+ assertEquals("Alignments coinside:", defaultValue, layout1
+ .getLayoutAlignmentY(container1), 1e-5f);
}
public void testGetLayoutAlignmentX() {
@@ -549,41 +554,32 @@
JComponent component22 = new JPanel();
JComponent component32 = new JPanel();
JComponent component42 = new JPanel();
-
component11.setMinimumSize(new Dimension(34, 10));
component11.setPreferredSize(new Dimension(34, 10));
component11.setMaximumSize(new Dimension(34, 10));
-
component21.setMinimumSize(new Dimension(34, 10));
component21.setPreferredSize(new Dimension(34, 10));
component21.setMaximumSize(new Dimension(34, 10));
-
component31.setMinimumSize(new Dimension(34, 10));
component31.setPreferredSize(new Dimension(34, 10));
component31.setMaximumSize(new Dimension(34, 10));
-
component41.setMinimumSize(new Dimension(34, 10));
component41.setPreferredSize(new Dimension(34, 10));
component41.setMaximumSize(new Dimension(34, 10));
-
component12.setMinimumSize(new Dimension(34, 10));
component12.setPreferredSize(new Dimension(34, 10));
component12.setMaximumSize(new Dimension(34, 10));
-
component22.setMinimumSize(new Dimension(34, 10));
component22.setPreferredSize(new Dimension(34, 10));
component22.setMaximumSize(new Dimension(34, 10));
-
component32.setMinimumSize(new Dimension(34, 10));
component32.setPreferredSize(new Dimension(34, 10));
component32.setMaximumSize(new Dimension(34, 10));
-
component42.setMinimumSize(new Dimension(34, 10));
component42.setPreferredSize(new Dimension(34, 10));
component42.setMaximumSize(new Dimension(34, 10));
-
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
container1.add(component11);
container1.add(component21);
container2.add(component12);
@@ -601,23 +597,26 @@
component22.setAlignmentX(value2);
component32.setAlignmentX(value3);
component42.setAlignmentX(value4);
-
- assertEquals("Alignments coinside:", defaultValue, layout1.getLayoutAlignmentX(container1), 1e-5f);
- assertEquals("Alignments coinside:", 0.30612245, layout2.getLayoutAlignmentX(container2), 1e-5f);
-
+ assertEquals("Alignments coinside:", defaultValue, layout1
+ .getLayoutAlignmentX(container1), 1e-5f);
+ assertEquals("Alignments coinside:", 0.30612245, layout2
+ .getLayoutAlignmentX(container2), 1e-5f);
container1.add(component31);
container2.add(component32);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("Alignments coinside:", defaultValue, layout1.getLayoutAlignmentX(container1), 1e-5f);
- assertEquals("Alignments coinside:", 0.33333334, layout2.getLayoutAlignmentX(container2), 1e-5f);
-
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("Alignments coinside:", defaultValue, layout1
+ .getLayoutAlignmentX(container1), 1e-5f);
+ assertEquals("Alignments coinside:", 0.33333334, layout2
+ .getLayoutAlignmentX(container2), 1e-5f);
container1.add(component41);
container2.add(component42);
- layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
- assertEquals("Alignments coinside:", defaultValue, layout1.getLayoutAlignmentX(container1), 1e-5f);
- assertEquals("Alignments coinside:", 0.47692308, layout2.getLayoutAlignmentX(container2), 1e-5f);
+ layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
+ assertEquals("Alignments coinside:", defaultValue, layout1
+ .getLayoutAlignmentX(container1), 1e-5f);
+ assertEquals("Alignments coinside:", 0.47692308, layout2
+ .getLayoutAlignmentX(container2), 1e-5f);
}
/*
@@ -629,14 +628,12 @@
public void testWriteObject() throws IOException {
Container container1 = new Panel();
Container container2 = new Panel();
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
-
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
ByteArrayOutputStream fo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(fo);
so.writeObject(layout1);
so.flush();
-
fo = new ByteArrayOutputStream();
so = new ObjectOutputStream(fo);
so.writeObject(layout2);
@@ -646,26 +643,23 @@
public void testReadObject() throws IOException, ClassNotFoundException {
Container container1 = new Panel();
Container container2 = new Panel();
- BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
- BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
-
+ BoxLayout layout1 = new BoxLayout(container1, BoxLayout.X_AXIS);
+ BoxLayout layout2 = new BoxLayout(container2, BoxLayout.Y_AXIS);
ByteArrayOutputStream fo = new ByteArrayOutputStream();
ObjectOutputStream so = new ObjectOutputStream(fo);
so.writeObject(layout1);
so.flush();
-
InputStream fi = new ByteArrayInputStream(fo.toByteArray());
ObjectInputStream si = new ObjectInputStream(fi);
- BoxLayout resurrectedLayout = (BoxLayout)si.readObject();
-
+ BoxLayout resurrectedLayout = (BoxLayout) si.readObject();
+ assertNotNull(resurrectedLayout);
fo = new ByteArrayOutputStream();
so = new ObjectOutputStream(fo);
so.writeObject(layout2);
so.flush();
-
fi = new ByteArrayInputStream(fo.toByteArray());
si = new ObjectInputStream(fi);
- resurrectedLayout = (BoxLayout)si.readObject();
+ resurrectedLayout = (BoxLayout) si.readObject();
+ assertNotNull(resurrectedLayout);
}
-
}
Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxTest.java?view=diff&rev=479240&r1=479239&r2=479240
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/BoxTest.java Sat Nov 25 16:04:10 2006
@@ -26,32 +26,17 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
-
import javax.accessibility.AccessibleContext;
public class BoxTest extends SwingTestCase {
-
- public static void main(final String[] args) {
- junit.textui.TestRunner.run(BoxTest.class);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
/*
* Class under test for AccessibleContext getAccessibleContext()
*/
public void testGetAccessibleContext() {
Component box = new Box(BoxLayout.LINE_AXIS);
AccessibleContext accessible = box.getAccessibleContext();
- assertEquals("Accessible context is correct ", Box.AccessibleBox.class, accessible.getClass());
- }
-
- public void testBox() {
+ assertEquals("Accessible context is correct ", Box.AccessibleBox.class, accessible
+ .getClass());
}
/*
@@ -59,7 +44,7 @@
*/
public void testSetLayoutLayoutManager() {
Box box = new Box(BoxLayout.X_AXIS);
- boolean thrown = false;
+ boolean thrown = false;
try {
box.setLayout(new GridLayout(3, 3));
} catch (AWTError err) {
@@ -71,64 +56,54 @@
public void testCreateRigidArea() {
Dimension size = new Dimension(100, 100);
Component box = Box.createRigidArea(size);
-
assertEquals("Minimum size initialized ", size, box.getMinimumSize());
assertEquals("Preferred size initialized ", size, box.getPreferredSize());
assertEquals("Maximum size initialized ", size, box.getMaximumSize());
-
assertFalse("Opaqueness initialized ", box.isOpaque());
}
public void testCreateVerticalBox() {
- Dimension nullSize = new Dimension(0, 0);
- Box box = (Box)Box.createVerticalBox();
-
+ Box box = Box.createVerticalBox();
assertFalse("Opaqueness initialized ", box.isOpaque());
-
- JPanel panel1 = new JPanel();
- JPanel panel2 = new JPanel();
- panel1.setMinimumSize(new Dimension(10 ,10));
- panel2.setMinimumSize(new Dimension(10 ,10));
+ JPanel panel1 = new JPanel();
+ JPanel panel2 = new JPanel();
+ panel1.setMinimumSize(new Dimension(10, 10));
+ panel2.setMinimumSize(new Dimension(10, 10));
panel1.setPreferredSize(new Dimension(100, 200));
panel2.setPreferredSize(new Dimension(1000, 2000));
box.add(panel1);
box.add(panel2);
-
assertEquals("Minimum size ", new Dimension(10, 20), box.getMinimumSize());
assertEquals("Preferred size ", new Dimension(1000, 2200), box.getPreferredSize());
- assertEquals("Maximum size ", new Dimension(Short.MAX_VALUE, 2*Short.MAX_VALUE), box.getMaximumSize());
-
+ assertEquals("Maximum size ", new Dimension(Short.MAX_VALUE, 2 * Short.MAX_VALUE), box
+ .getMaximumSize());
}
public void testCreateHorizontalBox() {
- Dimension nullSize = new Dimension(0, 0);
- Box box = (Box)Box.createHorizontalBox();
+ Box box = Box.createHorizontalBox();
assertFalse("Opaqueness initialized ", box.isOpaque());
-
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
- panel1.setMinimumSize(new Dimension(10 ,10));
- panel2.setMinimumSize(new Dimension(10 ,10));
+ panel1.setMinimumSize(new Dimension(10, 10));
+ panel2.setMinimumSize(new Dimension(10, 10));
panel1.setPreferredSize(new Dimension(100, 200));
panel2.setPreferredSize(new Dimension(1000, 2000));
box.add(panel1);
box.add(panel2);
-
assertEquals("Minimum size ", new Dimension(20, 10), box.getMinimumSize());
assertEquals("Preferred size ", new Dimension(1100, 2000), box.getPreferredSize());
- assertEquals("Maximum size ", new Dimension(2*Short.MAX_VALUE, Short.MAX_VALUE), box.getMaximumSize());
-}
+ assertEquals("Maximum size ", new Dimension(2 * Short.MAX_VALUE, Short.MAX_VALUE), box
+ .getMaximumSize());
+ }
public void testCreateVerticalStrut() {
int height = 100;
Dimension size = new Dimension(0, height);
Dimension maxSize = new Dimension(Short.MAX_VALUE, height);
Component box = Box.createVerticalStrut(height);
-
assertEquals("Minimum size initialized correctly ", size, box.getMinimumSize());
assertEquals("Preferred size initialized correctly ", size, box.getPreferredSize());
assertEquals("Maximum size initialized correctly ", maxSize, box.getMaximumSize());
-
assertFalse("Opaqueness initialized correctly", box.isOpaque());
}
@@ -137,11 +112,9 @@
Dimension size = new Dimension(width, 0);
Dimension maxSize = new Dimension(width, Short.MAX_VALUE);
Component box = Box.createHorizontalStrut(width);
-
assertEquals("Minimum size initialized correctly ", size, box.getMinimumSize());
assertEquals("Preferred size initialized correctly ", size, box.getPreferredSize());
assertEquals("Maximum size initialized correctly ", maxSize, box.getMaximumSize());
-
assertFalse("Opaqueness initialized correctly", box.isOpaque());
}
@@ -149,11 +122,9 @@
Dimension nullSize = new Dimension(0, 0);
Dimension maximumSize = new Dimension(0, Short.MAX_VALUE);
Component box = Box.createVerticalGlue();
-
assertEquals("Minimum size initialized correctly ", nullSize, box.getMinimumSize());
assertEquals("Preferred size initialized correctly ", nullSize, box.getPreferredSize());
assertEquals("Maximum size initialized correctly ", maximumSize, box.getMaximumSize());
-
assertFalse("Opaqueness initialized correctly", box.isOpaque());
}
@@ -161,11 +132,9 @@
Dimension nullSize = new Dimension(0, 0);
Dimension maximumSize = new Dimension(Short.MAX_VALUE, 0);
Component box = Box.createHorizontalGlue();
-
assertEquals("Minimum size initialized correctly ", nullSize, box.getMinimumSize());
assertEquals("Preferred size initialized correctly ", nullSize, box.getPreferredSize());
assertEquals("Maximum size initialized correctly ", maximumSize, box.getMaximumSize());
-
assertFalse("Opaqueness initialized correctly", box.isOpaque());
}
@@ -173,12 +142,9 @@
Dimension nullSize = new Dimension(0, 0);
Dimension maximumSize = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
Component box = Box.createGlue();
-
assertEquals("Minimum size initialized correctly ", nullSize, box.getMinimumSize());
assertEquals("Preferred size initialized correctly ", nullSize, box.getPreferredSize());
assertEquals("Maximum size initialized correctly ", maximumSize, box.getMaximumSize());
-
assertFalse("Opaqueness initialized correctly", box.isOpaque());
}
-
}