author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 32427 | c22b7e41adf3 |
permissions | -rw-r--r-- |
30927
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
32427
diff
changeset
|
2 |
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
30927
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
4 |
* |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
8 |
* |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
13 |
* accompanied this code). |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
14 |
* |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
18 |
* |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
21 |
* questions. |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
22 |
*/ |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
23 |
import java.awt.Button; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
24 |
import java.awt.Frame; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
25 |
import java.awt.Rectangle; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
26 |
import java.awt.Robot; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
27 |
import jdk.testlibrary.OSInfo; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
28 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
29 |
/* |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
30 |
* @test 1.2 98/08/05 |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
32427
diff
changeset
|
31 |
* @key headful |
30927
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
32 |
* @bug 4373478 8079255 |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
33 |
* @summary Test mouse wheel functionality of Robot |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
34 |
* @author bchristi: area=Robot |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
35 |
* @library ../../../../lib/testlibrary |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
36 |
* @build jdk.testlibrary.OSInfo |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
37 |
* @run main RobotWheelTest |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
38 |
*/ |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
39 |
public class RobotWheelTest { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
40 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
41 |
private static final int NUMTESTS = 20; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
42 |
private static volatile int wheelRotation; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
43 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
44 |
public static void main(String[] args) throws Exception { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
45 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
46 |
Frame frame = null; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
47 |
try { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
48 |
int wheelSign = OSInfo.getOSType().equals(OSInfo.OSType.MACOSX) ? -1 : 1; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
49 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
50 |
frame = new Frame(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
51 |
frame.setSize(200, 200); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
52 |
Button button = new Button("WheelButton"); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
53 |
button.addMouseWheelListener(e -> wheelRotation = e.getWheelRotation()); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
54 |
frame.add(button); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
55 |
frame.setVisible(true); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
56 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
57 |
Robot robot = new Robot(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
58 |
robot.setAutoDelay(100); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
59 |
robot.waitForIdle(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
60 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
61 |
Rectangle bounds = frame.getBounds(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
62 |
int centerX = bounds.x + bounds.width / 2; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
63 |
int centerY = bounds.y + bounds.height / 2; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
64 |
robot.mouseMove(centerX, centerY); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
65 |
robot.waitForIdle(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
66 |
|
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
67 |
for (int i = -NUMTESTS; i <= NUMTESTS; i++) { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
68 |
if (i == 0) { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
69 |
continue; |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
70 |
} |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
71 |
robot.mouseWheel(i); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
72 |
robot.waitForIdle(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
73 |
if (i != wheelSign * wheelRotation) { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
74 |
throw new RuntimeException("wheelRotation = " + wheelRotation |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
75 |
+ ", expected value = " + i); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
76 |
} |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
77 |
} |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
78 |
} finally { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
79 |
if (frame != null) { |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
80 |
frame.dispose(); |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
81 |
} |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
82 |
} |
463e3064cd46
8079255: [macosx] Test closed/java/awt/Robot/RobotWheelTest/RobotWheelTest fails for Mac only
alexsch
parents:
diff
changeset
|
83 |
} |
32427
c22b7e41adf3
8134984: Text files should end in exactly one newline
martin
parents:
30927
diff
changeset
|
84 |
} |