Skip to content

Commit

Permalink
8169468: NoResizeEventOnDMChangeTest.java fails because FS Window did…
Browse files Browse the repository at this point in the history
…n't receive all resizes!

Reviewed-by: serb
  • Loading branch information
Alexander Zuev committed Nov 16, 2021
1 parent e5ffdf9 commit b0a463f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ java/awt/xembed/server/RunTestXEmbed.java 7034201 linux-all
java/awt/Modal/ModalFocusTransferTests/FocusTransferDialogsDocModalTest.java 8164473 linux-all
java/awt/im/memoryleak/InputContextMemoryLeakTest.java 8023814 linux-all
java/awt/Frame/DisposeParentGC/DisposeParentGC.java 8079786 macosx-all
java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java 8169468 macosx-all

java/awt/GraphicsDevice/DisplayModes/CycleDMImage.java 7099223,8274106 macosx-aarch64,linux-all,windows-all
java/awt/keyboard/AllKeyCode/AllKeyCode.java 8242930 macosx-all
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,7 +26,6 @@
* @bug 6646411
* @summary Tests that full screen window and its children receive resize
event when display mode changes
* @author Dmitri.Trembovetski@sun.com: area=Graphics
* @run main/othervm NoResizeEventOnDMChangeTest
* @run main/othervm -Dsun.java2d.d3d=false NoResizeEventOnDMChangeTest
*/
Expand Down Expand Up @@ -151,9 +150,22 @@ public void run() {
System.err.printf("----------- Setting DM %dx%d:\n",
dm1.getWidth(), dm1.getHeight());
try {
Frame f = fsWin instanceof Frame ? (Frame) fsWin : (Frame) fsWin.getOwner();
DisplayMode oldMode = f.getGraphicsConfiguration().getDevice().getDisplayMode();
gd.setDisplayMode(dm1);
r1.incDmChanges();
r2.incDmChanges();
sleep(2000);
// Check if setting new display mode actually results in frame being
// placed onto display with different resolution.
DisplayMode newMode = f.getGraphicsConfiguration().getDevice().getDisplayMode();
if (oldMode.getWidth() != newMode.getWidth()
|| oldMode.getHeight() != newMode.getHeight()) {
r1.incDmChanges();
r2.incDmChanges();
} else {
System.out.println("Skipping this iteration. Details:");
System.out.println("Requested device = " + gd);
System.out.println("Actual device = " + f.getGraphicsConfiguration().getDevice());
}
} catch (IllegalArgumentException iae) {}
}
});
Expand All @@ -166,6 +178,7 @@ public void run() {
fsWin.removeComponentListener(r1);
c.removeComponentListener(r2);
}

try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
Expand All @@ -191,10 +204,14 @@ public void run() {
}

static void sleep(long ms) {
try {
Thread.sleep(ms);
} catch (InterruptedException ex) {}
long targetTime = System.currentTimeMillis() + ms;
do {
try {
Thread.sleep(targetTime - System.currentTimeMillis());
} catch (InterruptedException ex) {}
} while (System.currentTimeMillis() < targetTime);
}

static class ResizeEventChecker extends ComponentAdapter {
int dmChanges;
int resizes;
Expand Down

1 comment on commit b0a463f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.