author | serb |
Wed, 27 Feb 2019 18:46:55 -0800 | |
changeset 54231 | e4813eded7cb |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
25 |
@test |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
26 |
@key headful |
2 | 27 |
@bug 4664415 |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
28 |
@summary Test that double clicking the titlebar does not send RELEASE/CLICKED |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
29 |
@library ../../regtesthelpers |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
30 |
@build Util |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
31 |
@run main TitleBarDoubleClick |
2 | 32 |
*/ |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
33 |
|
2 | 34 |
import java.awt.*; |
35 |
import java.awt.event.*; |
|
36 |
import test.java.awt.regtesthelpers.Util; |
|
37 |
||
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
38 |
public class TitleBarDoubleClick implements MouseListener, |
2 | 39 |
WindowListener |
40 |
{ |
|
41 |
//Declare things used in the test, like buttons and labels here |
|
42 |
private final static Rectangle BOUNDS = new Rectangle(300, 300, 300, 300); |
|
43 |
private final static int TITLE_BAR_OFFSET = 10; |
|
44 |
||
45 |
Frame frame; |
|
46 |
Robot robot; |
|
47 |
||
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
48 |
public static void main(final String[] args) { |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
49 |
TitleBarDoubleClick app = new TitleBarDoubleClick(); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
50 |
app.start(); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
51 |
} |
2 | 52 |
|
53 |
public void start () |
|
54 |
{ |
|
55 |
robot = Util.createRobot(); |
|
56 |
robot.setAutoDelay(100); |
|
57 |
robot.mouseMove(BOUNDS.x + (BOUNDS.width / 2), |
|
58 |
BOUNDS.y + (BOUNDS.height/ 2)); |
|
59 |
||
60 |
frame = new Frame("TitleBarDoubleClick"); |
|
61 |
frame.setBounds(BOUNDS); |
|
62 |
frame.addMouseListener(this); |
|
63 |
frame.addWindowListener(this); |
|
64 |
frame.setVisible(true); |
|
65 |
}// start() |
|
66 |
||
67 |
// Move the mouse into the title bar and double click to maximize the |
|
68 |
// Frame |
|
69 |
static boolean hasRun = false; |
|
70 |
||
71 |
private void doTest() { |
|
72 |
if (hasRun) return; |
|
73 |
hasRun = true; |
|
74 |
||
75 |
System.out.println("doing test"); |
|
76 |
robot.mouseMove(BOUNDS.x + (BOUNDS.width / 2), |
|
77 |
BOUNDS.y + TITLE_BAR_OFFSET); |
|
78 |
robot.delay(50); |
|
79 |
// Util.waitForIdle(robot) seem always hangs here. |
|
80 |
// Need to use it instead robot.delay() when the bug become fixed. |
|
81 |
System.out.println("1st press: currentTimeMillis: " + System.currentTimeMillis()); |
|
82 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
83 |
robot.delay(50); |
|
84 |
System.out.println("1st release: currentTimeMillis: " + System.currentTimeMillis()); |
|
85 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
86 |
robot.delay(50); |
|
87 |
System.out.println("2nd press: currentTimeMillis: " + System.currentTimeMillis()); |
|
88 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
89 |
robot.delay(50); |
|
90 |
System.out.println("2nd release: currentTimeMillis: " + System.currentTimeMillis()); |
|
91 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
92 |
System.out.println("done: currentTimeMillis: " + System.currentTimeMillis()); |
|
93 |
} |
|
94 |
||
95 |
private void fail() { |
|
96 |
throw new AWTError("Test failed"); |
|
97 |
} |
|
98 |
||
99 |
public void mouseEntered(MouseEvent e) {} |
|
100 |
public void mouseExited(MouseEvent e) {} |
|
101 |
public void mousePressed(MouseEvent e) {fail();} |
|
102 |
public void mouseReleased(MouseEvent e) {fail();} |
|
103 |
public void mouseClicked(MouseEvent e) {fail();} |
|
104 |
||
105 |
public void windowActivated(WindowEvent e) {doTest();} |
|
106 |
public void windowClosed(WindowEvent e) {} |
|
107 |
public void windowClosing(WindowEvent e) {} |
|
108 |
public void windowDeactivated(WindowEvent e) {} |
|
109 |
public void windowDeiconified(WindowEvent e) {} |
|
110 |
public void windowIconified(WindowEvent e) {} |
|
111 |
public void windowOpened(WindowEvent e) {} |
|
112 |
||
113 |
}// class TitleBarDoubleClick |