Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java
41153 views
1
/*
2
* Copyright (c) 2020, 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
import java.awt.Color;
25
import java.awt.DisplayMode;
26
import java.awt.Frame;
27
import java.awt.Graphics;
28
import java.awt.GraphicsConfiguration;
29
import java.awt.GraphicsDevice;
30
import java.awt.GraphicsEnvironment;
31
import java.awt.Rectangle;
32
33
/**
34
* @test
35
* @bug 8211999
36
* @key headful
37
* @summary verifies the full-screen window bounds and graphics configuration
38
*/
39
public final class FullscreenWindowProps {
40
41
public static void main(String[] args) throws Exception {
42
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
43
GraphicsDevice gd = ge.getDefaultScreenDevice();
44
45
if (!gd.isFullScreenSupported()) {
46
return;
47
}
48
49
Frame frame = new Frame() {
50
@Override
51
public void paint(Graphics g) {
52
super.paint(g);
53
g.setColor(Color.GREEN);
54
g.fillRect(0, 0, getWidth(), getHeight());
55
}
56
};
57
try {
58
frame.setUndecorated(true); // workaround JDK-8256257
59
frame.setBackground(Color.MAGENTA);
60
frame.setVisible(true);
61
gd.setFullScreenWindow(frame);
62
Thread.sleep(4000);
63
64
for (DisplayMode dm : gd.getDisplayModes()) {
65
if (dm.getWidth() == 1024 && dm.getHeight() == 768) {
66
gd.setDisplayMode(dm);
67
Thread.sleep(4000);
68
break;
69
}
70
}
71
72
GraphicsConfiguration frameGC = frame.getGraphicsConfiguration();
73
Rectangle frameBounds = frame.getBounds();
74
75
GraphicsConfiguration screenGC = gd.getDefaultConfiguration();
76
Rectangle screenBounds = screenGC.getBounds();
77
78
if (frameGC != screenGC) {
79
System.err.println("Expected: " + screenGC);
80
System.err.println("Actual: " + frameGC);
81
throw new RuntimeException();
82
}
83
84
checkSize(frameBounds.x, screenBounds.x, "x");
85
checkSize(frameBounds.y, screenBounds.y, "Y");
86
checkSize(frameBounds.width, screenBounds.width, "width");
87
checkSize(frameBounds.height, screenBounds.height, "height");
88
} finally {
89
gd.setFullScreenWindow(null);
90
frame.dispose();
91
Thread.sleep(10000);
92
}
93
}
94
95
private static void checkSize(int actual, int expected, String prop) {
96
if (Math.abs(actual - expected) > 30) { // let's allow size variation,
97
// the bug is reproduced anyway
98
System.err.println("Expected: " + expected);
99
System.err.println("Actual: " + actual);
100
throw new RuntimeException(prop + " is wrong");
101
}
102
}
103
}
104
105