This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: DefaultListSelectionModel - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Wed, 31 May 2006 10:09:00 +0100
- Subject: FYI: DefaultListSelectionModel - new tests
This patch (committed) adds many new tests for the
DefaultListSelectionModel class:
2006-05-31 David Gilbert <david.gilbert@object-refinery.com>
*
gnu/testlet/javax/swing/DefaultListSelectionModel/addListSelectionListener.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/addSelectionInterval.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/clearSelection.java:
New file,
* gnu/testlet/javax/swing/DefaultListSelectionModel/clone.java: New
file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/constructor.java: New
file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getAnchorSelection.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getLeadSelectionIndex.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getListeners.java: New
file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getListSelectionListeners.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getMaxSelectionIndex.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getMinSelectionIndex.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getSelectionMode.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/getValueIsAdjusting.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/insertIndexInterval.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/isLeadAnchorNotificationEnabled.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectedIndex.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectionEmpty.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/moveLeadSelectionIndex.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/removeIndexInterval.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/removeListSelectionListener.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/removeSelectionInterval.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/setAnchorSelectionIndex.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionInterval.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionMode.java:
New file,
*
gnu/testlet/javax/swing/DefaultListSelectionModel/setValueIsAdjusting.java:
New file,
* gnu/testlet/javax/swing/DefaultListSelectionModel/toString.java:
New file.
Regards,
Dave
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/addListSelectionListener.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/addListSelectionListener.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/addListSelectionListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/addListSelectionListener.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,55 @@
+/* addListSelectionListener.java -- some checks for the addSelectionListener()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class addListSelectionListener
+ implements Testlet, ListSelectionListener {
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // ignore
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addListSelectionListener(this);
+ harness.check(m.getListSelectionListeners().length, 1);
+ harness.check(m.getListSelectionListeners()[0], this);
+
+ // try null
+ m.addListSelectionListener(null);
+ harness.check(m.getListSelectionListeners().length, 1);
+ harness.check(m.getListSelectionListeners()[0], this);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/addSelectionInterval.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/addSelectionInterval.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/addSelectionInterval.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/addSelectionInterval.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,204 @@
+/* addSelectionInterval.java -- some checks for the addSelectionInterval()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class addSelectionInterval implements Testlet, ListSelectionListener
+{
+
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testSingleSelection(harness);
+ testSingleIntervalSelection(harness);
+ testMultipleIntervalSelection(harness);
+ }
+
+ private void testSingleSelection(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addListSelectionListener(this);
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.addSelectionInterval(1, 3);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), false);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.getAnchorSelectionIndex(), 3);
+ harness.check(m.getLeadSelectionIndex(), 3);
+ harness.check(m.getMaxSelectionIndex(), 3);
+ harness.check(m.getMinSelectionIndex(), 3);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 3);
+
+ m.clearSelection();
+ m.addSelectionInterval(3, 1);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), false);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.getAnchorSelectionIndex(), 1);
+ harness.check(m.getLeadSelectionIndex(), 1);
+ harness.check(m.getMaxSelectionIndex(), 1);
+ harness.check(m.getMinSelectionIndex(), 1);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 1);
+ harness.check(lastEvent.getLastIndex(), 3);
+ }
+
+ private void testSingleIntervalSelection(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addListSelectionListener(this);
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m.addSelectionInterval(1, 3);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.getAnchorSelectionIndex(), 1);
+ harness.check(m.getLeadSelectionIndex(), 3);
+ harness.check(m.getMaxSelectionIndex(), 3);
+ harness.check(m.getMinSelectionIndex(), 1);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 1);
+ harness.check(lastEvent.getLastIndex(), 3);
+
+ // add a non-adjacent interval
+ m.addSelectionInterval(5, 6);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), false);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), false);
+ harness.check(m.getAnchorSelectionIndex(), 5);
+ harness.check(m.getLeadSelectionIndex(), 6);
+ harness.check(m.getMaxSelectionIndex(), 6);
+ harness.check(m.getMinSelectionIndex(), 5);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 1);
+ harness.check(lastEvent.getLastIndex(), 6);
+
+ // add an adjacent interval
+ m.addSelectionInterval(7, 8);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.isSelectedIndex(8), true);
+ harness.check(m.isSelectedIndex(9), false);
+ harness.check(m.getAnchorSelectionIndex(), 7);
+ harness.check(m.getLeadSelectionIndex(), 8);
+ harness.check(m.getMaxSelectionIndex(), 8);
+ harness.check(m.getMinSelectionIndex(), 5);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 5);
+ harness.check(lastEvent.getLastIndex(), 8);
+
+ // add another adjacent interval
+ m.addSelectionInterval(3, 4);
+ harness.check(m.isSelectedIndex(2), false);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.isSelectedIndex(8), true);
+ harness.check(m.isSelectedIndex(9), false);
+ harness.check(m.getAnchorSelectionIndex(), 3);
+ harness.check(m.getLeadSelectionIndex(), 4);
+ harness.check(m.getMaxSelectionIndex(), 8);
+ harness.check(m.getMinSelectionIndex(), 3);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 8);
+
+ m.clearSelection();
+ m.addSelectionInterval(3, 1);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.getAnchorSelectionIndex(), 3);
+ harness.check(m.getLeadSelectionIndex(), 1);
+ harness.check(m.getMaxSelectionIndex(), 3);
+ harness.check(m.getMinSelectionIndex(), 1);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 1);
+ harness.check(lastEvent.getLastIndex(), 4); // this is 4 because that
+ // is the old lead selection
+ }
+
+ private void testMultipleIntervalSelection(TestHarness harness)
+ {
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addSelectionInterval(1, 3);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+
+ m.clearSelection();
+ m.addSelectionInterval(2, 1);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), false);
+
+ // check what happens for negative indices...
+ m.clearSelection();
+ m.addSelectionInterval(-1, 1);
+ harness.check(m.isSelectedIndex(-2), false);
+ harness.check(m.isSelectedIndex(-1), false);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), false);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/clearSelection.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/clearSelection.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/clearSelection.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/clearSelection.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,133 @@
+/* clearSelection.java -- some checks for the clearSelection()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class clearSelection implements Testlet, ListSelectionListener
+{
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ lastEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testSingleSelection(harness);
+ testSingleIntervalSelection(harness);
+ testMultipleIntervalSelection(harness);
+ }
+
+ private void testSingleSelection(TestHarness harness)
+ {
+ // clearing an empty selection generates no event
+ harness.checkPoint("SINGLE_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.addListSelectionListener(this);
+ m.clearSelection();
+ harness.check(lastEvent, null);
+
+ harness.checkPoint("SINGLE_SELECTION (2)");
+ m.setSelectionInterval(3, 3);
+ lastEvent = null;
+ m.clearSelection();
+ harness.check(m.isSelectionEmpty());
+ harness.check(m.getAnchorSelectionIndex(), 3);
+ harness.check(m.getLeadSelectionIndex(), 3);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 3);
+ }
+
+ private void testSingleIntervalSelection(TestHarness harness)
+ {
+ // check 1 : clearing an empty selection generates no event
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m.addListSelectionListener(this);
+ harness.check(m.isSelectionEmpty(), true);
+ lastEvent = null;
+ m.clearSelection();
+ harness.check(m.isSelectionEmpty(), true);
+ harness.check(lastEvent, null);
+
+ // check 2 : clearing a selection generates an event with first and last
+ // indices covering the former selection
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (2)");
+ m.addSelectionInterval(10, 20);
+ lastEvent = null;
+ m.clearSelection();
+ harness.check(m.isSelectionEmpty(), true);
+ harness.check(m.isSelectedIndex(10), false);
+ harness.check(m.getAnchorSelectionIndex(), 10);
+ harness.check(m.getLeadSelectionIndex(), 20);
+ harness.check(m.getMinSelectionIndex(), -1);
+ harness.check(m.getMaxSelectionIndex(), -1);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 10);
+ harness.check(lastEvent.getLastIndex(), 20);
+ }
+
+ private void testMultipleIntervalSelection(TestHarness harness)
+ {
+ // check 1 : clearing an empty selection generates no event
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ m.addListSelectionListener(this);
+ harness.check(m.isSelectionEmpty(), true);
+ lastEvent = null;
+ m.clearSelection();
+ harness.check(m.isSelectionEmpty(), true);
+ harness.check(lastEvent, null);
+
+ // check 2 : clearing a selection generates an event with first and last
+ // indices covering the former selection
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION (2)");
+ m.addSelectionInterval(2, 3);
+ m.addSelectionInterval(12, 13);
+ lastEvent = null;
+ m.clearSelection();
+ harness.check(m.isSelectionEmpty(), true);
+ harness.check(m.getAnchorSelectionIndex(), 12);
+ harness.check(m.getLeadSelectionIndex(), 13);
+ harness.check(m.getMinSelectionIndex(), -1);
+ harness.check(m.getMaxSelectionIndex(), -1);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 13);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/clone.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/clone.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/clone.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/clone.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,78 @@
+/* clone.java -- some checks for the clone()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class clone implements Testlet, ListSelectionListener
+{
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // ignore
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m1 = new DefaultListSelectionModel();
+ m1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m1.setLeadAnchorNotificationEnabled(false);
+ m1.addListSelectionListener(this);
+ m1.addSelectionInterval(5, 9);
+
+ DefaultListSelectionModel m2 = null;
+ try
+ {
+ m2 = (DefaultListSelectionModel) m1.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+
+ }
+ harness.check(m2.getSelectionMode(),
+ ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ harness.check(m2.isLeadAnchorNotificationEnabled(), false);
+ harness.check(m2.isSelectedIndex(4), false);
+ harness.check(m2.isSelectedIndex(5), true);
+ harness.check(m2.isSelectedIndex(9), true);
+ harness.check(m2.isSelectedIndex(10), false);
+
+ // confirm that m1 and m2 are independent
+ m2.clearSelection();
+ harness.check(m2.isSelectionEmpty(), true);
+ harness.check(m1.isSelectionEmpty(), false);
+
+ // confirm that m2 doesn't have any listeners
+ ListSelectionListener[] listeners = m2.getListSelectionListeners();
+ harness.check(listeners.length, 0);
+ listeners = m1.getListSelectionListeners();
+ harness.check(listeners.length, 1);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/constructor.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/constructor.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/constructor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/constructor.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,46 @@
+/* constructor.java -- some checks for the constructor in the
+ DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+
+public class constructor implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getSelectionMode(),
+ ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ harness.check(m.isLeadAnchorNotificationEnabled(), true);
+ harness.check(m.getAnchorSelectionIndex(), -1);
+ harness.check(m.getLeadSelectionIndex(), -1);
+ harness.check(m.getMaxSelectionIndex(), -1);
+ harness.check(m.getMinSelectionIndex(), -1);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getAnchorSelectionIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getAnchorSelectionIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getAnchorSelectionIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getAnchorSelectionIndex.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,46 @@
+/* getAnchorSelectionIndex.java -- some checks for the
+ getAnchorSelectionIndex() method in the DefaultListSelectionModel
+ 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class getAnchorSelectionIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getAnchorSelectionIndex(), -1);
+ m.setAnchorSelectionIndex(99);
+ harness.check(m.getAnchorSelectionIndex(), 99);
+ m.clearSelection();
+ harness.check(m.getAnchorSelectionIndex(), 99);
+ m.addSelectionInterval(15, 11);
+ harness.check(m.getAnchorSelectionIndex(), 15);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getLeadSelectionIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getLeadSelectionIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getLeadSelectionIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getLeadSelectionIndex.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,48 @@
+/* getLeadSelectionIndex.java -- some checks for the getLeadSelectionIndex()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class getLeadSelectionIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getLeadSelectionIndex(), -1);
+ m.setAnchorSelectionIndex(1);
+ m.setLeadSelectionIndex(3);
+ harness.check(m.getLeadSelectionIndex(), 3);
+
+ m.clearSelection();
+ harness.check(m.getLeadSelectionIndex(), 3);
+
+ m.addSelectionInterval(15, 11);
+ harness.check(m.getLeadSelectionIndex(), 11);
+ }
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getListSelectionListeners.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getListSelectionListeners.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getListSelectionListeners.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getListSelectionListeners.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,54 @@
+/* getListSelectionListeners.java -- some checks for the
+ getSelectionListeners() method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class getListSelectionListeners
+ implements Testlet, ListSelectionListener
+{
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // ignore
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ ListSelectionListener[] listeners = m.getListSelectionListeners();
+ harness.check(listeners.length, 0);
+
+ m.addListSelectionListener(this);
+ listeners = m.getListSelectionListeners();
+ harness.check(listeners[0], this);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getListeners.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getListeners.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getListeners.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getListeners.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,66 @@
+/* getListeners.java -- some checks for the getListeners()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class getListeners implements Testlet, ListSelectionListener
+{
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // ignore
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ ListSelectionListener[] listeners
+ = (ListSelectionListener[]) m.getListeners(ListSelectionListener.class);
+ harness.check(listeners.length, 0);
+
+ m.addListSelectionListener(this);
+ listeners = (ListSelectionListener[])
+ m.getListeners(ListSelectionListener.class);
+ harness.check(listeners[0], this);
+
+ boolean pass = false;
+ try
+ {
+ m.getListeners(String.class);
+ }
+ catch (ClassCastException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getMaxSelectionIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getMaxSelectionIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getMaxSelectionIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getMaxSelectionIndex.java 31 May 2006 09:01:17 -0000
@@ -0,0 +1,43 @@
+/* getMaxSelectionIndex.java -- some checks for the getMaxSelectionIndex()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class getMaxSelectionIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getMaxSelectionIndex(), -1);
+ m.addSelectionInterval(99, 101);
+ harness.check(m.getMaxSelectionIndex(), 101);
+ m.clearSelection();
+ harness.check(m.getMaxSelectionIndex(), -1);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getMinSelectionIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getMinSelectionIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getMinSelectionIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getMinSelectionIndex.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,43 @@
+/* getMinSelectionIndex.java -- some checks for the getMinSelectionIndex()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class getMinSelectionIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getMinSelectionIndex(), -1);
+ m.addSelectionInterval(99, 101);
+ harness.check(m.getMinSelectionIndex(), 99);
+ m.clearSelection();
+ harness.check(m.getMinSelectionIndex(), -1);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getSelectionMode.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getSelectionMode.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getSelectionMode.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getSelectionMode.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,44 @@
+/* getSelectionMode.java -- some checks for the getSelectionMode()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+
+public class getSelectionMode implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getSelectionMode(),
+ ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ harness.check(m.getSelectionMode(),
+ ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/getValueIsAdjusting.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/getValueIsAdjusting.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/getValueIsAdjusting.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/getValueIsAdjusting.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,41 @@
+/* getValueIsAdjusting.java -- some checks for the getValueIsAdjusting()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class getValueIsAdjusting implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.getValueIsAdjusting(), false);
+ m.setValueIsAdjusting(true);
+ harness.check(m.getValueIsAdjusting(), true);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/insertIndexInterval.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/insertIndexInterval.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/insertIndexInterval.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/insertIndexInterval.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,230 @@
+/* insertIndexInterval.java -- some checks for the insertIndexInterval()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class insertIndexInterval implements Testlet, ListSelectionListener
+{
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ lastEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testSingleSelection(harness);
+ testSingleInterval(harness);
+ testMultipleInterval(harness);
+ }
+
+ private void testSingleSelection(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.addSelectionInterval(3, 3);
+ m.addListSelectionListener(this);
+ m.insertIndexInterval(3, 2, true);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.getAnchorSelectionIndex(), 5);
+ harness.check(m.getLeadSelectionIndex(), 5);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 5);
+
+ harness.checkPoint("SINGLE_SELECTION (2)");
+ lastEvent = null;
+ m.insertIndexInterval(5, 2, false); // this does nothing
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), false);
+ harness.check(lastEvent, null);
+
+ // try negative index
+ harness.checkPoint("SINGLE_SELECTION (3)");
+ boolean pass = false;
+ try
+ {
+ m.insertIndexInterval(-1, 1, true);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try negative count
+ harness.checkPoint("SINGLE_SELECTION (4)");
+ pass = false;
+ try
+ {
+ m.insertIndexInterval(0, -1, true);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try zero count
+ harness.checkPoint("SINGLE_SELECTION (5)");
+ lastEvent = null;
+ m.insertIndexInterval(0, 0, true);
+ harness.check(lastEvent.getFirstIndex(), 0);
+ harness.check(lastEvent.getLastIndex(), 6);
+ }
+
+ private void testSingleInterval(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m.setSelectionInterval(3, 3);
+ m.addListSelectionListener(this);
+
+ // here, we insert two new items in the list right before the selected item
+ // 3 (which moves up to position 5).
+ m.insertIndexInterval(3, 2, true);
+ harness.check(m.isSelectedIndex(3), true); // FIXME: surely wrong?
+ harness.check(m.isSelectedIndex(4), true); // FIXME: likewise?
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.getAnchorSelectionIndex(), 5);
+ harness.check(m.getLeadSelectionIndex(), 5);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 5);
+
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (2)");
+ m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m.setSelectionInterval(3, 3);
+ m.addListSelectionListener(this);
+ lastEvent = null;
+
+ // here, we insert two new items in the list right AFTER the selected item
+ // 3
+ m.insertIndexInterval(3, 2, false);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true); // FIXME: surely wrong?
+ harness.check(m.isSelectedIndex(5), true); // FIXME: likewise?
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.getAnchorSelectionIndex(), 3);
+ harness.check(m.getLeadSelectionIndex(), 3);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 4);
+ harness.check(lastEvent.getLastIndex(), 5);
+
+ // try negative index
+ boolean pass = false;
+ try
+ {
+ m.insertIndexInterval(-1, 1, true);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try negative count
+ pass = false;
+ try
+ {
+ m.insertIndexInterval(0, -1, true);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try zero count
+ lastEvent = null;
+ m.insertIndexInterval(0, 0, true);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 0);
+ harness.check(lastEvent.getLastIndex(), 6);
+ }
+
+ private void testMultipleInterval(TestHarness harness)
+ {
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ m.addSelectionInterval(1, 1);
+ m.addSelectionInterval(7, 7);
+ m.addSelectionInterval(3, 5);
+ m.addListSelectionListener(this);
+ m.insertIndexInterval(2, 2, true);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), false);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.isSelectedIndex(8), false);
+ harness.check(m.isSelectedIndex(9), true);
+ harness.check(m.isSelectedIndex(10), false);
+ harness.check(m.getAnchorSelectionIndex(), 5);
+ harness.check(m.getLeadSelectionIndex(), 7);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 9);
+
+ m.insertIndexInterval(1, 2, false);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.isSelectedIndex(8), true);
+ harness.check(m.isSelectedIndex(9), true);
+ harness.check(m.isSelectedIndex(10), false);
+ harness.check(m.isSelectedIndex(11), true);
+ harness.check(m.isSelectedIndex(12), false);
+ harness.check(m.getAnchorSelectionIndex(), 7);
+ harness.check(m.getLeadSelectionIndex(), 9);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 11);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/isLeadAnchorNotificationEnabled.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/isLeadAnchorNotificationEnabled.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/isLeadAnchorNotificationEnabled.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/isLeadAnchorNotificationEnabled.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,42 @@
+/* isLeadAnchorNotificationEnabled.java -- some checks for the
+ isLeadAnchorNotificationEnabled() method in the
+ DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class isLeadAnchorNotificationEnabled implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.isLeadAnchorNotificationEnabled(), true);
+ m.setLeadAnchorNotificationEnabled(false);
+ harness.check(m.isLeadAnchorNotificationEnabled(), false);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectedIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectedIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectedIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectedIndex.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,47 @@
+/* isSelectedIndex.java -- some checks for the isSelectedIndex()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class isSelectedIndex implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.isSelectedIndex(99), false);
+ m.addSelectionInterval(99, 99);
+ harness.check(m.isSelectedIndex(99), true);
+ m.clearSelection();
+ harness.check(m.isSelectedIndex(99), false);
+
+ // try a negative index
+ harness.check(m.isSelectedIndex(-1), false);
+ harness.check(m.isSelectedIndex(-2), false);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectionEmpty.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectionEmpty.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectionEmpty.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/isSelectionEmpty.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,43 @@
+/* isSelectionEmpty.java -- some checks for the isSelectionEmpty()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class isSelectionEmpty implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.isSelectionEmpty(), true);
+ m.addSelectionInterval(99, 99);
+ harness.check(m.isSelectionEmpty(), false);
+ m.clearSelection();
+ harness.check(m.isSelectionEmpty(), true);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/moveLeadSelectionIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/moveLeadSelectionIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/moveLeadSelectionIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/moveLeadSelectionIndex.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,57 @@
+/* moveLeadSelectionIndex.java -- some checks for the moveLeadSelectionIndex()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class moveLeadSelectionIndex implements Testlet, ListSelectionListener {
+
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ lastEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addSelectionInterval(3, 5);
+ m.addListSelectionListener(this);
+ m.moveLeadSelectionIndex(7);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), false);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 5);
+ harness.check(lastEvent.getLastIndex(), 7);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/removeIndexInterval.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/removeIndexInterval.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/removeIndexInterval.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/removeIndexInterval.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,153 @@
+/* removeIndexInterval.java -- some checks for the removeIndexInterval()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class removeIndexInterval implements Testlet, ListSelectionListener
+{
+ private ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testSingleSelection(harness);
+ testSingleInterval(harness);
+ testMultipleInterval(harness);
+ }
+
+ public void testSingleSelection(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+ // check 1 - the selected item is in the removed range
+ m.addSelectionInterval(6, 7);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.getAnchorSelectionIndex(), 7);
+ harness.check(m.getLeadSelectionIndex(), 7);
+ m.addListSelectionListener(this);
+ m.removeIndexInterval(5, 7);
+ harness.check(m.isSelectionEmpty(), true);
+ harness.check(m.getAnchorSelectionIndex(), 4);
+ harness.check(m.getLeadSelectionIndex(), 4);
+
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 4);
+ harness.check(lastEvent.getLastIndex(), 7);
+
+ // check 2 - the selected item is below the removed range
+ m.setSelectionInterval(1, 1);
+ lastEvent = null;
+ m.removeIndexInterval(2, 4);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.getAnchorSelectionIndex(), 1);
+ harness.check(m.getLeadSelectionIndex(), 1);
+ harness.check(lastEvent, null); // no event, because nothing changed
+
+ // check 3 - the selected item is above the removed range
+ m.setSelectionInterval(5, 5);
+ lastEvent = null;
+ m.removeIndexInterval(2, 4);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.getAnchorSelectionIndex(), 2);
+ harness.check(m.getLeadSelectionIndex(), 2);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 5);
+ }
+
+ public void testSingleInterval(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+
+ // check 1 - remove the middle of a selection interval
+ m.addSelectionInterval(2, 6);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), false);
+ m.addListSelectionListener(this);
+ m.removeIndexInterval(3, 5);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), false);
+ harness.check(m.getLeadSelectionIndex(), 3);
+ harness.check(m.getAnchorSelectionIndex(), 2);
+
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 6);
+ }
+
+ public void testMultipleInterval(TestHarness harness)
+ {
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ m.addSelectionInterval(2, 6);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), false);
+ m.addListSelectionListener(this);
+ m.removeIndexInterval(3, 5);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), false);
+
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 6);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/removeListSelectionListener.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/removeListSelectionListener.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/removeListSelectionListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/removeListSelectionListener.java 31 May 2006 09:01:18 -0000
@@ -0,0 +1,56 @@
+/* removeListSelectionListener.java -- some checks for the
+ removeSelectionListener() method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class removeListSelectionListener
+ implements Testlet, ListSelectionListener
+{
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // ignore
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addListSelectionListener(this);
+ harness.check(m.getListSelectionListeners().length, 1);
+ m.removeListSelectionListener(this);
+ harness.check(m.getListSelectionListeners().length, 0);
+ // remove a listener that isn't there
+ m.removeListSelectionListener(this);
+ harness.check(m.getListSelectionListeners().length, 0);
+ // try null
+ m.removeListSelectionListener(null);
+ harness.check(m.getListSelectionListeners().length, 0);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/removeSelectionInterval.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/removeSelectionInterval.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/removeSelectionInterval.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/removeSelectionInterval.java 31 May 2006 09:01:19 -0000
@@ -0,0 +1,126 @@
+/* removeSelectionInterval.java -- some checks for the
+ removeSelectionInterval() method in the DefaultListSelectionModel
+ 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class removeSelectionInterval implements Testlet, ListSelectionListener
+{
+ private ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testSingleSelection(harness);
+ testSingleInterval(harness);
+ testMultipleInterval(harness);
+ }
+
+ public void testSingleSelection(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.addSelectionInterval(1, 2);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), false);
+ m.addListSelectionListener(this);
+ m.removeSelectionInterval(2, 3);
+ harness.check(m.isSelectionEmpty(), true);
+
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 3);
+ }
+
+ public void testSingleInterval(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m.addSelectionInterval(2, 6);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), false);
+ m.addListSelectionListener(this);
+ m.removeSelectionInterval(3, 5);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), false);
+
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 6);
+ }
+
+ public void testMultipleInterval(TestHarness harness)
+ {
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ m.addSelectionInterval(2, 6);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), false);
+ m.addListSelectionListener(this);
+ m.removeSelectionInterval(3, 5);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), false);
+
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 6);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/setAnchorSelectionIndex.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/setAnchorSelectionIndex.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/setAnchorSelectionIndex.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/setAnchorSelectionIndex.java 31 May 2006 09:01:19 -0000
@@ -0,0 +1,80 @@
+/* setAnchorSelectionIndex.java -- some checks for the
+ setAnchorSelectionIndex() method in the DefaultListSelectionModel
+ 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class setAnchorSelectionIndex
+ implements Testlet, ListSelectionListener
+{
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addSelectionInterval(2, 4);
+ harness.check(m.getAnchorSelectionIndex(), 2);
+ harness.check(m.isLeadAnchorNotificationEnabled(), true);
+ m.addListSelectionListener(this);
+ m.setAnchorSelectionIndex(1);
+ harness.check(m.getAnchorSelectionIndex(), 1);
+ harness.check(m.isSelectedIndex(1), false);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 1);
+ harness.check(lastEvent.getLastIndex(), 2);
+
+ // setting the same index generates no event
+ lastEvent = null;
+ m.setAnchorSelectionIndex(1);
+ harness.check(lastEvent, null);
+
+ // try a negative value
+ m.setAnchorSelectionIndex(-2);
+ harness.check(m.getAnchorSelectionIndex(), -2);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), -2);
+ harness.check(lastEvent.getLastIndex(), 1);
+
+ // now try without notification
+ m.setLeadAnchorNotificationEnabled(false);
+ lastEvent = null;
+ m.setAnchorSelectionIndex(2);
+ harness.check(m.getAnchorSelectionIndex(), 2);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(lastEvent, null);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionInterval.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionInterval.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionInterval.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionInterval.java 31 May 2006 09:01:19 -0000
@@ -0,0 +1,281 @@
+/* setSelectionInterval.java -- some checks for the setSelectionInterval()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.List;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class setSelectionInterval implements Testlet, ListSelectionListener
+{
+ List events = new java.util.ArrayList();
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ events.add(e);
+ }
+
+ public void test(TestHarness harness)
+ {
+ testSingle(harness);
+ testSingleInterval(harness);
+ testMultipleInterval(harness);
+ testSingleX(harness);
+ }
+
+ private void testSingle(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.addListSelectionListener(this);
+
+ harness.checkPoint("SINGLE_SELECTION (1)");
+ m.setSelectionInterval(6, 7);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.getAnchorSelectionIndex(), 7);
+ harness.check(m.getLeadSelectionIndex(), 7);
+ ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 7);
+ harness.check(lastEvent.getLastIndex(), 7);
+
+ // no event is generated if we update the same again
+ events.clear();
+ harness.checkPoint("SINGLE_SELECTION (2)");
+ m.setSelectionInterval(6, 7);
+ harness.check(events.size(), 0);
+
+ // now if we set another selection, the event range should cover the old
+ // index too
+ events.clear();
+ harness.checkPoint("SINGLE_SELECTION (3)");
+ m.setSelectionInterval(3, 3);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(7), false);
+ lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 7);
+
+ // the anchor can move around independently of the selection, is it
+ // included in the event range? YES
+ harness.checkPoint("SINGLE_SELECTION (4)");
+ m.setAnchorSelectionIndex(5);
+ events.clear();
+ m.setSelectionInterval(4, 4);
+ lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 5);
+
+ // try -2 for the initial index
+ harness.checkPoint("SINGLE_SELECTION (5)");
+ m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.setSelectionInterval(2, 2);
+ m.addListSelectionListener(this);
+ events.clear();
+ m.setSelectionInterval(-2, 0);
+ lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 0);
+ harness.check(lastEvent.getLastIndex(), 2);
+ harness.check(m.getLeadSelectionIndex(), 0);
+ harness.check(m.getAnchorSelectionIndex(), 0);
+
+ // try -1 for the initial index
+ harness.checkPoint("SINGLE_SELECTION (6)");
+ m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.setSelectionInterval(2, 2);
+ m.addListSelectionListener(this);
+ events.clear();
+ m.setSelectionInterval(-1, 0);
+ harness.check(events.size(), 0);
+
+ // try -2 for the second index
+ harness.checkPoint("SINGLE_SELECTION (7)");
+ m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.setSelectionInterval(2, 2);
+ m.addListSelectionListener(this);
+ events.clear();
+ boolean pass = false;
+ try
+ {
+ m.setSelectionInterval(0, -2);
+ }
+ catch (IndexOutOfBoundsException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ // try -1 for the second index
+ harness.checkPoint("SINGLE_SELECTION (8)");
+ m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ m.setSelectionInterval(2, 2);
+ m.addListSelectionListener(this);
+ events.clear();
+ m.setSelectionInterval(0, -1);
+ harness.check(events.size(), 0);
+ }
+
+ /**
+ * Some checks for a model using SINGLE_INTERVAL_SELECTION.
+ *
+ * @param harness the test harness.
+ */
+ private void testSingleInterval(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (1)");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ events.clear();
+ m.addListSelectionListener(this);
+ m.setSelectionInterval(6, 7);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), true);
+ harness.check(m.isSelectedIndex(7), true);
+ harness.check(m.isSelectedIndex(8), false);
+ harness.check(m.getAnchorSelectionIndex(), 6);
+ harness.check(m.getLeadSelectionIndex(), 7);
+ harness.check(events.size(), 1);
+ ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 6);
+ harness.check(lastEvent.getLastIndex(), 7);
+
+ // no event is generated if we update the same again
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (2)");
+ events.clear();
+ m.setSelectionInterval(6, 7);
+ harness.check(events.size(), 0);
+
+ // now if we set another selection, the event range should cover the old
+ // index too
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (3)");
+ events.clear();
+ m.setSelectionInterval(3, 3);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.isSelectedIndex(7), false);
+ harness.check(events.size(), 1);
+ lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 7);
+
+ // the anchor can move around independently of the selection, is it
+ // included in the event range? YES
+ harness.checkPoint("SINGLE_INTERVAL_SELECTION (3)");
+ m.setAnchorSelectionIndex(5);
+ events.clear();
+ m.setSelectionInterval(4, 4);
+ harness.check(m.isSelectedIndex(3), false);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), false);
+ lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 5);
+ }
+
+ private void testMultipleInterval(TestHarness harness)
+ {
+ harness.checkPoint("MULTIPLE_INTERVAL_SELECTION");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ events.clear();
+ m.addListSelectionListener(this);
+ m.setSelectionInterval(3, 5);
+ harness.check(m.isSelectedIndex(2), false);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(m.isSelectedIndex(5), true);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.getAnchorSelectionIndex(), 3);
+ harness.check(m.getLeadSelectionIndex(), 5);
+ harness.check(m.getMinSelectionIndex(), 3);
+ harness.check(m.getMaxSelectionIndex(), 5);
+ harness.check(events.size(), 1);
+ ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 3);
+ harness.check(lastEvent.getLastIndex(), 5);
+ events.clear();
+
+ m.setSelectionInterval(2, 3);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), false);
+ harness.check(m.isSelectedIndex(5), false);
+ harness.check(m.isSelectedIndex(6), false);
+ harness.check(m.getAnchorSelectionIndex(), 2);
+ harness.check(m.getLeadSelectionIndex(), 3);
+ harness.check(m.getMinSelectionIndex(), 2);
+ harness.check(m.getMaxSelectionIndex(), 3);
+ lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 2);
+ harness.check(lastEvent.getLastIndex(), 5);
+ }
+
+ /**
+ * A special case where the model is SINGLE_SELECTION, but this mode is set
+ * AFTER a range of items is selected.
+ *
+ * @param harness
+ */
+ private void testSingleX(TestHarness harness)
+ {
+ harness.checkPoint("SINGLE_SELECTION_X");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addSelectionInterval(2, 4);
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ events.clear();
+ m.addListSelectionListener(this);
+ m.setSelectionInterval(0, 1);
+ harness.check(m.isSelectedIndex(0), false);
+ harness.check(m.isSelectedIndex(1), true);
+ harness.check(m.getAnchorSelectionIndex(), 1);
+ harness.check(m.getLeadSelectionIndex(), 1);
+ harness.check(events.size(), 1);
+ ListSelectionEvent lastEvent = (ListSelectionEvent) events.get(0);
+ harness.check(lastEvent.getSource(), m);
+ harness.check(lastEvent.getFirstIndex(), 1);
+ harness.check(lastEvent.getLastIndex(), 4);
+ }
+
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionMode.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionMode.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionMode.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/setSelectionMode.java 31 May 2006 09:01:20 -0000
@@ -0,0 +1,88 @@
+/* setSelectionMode.java -- some checks for the setSelectionMode()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class setSelectionMode implements Testlet, ListSelectionListener
+{
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent event) {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testGeneral(harness);
+ testIntervalToSingle(harness);
+ }
+
+ private void testGeneral(TestHarness harness)
+ {
+ harness.checkPoint("testGeneral()");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addListSelectionListener(this);
+ harness.check(m.getSelectionMode(),
+ ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ harness.check(m.getSelectionMode(),
+ ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ harness.check(lastEvent, null);
+
+ // try bad value
+ boolean pass = false;
+ try
+ {
+ m.setSelectionMode(99);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+
+ private void testIntervalToSingle(TestHarness harness)
+ {
+ harness.checkPoint("testIntervalToSingle()");
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ m.addSelectionInterval(2, 4);
+ m.addListSelectionListener(this);
+ m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ harness.check(m.getSelectionMode(), ListSelectionModel.SINGLE_SELECTION);
+ harness.check(m.isSelectedIndex(2), true);
+ harness.check(m.isSelectedIndex(3), true);
+ harness.check(m.isSelectedIndex(4), true);
+ harness.check(lastEvent, null);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/setValueIsAdjusting.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/setValueIsAdjusting.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/setValueIsAdjusting.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/setValueIsAdjusting.java 31 May 2006 09:01:20 -0000
@@ -0,0 +1,58 @@
+/* setValueIsAdjusting.java -- some checks for the setValueIsAdjusting()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+public class setValueIsAdjusting implements Testlet, ListSelectionListener
+{
+ ListSelectionEvent lastEvent;
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+ lastEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ m.addListSelectionListener(this);
+ harness.check(m.getValueIsAdjusting(), false);
+ m.setValueIsAdjusting(true);
+ harness.check(lastEvent, null);
+
+ m.addSelectionInterval(3, 5);
+ harness.check(lastEvent.getValueIsAdjusting(), true);
+
+ m.setValueIsAdjusting(false);
+ m.addSelectionInterval(1, 2);
+ harness.check(lastEvent.getValueIsAdjusting(), false);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultListSelectionModel/toString.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultListSelectionModel/toString.java
diff -N gnu/testlet/javax/swing/DefaultListSelectionModel/toString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultListSelectionModel/toString.java 31 May 2006 09:01:20 -0000
@@ -0,0 +1,43 @@
+/* toString.java -- some checks for the toString()
+ method in the DefaultListSelectionModel 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.5
+
+package gnu.testlet.javax.swing.DefaultListSelectionModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultListSelectionModel;
+
+public class toString implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultListSelectionModel m = new DefaultListSelectionModel();
+ harness.check(m.toString().endsWith(" ={}"));
+ m.addSelectionInterval(3, 5);
+ harness.check(m.toString().endsWith(" ={3, 4, 5}"));
+ m.addSelectionInterval(7, 7);
+ harness.check(m.toString().endsWith(" ={3, 4, 5, 7}"));
+ }
+}