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