Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8198619: java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayoutTraversalTest.java fails on mac #3618

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Expand Up @@ -132,7 +132,6 @@ javax/swing/dnd/7171812/bug7171812.java 8041447 macosx-all
java/awt/Focus/ChoiceFocus/ChoiceFocus.java 8169103 windows-all,macosx-all
java/awt/Focus/ClearLwQueueBreakTest/ClearLwQueueBreakTest.java 8198618 macosx-all
java/awt/Focus/ConsumeNextKeyTypedOnModalShowTest/ConsumeNextKeyTypedOnModalShowTest.java 6986252 macosx-all
java/awt/Focus/FocusTraversalPolicy/ButtonGroupLayoutTraversal/ButtonGroupLayoutTraversalTest.java 8198619 macosx-all
java/awt/Focus/KeyEventForBadFocusOwnerTest/KeyEventForBadFocusOwnerTest.java 8198621 macosx-all
java/awt/Focus/MouseClickRequestFocusRaceTest/MouseClickRequestFocusRaceTest.java 8194753 linux-all,macosx-all
java/awt/Focus/NoAutotransferToDisabledCompTest/NoAutotransferToDisabledCompTest.java 7152980 macosx-all
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -58,71 +58,76 @@ public class ButtonGroupLayoutTraversalTest {

public static void main(String[] args) throws Exception {

SwingUtilities.invokeAndWait(() -> changeLAF());
SwingUtilities.invokeAndWait(() -> initLayout(nx, ny));
Robot robot = new Robot();
robot.setAutoDelay(100);
robot.waitForIdle();
robot.delay(200);

for (int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
robot.keyPress(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_RIGHT);
}
try {
SwingUtilities.invokeAndWait(() -> changeLAF());
SwingUtilities.invokeAndWait(() -> initLayout(nx, ny));
Robot robot = new Robot();
robot.setAutoDelay(100);
robot.waitForIdle();
robot.delay(1000);

for (int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
robot.keyPress(KeyEvent.VK_RIGHT);
robot.keyRelease(KeyEvent.VK_RIGHT);
robot.waitForIdle();
}

for (int i = 0; i < nx * ny / 2; i++) {
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
}
for (int i = 0; i < nx * ny / 2; i++) {
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.waitForIdle();
}

robot.waitForIdle();
robot.delay(200);
robot.delay(200);

for (int i = 0; i < nx * ny; i++) {
if (focusCnt[i] < 1) {
SwingUtilities.invokeLater(window::dispose);
throw new RuntimeException("Component " + i
for (int i = 0; i < nx * ny; i++) {
if (focusCnt[i] < 1) {
throw new RuntimeException("Component " + i
+ " is not reachable in the forward focus cycle");
} else if (focusCnt[i] > 1) {
SwingUtilities.invokeLater(window::dispose);
throw new RuntimeException("Component " + i
} else if (focusCnt[i] > 1) {
throw new RuntimeException("Component " + i
+ " got focus more than once in the forward focus cycle");
}
}

for (int i = 0; i < nx * ny / 2; i++) {
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();
}

for (int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
robot.keyPress(KeyEvent.VK_LEFT);
robot.keyRelease(KeyEvent.VK_LEFT);
robot.waitForIdle();
}
}

for (int i = 0; i < nx * ny / 2; i++) {
robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SHIFT);
}

for (int i = 0; i < nx * ny - nx * ny / 2 - 1; i++) {
robot.keyPress(KeyEvent.VK_LEFT);
robot.keyRelease(KeyEvent.VK_LEFT);
}

robot.keyPress(KeyEvent.VK_SHIFT);
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_SHIFT);
robot.waitForIdle();

robot.waitForIdle();
robot.delay(200);
robot.delay(200);

for (int i = 0; i < nx * ny; i++) {
if (focusCnt[i] < 2) {
SwingUtilities.invokeLater(window::dispose);
throw new RuntimeException("Component " + i
for (int i = 0; i < nx * ny; i++) {
if (focusCnt[i] < 2) {
throw new RuntimeException("Component " + i
+ " is not reachable in the backward focus cycle");
} else if (focusCnt[i] > 2) {
SwingUtilities.invokeLater(window::dispose);
throw new RuntimeException("Component " + i
} else if (focusCnt[i] > 2) {
throw new RuntimeException("Component " + i
+ " got focus more than once in the backward focus cycle");
}
}
} finally {
SwingUtilities.invokeAndWait(() -> {
if (window != null) {
window.dispose();
}
});
}

SwingUtilities.invokeLater(window::dispose);
}

private static void changeLAF() {
Expand Down Expand Up @@ -179,6 +184,7 @@ public void focusGained(FocusEvent e) {
}
rootPanel.add(formPanel, BorderLayout.CENTER);
window.add(rootPanel);
window.setLocationRelativeTo(null);
window.pack();
window.setVisible(true);
}
Expand Down