This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: JMenuBar - new tests
- From: David Gilbert <david dot gilbert at object-refinery dot com>
- To: mauve-patches <mauve-patches at sources dot redhat dot com>
- Date: Thu, 29 Jun 2006 17:27:17 +0100
- Subject: FYI: JMenuBar - new tests
This patch (committed) adds some tests for the JMenuBar class:
2006-06-29 David Gilbert <david.gilbert@object-refinery.com>
* gnu/testlet/javax/swing/JMenuBar/getActionMap.java: New test,
* gnu/testlet/javax/swing/JMenuBar/getHelpMenu.java: New test,
* gnu/testlet/javax/swing/JMenuBar/setHelpMenu.java: New test,
* gnu/testlet/javax/swing/JMenuBar/setMargin.java: New test.
Regards,
Dave
Index: gnu/testlet/javax/swing/JMenuBar/getActionMap.java
===================================================================
RCS file: gnu/testlet/javax/swing/JMenuBar/getActionMap.java
diff -N gnu/testlet/javax/swing/JMenuBar/getActionMap.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JMenuBar/getActionMap.java 29 Jun 2006 16:23:09 -0000
@@ -0,0 +1,48 @@
+/* getActionMap.java -- some checks for the getActionMap() method in the
+ JMenuBar class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.JMenuBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.Action;
+import javax.swing.ActionMap;
+import javax.swing.JMenuBar;
+
+public class getActionMap implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ JMenuBar mb = new JMenuBar();
+ ActionMap m = mb.getActionMap();
+ harness.check(m.keys(), null);
+ ActionMap mp = m.getParent();
+ //Object[] keys = mp.keys();
+ //for (int i = 0; i < keys.length; i++)
+ // System.out.println(keys[i]);
+ harness.check(mp.get("takeFocus") instanceof Action);
+ harness.check(mp.keys().length, 1);
+ }
+}
Index: gnu/testlet/javax/swing/JMenuBar/getHelpMenu.java
===================================================================
RCS file: gnu/testlet/javax/swing/JMenuBar/getHelpMenu.java
diff -N gnu/testlet/javax/swing/JMenuBar/getHelpMenu.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JMenuBar/getHelpMenu.java 29 Jun 2006 16:23:09 -0000
@@ -0,0 +1,48 @@
+/* getHelpMenu.java -- some checks for the getHelpMenu() method in the
+ JMenuBar class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.JMenuBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JMenuBar;
+
+public class getHelpMenu implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ JMenuBar mb = new JMenuBar();
+ boolean pass = false;
+ try
+ {
+ mb.getHelpMenu();
+ }
+ catch (Error e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}
Index: gnu/testlet/javax/swing/JMenuBar/setHelpMenu.java
===================================================================
RCS file: gnu/testlet/javax/swing/JMenuBar/setHelpMenu.java
diff -N gnu/testlet/javax/swing/JMenuBar/setHelpMenu.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JMenuBar/setHelpMenu.java 29 Jun 2006 16:23:09 -0000
@@ -0,0 +1,49 @@
+/* setHelpMenu.java -- some checks for the setHelpMenu() method in the
+ JMenuBar class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.JMenuBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+
+public class setHelpMenu implements Testlet
+{
+ public void test(TestHarness harness)
+ {
+ JMenuBar mb = new JMenuBar();
+ boolean pass = false;
+ try
+ {
+ mb.setHelpMenu(new JMenu());
+ }
+ catch (Error e)
+ {
+ pass = true;
+ }
+ harness.check(pass);
+ }
+}
Index: gnu/testlet/javax/swing/JMenuBar/setMargin.java
===================================================================
RCS file: gnu/testlet/javax/swing/JMenuBar/setMargin.java
diff -N gnu/testlet/javax/swing/JMenuBar/setMargin.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JMenuBar/setMargin.java 29 Jun 2006 16:23:10 -0000
@@ -0,0 +1,79 @@
+/* setMargin.java -- some checks for the setMargin() method in the JMenuBar
+ class.
+ Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.4
+
+package gnu.testlet.javax.swing.JMenuBar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Insets;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import javax.swing.JMenuBar;
+
+public class setMargin implements Testlet, PropertyChangeListener
+{
+ List events = new java.util.ArrayList();
+
+ public void propertyChange(PropertyChangeEvent e)
+ {
+ events.add(e);
+ }
+
+ public void test(TestHarness harness)
+ {
+ JMenuBar mb = new JMenuBar();
+ harness.check(mb.getMargin(), new Insets(0, 0, 0, 0));
+ harness.check(mb.getMargin() != mb.getMargin());
+ mb.addPropertyChangeListener(this);
+ mb.setMargin(new Insets(1, 2, 3, 4));
+ harness.check(mb.getMargin(), new Insets(1, 2, 3, 4));
+ harness.check(events.size(), 1);
+ PropertyChangeEvent e = (PropertyChangeEvent) events.get(0);
+ harness.check(e.getSource(), mb);
+ harness.check(e.getPropertyName(), "margin");
+ harness.check(e.getNewValue(), new Insets(1, 2, 3, 4));
+ harness.check(e.getOldValue(), null);
+
+ // setting the same value generates no event
+ events.clear();
+ mb.setMargin(new Insets(1, 2, 3, 4));
+ harness.check(events.size(), 0);
+
+ // set to null
+ mb.setMargin(null);
+ harness.check(mb.getMargin(), new Insets(0, 0, 0, 0));
+ harness.check(events.size(), 1);
+ e = (PropertyChangeEvent) events.get(0);
+ harness.check(e.getSource(), mb);
+ harness.check(e.getPropertyName(), "margin");
+ harness.check(e.getNewValue(), null);
+ harness.check(e.getOldValue(), new Insets(1, 2, 3, 4));
+
+ }
+
+
+}