8168388: GetMousePositionTest fails with the message "Mouse position should not be null"
Reviewed-by: psadhukhan, serb
This commit is contained in:
parent
09f5235c65
commit
0c3eaea11c
test/jdk
@ -183,7 +183,6 @@ java/awt/Mixing/AWT_Mixing/JToggleButtonInGlassPaneOverlapping.java 8158801 wind
|
||||
java/awt/Mixing/AWT_Mixing/JToggleButtonOverlapping.java 8158801 windows-all
|
||||
java/awt/Mixing/MixingOnDialog.java 8225777 linux-all
|
||||
java/awt/Mixing/NonOpaqueInternalFrame.java 7124549 macosx-all
|
||||
java/awt/Mouse/GetMousePositionTest/GetMousePositionWithOverlay.java 8168388 linux-all
|
||||
java/awt/Focus/ActualFocusedWindowTest/ActualFocusedWindowRetaining.java 6829264 generic-all
|
||||
java/awt/datatransfer/DragImage/MultiResolutionDragImageTest.java 8080982 generic-all
|
||||
java/awt/datatransfer/SystemFlavorMap/AddFlavorTest.java 8079268 linux-all
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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,6 +25,7 @@ import java.awt.Frame;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@ -42,23 +43,21 @@ public class GetMousePositionWithOverlay {
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(100);
|
||||
|
||||
try{
|
||||
constructTestUI();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(GetMousePositionWithOverlay::constructTestUI);
|
||||
doTest();
|
||||
} finally {
|
||||
dispose();
|
||||
throw new RuntimeException("Unexpected Exception!");
|
||||
}
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
doTest();
|
||||
dispose();
|
||||
}
|
||||
|
||||
private static void doTest() {
|
||||
|
||||
frontFrame.toFront();
|
||||
private static void doTest() throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> frontFrame.toFront());
|
||||
robot.waitForIdle();
|
||||
|
||||
Rectangle bounds = new Rectangle(frontFrame.getLocationOnScreen(), frontFrame.getSize());
|
||||
@ -67,45 +66,44 @@ public class GetMousePositionWithOverlay {
|
||||
|
||||
Point pos = backFrame.getMousePosition();
|
||||
if (pos != null) {
|
||||
dispose();
|
||||
throw new RuntimeException("Test failed. Mouse position should be null but was " + pos);
|
||||
}
|
||||
|
||||
pos = frontFrame.getMousePosition();
|
||||
if (pos == null) {
|
||||
dispose();
|
||||
throw new RuntimeException("Test failed. Mouse position should not be null");
|
||||
}
|
||||
|
||||
robot.mouseMove(189, 189);
|
||||
robot.mouseMove(bounds.x + bounds.width + 5, bounds.y + bounds.height + 5);
|
||||
robot.waitForIdle();
|
||||
|
||||
pos = backFrame.getMousePosition();
|
||||
if (pos == null) {
|
||||
dispose();
|
||||
throw new RuntimeException("Test failed. Mouse position should not be null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void dispose() {
|
||||
private static void dispose() throws Exception {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (backFrame != null) {
|
||||
backFrame.dispose();
|
||||
}
|
||||
|
||||
if (backFrame != null) {
|
||||
backFrame.dispose();
|
||||
}
|
||||
|
||||
if (frontFrame != null) {
|
||||
frontFrame.dispose();
|
||||
}
|
||||
if (frontFrame != null) {
|
||||
frontFrame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void constructTestUI() {
|
||||
backFrame = new Frame();
|
||||
backFrame.setUndecorated(true);
|
||||
backFrame.setBounds(100, 100, 100, 100);
|
||||
backFrame.setResizable(false);
|
||||
backFrame.setVisible(true);
|
||||
|
||||
frontFrame = new Frame();
|
||||
frontFrame.setUndecorated(true);
|
||||
frontFrame.setBounds(120, 120, 60, 60);
|
||||
frontFrame.setResizable(false);
|
||||
frontFrame.setVisible(true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user