Skip to content

Commit 3a1a2e0

Browse files
Victor RudometovPaul Hohensee
authored andcommitted
8233551: [TESTBUG] SelectEditTableCell.java fails on MacOS
Reviewed-by: phh Backport-of: 9b3fb5d1d5a6a3f0fc699b10bdff6d43ae8d1898
1 parent 736c1fb commit 3a1a2e0

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

jdk/test/javax/swing/JTable/7124218/SelectEditTableCell.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,28 @@ public class SelectEditTableCell {
4848

4949
public static void main(String[] args) throws Exception {
5050
robot = new Robot();
51-
robot.delay(2000);
51+
robot.setAutoDelay(100);
5252
UIManager.LookAndFeelInfo[] lookAndFeelArray
5353
= UIManager.getInstalledLookAndFeels();
5454
for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
5555
executeCase(lookAndFeelItem.getClassName());
5656
}
57-
5857
}
5958

6059
private static void executeCase(String lookAndFeelString) throws Exception {
61-
if (tryLookAndFeel(lookAndFeelString)) {
62-
createUI(lookAndFeelString);
63-
robot.delay(2000);
64-
runTestCase();
65-
robot.delay(2000);
66-
cleanUp();
67-
robot.delay(2000);
60+
try {
61+
if (tryLookAndFeel(lookAndFeelString)) {
62+
createUI(lookAndFeelString);
63+
robot.delay(2000);
64+
runTestCase();
65+
robot.delay(2000);
66+
cleanUp();
67+
robot.delay(2000);
68+
}
69+
} finally {
70+
if (frame != null) {
71+
SwingUtilities.invokeAndWait(frame::dispose);
72+
}
6873
}
6974

7075
}
@@ -98,6 +103,7 @@ private static void runTestCase() throws Exception {
98103
robot.mouseMove(centerPoint.x, centerPoint.y);
99104
robot.mousePress(InputEvent.BUTTON1_MASK);
100105
robot.mouseRelease(InputEvent.BUTTON1_MASK);
106+
robot.waitForIdle();
101107
SwingUtilities.invokeAndWait(new Runnable() {
102108
@Override
103109
public void run() {
@@ -110,7 +116,7 @@ public void run() {
110116
}
111117
}
112118
});
113-
robot.waitForIdle();
119+
114120
int fetchKeyCode;
115121
keyTap(fetchKeyCode = isMac(lookAndFeel)
116122
? KeyEvent.VK_ENTER : KeyEvent.VK_SPACE);
@@ -127,7 +133,7 @@ public void run() {
127133
}
128134
}
129135
});
130-
robot.waitForIdle();
136+
131137
keyTap(KeyEvent.VK_SPACE);
132138
robot.waitForIdle();
133139
SwingUtilities.invokeAndWait(new Runnable() {
@@ -147,10 +153,12 @@ public void run() {
147153
}
148154
}
149155
});
150-
robot.waitForIdle();
156+
151157
// hitting a letter key will start editing
152158
keyTap(KeyEvent.VK_A);
159+
robot.waitForIdle();
153160
keyTap(KeyEvent.VK_SPACE);
161+
robot.waitForIdle();
154162
keyTap(KeyEvent.VK_A);
155163
robot.waitForIdle();
156164
SwingUtilities.invokeAndWait(new Runnable() {

0 commit comments

Comments
 (0)