java/awt/Choice/DragMouseOutAndRelease/DragMouseOutAndRelease.java
Print this page
@@ -1,16 +1,37 @@
/*
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
@test
@bug 6322625
@summary REG:Choice does not trigger MouseReleased when dragging and releasing the mouse outside choice, XAWT
@author andrei.dmitriev area=awt.choice
@run main DragMouseOutAndRelease
*/
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
public class DragMouseOutAndRelease
{
static Frame frame = new Frame("Test Frame");
static Choice choice1 = new Choice();
@@ -48,14 +69,15 @@
});
frame.pack();
frame.setVisible(true);
frame.validate();
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
try {
robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
testMouseDrag();
} catch (Throwable e) {
new RuntimeException("Test failed. Exception thrown: "+e);
}
DragMouseOutAndRelease.pass();
@@ -65,34 +87,34 @@
mousePressed = false;
mouseReleased = false;
pt = choice1.getLocationOnScreen();
robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y + choice1.getHeight()/2);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
//move mouse outside Choice
robot.mouseMove(pt.x + choice1.getWidth()/2, pt.y - choice1.getHeight());
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
robot.mouseRelease(InputEvent.BUTTON1_MASK);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
if (!mousePressed || !mouseReleased)
{
System.out.println("ERROR: "+ mousePressed+","+mouseReleased);
// close the choice
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
DragMouseOutAndRelease.fail("Test failed. Choice should generate PRESSED, RELEASED events outside if pressed on Choice ");
} else{
// close the choice
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
System.out.println("Choice did generated PRESSED and RELEASED after Drag outside the Choice ");
}
}