Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8169468: NoResizeEventOnDMChangeTest.java fails because FS Window didn't receive all resizes! #6186

Closed
wants to merge 6 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -497,7 +497,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/TextArea/AutoScrollOnSelectAndAppend/AutoScrollOnSelectAndAppend.java 8213120 macosx-all

java/awt/GraphicsDevice/DisplayModes/CycleDMImage.java 7099223,8274106 macosx-aarch64,linux-all,windows-all
@@ -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
@@ -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
*/
@@ -40,11 +39,14 @@
import java.awt.Graphics;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.concurrent.atomic.AtomicBoolean;

public class NoResizeEventOnDMChangeTest {
public static void main(String[] args) {
@@ -151,9 +153,21 @@ 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);
Copy link
Member

@mrserb mrserb Nov 9, 2021

Choose a reason for hiding this comment

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

probably it will be good to add a delay here? What is the longest display switch on the system where the bug is reproduced? a few seconds?

Copy link
Member Author

@azuev-java azuev-java Nov 10, 2021

Choose a reason for hiding this comment

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

Yeah, i think 2 seconds will be enough.

r1.incDmChanges();
r2.incDmChanges();
// 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) {}
}
});
@@ -166,6 +180,7 @@ public void run() {
fsWin.removeComponentListener(r1);
c.removeComponentListener(r2);
}

try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
@@ -191,10 +206,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;