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]

Re: FYI: JComboBox tests


Sorry for the extra mail - meant to include this in the last commit.
Adds editable-combobox tests to the robot tests.

2006-07-18  Francis Kung  <fkung@redhat.com>

	* gnu/testlet/javax/swing/JComboBox/ComboRobot.java
	(testCombo): Added parameter for editable comboboxes
	(test): Added iteration for editable comboboxes.

Francis



On Tue, 2006-07-18 at 14:20 -0400, Francis Kung wrote:
> This patch (committed) expands the robot tests with JComboBox.
> 
> 2006-07-18  Francis Kung  <fkung@redhat.com>
> 
> 	* gnu/testlet/javax/swing/JComboBox/ComboRobot.java: organized 
> 	imports
> 	(combo): Added item to combo box.
> 	(testCombo): Added additional tests for key selector.
> 
> 
> Francis
> 
Index: gnu/testlet/javax/swing/JComboBox/ComboRobot.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JComboBox/ComboRobot.java,v
retrieving revision 1.2
diff -u -r1.2 ComboRobot.java
--- gnu/testlet/javax/swing/JComboBox/ComboRobot.java	18 Jul 2006 18:20:43 -0000	1.2
+++ gnu/testlet/javax/swing/JComboBox/ComboRobot.java	18 Jul 2006 18:30:31 -0000
@@ -118,7 +118,7 @@
     r.keyRelease(code);
   }
   
-  public void testCombo() throws Exception
+  public void testCombo(boolean editable) throws Exception
   {
     // Click on combo box to give it focus
     click(combo, combo.getWidth() / 2, combo.getHeight() / 2);
@@ -141,36 +141,42 @@
     type(KeyEvent.VK_ENTER);
     assertEquals("Selecting forth component with keyboard", "d", getFocus());
     
-    // Reset to top & test the key selection manager
-    combo.setSelectedIndex(-1);
-
-    for (char i = 'a'; i <= 'f'; i++)
+    // Reset to top & test the key selection manager (only if not editable)
+    if (!editable)
       {
+        combo.setSelectedIndex(-1);
+    
+        for (char i = 'a'; i <= 'f'; i++)
+          {
+            type(KeyEvent.VK_DOWN);
+            type(KeyEvent.VK_A + (i-'a'));
+            type(KeyEvent.VK_ENTER);
+            assertEquals("Selecting with letter key, " + i,
+                         new String(new char[] { i }), getFocus());
+          }
+        
+        // Reset to top & test duplicate letters in key selection manager
+        combo.setSelectedIndex(-1);
+    
+        type(KeyEvent.VK_DOWN);
+        type(KeyEvent.VK_A);
+        type(KeyEvent.VK_ENTER);
+        assertEquals("Selecting with letter key (duplicate)", "a", getFocus());
+        
         type(KeyEvent.VK_DOWN);
-        type(KeyEvent.VK_A + (i-'a'));
+        type(KeyEvent.VK_A);
         type(KeyEvent.VK_ENTER);
-        assertEquals("Selecting with letter key, " + i,
-                     new String(new char[] { i }), getFocus());
+        assertEquals("Selecting with letter key (duplicate)", "a234", getFocus());
       }
     
-    // Reset to top & test duplicate letters in key selection manager
-    combo.setSelectedIndex(-1);
-
-    type(KeyEvent.VK_DOWN);
-    type(KeyEvent.VK_A);
-    type(KeyEvent.VK_ENTER);
-    assertEquals("Selecting with letter key (duplicate)", "a", getFocus());
-    
-    type(KeyEvent.VK_DOWN);
-    type(KeyEvent.VK_A);
-    type(KeyEvent.VK_ENTER);
-    assertEquals("Selecting with letter key (duplicate)", "a234", getFocus());
-    
     // Test the escape button too, for cancelling the popup
     type(KeyEvent.VK_DOWN);
     type(KeyEvent.VK_ESCAPE);
     assertEquals("Cancelling popup with escape key", false, combo.isPopupVisible());
 
+    // Reset to top
+    combo.setSelectedIndex(0);
+    
     Thread.sleep(5000);
   }
   
@@ -187,7 +193,12 @@
         setUp();
         try
           {
-            testCombo();
+            // Test with regular combo box...
+            testCombo(false);
+            
+            // And editable combo box
+            combo.setEditable(true);
+            testCombo(true);
           }
         finally
           {

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