Skip to content

Commit 0438cea

Browse files
author
Pankaj Bansal
committed
8136517: [macosx]Test java/awt/Focus/8073453/AWTFocusTransitionTest.java fails on MacOSX
Reviewed-by: serb
1 parent 6b5e5d7 commit 0438cea

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

test/jdk/ProblemList.txt

-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ java/awt/Focus/8013611/JDK8013611.java 8175366 windows-all,macosx-all
197197
java/awt/Focus/6378278/InputVerifierTest.java 8198616 macosx-all
198198
java/awt/Focus/6382144/EndlessLoopTest.java 8198617 macosx-all
199199
java/awt/Focus/6981400/Test1.java 8029675 windows-all,macosx-all
200-
java/awt/Focus/8073453/AWTFocusTransitionTest.java 8136517 macosx-all
201-
java/awt/Focus/8073453/SwingFocusTransitionTest.java 8136517 macosx-all
202200
java/awt/Focus/6981400/Test3.java 8173264 generic-all
203201
java/awt/event/KeyEvent/ExtendedKeyCode/ExtendedKeyCodeTest.java 8169476 windows-all,macosx-all
204202
java/awt/event/KeyEvent/KeyChar/KeyCharTest.java 8169474,8224055 macosx-all,windows-all

test/jdk/java/awt/Focus/8073453/AWTFocusTransitionTest.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,18 @@
2626
* @key headful
2727
* @bug 8073453
2828
* @summary Focus doesn't move when pressing Shift + Tab keys
29-
* @author Dmitry Markov
3029
* @compile AWTFocusTransitionTest.java
3130
* @run main/othervm AWTFocusTransitionTest
3231
*/
3332

34-
import java.awt.*;
33+
import java.awt.Button;
34+
import java.awt.Component;
35+
import java.awt.DefaultFocusTraversalPolicy;
36+
import java.awt.Frame;
37+
import java.awt.GridLayout;
38+
import java.awt.Panel;
39+
import java.awt.Robot;
40+
import java.awt.TextField;
3541
import java.awt.event.KeyEvent;
3642

3743
public class AWTFocusTransitionTest {
@@ -43,7 +49,7 @@ public class AWTFocusTransitionTest {
4349

4450
public static void main(String[] args) throws Exception {
4551
robot = new Robot();
46-
robot.setAutoDelay(50);
52+
robot.setAutoDelay(100);
4753

4854
try {
4955
createAndShowGUI();
@@ -101,14 +107,15 @@ private static void createAndShowGUI() {
101107
p.add(panel);
102108

103109
frame.add(p);
110+
frame.setLocationRelativeTo(null);
104111
frame.setVisible(true);
105112
}
106113

107114
private static void checkFocusOwner(Component component) {
108115
if (component != frame.getFocusOwner()) {
109-
throw new RuntimeException("Test Failed! Incorrect focus owner: " + frame.getFocusOwner() +
116+
throw new RuntimeException("Test Failed! Incorrect focus " +
117+
"owner: " + frame.getFocusOwner() +
110118
", but expected: " + component);
111119
}
112120
}
113121
}
114-

test/jdk/java/awt/Focus/8073453/SwingFocusTransitionTest.java

+16-7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,20 @@
2626
* @key headful
2727
* @bug 8073453
2828
* @summary Focus doesn't move when pressing Shift + Tab keys
29-
* @author Dmitry Markov
3029
* @compile SwingFocusTransitionTest.java
3130
* @run main/othervm SwingFocusTransitionTest
3231
*/
3332

34-
import javax.swing.*;
35-
import java.awt.*;
33+
import javax.swing.JButton;
34+
import javax.swing.JFrame;
35+
import javax.swing.JPanel;
36+
import javax.swing.JTextField;
37+
import javax.swing.LayoutFocusTraversalPolicy;
38+
import javax.swing.SwingUtilities;
39+
import java.awt.Component;
40+
import java.awt.DefaultFocusTraversalPolicy;
41+
import java.awt.GridLayout;
42+
import java.awt.Robot;
3643
import java.awt.event.KeyEvent;
3744

3845
public class SwingFocusTransitionTest {
@@ -44,7 +51,7 @@ public class SwingFocusTransitionTest {
4451

4552
public static void main(String[] args) throws Exception {
4653
robot = new Robot();
47-
robot.setAutoDelay(50);
54+
robot.setAutoDelay(100);
4855

4956
try {
5057
SwingUtilities.invokeAndWait(new Runnable() {
@@ -112,19 +119,21 @@ private static void createAndShowGUI() {
112119
p.add(panel);
113120

114121
frame.add(p);
122+
frame.setLocationRelativeTo(null);
115123
frame.setVisible(true);
116124
}
117125

118-
private static void checkFocusOwner(final Component component) throws Exception {
126+
private static void checkFocusOwner(final Component component)
127+
throws Exception {
119128
SwingUtilities.invokeAndWait(new Runnable() {
120129
@Override
121130
public void run() {
122131
if (component != frame.getFocusOwner()) {
123-
throw new RuntimeException("Test Failed! Incorrect focus owner: " + frame.getFocusOwner() +
132+
throw new RuntimeException("Test Failed! Incorrect focus" +
133+
" owner: " + frame.getFocusOwner() +
124134
", but expected: " + component);
125135
}
126136
}
127137
});
128138
}
129139
}
130-

0 commit comments

Comments
 (0)