Skip to content

8345767: javax/swing/JSplitPane/4164779/JSplitPaneKeyboardNavigationTest.java fails in ubuntu22.04 #3650

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2024, 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 @@ -64,7 +64,7 @@ public class JSplitPaneKeyboardNavigationTest {
public static void main(String[] s) throws Exception {
robot = new Robot();
robot.setAutoWaitForIdle(true);
robot.setAutoDelay(200);
robot.setAutoDelay(100);
List<String> lafs = Arrays.stream(getInstalledLookAndFeels())
.map(LookAndFeelInfo::getClassName)
.collect(Collectors.toList());
Expand All @@ -81,10 +81,13 @@ public static void main(String[] s) throws Exception {
continue;
}
robot.waitForIdle();
robot.delay(1000);

// Press Right button 1 and move focus to it.
pressButton(rightButton1);
hitKeys(KeyEvent.VK_F6);
robot.waitForIdle();
robot.delay(100);

// Verifier1 - Verifies that, F6 transfers focus to the right/bottom side of the splitpane
if (isFocusOwner(rightButton2)) {
Expand All @@ -98,9 +101,12 @@ public static void main(String[] s) throws Exception {
// Press Right button 2 and move focus to it.
pressButton(rightButton2);
hitKeys(KeyEvent.VK_F6);
robot.waitForIdle();
robot.delay(100);

// Verifier2 - Verifies that, F6 transfers focus to the left side of the parent splitpane,
// if the right/bottom side of splitpane already has focus, and it is contained within another splitpane
// if the right/bottom side of splitpane already has focus,
// and it is contained within another splitpane
if (isFocusOwner(leftButton)) {
System.out.println("Verifier 2 passed");
} else {
Expand All @@ -112,6 +118,9 @@ public static void main(String[] s) throws Exception {
// Press Left button and move focus to it.
pressButton(leftButton);
hitKeys(KeyEvent.VK_CONTROL, KeyEvent.VK_TAB);
robot.waitForIdle();
robot.delay(100);

// Verifier3 - Verifies that, CTRL-TAB navigates forward outside the JSplitPane
if (isFocusOwner(bottomButton)) {
System.out.println("Verifier 3 passed");
Expand All @@ -124,6 +133,8 @@ public static void main(String[] s) throws Exception {
// Press Left button and move focus to it.
pressButton(leftButton);
hitKeys(KeyEvent.VK_CONTROL, KeyEvent.VK_SHIFT, KeyEvent.VK_TAB);
robot.waitForIdle();
robot.delay(100);

// Verifier4 - Verifies that, CTRL-SHIFT-TAB navigates backward outside the JSplitPane
if (isFocusOwner(topButton)) {
Expand All @@ -137,7 +148,8 @@ public static void main(String[] s) throws Exception {
if (failedVerifiers.toString().isEmpty()) {
System.out.println("Test passed, All verifiers succeeded for " + laf);
} else {
throw new RuntimeException("Test failed, verifiers " + failedVerifiers.toString() + " failed for " + laf);
throw new RuntimeException("Test failed, verifiers "
+ failedVerifiers.toString() + " failed for " + laf);
}
} finally {
SwingUtilities.invokeAndWait(JSplitPaneKeyboardNavigationTest::disposeFrame);
Expand All @@ -159,13 +171,14 @@ private static void pressButton(JButton button) throws Exception {
loc.set(button.getLocationOnScreen());
});
final Point buttonLoc = loc.get();
robot.mouseMove(buttonLoc.x + 8, buttonLoc.y + 8);
robot.mouseMove(buttonLoc.x + button.getWidth() / 2,
buttonLoc.y + button.getHeight() / 2);
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}

public static void createUI() {
frame = new JFrame();
frame = new JFrame("JSplitPaneKeyboardNavigationTest");
panel = new JPanel();
panel.setLayout(new BorderLayout());
leftButton = new JButton("Left Button");
Expand All @@ -175,13 +188,14 @@ public static void createUI() {
bottomButton = new JButton("Bottom Button");
panel.add(topButton, BorderLayout.NORTH);
panel.add(bottomButton, BorderLayout.SOUTH);
final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, rightButton1, rightButton2);
final JSplitPane splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftButton, splitPane2);
final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
true, rightButton1, rightButton2);
final JSplitPane splitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
true, leftButton, splitPane2);
panel.add(splitPane1, BorderLayout.CENTER);
frame.setContentPane(panel);
frame.setSize(200, 200);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setAlwaysOnTop(true);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Expand Down Expand Up @@ -213,7 +227,6 @@ private static boolean setLookAndFeel(String lafName) {
private static void disposeFrame() {
if (frame != null) {
frame.dispose();
frame = null;
}
}

Expand Down