This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: Combo box mouseclicks
- From: Francis Kung <fkung at redhat dot com>
- To: mauve-patches <mauve-patches at sources dot redhat dot com>
- Date: Mon, 12 Jun 2006 15:50:14 -0400
- Subject: FYI: Combo box mouseclicks
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
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();