8208565: [TEST_BUG] javax\swing\PopupFactory\6276087\NonOpaquePopupMenuTest.java throws NPE
8065099: [macos] javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java fails: no background shine through Reviewed-by: jdv
This commit is contained in:
parent
4714fdcd6a
commit
72f82dd723
test/jdk
@ -677,7 +677,6 @@ javax/swing/text/DefaultCaret/HidingSelection/HidingSelectionTest.java 8194048 w
|
||||
javax/swing/text/DefaultCaret/HidingSelection/MultiSelectionTest.java 8213562 linux-all
|
||||
javax/swing/JFileChooser/6798062/bug6798062.java 8146446 windows-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/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) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2022, 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
|
||||
@ -25,71 +25,88 @@
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6276087
|
||||
* @author Romain Guy
|
||||
* @summary Tests opacity of a popup menu.
|
||||
*/
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.Point;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.SwingUtilities;
|
||||
import static javax.swing.UIManager.LookAndFeelInfo;
|
||||
import static javax.swing.UIManager.getInstalledLookAndFeels;
|
||||
import static javax.swing.UIManager.setLookAndFeel;
|
||||
|
||||
public class NonOpaquePopupMenuTest extends JFrame {
|
||||
public class NonOpaquePopupMenuTest {
|
||||
|
||||
private static JMenu fileMenu;
|
||||
private static JFrame frame;
|
||||
private static final String AQUALAF="com.apple.laf.AquaLookAndFeel";
|
||||
private volatile static Point p;
|
||||
private volatile static Dimension size;
|
||||
|
||||
public NonOpaquePopupMenuTest() {
|
||||
getContentPane().setBackground(java.awt.Color.RED);
|
||||
private static void createUI() {
|
||||
frame = new JFrame();
|
||||
frame.getContentPane().setBackground(java.awt.Color.RED);
|
||||
JMenuBar menuBar = new JMenuBar();
|
||||
fileMenu = new JMenu("File");
|
||||
JMenuItem menuItem = new JMenuItem("New");
|
||||
menuBar.add(fileMenu);
|
||||
setJMenuBar(menuBar);
|
||||
frame.setJMenuBar(menuBar);
|
||||
|
||||
fileMenu.add(menuItem);
|
||||
fileMenu.getPopupMenu().setOpaque(false);
|
||||
|
||||
setSize(new Dimension(640, 480));
|
||||
setLocationRelativeTo(null);
|
||||
setVisible(true);
|
||||
frame.setSize(new Dimension(640, 480));
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
LookAndFeelInfo[] lookAndFeelInfoArray = getInstalledLookAndFeels();
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
for (LookAndFeelInfo lookAndFeelInfo : lookAndFeelInfoArray) {
|
||||
System.out.println(lookAndFeelInfo.getClassName());
|
||||
if ( AQUALAF == lookAndFeelInfo.getClassName()) {
|
||||
System.out.println("This test scenario is not applicable for" +
|
||||
" Aqua LookandFeel and hence skipping the validation");
|
||||
continue;
|
||||
}
|
||||
setLookAndFeel(lookAndFeelInfo.getClassName());
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(250);
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new NonOpaquePopupMenuTest();
|
||||
try {
|
||||
System.out.println(lookAndFeelInfo.getClassName());
|
||||
if ( AQUALAF == lookAndFeelInfo.getClassName()) {
|
||||
System.out.println("This test scenario is not applicable for" +
|
||||
" Aqua LookandFeel and hence skipping the validation");
|
||||
continue;
|
||||
}
|
||||
});
|
||||
robot.delay(1000);
|
||||
setLookAndFeel(lookAndFeelInfo.getClassName());
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> createUI());
|
||||
|
||||
Point p = getMenuClickPoint();
|
||||
robot.mouseMove(p.x, p.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
robot.waitForIdle();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
p = fileMenu.getLocationOnScreen();
|
||||
size = fileMenu.getSize();
|
||||
});
|
||||
robot.mouseMove(p.x + size.width / 2, p.y + size.height / 2);
|
||||
robot.waitForIdle();
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
|
||||
if (isParentOpaque()) {
|
||||
throw new RuntimeException("Popup menu parent is opaque");
|
||||
robot.waitForIdle();
|
||||
|
||||
if (isParentOpaque()) {
|
||||
throw new RuntimeException("Popup menu parent is opaque");
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,23 +124,4 @@ public class NonOpaquePopupMenuTest extends JFrame {
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
private static Point getMenuClickPoint() throws Exception {
|
||||
final Point[] result = new Point[1];
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Point p = fileMenu.getLocationOnScreen();
|
||||
Dimension size = fileMenu.getSize();
|
||||
|
||||
result[0] = new Point(p.x + size.width / 2,
|
||||
p.y + size.height / 2);
|
||||
}
|
||||
});
|
||||
|
||||
return result[0];
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user