Skip to content

Commit 204f732

Browse files
author
Roland Mesde
committed
8221451: PIT: sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh fails
7184899: Test sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh fail Backport-of: f489598
1 parent 38d7614 commit 204f732

3 files changed

Lines changed: 47 additions & 63 deletions

File tree

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ sun/java2d/SunGraphics2D/PolyVertTest.java 6986565 generic-all
257257
sun/java2d/SunGraphics2D/SimplePrimQuality.java 6992007 generic-all
258258
sun/java2d/SunGraphics2D/SourceClippingBlitTest/SourceClippingBlitTest.java 8196185 generic-all
259259

260-
sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh 7184899,8221451 linux-all,macosx-aarch64
261260
java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java 8169469,8273617 windows-all,macosx-aarch64
262261
java/awt/FullScreen/UninitializedDisplayModeChangeTest/UninitializedDisplayModeChangeTest.java 8273617 macosx-all
263262
java/awt/print/PrinterJob/PSQuestionMark.java 7003378 generic-all
Lines changed: 46 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, 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
@@ -21,10 +21,10 @@
2121
* questions.
2222
*/
2323

24-
import java.awt.AWTException;
2524
import java.awt.Color;
2625
import java.awt.Component;
2726
import java.awt.Dimension;
27+
import java.awt.EventQueue;
2828
import java.awt.Frame;
2929
import java.awt.Graphics;
3030
import java.awt.Point;
@@ -42,18 +42,18 @@
4242
* make sure the pixels on the screen are red.
4343
*
4444
* Note that we force the use of shared memory pixmaps in the shell script.
45-
*
46-
* @author Dmitri.Trembovetski
4745
*/
4846

4947
public class SharedMemoryPixmapsTest {
50-
static final int IMAGE_SIZE = 100;
51-
static boolean show = false;
52-
final Frame testFrame;
53-
/** Creates a new instance of SharedMemoryPixmapsTest */
54-
public SharedMemoryPixmapsTest() {
48+
static final int IMAGE_SIZE = 200;
49+
static volatile boolean show = false;
50+
static volatile Frame testFrame;
51+
static volatile TestComponent testComponent;
52+
53+
static void createUI() {
5554
testFrame = new Frame("SharedMemoryPixmapsTest");
56-
testFrame.add(new TestComponent());
55+
testComponent = new TestComponent();
56+
testFrame.add(testComponent);
5757
testFrame.setUndecorated(true);
5858
testFrame.setResizable(false);
5959
testFrame.pack();
@@ -62,20 +62,51 @@ public SharedMemoryPixmapsTest() {
6262
testFrame.toFront();
6363
}
6464

65-
public static void main(String[] args) {
65+
public static void main(String[] args) throws Exception {
6666
for (String s : args) {
6767
if ("-show".equals(s)) {
6868
show = true;
6969
} else {
7070
System.err.println("Usage: SharedMemoryPixmapsTest [-show]");
7171
}
7272
}
73-
new SharedMemoryPixmapsTest();
73+
EventQueue.invokeAndWait(SharedMemoryPixmapsTest::createUI);
74+
if (testRendering()) {
75+
System.err.println("Test Passed");
76+
} else {
77+
System.err.println("Test Failed");
78+
}
79+
if (!show && testFrame != null) {
80+
EventQueue.invokeAndWait(testFrame::dispose);
81+
}
82+
}
83+
84+
static boolean testRendering() throws Exception {
85+
Robot r = new Robot();
86+
r.waitForIdle();
87+
r.delay(2000);
88+
Point p = testComponent.getLocationOnScreen();
89+
BufferedImage b =
90+
r.createScreenCapture(new Rectangle(p, testComponent.getPreferredSize()));
91+
for (int y = 20; y < b.getHeight() - 40; y++) {
92+
for (int x = 20; x < b.getWidth() - 40; x++) {
93+
if (b.getRGB(x, y) != Color.red.getRGB()) {
94+
System.err.println("Incorrect pixel at "
95+
+ x + "x" + y + " : " +
96+
Integer.toHexString(b.getRGB(x, y)));
97+
if (show) {
98+
return false;
99+
}
100+
System.err.println("Test Failed");
101+
System.exit(1);
102+
}
103+
}
104+
}
105+
return true;
74106
}
75107

76-
private class TestComponent extends Component {
108+
static class TestComponent extends Component {
77109
VolatileImage vi = null;
78-
boolean tested = false;
79110

80111
void initVI() {
81112
int res;
@@ -104,60 +135,15 @@ public synchronized void paint(Graphics g) {
104135
g.setColor(Color.green);
105136
g.fillRect(0, 0, getWidth(), getHeight());
106137

138+
vi = null;
107139
initVI();
108140
g.drawImage(vi, 0, 0, null);
109141
} while (vi.contentsLost());
110-
111-
Toolkit.getDefaultToolkit().sync();
112-
if (!tested) {
113-
if (testRendering()) {
114-
System.err.println("Test Passed");
115-
} else {
116-
System.err.println("Test Failed");
117-
}
118-
tested = true;
119-
}
120-
if (!show) {
121-
testFrame.setVisible(false);
122-
testFrame.dispose();
123-
}
124-
}
125-
126-
private boolean testRendering() throws RuntimeException {
127-
try {
128-
Thread.sleep(2000);
129-
} catch (InterruptedException ex) {}
130-
Robot r = null;
131-
try {
132-
r = new Robot();
133-
} catch (AWTException ex) {
134-
ex.printStackTrace();
135-
throw new RuntimeException("Can't create Robot");
136-
}
137-
Point p = getLocationOnScreen();
138-
BufferedImage b =
139-
r.createScreenCapture(new Rectangle(p, getPreferredSize()));
140-
for (int y = 0; y < b.getHeight(); y++) {
141-
for (int x = 0; x < b.getWidth(); x++) {
142-
if (b.getRGB(x, y) != Color.red.getRGB()) {
143-
System.err.println("Incorrect pixel" + " at "
144-
+ x + "x" + y + " : " +
145-
Integer.toHexString(b.getRGB(x, y)));
146-
if (show) {
147-
return false;
148-
}
149-
System.err.println("Test Failed");
150-
System.exit(1);
151-
}
152-
}
153-
}
154-
return true;
155142
}
156143

157144
@Override
158145
public Dimension getPreferredSize() {
159146
return new Dimension(IMAGE_SIZE, IMAGE_SIZE);
160147
}
161148
}
162-
163149
}

test/jdk/sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
#
3-
# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
3+
# Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
44
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55
#
66
# This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
2929
# by filling a VolatileImage with red color and copying it
3030
# to the screen.
3131
# Note that we force the use of shared memory pixmaps.
32-
# @author Dmitri.Trembovetski
3332

3433
echo "TESTJAVA=${TESTJAVA}"
3534
echo "TESTSRC=${TESTSRC}"

0 commit comments

Comments
 (0)