This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: DefaultButtonModel tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches at sources dot redhat dot com
- Date: Tue, 16 May 2006 23:00:31 +0100
- Subject: FYI: DefaultButtonModel tests
This patch (committed) adds tests for the DefaultButtonModel class:
2006-05-16 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/DefaultButtonModel/addActionListener.java:
New file,
* gnu/testlet/javax/swing/DefaultButtonModel/constants.java: Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/constructor.java:
Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/getSelectedObjects.java:
Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/MyDefaultButtonModel.java:
Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setActionCommand.java:
Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setArmed.java: Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setEnabled.java: Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setGroup.java: Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setMnemonic.java:
Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setPressed.java: Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setRollover.java:
Likewise,
* gnu/testlet/javax/swing/DefaultButtonModel/setSelected.java:
Likewise.
Regards,
Dave
Index: gnu/testlet/javax/swing/DefaultButtonModel/MyDefaultButtonModel.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/MyDefaultButtonModel.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/MyDefaultButtonModel.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/MyDefaultButtonModel.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,40 @@
+/* MyDefaultButtonModel.java -- subclass that provides access to protected
+ field.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package gnu.testlet.javax.swing.DefaultButtonModel;
+
+import javax.swing.DefaultButtonModel;
+
+public class MyDefaultButtonModel extends DefaultButtonModel
+{
+ public MyDefaultButtonModel()
+ {
+ super();
+ }
+ public int getStateMask()
+ {
+ return this.stateMask;
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/addActionListener.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/addActionListener.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/addActionListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/addActionListener.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,51 @@
+/* addActionListener.java -- some checks for the addActionListener() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+
+public class addActionListener implements Testlet, ActionListener
+{
+ public void actionPerformed(ActionEvent e)
+ {
+ // do nothing
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.addActionListener(this);
+ harness.check(m.getActionListeners()[0], this);
+ m.addActionListener(null);
+ harness.check(m.getActionListeners().length, 1);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/constants.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/constants.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/constants.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/constants.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,43 @@
+/* constants.java -- some checks for the constants in the DefaultButtonModel
+ 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultButtonModel;
+
+public class constants implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ harness.check(DefaultButtonModel.ARMED, 1);
+ harness.check(DefaultButtonModel.ENABLED, 8);
+ harness.check(DefaultButtonModel.PRESSED, 4);
+ harness.check(DefaultButtonModel.ROLLOVER, 16);
+ harness.check(DefaultButtonModel.SELECTED, 2);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/constructor.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/constructor.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/constructor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/constructor.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,46 @@
+/* constructor.java -- some checks for the constructor in the
+ DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultButtonModel;
+
+public class constructor implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ harness.check(m.getActionCommand(), null);
+ harness.check(m.getGroup(), null);
+ harness.check(m.isArmed(), false);
+ harness.check(m.isEnabled(), true);
+ harness.check(m.isPressed(), false);
+ harness.check(m.isRollover(), false);
+ harness.check(m.isSelected(), false);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/getSelectedObjects.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/getSelectedObjects.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/getSelectedObjects.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/getSelectedObjects.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,40 @@
+/* getSelectedObjects.java -- some checks for the getSelectedObjects() method
+ in the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultButtonModel;
+
+public class getSelectedObjects implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ harness.check(m.getSelectedObjects(), null);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setActionCommand.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setActionCommand.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setActionCommand.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setActionCommand.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,43 @@
+/* setActionCommand.java -- some checks for the setActionCommand() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultButtonModel;
+
+public class setActionCommand implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.setActionCommand("XYZ");
+ harness.check(m.getActionCommand(), "XYZ");
+ m.setActionCommand(null);
+ harness.check(m.getActionCommand(), null);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setArmed.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setArmed.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setArmed.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setArmed.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,81 @@
+/* setArmed.java -- some checks for the setArmed() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setArmed implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ MyDefaultButtonModel m = new MyDefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ m.setArmed(true);
+ harness.check(m.isArmed(), true);
+ harness.check(m.getStateMask(), DefaultButtonModel.ENABLED | DefaultButtonModel.ARMED);
+ harness.check(lastChangeEvent.getSource(), m);
+ harness.check(lastActionEvent, null);
+
+ // setting the same again causes no event
+ lastChangeEvent = null;
+ m.setArmed(true);
+ harness.check(lastChangeEvent, null);
+
+ // if we disable the model, it becomes unarmed
+ m.setEnabled(false);
+ harness.check(m.isArmed(), false);
+ harness.check(m.getStateMask(), 0);
+ m.setEnabled(true);
+ harness.check(m.isArmed(), false);
+ harness.check(m.getStateMask(), DefaultButtonModel.ENABLED);
+
+ m.setEnabled(false);
+ m.setArmed(true);
+ harness.check(m.isArmed(), false);
+ harness.check(m.getStateMask(), 0);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setEnabled.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setEnabled.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setEnabled.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setEnabled.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,80 @@
+/* setEnabled.java -- some checks for the setEnabled() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setEnabled implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ MyDefaultButtonModel m = new MyDefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ m.setEnabled(false);
+ harness.check(m.isEnabled(), false);
+ harness.check(m.getStateMask(), 0);
+ harness.check(lastChangeEvent.getSource(), m);
+ harness.check(lastActionEvent, null);
+
+ // setting the same again causes no event
+ lastChangeEvent = null;
+ m.setEnabled(false);
+ harness.check(m.getStateMask(), 0);
+ harness.check(lastChangeEvent, null);
+
+ m.setEnabled(true);
+ harness.check(m.getStateMask(), DefaultButtonModel.ENABLED);
+ harness.check(lastChangeEvent.getSource(), m);
+
+ // if a button is armed and enabled, setting it to disabled also disarms it
+ m.setArmed(true);
+ harness.check(m.getStateMask(), DefaultButtonModel.ENABLED | DefaultButtonModel.ARMED);
+ m.setEnabled(false);
+ harness.check(m.getStateMask(), 0);
+
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setGroup.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setGroup.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setGroup.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setGroup.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,75 @@
+/* setGroup.java -- some checks for the setGroup() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.ButtonGroup;
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setGroup implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ ButtonGroup bg = new ButtonGroup();
+ m.setGroup(bg);
+ harness.check(m.getGroup(), bg);
+ harness.check(lastChangeEvent, null);
+ harness.check(lastActionEvent, null);
+ harness.check(bg.getButtonCount(), 0);
+
+ // setting the same again causes no event
+ lastChangeEvent = null;
+ m.setGroup(bg);
+ harness.check(lastChangeEvent, null);
+
+ // try a null argument
+ m.setGroup(null);
+ harness.check(m.getGroup(), null);
+ harness.check(lastChangeEvent, null);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setMnemonic.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setMnemonic.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setMnemonic.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setMnemonic.java 16 May 2006 21:54:19 -0000
@@ -0,0 +1,73 @@
+/* setMnemonic.java -- some checks for the setMnemonic() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setMnemonic implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ m.setMnemonic(99);
+ harness.check(m.getMnemonic(), 99);
+ harness.check(lastChangeEvent.getSource(), m);
+ harness.check(lastActionEvent, null);
+
+ // setting the same again causes no event - actually, the reference
+ // implementation fails this test, I filed it as a bug report to Sun and
+ // will await their assessment...
+ lastChangeEvent = null;
+ m.setMnemonic(99);
+ harness.check(lastChangeEvent, null);
+
+ // try a wild argument
+ m.setMnemonic(Integer.MIN_VALUE);
+ harness.check(m.getMnemonic(), Integer.MIN_VALUE);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setPressed.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setPressed.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setPressed.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setPressed.java 16 May 2006 21:54:20 -0000
@@ -0,0 +1,107 @@
+/* setPressed.java -- some checks for the setPressed() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setPressed implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ testGeneral(harness);
+ testEvent(harness);
+ }
+
+ public void testGeneral(TestHarness harness)
+ {
+ harness.checkPoint("testGeneral");
+ MyDefaultButtonModel m = new MyDefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ m.setPressed(true);
+ harness.check(m.isPressed());
+ harness.check(m.getStateMask(), DefaultButtonModel.ENABLED | DefaultButtonModel.PRESSED);
+ harness.check(lastChangeEvent.getSource(), m);
+ harness.check(lastActionEvent, null);
+
+ // setting the same again causes no event
+ lastChangeEvent = null;
+ m.setPressed(true);
+ harness.check(lastChangeEvent, null);
+
+ // if we disable the model, it becomes not pressed
+ m.setEnabled(false);
+ harness.check(m.isPressed(), false);
+ harness.check(m.getStateMask(), 0);
+ m.setEnabled(true);
+ harness.check(m.isPressed(), false);
+ harness.check(m.getStateMask(), DefaultButtonModel.ENABLED);
+
+ m.setEnabled(false);
+ m.setPressed(true);
+ harness.check(m.isPressed(), false);
+ harness.check(m.getStateMask(), 0);
+ }
+
+ public void testEvent(TestHarness harness)
+ {
+ harness.checkPoint("testEvent");
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ lastActionEvent = null;
+ m.setActionCommand("ABC");
+ m.setArmed(true);
+ harness.check(lastActionEvent, null);
+ m.setPressed(true);
+ lastChangeEvent = null;
+ harness.check(lastActionEvent, null);
+ m.setPressed(false);
+ harness.check(lastActionEvent.getSource(), m);
+ harness.check(lastActionEvent.getActionCommand(), "ABC");
+ harness.check(lastChangeEvent.getSource(), m);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setRollover.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setRollover.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setRollover.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setRollover.java 16 May 2006 21:54:20 -0000
@@ -0,0 +1,75 @@
+/* setRollover.java -- some checks for the setRollover() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setRollover implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ m.setRollover(true);
+ harness.check(m.isRollover(), true);
+ harness.check(lastChangeEvent.getSource(), m);
+ harness.check(lastActionEvent, null);
+
+ // setting the same again causes no event
+ lastChangeEvent = null;
+ m.setRollover(true);
+ harness.check(lastChangeEvent, null);
+
+ // are the states independent? Seems so.
+ m.setPressed(true);
+ harness.check(m.isRollover(), true);
+ m.setEnabled(false);
+ harness.check(m.isRollover(), true);
+ m.setEnabled(true);
+ harness.check(m.isRollover(), true);
+ }
+}
Index: gnu/testlet/javax/swing/DefaultButtonModel/setSelected.java
===================================================================
RCS file: gnu/testlet/javax/swing/DefaultButtonModel/setSelected.java
diff -N gnu/testlet/javax/swing/DefaultButtonModel/setSelected.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/DefaultButtonModel/setSelected.java 16 May 2006 21:54:20 -0000
@@ -0,0 +1,75 @@
+/* setSelected.java -- some checks for the setSelected() method in
+ the DefaultButtonModel 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.DefaultButtonModel;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.DefaultButtonModel;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setSelected implements Testlet, ActionListener, ChangeListener
+{
+ ChangeEvent lastChangeEvent;
+
+ ActionEvent lastActionEvent;
+
+ public void stateChanged(ChangeEvent e) {
+ lastChangeEvent = e;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ lastActionEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultButtonModel m = new DefaultButtonModel();
+ m.addActionListener(this);
+ m.addChangeListener(this);
+ m.setSelected(true);
+ harness.check(m.isSelected(), true);
+ harness.check(lastChangeEvent.getSource(), m);
+ harness.check(lastActionEvent, null);
+
+ // setting the same again causes no event
+ lastChangeEvent = null;
+ m.setSelected(true);
+ harness.check(lastChangeEvent, null);
+
+ // are the states independent? Seems so.
+ m.setPressed(true);
+ harness.check(m.isSelected(), true);
+ m.setEnabled(false);
+ harness.check(m.isSelected(), true);
+ m.setEnabled(true);
+ harness.check(m.isSelected(), true);
+ }
+}