This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: BoxLayout tests


I committed this patch (some tests I wrote some time ago):

2005-09-13 David Gilbert <david.gilbert@object-refinery.com>

* gnu/testlet/javax/swing/BoxLayout/addLayoutComponent.java: new test,
* gnu/testlet/javax/swing/BoxLayout/constants.java: new test,
* gnu/testlet/javax/swing/BoxLayout/constructor.java: new test,
* gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentX.java: new test,
* gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentY.java: new test,
* gnu/testlet/javax/swing/BoxLayout/invalidateLayout.java: new test,
* gnu/testlet/javax/swing/BoxLayout/layoutContainer.java: new test,
* gnu/testlet/javax/swing/BoxLayout/maximumLayoutSize.java: new test,
* gnu/testlet/javax/swing/BoxLayout/minimumLayoutSize.java: new test,
* gnu/testlet/javax/swing/BoxLayout/preferredLayoutSize.java: new test,
* gnu/testlet/javax/swing/BoxLayout/removeLayoutComponent.java: new test.


Regards,

Dave
? deal.txt
? diff.txt
Index: gnu/testlet/javax/swing/BoxLayout/addLayoutComponent.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/addLayoutComponent.java
diff -N gnu/testlet/javax/swing/BoxLayout/addLayoutComponent.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/addLayoutComponent.java	13 Sep 2005 18:57:41 -0000
@@ -0,0 +1,76 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Component;
+
+import javax.swing.BoxLayout;
+import javax.swing.JButton;
+import javax.swing.JComponent;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the addLayoutComponent methods in the {@link BoxLayout} 
+ * class.
+ */
+public class addLayoutComponent implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    test1(harness);
+    test2(harness);
+  }
+  
+  private void test1(TestHarness harness)
+  {
+    harness.checkPoint("(Component, Object)");
+    // the addLayoutComponent() method is not used so nothing here should
+    // fail
+    BoxLayout layout = new BoxLayout(new JPanel(), BoxLayout.X_AXIS);
+    layout.addLayoutComponent(new JPanel(), "XYZ");
+    layout.addLayoutComponent((Component) null, (Object) null);
+    harness.check(true);
+  }
+  
+  private void test2(TestHarness harness)
+  {
+    harness.checkPoint("(String, Component)");
+    // the addLayoutComponent() method is not used so nothing here should
+    // fail
+    BoxLayout layout = new BoxLayout(new JPanel(), BoxLayout.X_AXIS);
+    layout.addLayoutComponent("Name", new JButton("Test"));
+    layout.addLayoutComponent((String) null, (JComponent) null);
+    harness.check(true);
+  }
+
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/constants.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/constants.java
diff -N gnu/testlet/javax/swing/BoxLayout/constants.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/constants.java	13 Sep 2005 18:57:41 -0000
@@ -0,0 +1,50 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.BoxLayout;
+
+/**
+ * Some checks for the constants defined in the {@link BoxLayout} class.
+ */
+public class constants implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    harness.check(BoxLayout.LINE_AXIS, 2);
+    harness.check(BoxLayout.PAGE_AXIS, 3);
+    harness.check(BoxLayout.X_AXIS, 0);
+    harness.check(BoxLayout.Y_AXIS, 1);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/constructor.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/constructor.java
diff -N gnu/testlet/javax/swing/BoxLayout/constructor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/constructor.java	13 Sep 2005 18:57:41 -0000
@@ -0,0 +1,65 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the constructor in the {@link BoxLayout} class.
+ */
+public class constructor implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    // a null container is accepted by the constructor but the resulting
+    // layout is useless...
+    BoxLayout layout = new BoxLayout(null, BoxLayout.X_AXIS);
+    harness.check(layout != null);
+    
+    // try an invalid axis type
+    boolean pass = false;
+    try
+      {
+        layout = new BoxLayout(new JPanel(), 99);
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentX.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentX.java
diff -N gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentX.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentX.java	13 Sep 2005 18:57:41 -0000
@@ -0,0 +1,64 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the getLayoutAlignmentX() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class getLayoutAlignmentX implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        /*float result =*/ layout.getLayoutAlignmentX(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentY.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentY.java
diff -N gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentY.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/getLayoutAlignmentY.java	13 Sep 2005 18:57:41 -0000
@@ -0,0 +1,64 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the getLayoutAlignmentY() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class getLayoutAlignmentY implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        /*float result =*/ layout.getLayoutAlignmentY(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/invalidateLayout.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/invalidateLayout.java
diff -N gnu/testlet/javax/swing/BoxLayout/invalidateLayout.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/invalidateLayout.java	13 Sep 2005 18:57:41 -0000
@@ -0,0 +1,64 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the invalidateLayout() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class invalidateLayout implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        layout.invalidateLayout(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/layoutContainer.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/layoutContainer.java
diff -N gnu/testlet/javax/swing/BoxLayout/layoutContainer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/layoutContainer.java	13 Sep 2005 18:57:42 -0000
@@ -0,0 +1,162 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Rectangle;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+import javax.swing.JSeparator;
+
+/**
+ * Some checks for the layoutContainer() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class layoutContainer implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    testXAxis(harness);
+    testYAxis(harness);
+    testLineAxis(harness);
+    testPageAxis(harness);
+    testOriginalContainer(harness);
+  }
+  
+  private void testXAxis(TestHarness harness)
+  {
+    harness.checkPoint("testXAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS));
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(p1.getBounds(), new Rectangle(0, 0, 11, 200));
+    harness.check(p2.getBounds(), new Rectangle(11, 0, 33, 200));
+    harness.check(p3.getBounds(), new Rectangle(44, 0, 55, 200));
+  }
+  
+  private void testYAxis(TestHarness harness)
+  {
+    harness.checkPoint("testYAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(p1.getBounds(), new Rectangle(0, 0, 100, 44));
+    harness.check(p2.getBounds(), new Rectangle(0, 44, 100, 66));
+    harness.check(p3.getBounds(), new Rectangle(0, 110, 100, 88));
+  }
+
+  private void testLineAxis(TestHarness harness)
+  {
+    harness.checkPoint("testLineAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS));
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(p1.getBounds(), new Rectangle(0, 0, 11, 200));
+    harness.check(p2.getBounds(), new Rectangle(11, 0, 33, 200));
+    harness.check(p3.getBounds(), new Rectangle(44, 0, 55, 200));
+  }
+
+  private void testPageAxis(TestHarness harness)
+  {
+    harness.checkPoint("testPageAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(p1.getBounds(), new Rectangle(0, 0, 100, 44));
+    harness.check(p2.getBounds(), new Rectangle(0, 44, 100, 66));
+    harness.check(p3.getBounds(), new Rectangle(0, 110, 100, 88));
+  }
+
+  private void testOriginalContainer(TestHarness harness)
+  {
+    harness.checkPoint("testOriginalContainer");
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        layout.layoutContainer(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/maximumLayoutSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/maximumLayoutSize.java
diff -N gnu/testlet/javax/swing/BoxLayout/maximumLayoutSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/maximumLayoutSize.java	13 Sep 2005 18:57:42 -0000
@@ -0,0 +1,157 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+import java.awt.Dimension;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the maximumLayoutSize() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class maximumLayoutSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    testBasic(harness);
+    testXAxis(harness);
+    testYAxis(harness);
+    testLineAxis(harness);
+    testPageAxis(harness);
+  }
+  
+  private void testBasic(TestHarness harness)
+  {
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    harness.check(layout.maximumLayoutSize(container), new Dimension(0, 0));
+    container.setBorder(BorderFactory.createEmptyBorder(1, 2, 3, 4));
+    harness.check(layout.maximumLayoutSize(container), new Dimension(6, 4));
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        /*Dimension result =*/ layout.maximumLayoutSize(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+  private void testXAxis(TestHarness harness)
+  {
+    harness.checkPoint("testXAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    harness.check(layout.maximumLayoutSize(container), new Dimension(98301, 32767));
+  }
+  
+  private void testYAxis(TestHarness harness)
+  {
+    harness.checkPoint("testYAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(layout.maximumLayoutSize(container), new Dimension(32767, 98301));
+  }
+
+  private void testLineAxis(TestHarness harness)
+  {
+    harness.checkPoint("testLineAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.LINE_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(layout.maximumLayoutSize(container), new Dimension(98301, 32767));
+  }
+
+  private void testPageAxis(TestHarness harness)
+  {
+    harness.checkPoint("testPageAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.PAGE_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(layout.maximumLayoutSize(container), new Dimension(32767, 98301));
+  }
+
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/minimumLayoutSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/minimumLayoutSize.java
diff -N gnu/testlet/javax/swing/BoxLayout/minimumLayoutSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/minimumLayoutSize.java	13 Sep 2005 18:57:42 -0000
@@ -0,0 +1,69 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+import java.awt.Dimension;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the minimumLayoutSize() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class minimumLayoutSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    harness.check(layout.minimumLayoutSize(container), new Dimension(0, 0));
+    container.setBorder(BorderFactory.createEmptyBorder(1, 2, 3, 4));
+    harness.check(layout.minimumLayoutSize(container), new Dimension(6, 4));
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        /*Dimension result =*/ layout.minimumLayoutSize(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/BoxLayout/preferredLayoutSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/preferredLayoutSize.java
diff -N gnu/testlet/javax/swing/BoxLayout/preferredLayoutSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/preferredLayoutSize.java	13 Sep 2005 18:57:42 -0000
@@ -0,0 +1,175 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.AWTError;
+import java.awt.Dimension;
+
+import javax.swing.BorderFactory;
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+import javax.swing.JSeparator;
+
+/**
+ * Some checks for the preferredLayoutSize() method defined in the 
+ * {@link BoxLayout} class.
+ */
+public class preferredLayoutSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    testBasic(harness);
+    testXAxis(harness);
+    testYAxis(harness);
+    testLineAxis(harness);
+    testPageAxis(harness);
+    testJSeparator(harness);
+  }
+  
+  private void testBasic(TestHarness harness)
+  {
+    JPanel container = new JPanel();
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    harness.check(layout.preferredLayoutSize(container), new Dimension(0, 0));
+    container.setBorder(BorderFactory.createEmptyBorder(1, 2, 3, 4));
+    harness.check(layout.preferredLayoutSize(container), new Dimension(6, 4));
+    
+    // must call with original container
+    boolean pass = false;
+    try
+      {
+        /*Dimension result =*/ layout.preferredLayoutSize(new JPanel());
+      }
+    catch (AWTError e)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+  
+  private void testXAxis(TestHarness harness)
+  {
+    harness.checkPoint("testXAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.X_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    harness.check(layout.preferredLayoutSize(container), new Dimension(99, 66));
+  }
+  
+  private void testYAxis(TestHarness harness)
+  {
+    harness.checkPoint("testYAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(layout.preferredLayoutSize(container), new Dimension(55, 132));
+  }
+
+  private void testLineAxis(TestHarness harness)
+  {
+    harness.checkPoint("testLineAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.LINE_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(layout.preferredLayoutSize(container), new Dimension(99, 66));
+  }
+
+  private void testPageAxis(TestHarness harness)
+  {
+    harness.checkPoint("testPageAxis");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.PAGE_AXIS);
+    container.setLayout(layout);
+    JPanel p1 = new JPanel();
+    JPanel p2 = new JPanel();
+    JPanel p3 = new JPanel();
+    p1.setPreferredSize(new Dimension(11, 22));
+    p2.setPreferredSize(new Dimension(33, 44));
+    p3.setPreferredSize(new Dimension(55, 66));
+    container.add(p1);
+    container.add(p2);
+    container.add(p3);
+    container.doLayout();
+    harness.check(layout.preferredLayoutSize(container), new Dimension(55, 132));
+  }
+
+  private void testJSeparator(TestHarness harness)
+  {
+    harness.checkPoint("testJSeparator");
+    JPanel container = new JPanel();
+    container.setSize(100, 200);
+    BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS);
+    container.setLayout(layout);
+    JSeparator s1 = new JSeparator();
+    container.add(s1);
+    container.doLayout();
+    harness.check(layout.preferredLayoutSize(container), new Dimension(0, 2));
+  }
+
+
+}
+
+
+
Index: gnu/testlet/javax/swing/BoxLayout/removeLayoutComponent.java
===================================================================
RCS file: gnu/testlet/javax/swing/BoxLayout/removeLayoutComponent.java
diff -N gnu/testlet/javax/swing/BoxLayout/removeLayoutComponent.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/BoxLayout/removeLayoutComponent.java	13 Sep 2005 18:57:42 -0000
@@ -0,0 +1,63 @@
+// Tags: JDK1.2 
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version. 
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING.  If not, write to
+// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+// Boston, MA 02110-1301 USA.
+
+
+package gnu.testlet.javax.swing.BoxLayout;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Component;
+
+import javax.swing.BoxLayout;
+import javax.swing.JPanel;
+
+/**
+ * Some checks for the removeLayoutComponent methods in the {@link BoxLayout} 
+ * class.
+ */
+public class removeLayoutComponent implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness) 
+  {
+    // the removeLayoutComponent() method is not used so nothing here should
+    // fail
+    try
+    {
+      BoxLayout layout = new BoxLayout(new JPanel(), BoxLayout.X_AXIS);
+      layout.removeLayoutComponent(new JPanel());
+      layout.removeLayoutComponent((Component) null);
+      harness.check(true);
+    }
+    catch (Throwable e)
+    {
+      harness.check(false);
+    }
+  }
+
+}
+

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]