This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fwd: FYI: some JComboBox tests]


This e-mail (patch notification) bounced earlier...

Regards,

Dave
--- Begin Message --- I committed these new tests:

2005-10-18 David Gilbert <david.gilbert@object-refinery.com>

   * gnu/testlet/javax/swing/JComboBox/addItem.java: New test,
   * gnu/testlet/javax/swing/JComboBox/getEditor.java: New test,
   * gnu/testlet/javax/swing/JComboBox/removeItem.java: New test,
   * gnu/testlet/javax/swing/JComboBox/setEditable.java: New test,
   * gnu/testlet/javax/swing/JComboBox/setEditor.java: New test.

Regards,

Dave
Index: gnu/testlet/javax/swing/JComboBox/addItem.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComboBox/addItem.java
diff -N gnu/testlet/javax/swing/JComboBox/addItem.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComboBox/addItem.java	18 Oct 2005 15:48:44 -0000
@@ -0,0 +1,71 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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.
+
+package gnu.testlet.javax.swing.JComboBox;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JComboBox;
+import javax.swing.UIManager;
+
+/**
+ * Some checks for the addItem() method in the {@link JComboBox} class.
+ */
+public class addItem 
+  implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {   
+    // use a known look and feel
+    try
+      {
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+      }
+    catch (Exception e)
+      {
+        harness.fail("Problem setting MetalLookAndFeel");
+      }
+    
+    JComboBox c1 = new JComboBox();
+    harness.check(c1.getSelectedIndex(), -1);
+    harness.check(c1.getSelectedItem(), null);
+    
+    c1.addItem("Item 1");
+    harness.check(c1.getSelectedIndex(), 0);
+    harness.check(c1.getSelectedItem(), "Item 1");
+    
+    c1.addItem("Item 2");
+    harness.check(c1.getSelectedIndex(), 0);
+    harness.check(c1.getSelectedItem(), "Item 1");
+    
+    // check null
+    c1.addItem(null);
+    harness.check(c1.getSelectedIndex(), 0);
+    harness.check(c1.getSelectedItem(), "Item 1");
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/JComboBox/getEditor.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComboBox/getEditor.java
diff -N gnu/testlet/javax/swing/JComboBox/getEditor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComboBox/getEditor.java	18 Oct 2005 15:48:44 -0000
@@ -0,0 +1,66 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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.
+
+package gnu.testlet.javax.swing.JComboBox;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.ComboBoxEditor;
+import javax.swing.JComboBox;
+import javax.swing.UIManager;
+import javax.swing.plaf.UIResource;
+import javax.swing.plaf.metal.MetalComboBoxEditor;
+
+/**
+ * Some checks for the getEditor() method in the {@link JComboBox} class.
+ */
+public class getEditor 
+  implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {   
+    // use a known look and feel
+    try
+      {
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+      }
+    catch (Exception e)
+      {
+        harness.fail("Problem setting MetalLookAndFeel");
+      }
+    
+    JComboBox c1 = new JComboBox(new Object[] {"A", "B", "C"});
+    ComboBoxEditor editor = c1.getEditor();
+    
+    // check default value
+    harness.check(editor instanceof MetalComboBoxEditor.UIResource);
+    
+    c1.setEditor(new MetalComboBoxEditor());
+    harness.check(!(c1.getEditor() instanceof UIResource));
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/JComboBox/removeItem.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComboBox/removeItem.java
diff -N gnu/testlet/javax/swing/JComboBox/removeItem.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComboBox/removeItem.java	18 Oct 2005 15:48:44 -0000
@@ -0,0 +1,87 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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.
+
+package gnu.testlet.javax.swing.JComboBox;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JComboBox;
+import javax.swing.UIManager;
+
+/**
+ * Some checks for the removeItem() method in the {@link JComboBox} class.
+ */
+public class removeItem 
+  implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {   
+    // use a known look and feel
+    try
+      {
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+      }
+    catch (Exception e)
+      {
+        harness.fail("Problem setting MetalLookAndFeel");
+      }
+    
+    JComboBox c1 = new JComboBox();
+    harness.check(c1.getSelectedIndex(), -1);
+    harness.check(c1.getSelectedItem(), null);
+    
+    // remove an item when it doesn't exist
+    c1.removeItem("Item 1");
+    harness.check(c1.getSelectedIndex(), -1);
+    harness.check(c1.getSelectedItem(), null);
+    
+    c1.addItem("Item 1");
+    harness.check(c1.getSelectedItem(), "Item 1");
+    c1.addItem("Item 2");
+    harness.check(c1.getSelectedItem(), "Item 1");
+    c1.addItem("Item 3");
+    harness.check(c1.getSelectedItem(), "Item 1");
+    c1.setSelectedItem("Item 3");
+    harness.check(c1.getSelectedItem(), "Item 3");
+    c1.removeItem("Item 3");
+    harness.check(c1.getSelectedItem(), "Item 2");
+
+    // check null
+    c1.removeItem(null);
+    harness.check(c1.getSelectedItem(), "Item 2");
+
+    c1.removeItem("Item 2");
+    harness.check(c1.getSelectedItem(), "Item 1");
+    harness.check(c1.getSelectedIndex(), 0);
+    
+    c1.addItem("Item A");
+    c1.removeItem("Item 1");
+    harness.check(c1.getSelectedItem(), "Item A");
+    harness.check(c1.getSelectedIndex(), 0);
+  }
+  
+}
+
Index: gnu/testlet/javax/swing/JComboBox/setEditable.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComboBox/setEditable.java
diff -N gnu/testlet/javax/swing/JComboBox/setEditable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComboBox/setEditable.java	18 Oct 2005 15:48:44 -0000
@@ -0,0 +1,80 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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.
+
+package gnu.testlet.javax.swing.JComboBox;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.JComboBox;
+
+/**
+ * Some checks for the setEditable() method in the 
+ * {@link JComboBox} class.
+ */
+public class setEditable 
+  implements Testlet, PropertyChangeListener 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {   
+    JComboBox c = new JComboBox();
+    c.setEditable(false);
+    harness.check(c.isEditable(), false);
+    
+    // now check property change events
+    c.addPropertyChangeListener(this);
+    
+    c.setEditable(true);
+    harness.check(c.isEditable(), true);
+    harness.check(event.getPropertyName(), "editable");
+    harness.check(event.getOldValue(), Boolean.FALSE);
+    harness.check(event.getNewValue(), Boolean.TRUE);
+    
+    c.setEditable(false);
+    harness.check(c.isEditable(), false);
+    harness.check(event.getPropertyName(), "editable");
+    harness.check(event.getOldValue(), Boolean.TRUE);
+    harness.check(event.getNewValue(), Boolean.FALSE);
+    
+    // no change = no event
+    event = null;
+    
+    c.setEditable(false);
+    harness.check(event == null);
+  }
+  
+  private PropertyChangeEvent event;
+  
+  public void propertyChange(PropertyChangeEvent e)
+  {
+    event = e;
+  }
+  
+
+}
+
Index: gnu/testlet/javax/swing/JComboBox/setEditor.java
===================================================================
RCS file: gnu/testlet/javax/swing/JComboBox/setEditor.java
diff -N gnu/testlet/javax/swing/JComboBox/setEditor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/JComboBox/setEditor.java	18 Oct 2005 15:48:44 -0000
@@ -0,0 +1,97 @@
+// Tags: JDK1.4
+
+// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+
+// 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.
+
+package gnu.testlet.javax.swing.JComboBox;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+import gnu.testlet.javax.swing.TestLookAndFeel;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.swing.ComboBoxEditor;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.UIManager;
+import javax.swing.plaf.basic.BasicComboBoxEditor;
+import javax.swing.plaf.metal.MetalComboBoxEditor;
+
+/**
+ * Some checks for the setEditor() method in the {@link JComponent} class.
+ */
+public class setEditor 
+  implements Testlet, PropertyChangeListener
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)      
+  {   
+    // use a known look and feel
+    try
+      {
+        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
+      }
+    catch (Exception e)
+      {
+        harness.fail("Problem setting MetalLookAndFeel");
+      }
+    
+    JComboBox c1 = new JComboBox(new Object[] {"A", "B", "C"});
+    c1.addPropertyChangeListener(this);
+    
+    ComboBoxEditor editor = new MetalComboBoxEditor();
+    c1.setEditor(editor);
+    harness.check(c1.getEditor(), editor);
+    harness.check(event.getPropertyName(), "editor");
+    harness.check(event.getNewValue(), editor);
+    
+    // set a new look and feel and see if the editor (which doesn't implement
+    // UIResource) gets replaced
+    try
+      {
+        UIManager.setLookAndFeel(new TestLookAndFeel());
+      }
+    catch (Exception e)
+      {
+        harness.fail("Problem setting TestLookAndFeel");
+      }
+    c1.updateUI();
+    JComboBox c2 = new JComboBox();
+    harness.check(c1.getEditor(), editor);
+    harness.check(c2.getEditor() instanceof BasicComboBoxEditor.UIResource);
+    
+    // try a null setting - no exceptions are thrown
+    c1.setEditor(null);
+    harness.check(c1.getEditor(), null);
+  }
+  
+  private PropertyChangeEvent event;
+  
+  public void propertyChange(PropertyChangeEvent e)
+  {
+    event = e;
+  }
+  
+}
+

--- End Message ---

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