Skip to content
Permalink
Browse files
8253274: The CycleDMImagetest brokes the system
Reviewed-by: prr
  • Loading branch information
mrserb committed Sep 18, 2020
1 parent 2c3a37c commit fd380d75b031d01e7cb06aabdf9ce8ca2a663c01
Showing 1 changed file with 15 additions and 17 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2020, 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
@@ -63,7 +63,7 @@ public class CycleDMImage extends Component implements Runnable, KeyListener {
boolean earlyExit = false;
Image rImage = null, wImage = null, bImage = null;
int imgSize = 10;
Robot robot = null;
static Robot robot = null;
volatile static boolean done = false;
static String errorMessage = null;

@@ -106,15 +106,6 @@ static void delay(long ms) {
}

public boolean checkResult(DisplayMode dm) {
if (robot == null) {
try {
robot = new Robot();
}
catch (Exception e) {
errorMessage = "Problems creating Robot";
return false;
}
}
Rectangle bounds = getGraphicsConfiguration().getBounds();
int pixels[] = new int[imgSize * 4];
BufferedImage clientPixels =
@@ -175,6 +166,7 @@ public void run() {
gd.setFullScreenWindow((Window) getParent());
// First, delay a bit just to let the fullscreen window
// settle down before switching display modes
robot.waitForIdle();
delay(1000);

if (!gd.isDisplayChangeSupported()) {
@@ -197,10 +189,12 @@ public void run() {
boolean skip = false;
for (final DisplayMode dmUnique : dmSubset) {
int bitDepth = dm.getBitDepth();
if (bitDepth == 24 ||
(dmUnique.getWidth() == dm.getWidth() &&
dmUnique.getHeight() == dm.getHeight() &&
dmUnique.getBitDepth() == dm.getBitDepth())) {
int width = dm.getWidth();
int height = dm.getHeight();
if (bitDepth == 24 || width <= 800 || height <= 600 ||
(dmUnique.getWidth() == width &&
dmUnique.getHeight() == height &&
dmUnique.getBitDepth() == bitDepth)) {
skip = true;
break;
}
@@ -265,7 +259,8 @@ public void keyPressed(KeyEvent e) {
public void keyReleased(KeyEvent e) {
}

public static void main(String args[]) {
public static void main(String args[]) throws Exception {
robot = new Robot();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
for (final GraphicsDevice gd: ge.getScreenDevices()) {
if (!gd.isFullScreenSupported()) {
@@ -274,6 +269,7 @@ public static void main(String args[]) {
continue;
}
done = false;
DisplayMode currentDM = gd.getDisplayMode();
Frame frame = new Frame(gd.getDefaultConfiguration());
try {
frame.setSize(400, 400);
@@ -292,14 +288,16 @@ public static void main(String args[]) {
}
}
} finally {
gd.setDisplayMode(currentDM);
gd.setFullScreenWindow(null);
frame.dispose();
}
if (errorMessage != null) {
throw new RuntimeException(errorMessage);
}
// delay a bit just to let the fullscreen window disposing complete
// before switching to next display
delay(4000);
delay(10000);
}
}
}

1 comment on commit fd380d7

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on fd380d7 Sep 18, 2020

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.