This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: JProgressBar - 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 11:35:58 +0100
- Subject: FYI: JProgressBar - new tests
This patch (committed) adds a bunch of new tests for the JProgressBar
component:
2006-05-31 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/JProgressBar/getAccessibleContext.java:
New file,
* gnu/testlet/javax/swing/JProgressBar/getPercentComplete.java: New
file,
* gnu/testlet/javax/swing/JProgressBar/getString.java: New file,
* gnu/testlet/javax/swing/JProgressBar/isStringPainted.java: New file,
* gnu/testlet/javax/swing/JProgressBar/MyJProgressBar.java: New file,
* gnu/testlet/javax/swing/JProgressBar/paramString.java: New file,
* gnu/testlet/javax/swing/JProgressBar/setBorderPainted.java: New file,
* gnu/testlet/javax/swing/JProgressBar/setModel.java: New file,
* gnu/testlet/javax/swing/JProgressBar/setOrientation.java: New file,
* gnu/testlet/javax/swing/JProgressBar/setString.java: New file,
* gnu/testlet/javax/swing/JProgressBar/setStringPainted.java: New file,
* gnu/testlet/javax/swing/JProgressBar/setValue.java: New file.
Regards,
Dave
Index: gnu/testlet/javax/swing/JProgressBar/MyJProgressBar.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/MyJProgressBar.java
diff -N gnu/testlet/javax/swing/JProgressBar/MyJProgressBar.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/MyJProgressBar.java 31 May 2006 10:27:46 -0000
@@ -0,0 +1,40 @@
+/* MyJProgressBar.java -- provides access to protected stuff in the
+ JProgressBar class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: not-a-test
+
+package gnu.testlet.javax.swing.JProgressBar;
+
+import javax.swing.JProgressBar;
+
+public class MyJProgressBar extends JProgressBar
+{
+ public MyJProgressBar()
+ {
+ super();
+ }
+
+ public String paramString()
+ {
+ return super.paramString();
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/getAccessibleContext.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/getAccessibleContext.java
diff -N gnu/testlet/javax/swing/JProgressBar/getAccessibleContext.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/getAccessibleContext.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,136 @@
+/* getAccessibleContext.java -- some checks for the getAccessibleContext()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+import javax.accessibility.AccessibleValue;
+import javax.swing.JProgressBar;
+import javax.swing.JSlider;
+
+public class getAccessibleContext implements Testlet, PropertyChangeListener
+{
+ List events = new java.util.ArrayList();
+
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ events.add(e);
+ }
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar progressBar = new JProgressBar(10, 90);
+ progressBar.setValue(50);
+ AccessibleContext ac = progressBar.getAccessibleContext();
+ harness.check(ac.getAccessibleName(), null);
+ harness.check(ac.getAccessibleRole(), AccessibleRole.PROGRESS_BAR);
+ harness.check(ac.getAccessibleAction(), null);
+ harness.check(ac.getAccessibleComponent(), ac);
+ harness.check(ac.getAccessibleDescription(), null);
+ harness.check(ac.getAccessibleEditableText(), null);
+ harness.check(ac.getAccessibleIcon(), null);
+ harness.check(ac.getAccessibleTable(), null);
+ harness.check(ac.getAccessibleText(), null);
+
+ // the AccessibleContext is also the AccessibleValue...
+ AccessibleValue av = ac.getAccessibleValue();
+ harness.check(av, ac);
+ harness.check(av.getCurrentAccessibleValue(), new Integer(50));
+ harness.check(av.getMinimumAccessibleValue(), new Integer(10));
+ harness.check(av.getMaximumAccessibleValue(), new Integer(90));
+
+ // check that setting the accessible value updates the slider
+ ac.addPropertyChangeListener(this);
+ boolean b = av.setCurrentAccessibleValue(new Integer(55));
+ harness.check(progressBar.getValue(), 55);
+ harness.check(b);
+ harness.check(events.size(), 1);
+ PropertyChangeEvent e0 = (PropertyChangeEvent) events.get(0);
+ harness.check(e0.getPropertyName(),
+ AccessibleContext.ACCESSIBLE_VALUE_PROPERTY);
+ harness.check(e0.getSource(), ac);
+ harness.check(e0.getOldValue(), new Integer(50));
+ harness.check(e0.getNewValue(), new Integer(55));
+
+ // set the value below the minimum
+ events.clear();
+ b = av.setCurrentAccessibleValue(new Integer(5));
+ harness.check(av.getCurrentAccessibleValue(), new Integer(10));
+ harness.check(b);
+ harness.check(events.size(), 1);
+ e0 = (PropertyChangeEvent) events.get(0);
+ harness.check(e0.getPropertyName(),
+ AccessibleContext.ACCESSIBLE_VALUE_PROPERTY);
+ harness.check(e0.getSource(), ac);
+ harness.check(e0.getOldValue(), new Integer(55));
+ harness.check(e0.getNewValue(), new Integer(10));
+
+ // set the value above the maximum
+ events.clear();
+ b = av.setCurrentAccessibleValue(new Integer(105));
+ harness.check(av.getCurrentAccessibleValue(), new Integer(90));
+ harness.check(b);
+ harness.check(events.size(), 1);
+ e0 = (PropertyChangeEvent) events.get(0);
+ harness.check(e0.getPropertyName(),
+ AccessibleContext.ACCESSIBLE_VALUE_PROPERTY);
+ harness.check(e0.getSource(), ac);
+ harness.check(e0.getOldValue(), new Integer(10));
+ harness.check(e0.getNewValue(), new Integer(90));
+
+ // set the value to null
+ events.clear();
+ b = av.setCurrentAccessibleValue(null);
+ harness.check(av.getCurrentAccessibleValue(), new Integer(90));
+ harness.check(events.size(), 0);
+ harness.check(!b);
+
+ // check the state settings...
+ AccessibleStateSet set = ac.getAccessibleStateSet();
+ harness.check(set.contains(AccessibleState.ENABLED));
+ harness.check(set.contains(AccessibleState.FOCUSABLE));
+ harness.check(set.contains(AccessibleState.VISIBLE));
+ harness.check(set.contains(AccessibleState.OPAQUE));
+ harness.check(set.contains(AccessibleState.HORIZONTAL));
+
+ // each call creates a new set...
+ AccessibleStateSet set2 = ac.getAccessibleStateSet();
+ harness.check(set != set2);
+
+ // check the orientation state setting...
+ progressBar.setOrientation(JSlider.VERTICAL);
+ set = ac.getAccessibleStateSet();
+ harness.check(set.contains(AccessibleState.VERTICAL));
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/getPercentComplete.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/getPercentComplete.java
diff -N gnu/testlet/javax/swing/JProgressBar/getPercentComplete.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/getPercentComplete.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,49 @@
+/* getPercentComplete.java -- some checks for the getPercentComplete()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JProgressBar;
+
+public class getPercentComplete implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar(0, 9);
+ harness.check(pb.getPercentComplete(), 0.0);
+ pb.setValue(3);
+ harness.check(pb.getPercentComplete(), 3.0 / 9.0);
+
+ pb = new JProgressBar(5, 10);
+ harness.check(pb.getPercentComplete(), 0.0);
+ pb.setValue(6);
+ harness.check(pb.getPercentComplete(), 0.2);
+
+ pb = new JProgressBar(10, 10);
+ harness.check(Double.isNaN(pb.getPercentComplete()));
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/getString.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/getString.java
diff -N gnu/testlet/javax/swing/JProgressBar/getString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/getString.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,47 @@
+/* getString.java -- some checks for the getString()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JProgressBar;
+
+public class getString implements Testlet
+{
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar();
+ harness.check(pb.getString(), "0%");
+
+ pb.setString("XYZ");
+ harness.check(pb.getString(), "XYZ");
+
+ pb.setString(null);
+ pb.setValue(100);
+ harness.check(pb.getString(), "100%");
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/isStringPainted.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/isStringPainted.java
diff -N gnu/testlet/javax/swing/JProgressBar/isStringPainted.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/isStringPainted.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,43 @@
+/* isStringPainted.java -- some checks for the isStringPainted()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JProgressBar;
+
+public class isStringPainted implements Testlet
+{
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar();
+ harness.check(pb.isStringPainted(), false);
+
+ pb.setStringPainted(true);
+ harness.check(pb.isStringPainted(), true);
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/paramString.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/paramString.java
diff -N gnu/testlet/javax/swing/JProgressBar/paramString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/paramString.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,37 @@
+/* paramString.java -- some checks for the paramString()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+public class paramString implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ MyJProgressBar p = new MyJProgressBar();
+ harness.check(p.paramString().endsWith(",orientation=HORIZONTAL,paintBorder=true,paintString=false,progressString=,indeterminateString=false"));
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/setBorderPainted.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/setBorderPainted.java
diff -N gnu/testlet/javax/swing/JProgressBar/setBorderPainted.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/setBorderPainted.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,59 @@
+/* setBorderPainted.java -- some checks for the setBorderPainted()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JProgressBar;
+
+public class setBorderPainted implements Testlet, PropertyChangeListener
+{
+ PropertyChangeEvent lastEvent;
+
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar();
+ harness.check(pb.isBorderPainted(), true);
+
+ pb.addPropertyChangeListener(this);
+ pb.setBorderPainted(true);
+ harness.check(lastEvent, null);
+
+ pb.setBorderPainted(false);
+ harness.check(pb.isBorderPainted(), false);
+ harness.check(lastEvent.getPropertyName(), "borderPainted");
+ harness.check(lastEvent.getOldValue(), Boolean.TRUE);
+ harness.check(lastEvent.getNewValue(), Boolean.FALSE);
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/setModel.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/setModel.java
diff -N gnu/testlet/javax/swing/JProgressBar/setModel.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/setModel.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,70 @@
+/* setModel.java -- some checks for the setModel()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.DefaultBoundedRangeModel;
+import javax.swing.JProgressBar;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setModel implements Testlet, ChangeListener
+{
+ ChangeEvent lastEvent;
+
+ public void stateChanged(ChangeEvent e)
+ {
+ lastEvent = e;
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultBoundedRangeModel m1 = new DefaultBoundedRangeModel(1, 2, 0, 10);
+ JProgressBar pb = new JProgressBar(m1);
+ pb.addChangeListener(this);
+ harness.check(m1.getExtent(), 0);
+ harness.check(m1.getChangeListeners().length, 1);
+ DefaultBoundedRangeModel m2 = new DefaultBoundedRangeModel(10, 20, 0, 100);
+ pb.setModel(m2);
+ harness.check(pb.getModel(), m2);
+ harness.check(m2.getExtent(), 0);
+ harness.check(m1.getChangeListeners().length, 0);
+ harness.check(m2.getChangeListeners().length, 1);
+ harness.check(lastEvent.getSource(), pb);
+
+ boolean pass = false;
+ try
+ {
+ pb.setModel(null);
+ }
+ catch (NullPointerException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/setOrientation.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/setOrientation.java
diff -N gnu/testlet/javax/swing/JProgressBar/setOrientation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/setOrientation.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,71 @@
+/* setOrientation.java -- some checks for the setOrientation()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JProgressBar;
+import javax.swing.SwingConstants;
+
+public class setOrientation implements Testlet, PropertyChangeListener
+{
+ PropertyChangeEvent lastEvent;
+
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar();
+ harness.check(pb.getOrientation(), SwingConstants.HORIZONTAL);
+
+ pb.addPropertyChangeListener(this);
+ pb.setOrientation(SwingConstants.VERTICAL);
+ harness.check(pb.getOrientation(), SwingConstants.VERTICAL);
+ harness.check(lastEvent.getPropertyName(), "orientation");
+ harness.check(lastEvent.getOldValue(),
+ new Integer(SwingConstants.HORIZONTAL));
+ harness.check(lastEvent.getNewValue(),
+ new Integer(SwingConstants.VERTICAL));
+
+ boolean pass = false;
+ try
+ {
+ pb.setOrientation(99);
+ }
+ catch (IllegalArgumentException e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/setString.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/setString.java
diff -N gnu/testlet/javax/swing/JProgressBar/setString.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/setString.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,63 @@
+/* setString.java -- some checks for the setString()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JProgressBar;
+
+public class setString implements Testlet, PropertyChangeListener
+{
+ PropertyChangeEvent lastEvent;
+
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar();
+ harness.check(pb.getString(), "0%");
+
+ pb.addPropertyChangeListener(this);
+ pb.setString("XYZ");
+ harness.check(pb.getString(), "XYZ");
+ harness.check(lastEvent.getPropertyName(), "string");
+ harness.check(lastEvent.getOldValue(), null);
+ harness.check(lastEvent.getNewValue(), "XYZ");
+
+ pb.setString(null);
+ harness.check(pb.getString(), "0%");
+ harness.check(lastEvent.getPropertyName(), "string");
+ harness.check(lastEvent.getOldValue(), "XYZ");
+ harness.check(lastEvent.getNewValue(), null);
+
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/setStringPainted.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/setStringPainted.java
diff -N gnu/testlet/javax/swing/JProgressBar/setStringPainted.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/setStringPainted.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,59 @@
+/* setStringPainted.java -- some checks for the setStringPainted()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JProgressBar;
+
+public class setStringPainted implements Testlet, PropertyChangeListener
+{
+ PropertyChangeEvent lastEvent;
+
+ public void propertyChange(PropertyChangeEvent event)
+ {
+ lastEvent = event;
+ }
+
+ public void test(TestHarness harness)
+ {
+ JProgressBar pb = new JProgressBar();
+ harness.check(pb.isStringPainted(), false);
+
+ pb.addPropertyChangeListener(this);
+ pb.setStringPainted(false);
+ harness.check(lastEvent, null);
+
+ pb.setStringPainted(true);
+ harness.check(pb.isStringPainted(), true);
+ harness.check(lastEvent.getPropertyName(), "stringPainted");
+ harness.check(lastEvent.getOldValue(), Boolean.FALSE);
+ harness.check(lastEvent.getNewValue(), Boolean.TRUE);
+ }
+}
Index: gnu/testlet/javax/swing/JProgressBar/setValue.java
===================================================================
RCS file: gnu/testlet/javax/swing/JProgressBar/setValue.java
diff -N gnu/testlet/javax/swing/JProgressBar/setValue.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JProgressBar/setValue.java 31 May 2006 10:27:47 -0000
@@ -0,0 +1,78 @@
+/* setValue.java -- some checks for the setValue()
+ method in the JProgressBar 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.JProgressBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.util.List;
+
+import javax.swing.DefaultBoundedRangeModel;
+import javax.swing.JProgressBar;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
+public class setValue implements Testlet, ChangeListener
+{
+ List events = new java.util.ArrayList();
+
+ public void stateChanged(ChangeEvent e)
+ {
+ events.add(e);
+ }
+
+ public void test(TestHarness harness)
+ {
+ DefaultBoundedRangeModel m = new DefaultBoundedRangeModel();
+ m.addChangeListener(this);
+ JProgressBar pb = new JProgressBar(m);
+ pb.addChangeListener(this);
+ harness.check(pb.getValue(), 0);
+ pb.setValue(55);
+ harness.check(pb.getValue(), 55);
+ harness.check(m.getValue(), 55);
+ harness.check(events.size(), 2);
+
+ // setting the same value triggers no events
+ events.clear();
+ pb.setValue(55);
+ harness.check(events.size(), 0);
+
+ // try value < minimum
+ events.clear();
+ pb.setValue(-1);
+ harness.check(pb.getValue(), 0);
+ harness.check(m.getValue(), 0);
+ harness.check(events.size(), 2);
+
+ // try value > maximum
+ events.clear();
+ pb.setValue(101);
+ harness.check(pb.getValue(), 100);
+ harness.check(m.getValue(), 100);
+ harness.check(events.size(), 2);
+ }
+
+}