* FYI: New JComponent tests
@ 2005-10-18 14:44 Roman Kennke
0 siblings, 0 replies; only message in thread
From: Roman Kennke @ 2005-10-18 14:44 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]
I committed a bunch of tests that check which properties should trigger
repaint and revalidate under which conditions.
2005-10-18 Roman Kennke <kennke@aicas.com>
* gnu/testlet/javax/swing/JComponent/TestComponent.java:
New auxiliary helper class.
* gnu/testlet/javax/swing/JComponent/paint.java:
* gnu/testlet/javax/swing/JComponent/setAlignmentX.java:
* gnu/testlet/javax/swing/JComponent/setAlignmentY.java:
* gnu/testlet/javax/swing/JComponent/setBackground.java:
* gnu/testlet/javax/swing/JComponent/setBorder.java:
* gnu/testlet/javax/swing/JComponent/setEnabled.java:
* gnu/testlet/javax/swing/JComponent/setFont.java:
* gnu/testlet/javax/swing/JComponent/setForeground.java:
* gnu/testlet/javax/swing/JComponent/setMaximumSize.java:
* gnu/testlet/javax/swing/JComponent/setMinimumSize.java:
* gnu/testlet/javax/swing/JComponent/setOpaque.java:
*
gnu/testlet/javax/swing/JComponent/setPreferredSize.java:
* gnu/testlet/javax/swing/JComponent/setUI.java:
* gnu/testlet/javax/swing/JComponent/setVisible.java:
New tests.
/Roman
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: JComponent-tests.diff --]
[-- Type: text/x-patch; name="JComponent-tests.diff", Size: 52032 bytes --]
Index: gnu/testlet/javax/swing/JComponent/TestComponent.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/TestComponent.java
diff -N gnu/testlet/javax/swing/JComponent/TestComponent.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/TestComponent.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,71 @@
+// Tags: not-a-test
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import javax.swing.JComponent;
+import javax.swing.plaf.ComponentUI;
+
+/**
+ * A subclass of {@link javax.swing.JComponent} that enables to check if
+ * certain methods (like repaint() or revalidate()) are called correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+class TestComponent extends JComponent
+{
+ /**
+ * A flag indicating if repaint() has been called.
+ */
+ boolean repaintCalled;
+
+ /**
+ * A flag indicating if revalidate() has been called.
+ */
+ boolean revalidateCalled;
+
+ /**
+ * Performs the superclass repaint and sets the repaintCalled flag to true.
+ */
+ public void repaint()
+ {
+ repaintCalled = true;
+ super.repaint();
+ }
+
+ /**
+ * Performs the superclass revalidate and sets the revalidateCalled flag
+ * to true.
+ */
+ public void revalidate()
+ {
+ revalidateCalled = true;
+ super.revalidate();
+ }
+
+ /**
+ * Overridden to make public.
+ *
+ * @param ui the UI to set
+ */
+ public void setUI(ComponentUI ui)
+ {
+ super.setUI(ui);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/paint.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/paint.java
diff -N gnu/testlet/javax/swing/JComponent/paint.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/paint.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,72 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Graphics;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+
+/**
+ * Tests if the paint() method works correctly.
+ */
+public class paint implements Testlet
+{
+ StringBuffer callOrder = new StringBuffer();
+ class TestComponent extends JComponent
+ {
+ protected void paintComponent(Graphics g)
+ {
+ callOrder.append('1');
+ }
+ protected void paintBorder(Graphics g)
+ {
+ callOrder.append('2');
+ }
+ protected void paintChildren(Graphics g)
+ {
+ callOrder.append('3');
+ }
+ }
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ JFrame f = new JFrame();
+ JComponent c = new TestComponent();
+ f.setContentPane(c);
+ f.setSize(100, 100);
+ f.setVisible(true);
+ callOrder.delete(0, callOrder.length());
+ Graphics g = c.getGraphics();
+ c.paint(g);
+ // If the components receives multiple paint requests (like the system
+ // triggers a repaint), then we might get 123123123 or something. To avoid
+ // trouble like this, we check using startsWith().
+ harness.check(callOrder.toString().startsWith("123"));
+ f.dispose();
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setAlignmentX.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setAlignmentX.java
diff -N gnu/testlet/javax/swing/JComponent/setAlignmentX.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setAlignmentX.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,99 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setAlignmentX works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setAlignmentX implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setAlignmentX triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to 0.0, so that we know the state.
+ c.setAlignmentX(0.0F);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setAlignmentX(0.5F);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setAlignmentX(0.5F);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setAlignmentX(1.0F);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setAlignmentX(1.0F);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setAlignmentX triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to 0.0, so that we know the state.
+ c.setAlignmentX(0.0F);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setAlignmentX(0.5F);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setAlignmentX(0.5F);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setAlignmentX(1.0F);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setAlignmentX(1.0F);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setAlignmentY.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setAlignmentY.java
diff -N gnu/testlet/javax/swing/JComponent/setAlignmentY.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setAlignmentY.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,99 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setAlignmentY works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setAlignmentY implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setAlignmentY triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to 0.0, so that we know the state.
+ c.setAlignmentY(0.0F);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setAlignmentY(0.5F);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setAlignmentY(0.5F);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setAlignmentY(1.0F);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setAlignmentY(1.0F);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setAlignmentY triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to 0.0, so that we know the state.
+ c.setAlignmentY(0.0F);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setAlignmentY(0.5F);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setAlignmentY(0.5F);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setAlignmentY(1.0F);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setAlignmentY(1.0F);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setBackground.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setBackground.java
diff -N gnu/testlet/javax/swing/JComponent/setBackground.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setBackground.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,102 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import java.awt.Color;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setBackground works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setBackground implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setBackground triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to white, so that we know the state.
+ c.setBackground(Color.WHITE);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setBackground(Color.BLACK);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setBackground(Color.BLACK);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setBackground(Color.WHITE);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setBackground(Color.WHITE);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setBackground triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ c.setBounds(10, 20, 30, 40);
+ // Set to white, so that we know the state.
+ c.setBackground(Color.WHITE);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setBackground(Color.BLACK);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setBackground(Color.BLACK);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setBackground(Color.WHITE);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setBackground(Color.WHITE);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setBorder.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setBorder.java
diff -N gnu/testlet/javax/swing/JComponent/setBorder.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setBorder.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,107 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import javax.swing.border.Border;
+import javax.swing.border.EtchedBorder;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setBorder works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setBorder implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setBorder triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ Border b1 = new EtchedBorder();
+ Border b2 = new EtchedBorder();
+ TestComponent c = new TestComponent();
+ // Set to b1, so that we know the state.
+ c.setBorder(b1);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setBorder(b2);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setBorder(b2);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setBorder(b1);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setBorder(b1);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setBorder triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ Border b1 = new EtchedBorder();
+ Border b2 = new EtchedBorder();
+ TestComponent c = new TestComponent();
+ c.setBounds(10, 20, 30, 40);
+ // Set to b1, so that we know the state.
+ c.setBorder(b1);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setBorder(b2);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setBorder(b2);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setBorder(b1);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setBorder(b1);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setEnabled.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setEnabled.java
diff -N gnu/testlet/javax/swing/JComponent/setEnabled.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setEnabled.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,101 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setEnabled works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setEnabled implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setEnabled triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ c.setBounds(10, 20, 30, 40);
+ // Set to false, so that we know the state.
+ c.setEnabled(false);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setEnabled(true);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setEnabled(true);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setEnabled(false);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setEnabled(false);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setEnabled triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ c.setBounds(10, 20, 30, 40);
+ // Set to false, so that we know the state.
+ c.setEnabled(false);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setEnabled(true);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setEnabled(true);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setEnabled(false);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setEnabled(false);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setFont.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setFont.java
diff -N gnu/testlet/javax/swing/JComponent/setFont.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setFont.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,110 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import java.awt.Color;
+import java.awt.Font;
+
+import javax.swing.BorderFactory;
+import javax.swing.border.Border;
+import javax.swing.border.EtchedBorder;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setFont works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setFont implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setFont triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ Font f1 = new Font("Dialog", Font.PLAIN, 12);
+ Font f2 = new Font("Dialog", Font.PLAIN, 14);
+ TestComponent c = new TestComponent();
+ // Set to f1, so that we know the state.
+ c.setFont(f1);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setFont(f2);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setFont(f2);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setFont(f1);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setFont(f1);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setFont triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ Font f1 = new Font("Dialog", Font.PLAIN, 12);
+ Font f2 = new Font("Dialog", Font.PLAIN, 14);
+ TestComponent c = new TestComponent();
+ // Set to f1, so that we know the state.
+ c.setFont(f1);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setFont(f2);
+ harness.check(c.revalidateCalled, true);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setFont(f2);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setFont(f1);
+ harness.check(c.revalidateCalled, true);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setFont(f1);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setForeground.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setForeground.java
diff -N gnu/testlet/javax/swing/JComponent/setForeground.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setForeground.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,101 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import java.awt.Color;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setForeground works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setForeground implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setForeground triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to white, so that we know the state.
+ c.setForeground(Color.WHITE);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setForeground(Color.BLACK);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setForeground(Color.BLACK);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setForeground(Color.WHITE);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setForeground(Color.WHITE);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setForeground triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to white, so that we know the state.
+ c.setForeground(Color.WHITE);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setForeground(Color.BLACK);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setForeground(Color.BLACK);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setForeground(Color.WHITE);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setForeground(Color.WHITE);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setMaximumSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setMaximumSize.java
diff -N gnu/testlet/javax/swing/JComponent/setMaximumSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setMaximumSize.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,106 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import java.awt.Color;
+import java.awt.Dimension;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setMaximumSize works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setMaximumSize implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setMaximumSize triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ Dimension s1 = new Dimension(100, 100);
+ Dimension s2 = new Dimension(200, 200);
+ TestComponent c = new TestComponent();
+ // Set to s1, so that we know the state.
+ c.setMaximumSize(s1);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setMaximumSize(s2);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setMaximumSize(s2);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setMaximumSize(s1);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setMaximumSize(s1);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setMaximumSize triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ Dimension s1 = new Dimension(100, 100);
+ Dimension s2 = new Dimension(200, 200);
+ TestComponent c = new TestComponent();
+ // Set to false, so that we know the state.
+ c.setMaximumSize(s1);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setMaximumSize(s2);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setMaximumSize(s2);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setMaximumSize(s1);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setMaximumSize(s1);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setMinimumSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setMinimumSize.java
diff -N gnu/testlet/javax/swing/JComponent/setMinimumSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setMinimumSize.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,105 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import java.awt.Dimension;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setMinimumSize works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setMinimumSize implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setMinimumSize triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ Dimension s1 = new Dimension(100, 100);
+ Dimension s2 = new Dimension(200, 200);
+ TestComponent c = new TestComponent();
+ // Set to s1, so that we know the state.
+ c.setMinimumSize(s1);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setMinimumSize(s2);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setMinimumSize(s2);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setMinimumSize(s1);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setMinimumSize(s1);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setMinimumSize triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ Dimension s1 = new Dimension(100, 100);
+ Dimension s2 = new Dimension(200, 200);
+ TestComponent c = new TestComponent();
+ // Set to false, so that we know the state.
+ c.setMinimumSize(s1);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setMinimumSize(s2);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setMinimumSize(s2);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setMinimumSize(s1);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setMinimumSize(s1);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setOpaque.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setOpaque.java
diff -N gnu/testlet/javax/swing/JComponent/setOpaque.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setOpaque.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,100 @@
+//Tags: JDK1.2
+//Uses: TestComponent
+
+//Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+* Tests if setOpaque works correctly.
+*
+* @author Roman Kennke (kennke@aicas.com)
+*/
+public class setOpaque implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setOpaque triggers a repaint. setOpaque should trigger a
+ * repaint() call whenever the actual value of the property changes.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to false, so that we know the state.
+ c.setOpaque(false);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setOpaque(true);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setOpaque(true);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setOpaque(false);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setOpaque(false);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setOpaque triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to false, so that we know the state.
+ c.setOpaque(false);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setOpaque(true);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setOpaque(true);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setOpaque(false);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setOpaque(false);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setPreferredSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setPreferredSize.java
diff -N gnu/testlet/javax/swing/JComponent/setPreferredSize.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setPreferredSize.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,105 @@
+// Tags: JDK1.2
+// Uses: TestComponent
+
+// Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import java.awt.Dimension;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+ * Tests if setPreferredSize works correctly.
+ *
+ * @author Roman Kennke (kennke@aicas.com)
+ */
+public class setPreferredSize implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setPreferredSize triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ Dimension s1 = new Dimension(100, 100);
+ Dimension s2 = new Dimension(200, 200);
+ TestComponent c = new TestComponent();
+ // Set to s1, so that we know the state.
+ c.setPreferredSize(s1);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setPreferredSize(s2);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setPreferredSize(s2);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setPreferredSize(s1);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setPreferredSize(s1);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setPreferredSize triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ Dimension s1 = new Dimension(100, 100);
+ Dimension s2 = new Dimension(200, 200);
+ TestComponent c = new TestComponent();
+ // Set to s1, so that we know the state.
+ c.setPreferredSize(s1);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setPreferredSize(s2);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setPreferredSize(s2);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setPreferredSize(s1);
+ harness.check(c.revalidateCalled, false);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setPreferredSize(s1);
+ harness.check(c.revalidateCalled, false);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setUI.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setUI.java
diff -N gnu/testlet/javax/swing/JComponent/setUI.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setUI.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,106 @@
+//Tags: JDK1.2
+//Uses: TestComponent
+
+//Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import javax.swing.plaf.ComponentUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+* Tests if setUI works correctly.
+*
+* @author Roman Kennke (kennke@aicas.com)
+*/
+public class setUI implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setUI triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ ComponentUI u1 = new ComponentUI(){};
+ ComponentUI u2 = new ComponentUI(){};
+ c.setBounds(10, 20, 30, 40);
+ // Set to u1, so that we know the state.
+ c.setUI(u1);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setUI(u2);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setUI(u2);
+ harness.check(c.repaintCalled, true);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setUI(u1);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setUI(u1);
+ harness.check(c.repaintCalled, true);
+ }
+
+ /**
+ * Tests if setUI triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ ComponentUI u1 = new ComponentUI(){};
+ ComponentUI u2 = new ComponentUI(){};
+ // Set to u1, so that we know the state.
+ c.setUI(u1);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setUI(u2);
+ harness.check(c.revalidateCalled, true);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setUI(u2);
+ harness.check(c.revalidateCalled, true);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setUI(u1);
+ harness.check(c.revalidateCalled, true);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setUI(u1);
+ harness.check(c.revalidateCalled, true);
+ }
+}
Index: gnu/testlet/javax/swing/JComponent/setVisible.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/setVisible.java
diff -N gnu/testlet/javax/swing/JComponent/setVisible.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/setVisible.java 18 Oct 2005 14:38:46 -0000
@@ -0,0 +1,136 @@
+//Tags: JDK1.2
+//Uses: TestComponent
+
+//Copyright (C) 2005 Roman Kennke <kennke@aicas.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.JComponent;
+
+import javax.swing.JFrame;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+/**
+* Tests if setVisible works correctly.
+*
+* @author Roman Kennke (kennke@aicas.com)
+*/
+public class setVisible implements Testlet
+{
+ /**
+ * Starts the test run.
+ *
+ * @param harness the test harness to use
+ */
+ public void test(TestHarness harness)
+ {
+ testRepaint(harness);
+ testRepaintNotShowing(harness);
+ testRevalidate(harness);
+ }
+
+ /**
+ * Tests if setVisible triggers a repaint.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaint(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ JFrame f = new JFrame();
+ f.getContentPane().add(c);
+ f.setSize(200, 200);
+ f.setVisible(true);
+ c.setBounds(10, 20, 30, 40);
+ // Set to false, so that we know the state.
+ c.setVisible(false);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setVisible(true);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setVisible(true);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setVisible(false);
+ harness.check(c.repaintCalled, true);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setVisible(false);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setVisible triggers a repaint when the component is not showing.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRepaintNotShowing(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ // Set to false, so that we know the state.
+ c.setVisible(false);
+ c.repaintCalled = false;
+ // Change state and check if repaint is called.
+ c.setVisible(true);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setVisible(true);
+ harness.check(c.repaintCalled, false);
+ // Change state and check if repaint is called.
+ c.repaintCalled = false;
+ c.setVisible(false);
+ harness.check(c.repaintCalled, false);
+ // Don't change state.
+ c.repaintCalled = false;
+ c.setVisible(false);
+ harness.check(c.repaintCalled, false);
+ }
+
+ /**
+ * Tests if setVisible triggers a revalidate.
+ *
+ * @param harness the test harness to use
+ */
+ private void testRevalidate(TestHarness harness)
+ {
+ TestComponent c = new TestComponent();
+ c.setBounds(10, 20, 30, 40);
+ // Set to false, so that we know the state.
+ c.setVisible(false);
+ c.revalidateCalled = false;
+ // Change state and check if repaint is called.
+ c.setVisible(true);
+ harness.check(c.revalidateCalled, true);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setVisible(true);
+ harness.check(c.revalidateCalled, false);
+ // Change state and check if repaint is called.
+ c.revalidateCalled = false;
+ c.setVisible(false);
+ harness.check(c.revalidateCalled, true);
+ // Don't change state.
+ c.revalidateCalled = false;
+ c.setVisible(false);
+ harness.check(c.revalidateCalled, false);
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-10-18 14:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-18 14:44 FYI: New JComponent tests Roman Kennke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).