author | serb |
Thu, 24 Oct 2019 14:54:31 -0700 | |
changeset 59175 | d2123a27cfe7 |
permissions | -rw-r--r-- |
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
1 |
/* |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
4 |
* |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
8 |
* |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
14 |
* |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
18 |
* |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
21 |
* questions. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
22 |
*/ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
23 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
24 |
import java.awt.Color; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
25 |
import java.awt.Component; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
26 |
import java.awt.DisplayMode; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
27 |
import java.awt.Frame; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
28 |
import java.awt.Graphics; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
29 |
import java.awt.GraphicsConfiguration; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
30 |
import java.awt.GraphicsDevice; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
31 |
import java.awt.GraphicsEnvironment; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
32 |
import java.awt.Image; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
33 |
import java.awt.Rectangle; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
34 |
import java.awt.Robot; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
35 |
import java.awt.Transparency; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
36 |
import java.awt.Window; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
37 |
import java.awt.event.KeyEvent; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
38 |
import java.awt.event.KeyListener; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
39 |
import java.awt.image.BufferedImage; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
40 |
import java.util.ArrayList; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
41 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
42 |
/** |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
43 |
* @test |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
44 |
* @bug 4836241 6364134 8232200 |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
45 |
* @key headful |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
46 |
* @summary verify that images are restored correctly after display mode |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
47 |
* switches and that no other rendering or crash problems occur |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
48 |
* @run main/timeout=500 CycleDMImage |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
49 |
*/ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
50 |
public class CycleDMImage extends Component implements Runnable, KeyListener { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
51 |
/** |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
52 |
* This test cycles through all available display modes, waiting after |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
53 |
* each call to setDisplayMode() to ensure that the new one is active |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
54 |
* before proceeding on to the next one. The Component is filled with |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
55 |
* a green background color and then compatible images of all 3 |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
56 |
* Transparency types are copied to the screen. The results of these |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
57 |
* operations are checked (using Robot) and the test fails if any of the |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
58 |
* rendering is wrong in any of the DisplayModes. The purpose of this |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
59 |
* test is to ensure that display mode switches do not cause problems |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
60 |
* with image restoration (or other rendering operations). |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
61 |
*/ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
62 |
boolean painted = false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
63 |
boolean earlyExit = false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
64 |
Image rImage = null, wImage = null, bImage = null; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
65 |
int imgSize = 10; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
66 |
Robot robot = null; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
67 |
volatile static boolean done = false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
68 |
static String errorMessage = null; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
69 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
70 |
public synchronized void paint(Graphics g) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
71 |
if (!painted) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
72 |
painted = true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
73 |
(new Thread(this)).start(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
74 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
75 |
if (rImage == null) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
76 |
GraphicsConfiguration gc = getGraphicsConfiguration(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
77 |
rImage = gc.createCompatibleImage(imgSize, imgSize); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
78 |
wImage = gc.createCompatibleImage(imgSize, imgSize, |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
79 |
Transparency.BITMASK); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
80 |
bImage = gc.createCompatibleImage(imgSize, imgSize, |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
81 |
Transparency.TRANSLUCENT); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
82 |
Graphics imgGraphics = rImage.getGraphics(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
83 |
imgGraphics.setColor(Color.red); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
84 |
imgGraphics.fillRect(0, 0, imgSize, imgSize); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
85 |
imgGraphics = wImage.getGraphics(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
86 |
imgGraphics.setColor(Color.white); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
87 |
imgGraphics.fillRect(0, 0, imgSize, imgSize); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
88 |
imgGraphics = bImage.getGraphics(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
89 |
imgGraphics.setColor(Color.blue); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
90 |
imgGraphics.fillRect(0, 0, imgSize, imgSize); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
91 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
92 |
g.setColor(Color.green); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
93 |
g.fillRect(0, 0, getWidth(), getHeight()); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
94 |
g.drawImage(rImage, 0, 0, this); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
95 |
g.drawImage(wImage, imgSize, 0, this); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
96 |
g.drawImage(bImage, imgSize*2, 0, this); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
97 |
g.drawImage(rImage, 0, getHeight()-imgSize, null); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
98 |
g.drawImage(rImage, getWidth()-imgSize, getHeight()-imgSize, null); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
99 |
g.drawImage(rImage, getWidth()-imgSize, 0, null); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
100 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
101 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
102 |
static void delay(long ms) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
103 |
try { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
104 |
Thread.sleep(ms); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
105 |
} catch (Exception e) {} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
106 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
107 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
108 |
public boolean checkResult(DisplayMode dm) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
109 |
if (robot == null) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
110 |
try { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
111 |
robot = new Robot(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
112 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
113 |
catch (Exception e) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
114 |
errorMessage = "Problems creating Robot"; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
115 |
return false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
116 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
117 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
118 |
Rectangle bounds = getGraphicsConfiguration().getBounds(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
119 |
int pixels[] = new int[imgSize * 4]; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
120 |
BufferedImage clientPixels = |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
121 |
robot.createScreenCapture(new Rectangle(bounds.x, bounds.y, |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
122 |
imgSize*4, 1)); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
123 |
clientPixels.getRGB(0, 0, imgSize * 4, 1, pixels, 0, getWidth()); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
124 |
// Now check the results. We expect: imgSize blocks of r/w/b/g |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
125 |
int colors[] = {0xffff0000, 0xffffffff, 0xff0000ff, 0xff00ff00}; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
126 |
for (int color = 0; color < 4; ++color) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
127 |
for (int i = 0; i < imgSize; ++i) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
128 |
int pixelIndex = imgSize * color + i; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
129 |
if (pixels[pixelIndex] != colors[color]) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
130 |
errorMessage = "\n DisplayMode(" + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
131 |
dm.getWidth() + " x " + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
132 |
dm.getHeight() + " x " + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
133 |
dm.getBitDepth() + "bpp x " + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
134 |
dm.getRefreshRate() + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
135 |
")\n Pixel " + i + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
136 |
": Expected " + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
137 |
Integer.toHexString(colors[color]) + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
138 |
", got " + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
139 |
Integer.toHexString(pixels[pixelIndex]) + |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
140 |
" at " + i; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
141 |
return false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
142 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
143 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
144 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
145 |
return true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
146 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
147 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
148 |
boolean displayModesEqual(DisplayMode dm1, DisplayMode dm2) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
149 |
if (dm1.equals(dm2)) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
150 |
return true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
151 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
152 |
// not enough - check whether the modes are equal except for |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
153 |
// refreshRate, if either mode has REFRESH_RATE_UNKNOWN |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
154 |
// value for this parameter |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
155 |
if (dm1.getWidth() != dm2.getWidth() || |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
156 |
dm1.getHeight() != dm2.getHeight() || |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
157 |
dm1.getBitDepth() != dm2.getBitDepth()) |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
158 |
{ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
159 |
// core parameters must match |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
160 |
return false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
161 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
162 |
// Now we know that w1 == w2, h1 == h2, and d1 == d2; must be the |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
163 |
// case that the refresh rates do not match. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
164 |
// Is either one REFRESH_RATE_UNKNOWN? |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
165 |
if (dm1.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN || |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
166 |
dm2.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN) |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
167 |
{ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
168 |
return true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
169 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
170 |
return false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
171 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
172 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
173 |
public void run() { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
174 |
GraphicsDevice gd = getGraphicsConfiguration().getDevice(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
175 |
gd.setFullScreenWindow((Window) getParent()); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
176 |
// First, delay a bit just to let the fullscreen window |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
177 |
// settle down before switching display modes |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
178 |
delay(1000); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
179 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
180 |
if (!gd.isDisplayChangeSupported()) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
181 |
System.err.println("Display change is not supported,"+ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
182 |
" the test is considered passed."); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
183 |
finished(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
184 |
return; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
185 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
186 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
187 |
// We are really only interested in unique w/h/d resolutions |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
188 |
// and it would be nice to skip the myriad of refresh rate |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
189 |
// varations, so let us construct a subset that contains |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
190 |
// only those DisplayModes with unique w/h/d values |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
191 |
// Also, due to a current bug (4837228), we should skip the |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
192 |
// 24-bit depths since attempting to create bitmask-transparent |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
193 |
// ddraw images can cause the test to crash (we should change this |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
194 |
// test to include that depth when the bug is fixed). |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
195 |
ArrayList<DisplayMode> dmSubset = new ArrayList<>(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
196 |
for (final DisplayMode dm : gd.getDisplayModes()) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
197 |
boolean skip = false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
198 |
for (final DisplayMode dmUnique : dmSubset) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
199 |
int bitDepth = dm.getBitDepth(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
200 |
if (bitDepth == 24 || |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
201 |
(dmUnique.getWidth() == dm.getWidth() && |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
202 |
dmUnique.getHeight() == dm.getHeight() && |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
203 |
dmUnique.getBitDepth() == dm.getBitDepth())) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
204 |
skip = true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
205 |
break; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
206 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
207 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
208 |
if (!skip) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
209 |
dmSubset.add(dm); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
210 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
211 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
212 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
213 |
// Now, cycle through the display modes one-by-one. For |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
214 |
// each new display mode, delay until we detect that the |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
215 |
// new mode == the current mode. Then delay an additional |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
216 |
// second (to allow any repaints to occur) |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
217 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
218 |
for (DisplayMode newDM : dmSubset) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
219 |
gd.setDisplayMode(newDM); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
220 |
while (!displayModesEqual(newDM, gd.getDisplayMode())) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
221 |
delay(100); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
222 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
223 |
// Delay another few seconds after the new display mode is active |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
224 |
delay(4000); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
225 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
226 |
// Check the rendering results |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
227 |
if (!checkResult(newDM)) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
228 |
finished(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
229 |
return; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
230 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
231 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
232 |
// Escape out if requested by the user |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
233 |
if (earlyExit) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
234 |
System.out.println("Exiting test early, by request"); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
235 |
System.exit(0); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
236 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
237 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
238 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
239 |
// Done with test; if we got here, we passed |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
240 |
System.out.println("Passed"); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
241 |
finished(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
242 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
243 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
244 |
public static void finished() { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
245 |
synchronized (CycleDMImage.class) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
246 |
done = true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
247 |
CycleDMImage.class.notify(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
248 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
249 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
250 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
251 |
/** |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
252 |
* KeyListener methods; these provide a way for a user to escape out of |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
253 |
* a potentially lengthy test. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
254 |
*/ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
255 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
256 |
public void keyTyped(KeyEvent e) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
257 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
258 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
259 |
public void keyPressed(KeyEvent e) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
260 |
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
261 |
earlyExit = true; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
262 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
263 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
264 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
265 |
public void keyReleased(KeyEvent e) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
266 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
267 |
|
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
268 |
public static void main(String args[]) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
269 |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
270 |
for (final GraphicsDevice gd: ge.getScreenDevices()) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
271 |
if (!gd.isFullScreenSupported()) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
272 |
System.err.println("FullScreen mode is not supported,"+ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
273 |
" the test is considered passed."); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
274 |
continue; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
275 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
276 |
done = false; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
277 |
Frame frame = new Frame(gd.getDefaultConfiguration()); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
278 |
try { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
279 |
frame.setSize(400, 400); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
280 |
frame.setUndecorated(true); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
281 |
CycleDMImage comp = new CycleDMImage(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
282 |
frame.addKeyListener(comp); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
283 |
frame.add(comp); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
284 |
frame.setVisible(true); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
285 |
// Sleep awaiting frame disposal |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
286 |
synchronized (CycleDMImage.class) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
287 |
while (!done) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
288 |
try { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
289 |
CycleDMImage.class.wait(100); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
290 |
} catch (InterruptedException e) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
291 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
292 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
293 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
294 |
} finally { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
295 |
frame.dispose(); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
296 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
297 |
if (errorMessage != null) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
298 |
throw new RuntimeException(errorMessage); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
299 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
300 |
// delay a bit just to let the fullscreen window disposing complete |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
301 |
// before switching to next display |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
302 |
delay(4000); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
303 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
304 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
diff
changeset
|
305 |
} |