Skip to content
Permalink
Browse files
8196017: java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopu…
…p.java fails

Reviewed-by: serb
  • Loading branch information
Alexander Zuev committed Oct 30, 2021
1 parent 6875678 commit b7104ba9a9006ab65e08ea9d7db22e72611ed07c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
@@ -205,7 +205,6 @@ java/awt/event/MouseEvent/MouseButtonsAndKeyMasksTest/MouseButtonsAndKeyMasksTes
java/awt/dnd/URIListToFileListBetweenJVMsTest/URIListToFileListBetweenJVMsTest.java 8194947 generic-all
java/awt/Frame/FramesGC/FramesGC.java 8079069 macosx-all
java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java 8000171 windows-all
java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java 8196017 windows-all
java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWheelTest.java 8196018 windows-all,linux-all
java/awt/TrayIcon/ActionCommand/ActionCommand.java 8150540 windows-all
java/awt/TrayIcon/ActionEventMask/ActionEventMask.java 8150540 windows-all
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2017, 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
@@ -23,8 +23,10 @@

import test.java.awt.regtesthelpers.Util;

import javax.swing.*;
import java.awt.*;
import javax.swing.SwingUtilities;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

@@ -33,11 +35,10 @@
* @key headful
* @bug 8012026 8027154
* @summary Component.getMousePosition() does not work in an applet on MacOS
* @author Petr Pchelko
* @library ../../regtesthelpers
* @build Util
* @compile GetMousePositionWithPopup.java
* @run main/othervm GetMousePositionWithPopup
* @run main GetMousePositionWithPopup
*/

public class GetMousePositionWithPopup {
@@ -48,6 +49,7 @@ public class GetMousePositionWithPopup {
public static void main(String[] args) throws Exception {
try {
Robot r = Util.createRobot();
r.setAutoDelay(100);
r.mouseMove(0, 0);
Util.waitForIdle(null);

@@ -61,7 +63,7 @@ public void run() {
Util.waitForIdle(null);
r.mouseMove(149, 149);
Util.waitForIdle(null);
r.mouseMove(150, 150);
r.mouseMove(170, 170);
Util.waitForIdle(null);

} finally {
@@ -78,20 +80,25 @@ public void run() {
private static void constructTestUI() {
frame1 = new Frame();
frame1.setBounds(100, 100, 100, 100);
frame1.setVisible(true);
frame1.addMouseMotionListener(new MouseMotionAdapter() {

@Override
public void mouseMoved(MouseEvent e) {
if (frame2 != null) {
return;
}
frame2 = new Frame();
frame2.setBounds(120, 120, 120, 120);

frame2.setVisible(true);
frame2.addMouseMotionListener(new MouseMotionAdapter() {
@Override
public void mouseMoved(MouseEvent e)
{
Point positionInFrame2 = frame2.getMousePosition();
if (positionInFrame2.x != 30 || positionInFrame2.y != 30) {
throw new RuntimeException("Wrong position reported. Should be [30, 30] but was [" +
int deltaX = Math.abs(50 - positionInFrame2.x);
int deltaY = Math.abs(50 - positionInFrame2.y);
if (deltaX > 2 || deltaY > 2) {
throw new RuntimeException("Wrong position reported. Should be [50, 50] but was [" +
positionInFrame2.x + ", " + positionInFrame2.y + "]");
}

@@ -101,10 +108,7 @@ public void mouseMoved(MouseEvent e)
}
}
});

frame2.setVisible(true);
}
});
frame1.setVisible(true);
}
}
}

1 comment on commit b7104ba

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b7104ba Oct 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.