8352149: Test java/awt/Frame/MultiScreenTest.java fails: Window list is empty
Reviewed-by: aivanov, abhiscxk
This commit is contained in:
parent
56ce70c5df
commit
5ae32c4c86
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,6 +43,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.TextField;
|
import java.awt.TextField;
|
||||||
|
|
||||||
|
import java.awt.Window;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ public class MultiScreenTest {
|
|||||||
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
gs = ge.getScreenDevices();
|
gs = ge.getScreenDevices();
|
||||||
if (gs.length < 2) {
|
if (gs.length < 2) {
|
||||||
throw new SkippedException("You have only one monitor in your system - test passed");
|
throw new SkippedException("You have only one monitor in your system");
|
||||||
}
|
}
|
||||||
MultiScreenTest obj = new MultiScreenTest();
|
MultiScreenTest obj = new MultiScreenTest();
|
||||||
String INSTRUCTIONS =
|
String INSTRUCTIONS =
|
||||||
@ -82,38 +83,42 @@ public class MultiScreenTest {
|
|||||||
"You have " + gs.length + " monitors in your system.\n" +
|
"You have " + gs.length + " monitors in your system.\n" +
|
||||||
"Actively drag the DitherTest frames on the secondary screen and " +
|
"Actively drag the DitherTest frames on the secondary screen and " +
|
||||||
"if you see garbage appearing on your primary screen " +
|
"if you see garbage appearing on your primary screen " +
|
||||||
"test failed otherwise it passed.";;
|
"test failed otherwise it passed.";
|
||||||
|
|
||||||
PassFailJFrame.builder()
|
PassFailJFrame.builder()
|
||||||
.title("MultiScreenTest Instruction")
|
|
||||||
.instructions(INSTRUCTIONS)
|
.instructions(INSTRUCTIONS)
|
||||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
|
||||||
.columns(40)
|
.columns(40)
|
||||||
.testUI(obj::init)
|
.testUI(obj::init)
|
||||||
|
.positionTestUI(MultiScreenTest::positionTestWindows)
|
||||||
.build()
|
.build()
|
||||||
.awaitAndCheck();
|
.awaitAndCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void positionTestWindows(List<Window> windows, PassFailJFrame.InstructionUI instructionUI) {
|
||||||
|
// Do nothing - the location of each window is set when they're created
|
||||||
|
}
|
||||||
|
|
||||||
public List<JFrame> init() {
|
public List<JFrame> init() {
|
||||||
List<JFrame> list = new ArrayList<>();
|
List<JFrame> list = new ArrayList<>();
|
||||||
for (int j = 0; j < gs.length; j++) {
|
for (int j = 0; j < gs.length; j++) {
|
||||||
GraphicsConfiguration[] gc = gs[j].getConfigurations();
|
GraphicsConfiguration[] gc = gs[j].getConfigurations();
|
||||||
if (gc.length > 0) {
|
if (gc.length > 0) {
|
||||||
for (int i = 0; i < gc.length / 2; i++) {
|
for (int i = 0; i < gc.length && i < 10; i++) {
|
||||||
JFrame f = new JFrame(gc[i]); //test JFrame( gc )
|
JFrame f = new JFrame(gc[i]);
|
||||||
GCCanvas c = new GCCanvas(gc[i]);//test canvas( gc )
|
GCCanvas c = new GCCanvas(gc[i]);
|
||||||
Rectangle gcBounds = gc[i].getBounds(); //test getBounds()
|
Rectangle gcBounds = gc[i].getBounds();
|
||||||
int xoffs = gcBounds.x;
|
int xoffs = gcBounds.x;
|
||||||
int yoffs = gcBounds.y;
|
int yoffs = gcBounds.y;
|
||||||
|
|
||||||
f.getContentPane().add(c);
|
f.getContentPane().add(c);
|
||||||
f.setTitle("Screen# " + Integer.toString(j) + ", GC#" + Integer.toString(i));
|
f.setTitle("Screen# " + j + ", GC#" + i);
|
||||||
f.setSize(300, 200);
|
f.setSize(300, 200);
|
||||||
f.setLocation(400 + xoffs, (i * 150) + yoffs);//test displaying in right location
|
// test displaying in right location
|
||||||
|
f.setLocation(400 + xoffs, (i * 150) + yoffs);
|
||||||
list.add(f);
|
list.add(f);
|
||||||
|
|
||||||
Frame ditherfs = new Frame("DitherTest GC#" + Integer.toString(i), gc[i]);
|
Frame ditherfs = new Frame("DitherTest GC#" + i, gc[i]);
|
||||||
ditherfs.setLayout(new BorderLayout()); //showDitherTest
|
ditherfs.setLayout(new BorderLayout());
|
||||||
DitherTest ditherTest = new DitherTest(gc[i]);
|
DitherTest ditherTest = new DitherTest(gc[i]);
|
||||||
ditherfs.add("Center", ditherTest);
|
ditherfs.add("Center", ditherTest);
|
||||||
ditherfs.setBounds(300, 200, 300, 200);
|
ditherfs.setBounds(300, 200, 300, 200);
|
||||||
@ -126,13 +131,12 @@ public class MultiScreenTest {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class GCCanvas extends Canvas {
|
|
||||||
|
static class GCCanvas extends Canvas {
|
||||||
|
|
||||||
GraphicsConfiguration gc;
|
GraphicsConfiguration gc;
|
||||||
Rectangle bounds;
|
Rectangle bounds;
|
||||||
Graphics g = this.getGraphics();
|
|
||||||
Dimension size = getSize();
|
Dimension size = getSize();
|
||||||
|
|
||||||
public GCCanvas(GraphicsConfiguration gc) {
|
public GCCanvas(GraphicsConfiguration gc) {
|
||||||
@ -141,6 +145,7 @@ class GCCanvas extends Canvas {
|
|||||||
bounds = gc.getBounds();
|
bounds = gc.getBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void paint( Graphics _g ) {
|
public void paint( Graphics _g ) {
|
||||||
|
|
||||||
Graphics2D g = (Graphics2D) _g;
|
Graphics2D g = (Graphics2D) _g;
|
||||||
@ -174,12 +179,13 @@ class GCCanvas extends Canvas {
|
|||||||
g.fillArc(150, 30, 30, 30, 0, 200);
|
g.fillArc(150, 30, 30, 30, 0, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize(){
|
public Dimension getPreferredSize(){
|
||||||
return new Dimension(300, 200);
|
return new Dimension(300, 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DitherCanvas extends Canvas {
|
static class DitherCanvas extends Canvas {
|
||||||
Image img;
|
Image img;
|
||||||
static String calcString = "Calculating...";
|
static String calcString = "Calculating...";
|
||||||
|
|
||||||
@ -194,6 +200,7 @@ class DitherCanvas extends Canvas {
|
|||||||
return mGC;
|
return mGC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
int w = getSize().width;
|
int w = getSize().width;
|
||||||
int h = getSize().height;
|
int h = getSize().height;
|
||||||
@ -209,14 +216,17 @@ class DitherCanvas extends Canvas {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void update(Graphics g) {
|
public void update(Graphics g) {
|
||||||
paint(g);
|
paint(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getMinimumSize() {
|
public Dimension getMinimumSize() {
|
||||||
return new Dimension(20, 20);
|
return new Dimension(20, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Dimension getPreferredSize() {
|
public Dimension getPreferredSize() {
|
||||||
return new Dimension(200, 200);
|
return new Dimension(200, 200);
|
||||||
}
|
}
|
||||||
@ -231,7 +241,7 @@ class DitherCanvas extends Canvas {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DitherTest extends Panel implements Runnable {
|
static class DitherTest extends Panel implements Runnable {
|
||||||
final static int NOOP = 0;
|
final static int NOOP = 0;
|
||||||
final static int RED = 1;
|
final static int RED = 1;
|
||||||
final static int GREEN = 2;
|
final static int GREEN = 2;
|
||||||
@ -371,6 +381,7 @@ class DitherTest extends Panel implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
canvas.setImage(null); // Wipe previous image
|
canvas.setImage(null); // Wipe previous image
|
||||||
Image img = calculateImage();
|
Image img = calculateImage();
|
||||||
@ -440,7 +451,7 @@ class DitherTest extends Panel implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DitherControls extends Panel implements ActionListener {
|
static class DitherControls extends Panel implements ActionListener {
|
||||||
TextField start;
|
TextField start;
|
||||||
TextField end;
|
TextField end;
|
||||||
Button button;
|
Button button;
|
||||||
@ -477,9 +488,11 @@ class DitherControls extends Panel implements ActionListener {
|
|||||||
return choice.getSelectedIndex();
|
return choice.getSelectedIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (e.getSource() == button) {
|
if (e.getSource() == button) {
|
||||||
dt.start();
|
dt.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user