Skip to content

Commit

Permalink
8235900: [TESTBUG] [macos] PopupMenu Opaque property is not reflectin…
Browse files Browse the repository at this point in the history
…g the Parents property on MAC OS

Reviewed-by: serb
  • Loading branch information
smahaliswamy authored and arapte committed Feb 3, 2020
1 parent 9fb0aee commit 060e4ec
Showing 1 changed file with 31 additions and 17 deletions.
Expand Up @@ -32,10 +32,14 @@
import java.awt.event.*; import java.awt.event.*;


import javax.swing.*; import javax.swing.*;
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 extends JFrame {


private static JMenu fileMenu; private static JMenu fileMenu;
private static final String AQUALAF="com.apple.laf.AquaLookAndFeel";


public NonOpaquePopupMenuTest() { public NonOpaquePopupMenuTest() {
getContentPane().setBackground(java.awt.Color.RED); getContentPane().setBackground(java.awt.Color.RED);
Expand All @@ -53,30 +57,40 @@ public NonOpaquePopupMenuTest() {
} }


public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
Robot robot = new Robot(); LookAndFeelInfo[] lookAndFeelInfoArray = getInstalledLookAndFeels();
robot.setAutoDelay(250);
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() { SwingUtilities.invokeAndWait(new Runnable() {


@Override @Override
public void run() { public void run() {
new NonOpaquePopupMenuTest(); new NonOpaquePopupMenuTest();
} }
}); });


robot.waitForIdle(); robot.waitForIdle();


Point p = getMenuClickPoint(); Point p = getMenuClickPoint();
robot.mouseMove(p.x, p.y); robot.mouseMove(p.x, p.y);
robot.mousePress(InputEvent.BUTTON1_MASK); robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK);


robot.waitForIdle(); robot.waitForIdle();


if (isParentOpaque()) { if (isParentOpaque()) {
throw new RuntimeException("Popup menu parent is opaque"); throw new RuntimeException("Popup menu parent is opaque");
}
} }

} }


private static boolean isParentOpaque() throws Exception { private static boolean isParentOpaque() throws Exception {
Expand Down

0 comments on commit 060e4ec

Please sign in to comment.