8339524: Clean up a few ExtendedRobot tests

Reviewed-by: honkar, aivanov, prr
This commit is contained in:
Alisen Chung 2024-11-25 22:32:59 +00:00
parent 027607968b
commit 16232578d9

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -21,68 +21,61 @@
* questions. * questions.
*/ */
/* @test /*
* @test
* @key headful * @key headful
* @bug 6725409 * @bug 6725409
* @requires (os.family == "windows") * @requires (os.family == "windows")
* @summary Checks that JInternalFrame's system menu * @summary Checks that JInternalFrame's system menu
* can be localized during run-time * can be localized during run-time
* @author Mikhail Lapshin
* @library /lib/client/
* @modules java.desktop/com.sun.java.swing.plaf.windows * @modules java.desktop/com.sun.java.swing.plaf.windows
* @build ExtendedRobot
* @run main bug6725409 * @run main bug6725409
*/ */
import javax.swing.*; import java.awt.Robot;
import java.awt.*; import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel;
import com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane;
public class bug6725409 { public class bug6725409 {
private JFrame frame; private JFrame frame;
private JInternalFrame iFrame; private JInternalFrame iFrame;
private TestTitlePane testTitlePane; private static TestTitlePane testTitlePane;
private boolean passed; private static volatile boolean passed;
private static ExtendedRobot robot = createRobot(); private static Robot robot;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
try { UIManager.setLookAndFeel(
UIManager.setLookAndFeel( new WindowsClassicLookAndFeel());
new com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel());
} catch(UnsupportedLookAndFeelException e) {
System.out.println("The test is for Windows LaF only");
return;
}
robot = new Robot();
final bug6725409 bug6725409 = new bug6725409(); final bug6725409 bug6725409 = new bug6725409();
try { try {
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(bug6725409::setupUIStep1);
public void run() {
bug6725409.setupUIStep1();
}
});
sync(); sync();
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(bug6725409::setupUIStep2);
public void run() {
bug6725409.setupUIStep2();
}
});
sync(); sync();
SwingUtilities.invokeAndWait(new Runnable() { SwingUtilities.invokeAndWait(bug6725409::test);
public void run() {
bug6725409.test();
}
});
sync(); sync();
bug6725409.checkResult(); bug6725409.checkResult();
} finally { } finally {
if (bug6725409.frame != null) { SwingUtilities.invokeAndWait(() -> {
bug6725409.frame.dispose(); if (bug6725409.frame != null) {
} bug6725409.frame.dispose();
}
});
} }
} }
private void setupUIStep1() { private void setupUIStep1() {
frame = new JFrame(); frame = new JFrame("bug6725409");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JDesktopPane desktop = new JDesktopPane(); JDesktopPane desktop = new JDesktopPane();
@ -147,19 +140,9 @@ public class bug6725409 {
private static void sync() { private static void sync() {
robot.waitForIdle(); robot.waitForIdle();
} }
private static ExtendedRobot createRobot() {
try {
ExtendedRobot robot = new ExtendedRobot();
return robot;
}catch(Exception ex) {
ex.printStackTrace();
throw new Error("Unexpected Failure");
}
}
// Extend WindowsInternalFrameTitlePane to get access to systemPopupMenu // Extend WindowsInternalFrameTitlePane to get access to systemPopupMenu
private class TestTitlePane extends private class TestTitlePane extends WindowsInternalFrameTitlePane {
com.sun.java.swing.plaf.windows.WindowsInternalFrameTitlePane {
private JPopupMenu systemPopupMenu; private JPopupMenu systemPopupMenu;
public TestTitlePane(JInternalFrame f) { public TestTitlePane(JInternalFrame f) {