mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-18 11:53:17 +00:00
8202880: Test javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java fails
Reviewed-by: aivanov
This commit is contained in:
parent
68cf65d284
commit
3f19ef63b7
@ -1,6 +1,6 @@
|
||||
###########################################################################
|
||||
#
|
||||
# Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2009, 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
|
||||
@ -754,7 +754,6 @@ javax/swing/JInternalFrame/Test6325652.java 8224977 macosx-all
|
||||
javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all
|
||||
javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java 8065099,8208565 macosx-all,linux-all
|
||||
javax/swing/UIDefaults/6302464/bug6302464.java 8199079 macosx-all
|
||||
javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java 202880 linux-all
|
||||
javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all
|
||||
javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all
|
||||
javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 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
|
||||
@ -46,58 +46,39 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
public class ContextMenuScrollTest extends JPopupMenu
|
||||
{
|
||||
private JMenuItem undo;
|
||||
private JMenuItem redo;
|
||||
private JMenuItem cut;
|
||||
private JMenuItem copy;
|
||||
private JMenuItem paste;
|
||||
private JMenuItem delete;
|
||||
private JMenuItem selectAll;
|
||||
private final Robot robot;
|
||||
private JFrame frame;
|
||||
private JMenuBar menuBar;
|
||||
private JMenu menu;
|
||||
private volatile Point p = null;
|
||||
private volatile Dimension d = null;
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
private static JMenu menu;
|
||||
private static volatile Point p = null;
|
||||
private static volatile Dimension d = null;
|
||||
private static volatile boolean popupVisible = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new ContextMenuScrollTest();
|
||||
}
|
||||
void blockTillDisplayed(JComponent comp) throws Exception {
|
||||
while (p == null) {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
p = comp.getLocationOnScreen();
|
||||
d = menu.getSize();
|
||||
});
|
||||
} catch (IllegalStateException e) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ContextMenuScrollTest() throws Exception
|
||||
{
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(200);
|
||||
robot.setAutoDelay(100);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(()->createGUI());
|
||||
blockTillDisplayed(menu);
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
p = menu.getLocationOnScreen();
|
||||
d = menu.getSize();
|
||||
});
|
||||
System.out.println("p " + p + " d " + d);
|
||||
robot.mouseMove(p.x + d.width/2, p.y + d.height/2);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
System.out.println("popmenu visible " + menu.isPopupMenuVisible());
|
||||
robot.mouseWheel(1);
|
||||
robot.waitForIdle();
|
||||
System.out.println("popmenu visible " + menu.isPopupMenuVisible());
|
||||
if (!menu.isPopupMenuVisible()) {
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
popupVisible = menu.isPopupMenuVisible();
|
||||
});
|
||||
if (!popupVisible) {
|
||||
throw new RuntimeException("Popup closes on mouse scroll");
|
||||
}
|
||||
} finally {
|
||||
@ -105,13 +86,14 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
}
|
||||
}
|
||||
|
||||
public void createGUI() {
|
||||
|
||||
public static void createGUI() {
|
||||
frame = new JFrame();
|
||||
menuBar = new JMenuBar();
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
menu = new JMenu("Menu");
|
||||
menuBar.add(menu);
|
||||
|
||||
undo = new JMenuItem("Undo");
|
||||
JMenuItem undo = new JMenuItem("Undo");
|
||||
undo.setEnabled(false);
|
||||
undo.setAccelerator(KeyStroke.getKeyStroke("control Z"));
|
||||
undo.addActionListener(new ActionListener() {
|
||||
@ -122,7 +104,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
|
||||
menu.add(undo);
|
||||
|
||||
redo = new JMenuItem("Redo");
|
||||
JMenuItem redo = new JMenuItem("Redo");
|
||||
redo.setEnabled(false);
|
||||
redo.setAccelerator(KeyStroke.getKeyStroke("control Y"));
|
||||
redo.addActionListener(new ActionListener() {
|
||||
@ -134,7 +116,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
|
||||
menu.add(new JSeparator());
|
||||
|
||||
cut = new JMenuItem("Cut");
|
||||
JMenuItem cut = new JMenuItem("Cut");
|
||||
cut.setEnabled(false);
|
||||
cut.setAccelerator(KeyStroke.getKeyStroke("control X"));
|
||||
cut.addActionListener(new ActionListener() {
|
||||
@ -145,7 +127,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
|
||||
menu.add(cut);
|
||||
|
||||
copy = new JMenuItem("Copy");
|
||||
JMenuItem copy = new JMenuItem("Copy");
|
||||
copy.setEnabled(false);
|
||||
copy.setAccelerator(KeyStroke.getKeyStroke("control C"));
|
||||
copy.addActionListener(new ActionListener() {
|
||||
@ -156,7 +138,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
|
||||
menu.add(copy);
|
||||
|
||||
paste = new JMenuItem("Paste");
|
||||
JMenuItem paste = new JMenuItem("Paste");
|
||||
paste.setEnabled(false);
|
||||
paste.setAccelerator(KeyStroke.getKeyStroke("control V"));
|
||||
paste.addActionListener(new ActionListener() {
|
||||
@ -167,7 +149,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
|
||||
menu.add(paste);
|
||||
|
||||
delete = new JMenuItem("Delete");
|
||||
JMenuItem delete = new JMenuItem("Delete");
|
||||
delete.setEnabled(false);
|
||||
delete.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0));
|
||||
delete.addActionListener(new ActionListener() {
|
||||
@ -180,7 +162,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
|
||||
menu.add(new JSeparator());
|
||||
|
||||
selectAll = new JMenuItem("Select All");
|
||||
JMenuItem selectAll = new JMenuItem("Select All");
|
||||
selectAll.setEnabled(false);
|
||||
selectAll.setAccelerator(KeyStroke.getKeyStroke("control A"));
|
||||
selectAll.addActionListener(new ActionListener() {
|
||||
@ -192,6 +174,7 @@ public class ContextMenuScrollTest extends JPopupMenu
|
||||
frame.setJMenuBar(menuBar);
|
||||
|
||||
frame.pack();
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user