--- old/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java 2017-08-24 15:25:08.000000000 +0530 +++ new/test/java/awt/Mouse/EnterExitEvents/DragWindowOutOfFrameTest.java 2017-08-24 15:25:08.000000000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, 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 @@ -24,7 +24,7 @@ /* * @test * @key headful - * @bug 7154048 + * @bug 7154048 8177326 * @summary Window created under a mouse does not receive mouse enter event. * Mouse Entered/Exited events should be generated during dragging the window * out of the frame and to the frame. @@ -33,12 +33,23 @@ * @author alexandr.scherbatiy area=awt.event * @run main DragWindowOutOfFrameTest */ -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - -import java.util.concurrent.*; - +import java.awt.Robot; +import java.awt.Point; +import java.awt.Component; +import java.awt.Rectangle; +import java.awt.Window; +import java.awt.BorderLayout; +import java.awt.Panel; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseAdapter; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import java.util.concurrent.Callable; +import java.util.Random; import test.java.awt.regtesthelpers.Util; public class DragWindowOutOfFrameTest { @@ -54,6 +65,7 @@ private static MyDragWindow dragWindow; private static JLabel label; private static JButton button; + private static JFrame frame; public static void main(String[] args) throws Exception { @@ -78,9 +90,15 @@ } }); + /* The mouse is moved at the beginning of the test to make sure the initial mouse move + on the label always happens. + */ + robot.mouseMove(pointToClick.x, pointToClick.y + 10); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.mouseMove(pointToClick.x, pointToClick.y); - robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); if (dragWindowMouseEnteredCount != 1 && dragWindowMouseExitedCount != 0) { @@ -127,12 +145,14 @@ "Wrong number Mouse Entered/Exited events on button!"); } - robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); robot.waitForIdle(); if (labelMouseReleasedCount != 1) { throw new RuntimeException("No MouseReleased event on label!"); } + + frame.dispose(); } private static Point getCenterPoint(Component comp) { @@ -143,7 +163,7 @@ private static void createAndShowGUI() { - JFrame frame = new JFrame("Main Frame"); + frame = new JFrame("Main Frame"); frame.setLocation(100, 100); frame.setSize(300, 200); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);