public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: Combo box mouseclicks
@ 2006-06-12 19:50 Francis Kung
  0 siblings, 0 replies; only message in thread
From: Francis Kung @ 2006-06-12 19:50 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

Thanks to Lillian and Tom for pointing me to the Robot class; new mauve
test (committed) for the JComboBox mouseclick patch I submitted earlier
on the classpath list.

Francis


2006-06-12  Francis Kung  <fkung@redhat.com>

	* gnu/testlet/javax/swing/JComboBox/basic.java:
	(test): added new test
	(testTogglingVisibility): new test for mouse clicks


[-- Attachment #2: mauve-JComboBox.diff --]
[-- Type: text/x-patch, Size: 2671 bytes --]

Index: gnu/testlet/javax/swing/JComboBox/basic.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/JComboBox/basic.java,v
retrieving revision 1.1
diff -u -r1.1 basic.java
--- gnu/testlet/javax/swing/JComboBox/basic.java	23 Feb 2005 10:59:05 -0000	1.1
+++ gnu/testlet/javax/swing/JComboBox/basic.java	12 Jun 2006 19:35:33 -0000
@@ -24,12 +24,18 @@
 import gnu.testlet.TestHarness;
 import gnu.testlet.Testlet;
 
+import java.awt.BorderLayout;
+import java.awt.Container;
+import java.awt.Robot;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 
 import javax.swing.JComboBox;
+import javax.swing.JFrame;
+import javax.swing.plaf.basic.BasicComboBoxUI;
 
 /**
  * The the basic JComboBox features (including listeners).
@@ -52,6 +58,8 @@
     testItemRemoving(harness, box);
 
     testAddingItems(harness, box);
+    
+    testTogglingVisibility(harness);
   }
 
   private void testAddingItems(TestHarness harness, JComboBox box) {
@@ -161,6 +169,51 @@
     command = UNASSIGNED;
   }
 
+  private void testTogglingVisibility(TestHarness harness)
+  {
+    JFrame frame = new JFrame();
+    frame.setSize(200, 100);
+    Container contentPane = frame.getContentPane();
+    
+    JComboBox box = new JComboBox();
+    box.addItem("123");
+    box.addItem("aaa");
+    box.addItem("abc");
+    
+    contentPane.add(box, BorderLayout.SOUTH);
+    frame.show();
+    
+    // A new box should not be visible
+    harness.check(box.isPopupVisible() == false);
+
+    // Prepare robot to perform mouse click; position in middle of box
+    Robot r = harness.createRobot ();
+    r.waitForIdle ();
+    r.delay (100);
+    r.mouseMove(box.getLocationOnScreen().x + (box.getSize().width / 2),
+                box.getLocationOnScreen().y + (box.getSize().height / 2));
+
+    // Simulate user click on button; popup should now be visible
+    r.waitForIdle ();
+    r.delay (100);
+    r.mousePress(InputEvent.BUTTON1_MASK);
+    r.mouseRelease(InputEvent.BUTTON1_MASK);
+    
+    r.waitForIdle ();
+    r.delay (100);
+    harness.check(box.isPopupVisible());
+    
+    // Click it again - this should toggle the popup and make it invisible
+    r.waitForIdle ();
+    r.delay (100);
+    r.mousePress(InputEvent.BUTTON1_MASK);
+    r.mouseRelease(InputEvent.BUTTON1_MASK);
+    
+    r.waitForIdle ();
+    r.delay (100);
+    harness.check(box.isPopupVisible() == false);
+  }
+
   public void actionPerformed(ActionEvent e)
   {
     command = e.getActionCommand();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-12 19:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-12 19:50 FYI: Combo box mouseclicks Francis Kung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).