This is the mail archive of the
mauve-patches@sources.redhat.com
mailing list for the Mauve project.
javax.swing.SwingUtilities - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: Mauve Patches <mauve-patches at sources dot redhat dot com>
- Date: Wed, 17 Nov 2004 22:46:12 +0000
- Subject: javax.swing.SwingUtilities - new tests
I've committed these new tests:
2004-11-17 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/SwingUtilities/computeIntersection.java,
gnu/testlet/javax/swing/SwingUtilities/computeUnion.java,
gnu/testlet/javax/swing/SwingUtilities/isRectangleContainingRectangle.java:
New tests.
See the attached patch.
Regards,
Dave
Index: ChangeLog
===================================================================
RCS file: /cvs/mauve/mauve/ChangeLog,v
retrieving revision 1.744
diff -u -r1.744 ChangeLog
--- ChangeLog 17 Nov 2004 21:30:14 -0000 1.744
+++ ChangeLog 17 Nov 2004 22:23:55 -0000
@@ -1,3 +1,10 @@
+2004-11-17 David Gilbert <david.gilbert@object-refinery.com>
+
+ * gnu/testlet/javax/swing/SwingUtilities/computeIntersection.java,
+ gnu/testlet/javax/swing/SwingUtilities/computeUnion.java,
+ gnu/testlet/javax/swing/SwingUtilities/isRectangleContainingRectangle.java:
+ New tests.
+
2004-11-17 Michael Koch <konqueror@gmx.de>
* gnu/testlet/java/net/InetSocketAddress/InetSocketAddressTest.java:
Index: gnu/testlet/javax/swing/SwingUtilities/computeIntersection.java
===================================================================
RCS file: gnu/testlet/javax/swing/SwingUtilities/computeIntersection.java
diff -N gnu/testlet/javax/swing/SwingUtilities/computeIntersection.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SwingUtilities/computeIntersection.java 17 Nov 2004 22:24:02 -0000
@@ -0,0 +1,145 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.javax.swing.SwingUtilities;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Rectangle;
+
+import javax.swing.SwingUtilities;
+
+/**
+ * Some checks for the computeIntersection() method in the SwingUtilities
+ * class.
+ */
+public class computeIntersection implements Testlet {
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness) {
+
+ Rectangle dest = new Rectangle(1, 1, 3, 3);
+
+ harness.checkPoint("No intersection");
+
+ // no intersection - top left
+ dest = SwingUtilities.computeIntersection(0, 4, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - top
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(2, 4, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - top right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(4, 4, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - bottom left
+ dest = SwingUtilities.computeIntersection(0, 0, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - bottom
+ dest = SwingUtilities.computeIntersection(2, 0, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - bottom right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(4, 0, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(0, 2, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(4, 2, 1, 1, dest);
+ harness.check(dest.isEmpty());
+
+ // no intersection - empty rectangle
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(2, 2, 0, 0, dest);
+ harness.check(dest.isEmpty());
+
+ harness.checkPoint("Intersection");
+
+ // intersection - top left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(0, 3, 2, 2, dest);
+ harness.check(dest, new Rectangle(1, 3, 1, 1));
+
+ // intersection - top
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(2, 3, 1, 2, dest);
+ harness.check(dest, new Rectangle(2, 3, 1, 1));
+
+ // intersection - top right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(3, 3, 2, 2, dest);
+ harness.check(dest, new Rectangle(3, 3, 1, 1));
+
+ // intersection - bottom left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(0, 0, 2, 2, dest);
+ harness.check(dest, new Rectangle(1, 1, 1, 1));
+
+ // intersection - bottom
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(2, 0, 1, 2, dest);
+ harness.check(dest, new Rectangle(2, 1, 1, 1));
+
+ // intersection - bottom right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(3, 0, 2, 2, dest);
+ harness.check(dest, new Rectangle(3, 1, 1, 1));
+
+ // intersection - left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(0, 2, 2, 1, dest);
+ harness.check(dest, new Rectangle(1, 2, 1, 1));
+
+ // no intersection - right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeIntersection(3, 2, 2, 1, dest);
+ harness.check(dest, new Rectangle(3, 2, 1, 1));
+
+ harness.checkPoint("Null arguments");
+ // test null argument - the API spec doesn't specify what should
+ // happen, but a NullPointerException is the usual result elsewhere
+ try
+ {
+ /* Rectangle r2 = */ SwingUtilities.computeIntersection(1, 2, 3, 4, null);
+ harness.check(false);
+ }
+ catch (NullPointerException e)
+ {
+ harness.check(true);
+ }
+
+ }
+
+}
Index: gnu/testlet/javax/swing/SwingUtilities/computeUnion.java
===================================================================
RCS file: gnu/testlet/javax/swing/SwingUtilities/computeUnion.java
diff -N gnu/testlet/javax/swing/SwingUtilities/computeUnion.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SwingUtilities/computeUnion.java 17 Nov 2004 22:24:02 -0000
@@ -0,0 +1,155 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.javax.swing.SwingUtilities;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Rectangle;
+
+import javax.swing.SwingUtilities;
+
+/**
+ * Some checks for the computeUnion() method in the SwingUtilities
+ * class.
+ */
+public class computeUnion implements Testlet {
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness) {
+
+ Rectangle dest = new Rectangle(1, 1, 3, 3);
+
+ harness.checkPoint("No intersection");
+
+ // no intersection - top left
+ dest = SwingUtilities.computeUnion(0, 4, 1, 1, dest);
+ harness.check(dest, new Rectangle(0, 1, 4, 4)); // 1
+
+ // no intersection - top
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(2, 4, 1, 1, dest);
+ harness.check(dest, new Rectangle(1, 1, 3, 4)); // 2
+
+ // no intersection - top right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(4, 4, 1, 1, dest);
+ harness.check(dest, new Rectangle(1, 1, 4, 4)); // 3
+
+ // no intersection - bottom left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 0, 1, 1, dest);
+ harness.check(dest, new Rectangle(0, 0, 4, 4)); // 4
+
+ // no intersection - bottom
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(2, 0, 1, 1, dest);
+ harness.check(dest, new Rectangle(1, 0, 3, 4)); // 5
+
+ // no intersection - bottom right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(4, 0, 1, 1, dest);
+ harness.check(dest, new Rectangle(1, 0, 4, 4)); // 6
+
+ // no intersection - left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 2, 1, 1, dest);
+ harness.check(dest, new Rectangle(0, 1, 4, 3)); // 7
+
+ // no intersection - right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(4, 2, 1, 1, dest);
+ harness.check(dest, new Rectangle(1, 1, 4, 3)); // 8
+
+ // no intersection - empty rectangle
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(2, 2, 0, 0, dest);
+ harness.check(dest, new Rectangle(1, 1, 3, 3)); // 9
+
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 0, 0, 0, dest);
+ harness.check(dest, new Rectangle(0, 0, 4, 4)); // 10
+
+ harness.checkPoint("Intersection");
+
+ // intersection - top left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 3, 2, 2, dest);
+ harness.check(dest, new Rectangle(0, 1, 4, 4));
+
+ // intersection - top
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(2, 3, 1, 2, dest);
+ harness.check(dest, new Rectangle(1, 1, 3, 4));
+
+ // intersection - top right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(3, 3, 2, 2, dest);
+ harness.check(dest, new Rectangle(1, 1, 4, 4));
+
+ // intersection - bottom left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 0, 2, 2, dest);
+ harness.check(dest, new Rectangle(0, 0, 4, 4));
+
+ // intersection - bottom
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(2, 0, 1, 2, dest);
+ harness.check(dest, new Rectangle(1, 0, 3, 4));
+
+ // intersection - bottom right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(3, 0, 2, 2, dest);
+ harness.check(dest, new Rectangle(1, 0, 4, 4));
+
+ // intersection - left
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 2, 2, 1, dest);
+ harness.check(dest, new Rectangle(0, 1, 4, 3));
+
+ // no intersection - right
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(3, 2, 2, 1, dest);
+ harness.check(dest, new Rectangle(1, 1, 4, 3));
+
+ dest = new Rectangle(1, 1, 3, 3);
+ dest = SwingUtilities.computeUnion(0, 0, 4, 4, dest);
+ harness.check(dest, new Rectangle(0, 0, 4, 4));
+
+ harness.checkPoint("Null arguments");
+ // test null argument - the API spec doesn't specify what should
+ // happen, but a NullPointerException is the usual result elsewhere
+ try
+ {
+ /* Rectangle r2 = */ SwingUtilities.computeIntersection(1, 2, 3, 4, null);
+ harness.check(false);
+ }
+ catch (NullPointerException e)
+ {
+ harness.check(true);
+ }
+
+ }
+
+}
Index: gnu/testlet/javax/swing/SwingUtilities/isRectangleContainingRectangle.java
===================================================================
RCS file: gnu/testlet/javax/swing/SwingUtilities/isRectangleContainingRectangle.java
diff -N gnu/testlet/javax/swing/SwingUtilities/isRectangleContainingRectangle.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/SwingUtilities/isRectangleContainingRectangle.java 17 Nov 2004 22:24:02 -0000
@@ -0,0 +1,83 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2004 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA. */
+
+package gnu.testlet.javax.swing.SwingUtilities;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Rectangle;
+
+import javax.swing.SwingUtilities;
+
+/**
+ * Some checks for the isRectangleContainingRectangle() method in the
+ * SwingUtilities class.
+ */
+public class isRectangleContainingRectangle implements Testlet {
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness) {
+
+ Rectangle r0 = new Rectangle(0, 0, 0, 0);
+ Rectangle r1 = new Rectangle(0, 0, 1, 1);
+ Rectangle r2 = new Rectangle(1, 1, 1, 1);
+ Rectangle r3 = new Rectangle(-1, -1, 2, 2);
+
+ harness.check(SwingUtilities.isRectangleContainingRectangle(r0, r0));
+ harness.check(!SwingUtilities.isRectangleContainingRectangle(r0, r1));
+ harness.check(SwingUtilities.isRectangleContainingRectangle(r1, r0));
+ harness.check(SwingUtilities.isRectangleContainingRectangle(r1, r1));
+ harness.check(!SwingUtilities.isRectangleContainingRectangle(r1, r2));
+ harness.check(!SwingUtilities.isRectangleContainingRectangle(r2, r0));
+ harness.check(!SwingUtilities.isRectangleContainingRectangle(r2, r1));
+ harness.check(SwingUtilities.isRectangleContainingRectangle(r2, r2));
+ harness.check(SwingUtilities.isRectangleContainingRectangle(r3, r0));
+ harness.check(SwingUtilities.isRectangleContainingRectangle(r3, r1));
+ harness.check(!SwingUtilities.isRectangleContainingRectangle(r3, r2));
+
+ harness.checkPoint("Null arguments");
+ // test null argument - the API spec doesn't specify what should
+ // happen, but a NullPointerException is the usual result elsewhere
+ try
+ {
+ /* Rectangle r2 = */ SwingUtilities.isRectangleContainingRectangle(null, new Rectangle());
+ harness.check(false);
+ }
+ catch (NullPointerException e)
+ {
+ harness.check(true);
+ }
+
+ try
+ {
+ /* Rectangle r2 = */ SwingUtilities.isRectangleContainingRectangle(new Rectangle(), null);
+ harness.check(false);
+ }
+ catch (NullPointerException e)
+ {
+ harness.check(true);
+ }
+ }
+
+}
\ No newline at end of file