Skip to content

Commit b0a463f

Browse files
author
Alexander Zuev
committedNov 16, 2021
8169468: NoResizeEventOnDMChangeTest.java fails because FS Window didn't receive all resizes!
Reviewed-by: serb
1 parent e5ffdf9 commit b0a463f

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed
 

‎test/jdk/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all
489489
java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all
490490
java/awt/im/memoryleak/InputContextMemoryLeakTest.java 8023814 linux-all
491491
java/awt/Frame/DisposeParentGC/DisposeParentGC.java 8079786 macosx-all
492-
java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java 8169468 macosx-all
493492

494493
java/awt/GraphicsDevice/DisplayModes/CycleDMImage.java 7099223,8274106 macosx-aarch64,linux-all,windows-all
495494
java/awt/keyboard/AllKeyCode/AllKeyCode.java 8242930 macosx-all

‎test/jdk/java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
2626
* @bug 6646411
2727
* @summary Tests that full screen window and its children receive resize
2828
event when display mode changes
29-
* @author Dmitri.Trembovetski@sun.com: area=Graphics
3029
* @run main/othervm NoResizeEventOnDMChangeTest
3130
* @run main/othervm -Dsun.java2d.d3d=false NoResizeEventOnDMChangeTest
3231
*/
@@ -151,9 +150,22 @@ public void run() {
151150
System.err.printf("----------- Setting DM %dx%d:\n",
152151
dm1.getWidth(), dm1.getHeight());
153152
try {
153+
Frame f = fsWin instanceof Frame ? (Frame) fsWin : (Frame) fsWin.getOwner();
154+
DisplayMode oldMode = f.getGraphicsConfiguration().getDevice().getDisplayMode();
154155
gd.setDisplayMode(dm1);
155-
r1.incDmChanges();
156-
r2.incDmChanges();
156+
sleep(2000);
157+
// Check if setting new display mode actually results in frame being
158+
// placed onto display with different resolution.
159+
DisplayMode newMode = f.getGraphicsConfiguration().getDevice().getDisplayMode();
160+
if (oldMode.getWidth() != newMode.getWidth()
161+
|| oldMode.getHeight() != newMode.getHeight()) {
162+
r1.incDmChanges();
163+
r2.incDmChanges();
164+
} else {
165+
System.out.println("Skipping this iteration. Details:");
166+
System.out.println("Requested device = " + gd);
167+
System.out.println("Actual device = " + f.getGraphicsConfiguration().getDevice());
168+
}
157169
} catch (IllegalArgumentException iae) {}
158170
}
159171
});
@@ -166,6 +178,7 @@ public void run() {
166178
fsWin.removeComponentListener(r1);
167179
c.removeComponentListener(r2);
168180
}
181+
169182
try {
170183
EventQueue.invokeAndWait(new Runnable() {
171184
public void run() {
@@ -191,10 +204,14 @@ public void run() {
191204
}
192205

193206
static void sleep(long ms) {
194-
try {
195-
Thread.sleep(ms);
196-
} catch (InterruptedException ex) {}
207+
long targetTime = System.currentTimeMillis() + ms;
208+
do {
209+
try {
210+
Thread.sleep(targetTime - System.currentTimeMillis());
211+
} catch (InterruptedException ex) {}
212+
} while (System.currentTimeMillis() < targetTime);
197213
}
214+
198215
static class ResizeEventChecker extends ComponentAdapter {
199216
int dmChanges;
200217
int resizes;

0 commit comments

Comments
 (0)
Please sign in to comment.