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 test for JComponent.getFont()


The getFont() method should return null in a newly created JComponent (before the UI delegate is installed). This test checks for that, highlighting a bug in our implementation:

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

   * gnu/testlet/javax/swing/JComponent/getFont.java: new test,
   * gnu/testlet/javax/swing/JComponent/MyJLabel.java: new support class.

Regards,

Dave Gilbert
Index: gnu/testlet/javax/swing/JComponent/MyJLabel.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/MyJLabel.java
diff -N gnu/testlet/javax/swing/JComponent/MyJLabel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/MyJLabel.java	23 Sep 2005 13:16:59 -0000
@@ -0,0 +1,41 @@
+// Tags: not-a-test
+
+// Copyright (C) 2005 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.JComponent;
+
+import javax.swing.JLabel;
+
+/**
+ * A simple component that won't install a UI delegate (used to check default
+ * settings before the UI delegate is installed).
+ */
+public class MyJLabel extends JLabel {
+    
+    public MyJLabel(String label)
+    {
+      super(label);
+    }
+    
+    public void updateUI() 
+    {
+      // ignore this - we want the raw component, not one that has been 
+      // configured by a UI delegate
+    }
+
+}
Index: gnu/testlet/javax/swing/JComponent/getFont.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComponent/getFont.java
diff -N gnu/testlet/javax/swing/JComponent/getFont.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComponent/getFont.java	23 Sep 2005 13:17:02 -0000
@@ -0,0 +1,45 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.JComponent;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JComponent;
+
+/**
+ * Some checks for the getFont() method in the {@link JComponent} class.
+ */
+public class getFont implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {   
+    // MyJLabel is a label that by-passes installation of a UI-delegate
+    // so we can check the default font is null
+    JComponent label = new MyJLabel("Test");
+    harness.check(label.getFont(), null);    
+  }
+}

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