This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: New UIManager test
- From: "Roman Kennke" <kennke at aicas dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Tue, 18 Oct 2005 15:24:49 +0000
- Subject: FYI: New UIManager test
- Bounce-to: "Roman Kennke" <kennke@aicas.com>
I checked in a small test for UIManager.
2005-10-18 Roman Kennke <kennke@aicas.com>
* gnu/testlet/javax/swing/UIManager/TestLabelUI.java:
New auxiliary helper class.
* gnu/testlet/javax/swing/UIManager/getUI.java:
New test.
* gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java:
Added default test UI for JLabel.
/Roman
Index: gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java,v
retrieving revision 1.1
diff -u -r1.1 MyLookAndFeel.java
--- gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java 23 Aug 2005 13:53:36 -0000 1.1
+++ gnu/testlet/javax/swing/UIManager/MyLookAndFeel.java 18 Oct 2005 15:21:54 -0000
@@ -20,6 +20,7 @@
package gnu.testlet.javax.swing.UIManager;
import javax.swing.LookAndFeel;
+import javax.swing.UIDefaults;
/**
* A minimal look and feel class for use in testing.
@@ -42,4 +43,11 @@
public boolean isSupportedLookAndFeel() {
return true;
}
+ public UIDefaults getDefaults()
+ {
+ UIDefaults def = new UIDefaults();
+ def.put("LabelUI", "gnu.testlet.javax.swing.UIManager.TestLabelUI");
+ return def;
+ }
+
}
Index: gnu/testlet/javax/swing/UIManager/TestLabelUI.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/TestLabelUI.java
diff -N gnu/testlet/javax/swing/UIManager/TestLabelUI.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/TestLabelUI.java 18 Oct 2005 15:21:54 -0000
@@ -0,0 +1,40 @@
+// 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.UIManager;
+
+import javax.swing.JComponent;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.LabelUI;
+
+/**
+ * A minimal UI for JLabel for testing.
+ */
+public class TestLabelUI extends LabelUI {
+ static boolean installUICalled = false;
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ installUICalled = true;
+ }
+ public static ComponentUI createUI(JComponent c)
+ {
+ return new TestLabelUI();
+ }
+}
Index: gnu/testlet/javax/swing/UIManager/getUI.java
===================================================================
RCS file: gnu/testlet/javax/swing/UIManager/getUI.java
diff -N gnu/testlet/javax/swing/UIManager/getUI.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/UIManager/getUI.java 18 Oct 2005 15:21:54 -0000
@@ -0,0 +1,63 @@
+// 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.UIManager;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JLabel;
+import javax.swing.UIManager;
+import javax.swing.plaf.LabelUI;
+
+/**
+ * Some checks for the getUI() method in the
+ * {@link UIManager} class.
+ */
+public class getUI implements Testlet {
+
+ class TestLabel extends JLabel
+ {
+ public void setUI(LabelUI ui)
+ {
+ // Overridden for test.
+ }
+ }
+
+ /**
+ * Runs the test using the specified harness.
+ *
+ * @param harness the test harness (<code>null</code> not permitted).
+ */
+ public void test(TestHarness harness)
+ {
+ try
+ {
+ UIManager.setLookAndFeel(new MyLookAndFeel());
+ }
+ catch (Exception ex)
+ {
+ harness.fail(ex.getMessage());
+ }
+
+ TestLabel l = new TestLabel();
+ UIManager.getUI(l);
+ harness.check(TestLabelUI.installUICalled, true);
+ }
+}