Skip to content

Commit 49c4978

Browse files
committed
8060202: [macosx] Test closed/java/awt/Choice/GetSizeTest/GetSizeTest fails only in MacOSX(10.10)
Reviewed-by: prr
1 parent 2b47a58 commit 49c4978

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

test/jdk/java/awt/Choice/GetSizeTest/GetSizeTest.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2020, 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
@@ -29,8 +29,14 @@
2929
run main GetSizeTest.html
3030
*/
3131

32-
import java.awt.*;
33-
import java.awt.event.*;
32+
import java.awt.Choice;
33+
import java.awt.Frame;
34+
import java.awt.Panel;
35+
import java.awt.Point;
36+
import java.awt.Robot;
37+
import java.awt.event.InputEvent;
38+
import java.awt.event.MouseAdapter;
39+
import java.awt.event.MouseEvent;
3440

3541
public class GetSizeTest {
3642

@@ -40,16 +46,15 @@ public class GetSizeTest {
4046
"what choices do I have?",
4147
"Will I pick the same thing in the future?",
4248
};
43-
static boolean passed = false;
44-
static Robot robot = null;
49+
static volatile boolean passed = false;
4550

46-
public static void main(String args[])
47-
{
51+
public static void main(String args[]) throws Exception {
52+
Frame f = null;
4853
try {
49-
robot = new Robot();
50-
robot.setAutoDelay(50);
54+
Robot robot = new Robot();
55+
robot.setAutoDelay(150);
5156

52-
Frame f = new Frame("choice test");
57+
f = new Frame("choice test");
5358

5459
Panel p = new Panel();
5560
p.setLayout(null);
@@ -70,14 +75,7 @@ public void mouseReleased(MouseEvent e) {
7075
f.add(p);
7176

7277
f.setSize(300, 300);
73-
74-
f.addWindowListener(new WindowAdapter() {
75-
public void windowClosing(WindowEvent we) {
76-
System.err.println("Test passed");
77-
passed = true;
78-
}
79-
});
80-
78+
f.setLocationRelativeTo(null);
8179
f.setVisible(true);
8280

8381
c.setSize(200, 200);
@@ -88,14 +86,13 @@ public void windowClosing(WindowEvent we) {
8886
Point pt = c.getLocationOnScreen();
8987
robot.mouseMove(pt.x + c.getWidth() - 10, pt.y + c.getHeight() / 2);
9088
robot.waitForIdle();
91-
robot.mousePress(InputEvent.BUTTON2_MASK);
92-
robot.mouseRelease(InputEvent.BUTTON2_MASK);
89+
robot.mousePress(InputEvent.BUTTON2_DOWN_MASK);
90+
robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK);
9391
robot.waitForIdle();
94-
} catch (Throwable e) {
95-
if (robot == null){
96-
throw new RuntimeException( "Test failed.Unable to initialize Robot "+e);
92+
} finally {
93+
if (f != null) {
94+
f.dispose();
9795
}
98-
throw new RuntimeException( "Test failed due to thrown exception "+e);
9996
}
10097
if (!passed) {
10198
throw new RuntimeException( "Timeout. Choice component size is not actual size." );

0 commit comments

Comments
 (0)