Skip to content

Commit 57c1b21

Browse files
committedOct 10, 2022
8079267: [TEST_BUG] Test java/awt/Frame/MiscUndecorated/RepaintTest.java fails
Backport-of: 6f35eede4576b6252544f553c3651312b024e7ea
1 parent df5f253 commit 57c1b21

File tree

2 files changed

+22
-33
lines changed

2 files changed

+22
-33
lines changed
 

‎test/jdk/ProblemList.txt

-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ java/awt/Component/GetScreenLocTest/GetScreenLocTest.java 4753654 generic-all
243243
java/awt/Component/SetEnabledPerformance/SetEnabledPerformance.java 8165863 macosx-all
244244
java/awt/Choice/SelectCurrentItemTest/SelectCurrentItemTest.html 8192929 windows-all,linux-all
245245
java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java 8017454 macosx-all
246-
java/awt/Frame/MiscUndecorated/RepaintTest.java 8079267 windows-all,linux-all
247246
java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java 8157173 generic-all
248247
java/awt/Modal/FileDialog/FileDialogAppModal1Test.java 8198664 macosx-all
249248
java/awt/Modal/FileDialog/FileDialogAppModal2Test.java 8198664 macosx-all

‎test/jdk/java/awt/Frame/MiscUndecorated/RepaintTest.java

+22-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2021, 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
@@ -33,27 +33,38 @@
3333
* @run main RepaintTest
3434
*/
3535

36-
import java.awt.*;
36+
import java.awt.BorderLayout;
37+
import java.awt.Button;
38+
import java.awt.Color;
39+
import java.awt.Component;
40+
import java.awt.Container;
41+
import java.awt.Frame;
42+
import java.awt.Panel;
43+
import java.awt.Point;
44+
import java.awt.Rectangle;
45+
import java.awt.TextField;
46+
import java.awt.Toolkit;
3747
import java.awt.event.*;
3848
import javax.swing.JFrame;
3949
import javax.swing.JButton;
4050
import javax.swing.JTextField;
4151
import javax.swing.JPanel;
42-
import java.io.*;
43-
import java.awt.image.*;
52+
import java.awt.image.BufferedImage;
53+
import java.awt.image.PixelGrabber;
54+
import java.io.File;
4455

4556
public class RepaintTest {
46-
private static int delay = 150;
57+
private static final int delay = 150;
4758

4859
private Frame frame;
4960
private Container panel1, panel2;
5061
private Component button;
5162
private Component textField;
5263
private ExtendedRobot robot;
53-
private Object buttonLock = new Object();
64+
private final Object buttonLock = new Object();
5465
private boolean passed = true;
5566
private boolean buttonClicked = false;
56-
private int MAX_TOLERANCE_LEVEL = 10;
67+
private final int MAX_TOLERANCE_LEVEL = 10;
5768

5869
public static void main(String[] args) {
5970
RepaintTest test = new RepaintTest();
@@ -81,25 +92,6 @@ public void run() {
8192
}
8293
}
8394

84-
/**
85-
* Do screen capture and save it as image
86-
*/
87-
private static void captureScreenAndSave() {
88-
89-
try {
90-
Robot robot = new Robot();
91-
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
92-
Rectangle rectangle = new Rectangle(0, 0, screenSize.width, screenSize.height);
93-
System.out.println("About to screen capture - " + rectangle);
94-
BufferedImage image = robot.createScreenCapture(rectangle);
95-
javax.imageio.ImageIO.write(image, "jpg", new File("ScreenImage.jpg"));
96-
robot.delay(3000);
97-
} catch (Throwable t) {
98-
System.out.println("WARNING: Exception thrown while screen capture!");
99-
t.printStackTrace();
100-
}
101-
}
102-
10395
private void initializeGUI(boolean swingControl) {
10496
frame = swingControl ? new JFrame() : new Frame();
10597
frame.setLayout(new BorderLayout());
@@ -115,10 +107,10 @@ private void initializeGUI(boolean swingControl) {
115107
panel2.add(textField);
116108
frame.add(panel2, BorderLayout.SOUTH);
117109
frame.add(panel1, BorderLayout.NORTH);
110+
frame.setLocationRelativeTo(null);
118111

119112
frame.setBackground(Color.green);
120113
frame.setVisible(true);
121-
frame.toFront();
122114
}
123115
private Component createButton(boolean swingControl, String txt) {
124116
if(swingControl) {
@@ -136,7 +128,7 @@ public void actionPerformed(ActionEvent e) {
136128
}
137129
});
138130
return jbtn;
139-
}else {
131+
} else {
140132
Button btn = new Button(txt);
141133
btn.addActionListener(new ActionListener() {
142134
public void actionPerformed(ActionEvent e) {
@@ -175,10 +167,9 @@ public void run() {
175167

176168
robot.mouseMove(button.getLocationOnScreen().x + button.getSize().width / 2,
177169
button.getLocationOnScreen().y + button.getSize().height / 2);
170+
171+
robot.click();
178172
robot.waitForIdle(delay);
179-
robot.mousePress(InputEvent.BUTTON1_MASK);
180-
robot.waitForIdle(delay);
181-
robot.mouseRelease(InputEvent.BUTTON1_MASK);
182173

183174
if (! buttonClicked) {
184175
synchronized (buttonLock) {
@@ -230,7 +221,6 @@ public void run() {
230221
Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(new Runnable() {
231222
public void run() {
232223
frame.setExtendedState(Frame.NORMAL);
233-
frame.toFront();
234224
}
235225
});
236226
} catch (Exception e) {

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Oct 10, 2022

@openjdk-notifier[bot]
Please sign in to comment.