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: New JSplitPane / UI tests


This tests some methods in the JSplitPane and its UI class.

2006-10-09  Roman Kennke <kennke@aicas.com>

	* gnu/testlet/javax/swing/JSplitPane/getDividerLocation.java,
	*
gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/getDividerLocation.java,
	*
gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/BasicHorizontalLayoutManager/layoutContainer.java:
	New tests.

/Roman

Index: gnu/testlet/javax/swing/JSplitPane/getDividerLocation.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSplitPane/getDividerLocation.java
diff -N gnu/testlet/javax/swing/JSplitPane/getDividerLocation.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSplitPane/getDividerLocation.java	9 Oct 2006 13:35:07 -0000
@@ -0,0 +1,70 @@
+/* getDividerLocation.java -- Checks JSplitPane.getDividerLocation()
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.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.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.JSplitPane;
+
+import javax.swing.JSplitPane;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Checks JSplitPane.getDividerLocation().
+ */
+public class getDividerLocation implements Testlet
+{
+
+  /**
+   * Overrides BasicSplitPaneUI.getDividerLocation() for testing.
+   */
+  private class TestSplitPaneUI extends BasicSplitPaneUI
+  {
+    public int getDividerLocation(JSplitPane sp)
+    {
+      return 9876;
+    }
+  }
+
+  /**
+   * Entry point into the test.
+   */
+  public void test(TestHarness harness)
+  {
+    testCallUI(harness);
+  }
+
+  /**
+   * Checks that getDividerLocation() does _not_ call into the UI, and
+   * rather manages its property itself.
+   *
+   * @param h the test harness
+   */
+  private void testCallUI(TestHarness h)
+  {
+    JSplitPane sp = new JSplitPane();
+    sp.setDividerLocation(1234);
+    sp.setUI(new TestSplitPaneUI());
+    h.check(sp.getDividerLocation(), 1234);
+  }
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/getDividerLocation.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/getDividerLocation.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/getDividerLocation.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/getDividerLocation.java	9 Oct 2006 13:35:07 -0000
@@ -0,0 +1,65 @@
+/* getDividerLocation.java -- Checks BasicSplitPaneUI.getDividerLocation()
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.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.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.plaf.basic.BasicSplitPaneUI;
+
+import java.awt.Component;
+
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Checks BasicSplitPaneUI.getDividerLocation().
+ */
+public class getDividerLocation implements Testlet
+{
+
+  /**
+   * Checks that BasicSplitPaneUI.getDividerLocation() simply
+   * returns the real location of the divider component, regardless
+   * of the JSplitPaneUI setting.
+   */
+  public void test(TestHarness harness)
+  {
+    // Check horizontal.
+    JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
+                                   new JPanel(), new JPanel());
+    BasicSplitPaneUI ui = (BasicSplitPaneUI) sp.getUI();
+    Component divider = sp.getComponent(2);
+    divider.setLocation(1234, 5678);
+    harness.check(ui.getDividerLocation(sp), 1234);
+
+    // Check vertical.
+    sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
+                                   new JPanel(), new JPanel());
+    ui = (BasicSplitPaneUI) sp.getUI();
+    divider = sp.getComponent(2);
+    divider.setLocation(1234, 5678);
+    harness.check(ui.getDividerLocation(sp), 5678);
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/BasicHorizontalLayoutManager/layoutContainer.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/BasicHorizontalLayoutManager/layoutContainer.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/BasicHorizontalLayoutManager/layoutContainer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicSplitPaneUI/BasicHorizontalLayoutManager/layoutContainer.java	9 Oct 2006 13:35:07 -0000
@@ -0,0 +1,75 @@
+/* layoutContainer.java -- Checks the layout manager layoutContainer()
+   Copyright (C) 2006 Roman Kennke (kennke@aicas.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.
+
+*/
+
+// Tags: JDK1.2
+
+package gnu.testlet.javax.swing.plaf.basic.BasicSplitPaneUI.BasicHorizontalLayoutManager;
+
+import java.awt.Dimension;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class layoutContainer implements Testlet
+{
+
+  public void test(TestHarness harness)
+  {
+    testMinimumSize(harness);
+  }
+
+  /**
+   * Tests that the layout manager honors the minimum size of the
+   * components.
+   *
+   * @param h the test harness
+   */
+  private void testMinimumSize(TestHarness h)
+  {
+    // Check without calling setDividerLocation().
+    JPanel c1 = new JPanel();
+    c1.setMinimumSize(new Dimension(100, 100));
+    JPanel c2 = new JPanel();
+    JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, c1, c2);
+    sp.setSize(200, 200);
+    h.check(sp.getLayout()
+            instanceof BasicSplitPaneUI.BasicHorizontalLayoutManager);
+    sp.getLayout().layoutContainer(sp);
+    h.check(c1.getWidth(), 100);
+
+    // Check with calling setDividerLocation().
+    c1 = new JPanel();
+    c1.setMinimumSize(new Dimension(100, 100));
+    c2 = new JPanel();
+    sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, c1, c2);
+    sp.setDividerLocation(0);
+    sp.setSize(200, 200);
+    h.check(sp.getLayout()
+            instanceof BasicSplitPaneUI.BasicHorizontalLayoutManager);
+    sp.getLayout().layoutContainer(sp);
+    h.check(c1.getWidth(), 0);
+  }
+}

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