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: JLabel - new tests


This patch (committed) adds some new tests for the JLabel class:

2006-05-31 David Gilbert <david.gilbert@object-refinery.com>

   * gnu/testlet/javax/swing/JLabel/getAccessibleContext.java: New file,
   * gnu/testlet/javax/swing/JLabel/paramString.java: New file,
   * gnu/testlet/javax/swing/JLabel/setLabelFor.java: New file,
   * gnu/testlet/javax/swing/JLabel/MyJLabel.java: New file.

Regards,

Dave
Index: gnu/testlet/javax/swing/JLabel/MyJLabel.java
===================================================================
RCS file: gnu/testlet/javax/swing/JLabel/MyJLabel.java
diff -N gnu/testlet/javax/swing/JLabel/MyJLabel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JLabel/MyJLabel.java	31 May 2006 12:29:47 -0000
@@ -0,0 +1,40 @@
+/* MyJLabel.java -- provides access to protected stuff in the JLabel class,
+       for testing purposes.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.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.JLabel;
+
+import javax.swing.JLabel;
+
+public class MyJLabel extends JLabel 
+{
+  public MyJLabel()
+  {
+    super();
+  }
+  
+  public String paramString()
+  {
+    return super.paramString();
+  }
+}
Index: gnu/testlet/javax/swing/JLabel/getAccessibleContext.java
===================================================================
RCS file: gnu/testlet/javax/swing/JLabel/getAccessibleContext.java
diff -N gnu/testlet/javax/swing/JLabel/getAccessibleContext.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JLabel/getAccessibleContext.java	31 May 2006 12:29:47 -0000
@@ -0,0 +1,44 @@
+/* getAccessibleContext.java -- some checks for the getAccessibleContext()
+       method in the JLabel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.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.JLabel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.swing.JLabel;
+
+public class getAccessibleContext implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    JLabel label = new JLabel("ABC");
+    AccessibleContext ac = label.getAccessibleContext();
+    harness.check(ac.getAccessibleRole(), AccessibleRole.LABEL);
+    harness.check(ac.getAccessibleName(), "ABC");
+    harness.check(ac.getAccessibleDescription(), null);
+  }
+}
Index: gnu/testlet/javax/swing/JLabel/paramString.java
===================================================================
RCS file: gnu/testlet/javax/swing/JLabel/paramString.java
diff -N gnu/testlet/javax/swing/JLabel/paramString.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JLabel/paramString.java	31 May 2006 12:29:47 -0000
@@ -0,0 +1,37 @@
+/* paramString.java -- some checks for the paramString() method in the
+       JLabel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.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.JLabel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class paramString implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    MyJLabel label = new MyJLabel();
+    harness.check(label.paramString().endsWith(",defaultIcon=,disabledIcon=,horizontalAlignment=LEADING,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=,verticalAlignment=CENTER,verticalTextPosition=CENTER"));
+  }
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/JLabel/setLabelFor.java
===================================================================
RCS file: gnu/testlet/javax/swing/JLabel/setLabelFor.java
diff -N gnu/testlet/javax/swing/JLabel/setLabelFor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JLabel/setLabelFor.java	31 May 2006 12:29:47 -0000
@@ -0,0 +1,81 @@
+/* setLabelFor.java -- some checks for the setLabelFor() method in the
+       JLabel class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.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.JLabel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+
+public class setLabelFor implements Testlet, PropertyChangeListener
+{
+  List events = new ArrayList();
+
+  public void propertyChange(PropertyChangeEvent e) 
+  {
+    events.add(e);  
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    JButton b = new JButton("ABC");
+    JLabel l = new JLabel("XYZ");
+    b.addPropertyChangeListener(this);
+    l.addPropertyChangeListener(this);
+    l.setLabelFor(b);
+    harness.check(l.getLabelFor(), b);
+    harness.check(events.size(), 2);
+    PropertyChangeEvent pce1 = (PropertyChangeEvent) events.get(0);
+    harness.check(pce1.getSource(), l);
+    harness.check(pce1.getPropertyName(), "labelFor");
+    harness.check(pce1.getOldValue(), null);
+    harness.check(pce1.getNewValue(), b);
+    
+    PropertyChangeEvent pce2 = (PropertyChangeEvent) events.get(1);
+    harness.check(pce2.getSource(), b);
+    harness.check(pce2.getPropertyName(), "labeledBy");
+    harness.check(pce2.getOldValue(), null);
+    harness.check(pce2.getNewValue(), l);
+    
+    harness.check(b.getClientProperty("labeledBy"), l);
+    
+    // setting the same component should generate no events
+    events.clear();
+    l.setLabelFor(b);
+    harness.check(events.size(), 0);
+    
+    // try null
+    events.clear();
+    l.setLabelFor(null);
+    harness.check(events.size(), 2);
+  }
+  
+}

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