java/awt/event/MouseEvent/ClickDuringKeypress/ClickDuringKeypress.java
Print this page
@@ -1,47 +1,45 @@
/*
+ * Copyright (c) 1998, 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 1.2 98/08/05
@bug 4515763
@summary Tests that clicking mouse and pressing keys generates correct amount of click-counts
@author andrei.dmitriev: area=awt.mouse
@run main ClickDuringKeypress
*/
-// Note there is no @ in front of test above. This is so that the
-// harness will not mistake this file as a test file. It should
-// only see the html file as a test file. (the harness runs all
-// valid test files, so it would run this test twice if this file
-// were valid as well as the html file.)
-// Also, note the area= after Your Name in the author tag. Here, you
-// should put which functional area the test falls in. See the
-// AWT-core home page -> test areas and/or -> AWT team for a list of
-// areas.
-// Note also the 'ClickDuringKeypress.html' in the run tag. This should
-// be changed to the name of the test.
-
-
/**
* ClickDuringKeypress.java
*
* summary:
*/
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
-import sun.awt.SunToolkit;
-
-//Automated tests should run as applet tests if possible because they
-// get their environments cleaned up, including AWT threads, any
-// test created threads, and any system resources used by the test
-// such as file descriptors. (This is normally not a problem as
-// main tests usually run in a separate VM, however on some platforms
-// such as the Mac, separate VMs are not possible and non-applet
-// tests will cause problems). Also, you don't have to worry about
-// synchronisation stuff in Applet tests they way you do in main
-// tests...
-
public class ClickDuringKeypress implements MouseListener
{
//Declare things used in the test, like buttons and labels here
final static int CLICKCOUNT = 10;
@@ -109,12 +107,12 @@
}// start()
// Mouse should be over the Frame by this point
private void doTest() {
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
robot.setAutoDelay(2000);
+ robot.waitForIdle();
robot.keyPress(KeyEvent.VK_B);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(10);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
// Should trigger mouseClicked
@@ -131,11 +129,11 @@
robot.keyRelease(KeyEvent.VK_B);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(10);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
- ((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+ robot.waitForIdle();
// check results
robot.delay(200);
if (!clicked) {
System.out.println("No MOUSE_CLICKED events received. Test fails.");
throw new RuntimeException("No MOUSE_CLICKED events received. Test fails.");