7161766: [macosx] javax/swing/JPopupMenu/6694823/bug6694823.java failed on Mac OS X
Reviewed-by: rupashka
This commit is contained in:
parent
a036af76db
commit
cb35692923
@ -33,6 +33,8 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
import java.security.Permission;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
public class bug6694823 {
|
||||
private static JFrame frame;
|
||||
@ -48,6 +50,8 @@ public class bug6694823 {
|
||||
}
|
||||
});
|
||||
|
||||
toolkit.realSync();
|
||||
|
||||
// Get screen insets
|
||||
screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
|
||||
if (screenInsets.bottom == 0) {
|
||||
@ -55,26 +59,23 @@ public class bug6694823 {
|
||||
return;
|
||||
}
|
||||
|
||||
// Show popup as if from a standalone application
|
||||
// The popup should be able to overlap the task bar
|
||||
showPopup(false);
|
||||
System.setSecurityManager(new SecurityManager(){
|
||||
|
||||
// Emulate applet security restrictions
|
||||
toolkit.realSync();
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
private String allowsAlwaysOnTopPermission = SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName();
|
||||
|
||||
@Override
|
||||
public void checkPermission(Permission perm) {
|
||||
if (allowsAlwaysOnTopPermission.equals(perm.getName())) {
|
||||
throw new SecurityException();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Show popup as if from an applet
|
||||
// The popup shouldn't overlap the task bar. It should be shifted up.
|
||||
showPopup(true);
|
||||
checkPopup();
|
||||
|
||||
toolkit.realSync();
|
||||
System.out.println("Test passed!");
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void createGui() {
|
||||
@ -93,7 +94,7 @@ public class bug6694823 {
|
||||
frame.setSize(200, 200);
|
||||
}
|
||||
|
||||
private static void showPopup(final boolean shouldBeShifted) throws Exception {
|
||||
private static void checkPopup() throws Exception {
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
// Place frame just above the task bar
|
||||
@ -121,20 +122,14 @@ public class bug6694823 {
|
||||
toolkit.realSync();
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
Point frameLoc = frame.getLocationOnScreen();
|
||||
if (shouldBeShifted) {
|
||||
if (popup.getLocationOnScreen()
|
||||
.equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
|
||||
throw new RuntimeException("Popup is not shifted");
|
||||
}
|
||||
} else {
|
||||
if (!popup.getLocationOnScreen()
|
||||
.equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
|
||||
throw new RuntimeException("Popup is unexpectedly shifted");
|
||||
}
|
||||
if (popup.getLocationOnScreen().equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
|
||||
throw new RuntimeException("Popup is not shifted");
|
||||
}
|
||||
popup.setVisible(false);
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user