Skip to content

Commit 35284e4

Browse files
committed
8255916: [macos] javax/swing/JInternalFrame/6647340/bug6647340.java timed out
Reviewed-by: serb
1 parent 8638cd9 commit 35284e4

File tree

1 file changed

+43
-54
lines changed

1 file changed

+43
-54
lines changed

test/jdk/javax/swing/JInternalFrame/6647340/bug6647340.java

Lines changed: 43 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
* @bug 6647340
2727
* @summary Checks that iconified internal frame follows
2828
* the main frame borders properly.
29-
* @author Mikhail Lapshin
30-
* @library /lib/client/
31-
* @build ExtendedRobot
3229
* @run main bug6647340
3330
*/
3431

@@ -38,22 +35,22 @@
3835

3936
public class bug6647340 {
4037
private JFrame frame;
41-
private Point location;
38+
private volatile Point location;
39+
private volatile Point iconloc;
4240
private JInternalFrame jif;
43-
private static ExtendedRobot robot = createRobot();
41+
private static Robot robot;
4442

4543
public static void main(String[] args) throws Exception {
44+
robot = new Robot();
4645
final bug6647340 test = new bug6647340();
4746
try {
48-
SwingUtilities.invokeAndWait(new Runnable() {
49-
public void run() {
50-
test.setupUI();
51-
}
52-
});
47+
SwingUtilities.invokeAndWait(() -> test.setupUI());
48+
robot.waitForIdle();
49+
robot.delay(1000);
5350
test.test();
5451
} finally {
5552
if (test.frame != null) {
56-
test.frame.dispose();
53+
SwingUtilities.invokeAndWait(() -> test.frame.dispose());
5754
}
5855
}
5956
}
@@ -77,77 +74,69 @@ private void setupUI() {
7774
}
7875

7976
private void test() throws Exception {
80-
sync();
8177
test1();
82-
sync();
78+
79+
robot.waitForIdle();
80+
robot.delay(500);
8381
check1();
84-
sync();
82+
robot.waitForIdle();
83+
8584
test2();
86-
sync();
85+
robot.waitForIdle();
86+
robot.delay(500);
8787
check2();
8888
}
8989

9090
private void test1() throws Exception {
91-
SwingUtilities.invokeAndWait(new Runnable() {
92-
public void run() {
93-
setIcon(true);
94-
location = jif.getDesktopIcon().getLocation();
95-
Dimension size = frame.getSize();
96-
frame.setSize(size.width + 100, size.height + 100);
97-
}
91+
SwingUtilities.invokeAndWait(() -> {
92+
setIcon(true);
93+
location = jif.getDesktopIcon().getLocation();
94+
Dimension size = frame.getSize();
95+
frame.setSize(size.width + 100, size.height + 100);
9896
});
9997
}
10098

10199
private void test2() throws Exception {
102-
SwingUtilities.invokeAndWait(new Runnable() {
103-
public void run() {
104-
setIcon(false);
105-
}
100+
SwingUtilities.invokeAndWait(() -> {
101+
setIcon(false);
106102
});
107-
sync();
108-
SwingUtilities.invokeAndWait(new Runnable() {
109-
public void run() {
110-
Dimension size = frame.getSize();
111-
frame.setSize(size.width - 100, size.height - 100);
112-
}
103+
robot.waitForIdle();
104+
robot.delay(500);
105+
106+
SwingUtilities.invokeAndWait(() -> {
107+
Dimension size = frame.getSize();
108+
frame.setSize(size.width - 100, size.height - 100);
113109
});
114-
sync();
115-
SwingUtilities.invokeAndWait(new Runnable() {
116-
public void run() {
117-
setIcon(true);
118-
}
110+
robot.waitForIdle();
111+
robot.delay(500);
112+
113+
SwingUtilities.invokeAndWait(() -> {
114+
setIcon(true);
119115
});
120116
}
121117

122-
private void check1() {
123-
if (!jif.getDesktopIcon().getLocation().equals(location)) {
118+
private void check1() throws Exception {
119+
SwingUtilities.invokeAndWait(() -> {
120+
iconloc = jif.getDesktopIcon().getLocation();
121+
});
122+
if (!iconloc.equals(location)) {
124123
System.out.println("First test passed");
125124
} else {
126125
throw new RuntimeException("Icon isn't shifted with the frame bounds");
127126
}
128127
}
129128

130-
private void check2() {
131-
if (jif.getDesktopIcon().getLocation().equals(location)) {
129+
private void check2() throws Exception {
130+
SwingUtilities.invokeAndWait(() -> {
131+
iconloc = jif.getDesktopIcon().getLocation();
132+
});
133+
if (iconloc.equals(location)) {
132134
System.out.println("Second test passed");
133135
} else {
134136
throw new RuntimeException("Icon isn't located near the frame bottom");
135137
}
136138
}
137139

138-
private static void sync() {
139-
robot.waitForIdle();
140-
}
141-
private static ExtendedRobot createRobot() {
142-
try {
143-
ExtendedRobot robot = new ExtendedRobot();
144-
return robot;
145-
}catch(Exception ex) {
146-
ex.printStackTrace();
147-
throw new Error("Unexpected Failure");
148-
}
149-
}
150-
151140
private void setIcon(boolean b) {
152141
try {
153142
jif.setIcon(b);

0 commit comments

Comments
 (0)