Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/FullScreen/8013581/bug8013581.java
41155 views
1
/*
2
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
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
*
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.
22
*/
23
24
/*
25
* @test
26
* @key headful
27
* @bug 8013581
28
* @summary [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
29
* @author [email protected]
30
* @run main bug8013581
31
*/
32
33
import java.awt.*;
34
import java.awt.event.*;
35
36
public class bug8013581 {
37
private static Frame frame;
38
private static volatile int listenerCallCounter = 0;
39
40
public static void main(String[] args) throws Exception {
41
final GraphicsEnvironment ge = GraphicsEnvironment
42
.getLocalGraphicsEnvironment();
43
final GraphicsDevice[] devices = ge.getScreenDevices();
44
45
final Robot robot = new Robot();
46
robot.setAutoDelay(50);
47
48
createAndShowGUI();
49
robot.waitForIdle();
50
51
Exception error = null;
52
for (final GraphicsDevice device : devices) {
53
if (!device.isFullScreenSupported()) {
54
continue;
55
}
56
57
device.setFullScreenWindow(frame);
58
sleep(robot);
59
60
robot.keyPress(KeyEvent.VK_A);
61
robot.keyRelease(KeyEvent.VK_A);
62
robot.waitForIdle();
63
64
device.setFullScreenWindow(null);
65
sleep(robot);
66
67
if (listenerCallCounter != 2) {
68
error = new Exception("Test failed: KeyListener called " + listenerCallCounter + " times instead of 2!");
69
break;
70
}
71
72
listenerCallCounter = 0;
73
}
74
75
frame.dispose();
76
77
if (error != null) {
78
throw error;
79
}
80
}
81
82
private static void createAndShowGUI() {
83
frame = new Frame("Test");
84
frame.addKeyListener(new KeyAdapter() {
85
@Override
86
public void keyPressed(KeyEvent e) {
87
listenerCallCounter++;
88
}
89
90
@Override
91
public void keyReleased(KeyEvent e) {
92
listenerCallCounter++;
93
}
94
});
95
96
frame.setUndecorated(true);
97
frame.setVisible(true);
98
}
99
100
private static void sleep(Robot robot) {
101
robot.waitForIdle();
102
try {
103
Thread.sleep(2000);
104
} catch (InterruptedException ignored) {
105
}
106
}
107
}
108
109