2008-03-26 16:20:01 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Sun Microsystems, Inc. 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
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
|
|
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
|
|
* have any questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2008-03-26 17:38:26 +03:00
|
|
|
@test
|
|
|
|
@bug 4752312
|
|
|
|
@summary Tests that after moving non-focusable window it ungrabs mouse pointer
|
|
|
|
@author Denis Mikhalkin: area=awt.focus
|
|
|
|
@library ../../regtesthelpers
|
|
|
|
@build Util
|
|
|
|
@run main FrameJumpingToMouse
|
2008-03-26 16:20:01 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
import java.applet.Applet;
|
2008-03-26 17:38:26 +03:00
|
|
|
import java.awt.BorderLayout;
|
|
|
|
import java.awt.Dialog;
|
|
|
|
import java.awt.Frame;
|
|
|
|
import java.awt.Point;
|
|
|
|
import java.awt.Robot;
|
|
|
|
import java.awt.TextArea;
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
import java.awt.event.InputEvent;
|
2008-03-26 16:20:01 +03:00
|
|
|
import javax.swing.JFrame;
|
2008-03-26 17:38:26 +03:00
|
|
|
import test.java.awt.regtesthelpers.Util;
|
2008-03-26 16:20:01 +03:00
|
|
|
|
|
|
|
public class FrameJumpingToMouse extends Applet
|
|
|
|
{
|
|
|
|
JFrame frame = new JFrame("Test jumping frame");
|
2008-03-26 17:38:26 +03:00
|
|
|
Robot robot = Util.createRobot();
|
2008-03-26 16:20:01 +03:00
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
public static void main(String[] args) {
|
|
|
|
FrameJumpingToMouse test = new FrameJumpingToMouse();
|
|
|
|
test.init();
|
|
|
|
test.start();
|
|
|
|
}
|
2008-03-26 16:20:01 +03:00
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
public void init() {
|
2008-03-26 16:20:01 +03:00
|
|
|
frame.setFocusableWindowState(false);
|
|
|
|
frame.setBounds(100, 100, 100, 100);
|
2008-03-26 17:38:26 +03:00
|
|
|
}
|
2008-03-26 16:20:01 +03:00
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
public void start() {
|
2008-03-26 16:20:01 +03:00
|
|
|
frame.setVisible(true);
|
2008-03-26 17:38:26 +03:00
|
|
|
Util.waitTillShown(frame);
|
2008-03-26 16:20:01 +03:00
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
Point loc = frame.getLocationOnScreen();
|
|
|
|
robot.mouseMove(loc.x + frame.getWidth() / 4, loc.y + frame.getInsets().top / 2);
|
|
|
|
robot.delay(50);
|
2008-03-26 16:20:01 +03:00
|
|
|
robot.mousePress(InputEvent.BUTTON1_MASK);
|
2008-03-26 17:38:26 +03:00
|
|
|
robot.delay(50);
|
|
|
|
robot.mouseMove(loc.x + 100, loc.y + 50);
|
|
|
|
robot.delay(50);
|
2008-03-26 16:20:01 +03:00
|
|
|
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
Util.waitForIdle(robot);
|
2008-03-26 16:20:01 +03:00
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
loc = frame.getLocation();
|
|
|
|
robot.mouseMove(loc.x + frame.getWidth() / 2, loc.y + frame.getHeight() / 2);
|
|
|
|
Util.waitForIdle(robot);
|
2008-03-26 16:20:01 +03:00
|
|
|
|
2008-03-26 17:38:26 +03:00
|
|
|
if (!(frame.getLocation().equals(loc))) {
|
|
|
|
throw new RuntimeException("Test failed: frame is moving to mouse with grab!");
|
2008-03-26 16:20:01 +03:00
|
|
|
}
|
2008-03-26 17:38:26 +03:00
|
|
|
System.out.println("Test passed.");
|
2008-03-26 16:20:01 +03:00
|
|
|
}
|
2008-03-26 17:38:26 +03:00
|
|
|
}
|