提交 4c70c891 编写于 作者: R rupashka

7071609: javax/swing/JPopupMenu/6694823/bug6694823.java failed on solaris10

Reviewed-by: alexp
上级 c345ae6c
...@@ -69,7 +69,12 @@ public class bug6694823 { ...@@ -69,7 +69,12 @@ public class bug6694823 {
toolkit.realSync(); toolkit.realSync();
System.out.println("Test passed!"); System.out.println("Test passed!");
frame.dispose();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
frame.dispose();
}
});
} }
private static void createGui() { private static void createGui() {
...@@ -88,30 +93,44 @@ public class bug6694823 { ...@@ -88,30 +93,44 @@ public class bug6694823 {
frame.setSize(200, 200); frame.setSize(200, 200);
} }
private static void showPopup(final boolean shouldBeShifted) { private static void showPopup(final boolean shouldBeShifted) throws Exception {
SwingUtilities.invokeLater(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
Dimension screenSize = toolkit.getScreenSize(); Dimension screenSize = toolkit.getScreenSize();
frame.setLocation(screenSize.width / 2, frame.setLocation(screenSize.width / 2,
screenSize.height - frame.getHeight() - screenInsets.bottom); screenSize.height - frame.getHeight() - screenInsets.bottom);
frame.setVisible(true); frame.setVisible(true);
}
});
// Ensure frame is visible
toolkit.realSync();
final Point point = new Point();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
// Place popup over the task bar // Place popup over the task bar
Point frameLoc = frame.getLocationOnScreen(); point.x = 0;
int x = 0; point.y = frame.getHeight() - popup.getPreferredSize().height + screenInsets.bottom;
int y = frame.getHeight() popup.show(frame, point.x, point.y);
- popup.getPreferredSize().height + screenInsets.bottom; }
popup.show(frame, x, y); });
// Ensure popup is visible
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
Point frameLoc = frame.getLocationOnScreen();
if (shouldBeShifted) { if (shouldBeShifted) {
if (popup.getLocationOnScreen() if (popup.getLocationOnScreen()
.equals(new Point(frameLoc.x, frameLoc.y + y))) { .equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
throw new RuntimeException("Popup is not shifted"); throw new RuntimeException("Popup is not shifted");
} }
} else { } else {
if (!popup.getLocationOnScreen() if (!popup.getLocationOnScreen()
.equals(new Point(frameLoc.x, frameLoc.y + y))) { .equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
throw new RuntimeException("Popup is unexpectedly shifted"); throw new RuntimeException("Popup is unexpectedly shifted");
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册