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]

JList setValueIsAdjusting() and setVisibleRowCount() tests


This patch (committed) adds a couple of new tests:

2006-06-26 David Gilbert <david.gilbert@object-refinery.com>

   * gnu/testlet/javax/swing/JList/setValueIsAdjusting.java: New test,
   * gnu/testlet/javax/swing/JList/setVisibleRowCount.java: New test.

Regards,

Dave
Index: gnu/testlet/javax/swing/JList/setValueIsAdjusting.java
===================================================================
RCS file: gnu/testlet/javax/swing/JList/setValueIsAdjusting.java
diff -N gnu/testlet/javax/swing/JList/setValueIsAdjusting.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JList/setValueIsAdjusting.java	26 Jun 2006 15:17:06 -0000
@@ -0,0 +1,68 @@
+/* setValueIsAdjusting.java -- some checks for the setValueIsAdjusting() method
+       in the JList 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.JList;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.swing.JList;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class setValueIsAdjusting 
+  implements Testlet, PropertyChangeListener, ListSelectionListener 
+{
+  List events = new java.util.ArrayList();
+  
+  public void valueChanged(ListSelectionEvent e) 
+  {
+    events.add(e);
+  }
+  
+  public void propertyChange(PropertyChangeEvent e) 
+  {
+    events.add(e); 
+  }
+  
+  public void test(TestHarness harness) 
+  {
+    JList list = new JList();
+    list.addListSelectionListener(this);
+    harness.check(list.getValueIsAdjusting(), false);
+    harness.check(list.getSelectionModel().getValueIsAdjusting(), false);
+    list.setValueIsAdjusting(true);
+    harness.check(list.getValueIsAdjusting(), true);
+    harness.check(list.getSelectionModel().getValueIsAdjusting(), true);
+    harness.check(events.size(), 0);
+    
+    list.getSelectionModel().setValueIsAdjusting(false);
+    harness.check(list.getValueIsAdjusting(), false);
+  }
+
+}
Index: gnu/testlet/javax/swing/JList/setVisibleRowCount.java
===================================================================
RCS file: gnu/testlet/javax/swing/JList/setVisibleRowCount.java
diff -N gnu/testlet/javax/swing/JList/setVisibleRowCount.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JList/setVisibleRowCount.java	26 Jun 2006 15:17:06 -0000
@@ -0,0 +1,88 @@
+/* setVisibleRowCount.java -- some checks for the setVisibleRowCount() method
+       in the JList 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.JList;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.swing.JList;
+
+public class setVisibleRowCount implements Testlet, PropertyChangeListener
+{
+  List events = new java.util.ArrayList();
+  
+  public void propertyChange(PropertyChangeEvent e) 
+  {
+    events.add(e);
+  }
+
+  public void test(TestHarness harness)
+  {
+    JList list = new JList();
+    harness.check(list.getVisibleRowCount(), 8);
+    list.addPropertyChangeListener(this);
+    list.setVisibleRowCount(13);
+    harness.check(list.getVisibleRowCount(), 13);
+    harness.check(events.size(), 1);
+    PropertyChangeEvent e0 = (PropertyChangeEvent) events.get(0);
+    harness.check(e0.getSource(), list);
+    harness.check(e0.getPropertyName(), "visibleRowCount");
+    harness.check(e0.getOldValue(), new Integer(8));
+    harness.check(e0.getNewValue(), new Integer(13));
+    
+    // setting the same value generates no event
+    events.clear();
+    list.setVisibleRowCount(13);
+    harness.check(events.size(), 0);
+    
+    // try zero
+    list.setVisibleRowCount(0);
+    harness.check(list.getVisibleRowCount(), 0);
+    
+    // try a negative value
+    events.clear();
+    list.setVisibleRowCount(-1);
+    harness.check(list.getVisibleRowCount(), 0);
+    harness.check(events.size(), 1);
+    e0 = (PropertyChangeEvent) events.get(0);
+    harness.check(e0.getSource(), list);
+    harness.check(e0.getPropertyName(), "visibleRowCount");
+    harness.check(e0.getOldValue(), new Integer(0));
+    harness.check(e0.getNewValue(), new Integer(-1));
+        
+    events.clear();
+    list.setVisibleRowCount(-99);
+    harness.check(list.getVisibleRowCount(), 0);
+    e0 = (PropertyChangeEvent) events.get(0);
+    harness.check(e0.getSource(), list);
+    harness.check(e0.getPropertyName(), "visibleRowCount");
+    harness.check(e0.getOldValue(), new Integer(0));
+    harness.check(e0.getNewValue(), new Integer(-99));
+  }
+}

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