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: JSpinner tests


I committed the following tests for the JSpinner class:

2006-02-15 David Gilbert <david.gilbert@object-refinery.com>

   * gnu/testlet/javax/swing/JSpinner/addChangeListener.java: New test,
   * gnu/testlet/javax/swing/JSpinner/constructors.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/createEditor.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/getChangeListeners.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/getEditor.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/getModel.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/getNextValue.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/getPreviousValue.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/getUIClassID.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/MyJSpinner.java: New support class,
   * gnu/testlet/javax/swing/JSpinner/removeChangeListener.java: New test,
   * gnu/testlet/javax/swing/JSpinner/setEditor.java: Likewise,
   * gnu/testlet/javax/swing/JSpinner/setModel.java: Likewise.

I have a version of JSpinner that passes all these tests, and will get it into GNU Classpath CVS soon.

Regards,

Dave
Index: gnu/testlet/javax/swing/JSpinner/MyJSpinner.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/MyJSpinner.java
diff -N gnu/testlet/javax/swing/JSpinner/MyJSpinner.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/MyJSpinner.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,47 @@
+/* MyJSpinner.java -- Support 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: not-a-test
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import javax.swing.JComponent;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerModel;
+
+public class MyJSpinner extends JSpinner 
+{
+  public MyJSpinner() 
+  {
+    super();
+  }
+
+  public MyJSpinner(SpinnerModel m) 
+  {
+    super(m);
+  }
+  
+  public JComponent createEditor(SpinnerModel model) 
+  {
+    return super.createEditor(model);
+  }
+  
+}
Index: gnu/testlet/javax/swing/JSpinner/addChangeListener.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/addChangeListener.java
diff -N gnu/testlet/javax/swing/JSpinner/addChangeListener.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/addChangeListener.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,67 @@
+/* addChangeListener.java -- Checks for the addChangeListener() method in the
+                             JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.List;
+
+import javax.swing.JSpinner;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class addChangeListener implements Testlet, ChangeListener 
+{
+  List events = new java.util.ArrayList();
+  
+  public void stateChanged(ChangeEvent event) 
+  {
+    this.events.add(event);    
+  }
+  
+  public void test(TestHarness harness)
+  {
+    harness.checkPoint("addChangeListener()");
+    JSpinner s = new JSpinner();
+    s.addChangeListener(this);
+    s.getModel().setValue(new Integer(11));
+    harness.check(events.size(), 1);
+    ChangeEvent e = (ChangeEvent) events.get(0);
+    harness.check(e.getSource(), s);
+    
+    // try null listener - it is permitted
+    boolean pass = true;
+    try
+    {
+      s.addChangeListener(null);
+    }
+    catch (NullPointerException npe)
+    {
+      pass = false;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/constructors.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/constructors.java
diff -N gnu/testlet/javax/swing/JSpinner/constructors.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/constructors.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,108 @@
+/* constructors.java -- Some checks for the constructors in the JSpinner 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.4
+ 
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+import java.util.EventListener;
+
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.event.ChangeListener;
+import javax.swing.plaf.metal.DefaultMetalTheme;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * Some checks for the constructors in the {@link JSpinner} class.
+ */
+public class constructors implements Testlet {
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {
+    constructor1(harness);
+    constructor2(harness);
+  }
+  
+  public void constructor1(TestHarness harness) 
+  {
+    harness.checkPoint("()");
+    
+    // use a known look and feel
+    MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
+    try
+      {
+        UIManager.setLookAndFeel(new MetalLookAndFeel());
+      }
+    catch (UnsupportedLookAndFeelException e)
+      {
+        harness.fail(e.toString());  
+      }
+    
+    SpinnerNumberModel m = new SpinnerNumberModel();
+    JSpinner spinner = new JSpinner(m);
+    harness.check(spinner.getValue(), new Integer(0));
+    harness.check(spinner.getEditor() instanceof JSpinner.NumberEditor);
+    
+    // the model has a listener, but it isn't the spinner, editor or UI
+    // some private class is listening and passing on events
+    EventListener[] mListeners = m.getListeners(ChangeListener.class);
+    harness.check(mListeners.length, 1);
+    System.out.println(mListeners[0]);
+    harness.check(!Arrays.asList(mListeners).contains(spinner));
+    harness.check(!Arrays.asList(mListeners).contains(spinner.getUI()));
+    harness.check(!Arrays.asList(mListeners).contains(spinner.getEditor()));
+  }
+
+  public void constructor2(TestHarness harness) 
+  {
+    harness.checkPoint("(SpinnerModel)");
+    SpinnerNumberModel m = new SpinnerNumberModel(5, 0, 10, 1);
+    JSpinner spinner = new JSpinner(m);
+    harness.check(spinner.getValue(), new Integer(5));
+    harness.check(spinner.getEditor() instanceof JSpinner.NumberEditor);
+    
+    // try null model
+    boolean pass = false;
+    try
+    {
+      /*JSpinner s =*/ new JSpinner(null);
+    }
+    catch (NullPointerException e) 
+    {
+      pass = true;
+    }
+    harness.check(pass);
+  }
+
+}
+
Index: gnu/testlet/javax/swing/JSpinner/createEditor.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/createEditor.java
diff -N gnu/testlet/javax/swing/JSpinner/createEditor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/createEditor.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,74 @@
+/* createEditor.java -- Checks for the createEditor() method in the JSpinner 
+                        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.4
+// Uses: MyJSpinner
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.EventListener;
+
+import javax.swing.JComponent;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerDateModel;
+import javax.swing.SpinnerListModel;
+import javax.swing.SpinnerModel;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeListener;
+
+public class createEditor implements Testlet 
+{
+  public void test(TestHarness harness) 
+  {
+    harness.checkPoint("(SpinnerModel)");
+    MyJSpinner s1 = new MyJSpinner();
+    SpinnerModel m1 = new SpinnerNumberModel();
+    JComponent e1 = s1.createEditor(m1);
+    harness.check(e1 instanceof JSpinner.NumberEditor);
+    // no listeners added to the editor yet
+    EventListener[] e1l = e1.getListeners(ChangeListener.class);
+    harness.check(e1l.length, 0);
+    
+    SpinnerModel m2 = new SpinnerDateModel();
+    MyJSpinner s2 = new MyJSpinner(m2);
+    JComponent e2 = s2.createEditor(m2);
+    harness.check(e2 instanceof JSpinner.DateEditor);
+    // no listeners added to the editor yet
+    EventListener[] e2l = e2.getListeners(ChangeListener.class);
+    harness.check(e2l.length, 0);
+    
+    SpinnerModel m3 = new SpinnerListModel();
+    MyJSpinner s3 = new MyJSpinner(m3);
+    JComponent e3 = s3.createEditor(m3);
+    harness.check(e3 instanceof JSpinner.ListEditor);
+    // no listeners added to the editor yet
+    EventListener[] e3l = e3.getListeners(ChangeListener.class);
+    harness.check(e3l.length, 0);
+    
+    // try null argument
+    e3 = s3.createEditor(null);  
+    harness.check(e3 instanceof JSpinner.DefaultEditor);
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/getChangeListeners.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/getChangeListeners.java
diff -N gnu/testlet/javax/swing/JSpinner/getChangeListeners.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/getChangeListeners.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,64 @@
+/* getChangeListeners.java -- Checks for the getChangeListeners() method in the
+                              JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.swing.JSpinner;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class getChangeListeners implements Testlet, ChangeListener 
+{
+  List events = new java.util.ArrayList();
+  
+  public void stateChanged(ChangeEvent event) 
+  {
+    this.events.add(event);    
+  }
+  
+  public void test(TestHarness harness)
+  {
+    harness.checkPoint("()");
+    JSpinner s = new JSpinner();
+    ChangeListener[] cl = s.getChangeListeners();
+    harness.check(cl.length, 1);
+    harness.check(cl[0], s.getEditor());
+    
+    s.addChangeListener(this);
+    cl = s.getChangeListeners();
+    harness.check(cl.length, 2);
+    harness.check(Arrays.asList(cl).contains(this));
+    
+    s.removeChangeListener(this);    
+    cl = s.getChangeListeners();
+    harness.check(cl.length, 1);
+    harness.check(!Arrays.asList(cl).contains(this));
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/getEditor.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/getEditor.java
diff -N gnu/testlet/javax/swing/JSpinner/getEditor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/getEditor.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,44 @@
+/* getEditor.java -- Checks for the getEditor() method in the JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JSpinner;
+
+public class getEditor implements Testlet
+{
+    
+  public void test(TestHarness harness)
+  {
+    harness.checkPoint("()");
+    JSpinner s = new JSpinner();
+    JSpinner.NumberEditor e = new JSpinner.NumberEditor(s);
+    s.setEditor(e);
+    harness.check(s.getEditor(), e);
+  }
+
+}
+
Index: gnu/testlet/javax/swing/JSpinner/getModel.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/getModel.java
diff -N gnu/testlet/javax/swing/JSpinner/getModel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/getModel.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,44 @@
+/* getModel.java -- Checks for the getModel() method in the JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JSpinner;
+import javax.swing.SpinnerDateModel;
+
+public class getModel implements Testlet
+{
+  
+   public void test(TestHarness harness) 
+   {
+     harness.checkPoint("()");
+     JSpinner s = new JSpinner();
+     SpinnerDateModel m = new SpinnerDateModel();
+     s.setModel(m);
+     harness.check(s.getModel(), m);
+   }
+   
+}
Index: gnu/testlet/javax/swing/JSpinner/getNextValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/getNextValue.java
diff -N gnu/testlet/javax/swing/JSpinner/getNextValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/getNextValue.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,51 @@
+/* getNextValue.java -- some checks for the getNextValue() method in the
+                        JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
+
+public class getNextValue implements Testlet {
+
+  
+  public void test(TestHarness harness) 
+  {
+    harness.checkPoint("()");
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    JSpinner s = new JSpinner(m);
+    harness.check(s.getValue(), new Double(2.0));
+    harness.check(s.getNextValue(), new Double(2.5));
+    
+    // accessing the next value doesn't update the current value
+    harness.check(s.getValue(), new Double(2.0));
+    s.setValue(new Double(2.5));
+    harness.check(s.getNextValue(), new Double(3.0));
+    s.setValue(new Double(3.0));
+    harness.check(s.getNextValue(), null);
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/getPreviousValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/getPreviousValue.java
diff -N gnu/testlet/javax/swing/JSpinner/getPreviousValue.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/getPreviousValue.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,50 @@
+/* getPreviousValue.java -- some checks for the getPreviousValue() method in the
+                            JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
+
+public class getPreviousValue implements Testlet {
+
+  
+  public void test(TestHarness harness) 
+  {
+    harness.checkPoint("()");
+    SpinnerNumberModel m = new SpinnerNumberModel(2.0, 1.0, 3.0, 0.5);
+    JSpinner s = new JSpinner(m);
+    harness.check(s.getValue(), new Double(2.0));
+    harness.check(s.getPreviousValue(), new Double(1.5));
+    // accessing the previous value doesn't update the current value
+    harness.check(s.getValue(), new Double(2.0));
+    s.setValue(new Double(1.5));
+    harness.check(s.getPreviousValue(), new Double(1.0));
+    s.setValue(new Double(1.0));
+    harness.check(s.getPreviousValue(), null);
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/getUIClassID.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/getUIClassID.java
diff -N gnu/testlet/javax/swing/JSpinner/getUIClassID.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/getUIClassID.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,40 @@
+/* getUIClassID.java -- Checks for the getUIClassID() method in the JSpinner
+                        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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JSpinner;
+
+public class getUIClassID implements Testlet 
+{
+  public void test(TestHarness harness) 
+  {
+    harness.checkPoint("()");
+    JSpinner s = new JSpinner();
+    harness.check(s.getUIClassID(), "SpinnerUI");
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/removeChangeListener.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/removeChangeListener.java
diff -N gnu/testlet/javax/swing/JSpinner/removeChangeListener.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/removeChangeListener.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,73 @@
+/* removeChangeListener.java -- Checks for the removeChangeListener() method in 
+                                the JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.List;
+
+import javax.swing.JSpinner;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class removeChangeListener implements Testlet, ChangeListener 
+{
+  List events = new java.util.ArrayList();
+  
+  public void stateChanged(ChangeEvent event) 
+  {
+    this.events.add(event);    
+  }
+  
+  public void test(TestHarness harness)
+  {
+    harness.checkPoint("(ChangeListener)");
+    JSpinner s = new JSpinner();
+    s.addChangeListener(this);
+    s.getModel().setValue(new Integer(11));
+    harness.check(events.size(), 1);
+    ChangeEvent e = (ChangeEvent) events.get(0);
+    harness.check(e.getSource(), s);
+    
+    // now remove the listener and repeat
+    events.clear();
+    s.removeChangeListener(this);
+    s.getModel().setValue(new Integer(22));
+    harness.check(events.size(), 0);
+    
+    // try null listener - it is permitted
+    boolean pass = true;
+    try
+    {
+      s.removeChangeListener(null);
+    }
+    catch (NullPointerException npe)
+    {
+      pass = false;
+    }
+    harness.check(pass);
+  }
+}
Index: gnu/testlet/javax/swing/JSpinner/setEditor.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/setEditor.java
diff -N gnu/testlet/javax/swing/JSpinner/setEditor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/setEditor.java	15 Feb 2006 14:33:26 -0000
@@ -0,0 +1,87 @@
+/* setEditor.java -- Checks for the setEditor() method in the JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Arrays;
+import java.util.EventListener;
+import java.util.List;
+
+import javax.swing.JComponent;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.event.ChangeListener;
+
+public class setEditor implements Testlet, PropertyChangeListener 
+{
+
+   List events = new java.util.ArrayList();
+   
+   public void propertyChange(PropertyChangeEvent e) 
+   {
+     events.add(e);
+   }
+    
+  public void test(TestHarness harness)
+  {
+    harness.checkPoint("(JComponent)");
+    JSpinner s = new JSpinner();
+    s.addPropertyChangeListener(this);
+    JComponent e = s.getEditor();
+    SpinnerNumberModel m = (SpinnerNumberModel) s.getModel();
+    
+    EventListener[] l1 = s.getListeners(ChangeListener.class);
+    harness.check(Arrays.asList(l1).contains(e));
+    harness.check(!Arrays.asList(l1).contains(m));
+
+    JSpinner.NumberEditor e2 = new JSpinner.NumberEditor(s);
+    s.setEditor(e2);
+    harness.check(s.getEditor(), e2);
+    harness.check(events.size(), 1);
+    PropertyChangeEvent pce = (PropertyChangeEvent) events.get(0);
+    harness.check(pce.getPropertyName(), "editor");
+    harness.check(pce.getOldValue(), e);
+    harness.check(pce.getNewValue(), e2);
+    l1 = s.getListeners(ChangeListener.class);
+    harness.check(Arrays.asList(l1).contains(e2));
+    harness.check(!Arrays.asList(l1).contains(e));
+    
+    // try null argument
+    boolean pass = false;
+    try
+      {
+        s.setEditor(null);
+      }
+    catch (IllegalArgumentException iae)
+      {
+        pass = true;
+      }
+    harness.check(pass);
+  }
+
+}
Index: gnu/testlet/javax/swing/JSpinner/setModel.java
===================================================================
RCS file: gnu/testlet/javax/swing/JSpinner/setModel.java
diff -N gnu/testlet/javax/swing/JSpinner/setModel.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JSpinner/setModel.java	15 Feb 2006 14:33:27 -0000
@@ -0,0 +1,85 @@
+/* setModel.java -- Checks for the setModel() method in the JSpinner 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.4
+
+package gnu.testlet.javax.swing.JSpinner;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.swing.JSpinner;
+import javax.swing.SpinnerDateModel;
+import javax.swing.SpinnerNumberModel;
+
+public class setModel implements Testlet, PropertyChangeListener 
+{
+   List events = new java.util.ArrayList();
+   
+   public void propertyChange(PropertyChangeEvent e) 
+   {
+     events.add(e);
+   }
+   
+   public void test(TestHarness harness) 
+   {
+     harness.checkPoint("(SpinnerModel)");
+     JSpinner s = new JSpinner();
+     harness.check(s.getEditor() instanceof JSpinner.NumberEditor);
+     s.addPropertyChangeListener(this);
+     SpinnerDateModel m = new SpinnerDateModel();
+     s.setModel(m);
+     harness.check(s.getModel(), m);
+     harness.check(events.size(), 2);
+     PropertyChangeEvent e1 = (PropertyChangeEvent) events.get(0);
+     harness.check(e1.getPropertyName(), "model");
+     harness.check(e1.getSource(), s);
+     harness.check(e1.getNewValue(), m);
+     harness.check(e1.getOldValue() instanceof SpinnerNumberModel);
+     PropertyChangeEvent e2 = (PropertyChangeEvent) events.get(1);
+     harness.check(e2.getPropertyName(), "editor");
+     harness.check(e2.getSource(), s);
+     harness.check(e2.getNewValue() instanceof JSpinner.DateEditor);
+     harness.check(e2.getOldValue() instanceof JSpinner.NumberEditor);
+   
+     // setting the same model generates no event
+     events.clear();
+     s.setModel(m);
+     harness.check(events.size(), 0);
+     
+     // try null argument
+     boolean pass = false;
+     try
+       {
+         s.setModel(null);
+       }
+     catch (IllegalArgumentException e) 
+       {
+         pass = true;
+       }
+     harness.check(pass);
+   }
+   
+}

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