author | ohair |
Tue, 25 May 2010 15:58:33 -0700 | |
changeset 5506 | 202f599c92aa |
parent 425 | 89b44fab010f |
child 39056 | d99e63b6d962 |
permissions | -rw-r--r-- |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
4 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
8 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
13 |
* accompanied this code). |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
14 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
22 |
*/ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
23 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
24 |
/* |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
25 |
@test |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
26 |
@bug 4752312 |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
27 |
@summary Tests that after moving non-focusable window it ungrabs mouse pointer |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
28 |
@author Denis Mikhalkin: area=awt.focus |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
29 |
@library ../../regtesthelpers |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
30 |
@build Util |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
31 |
@run main FrameJumpingToMouse |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
32 |
*/ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
33 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
34 |
import java.applet.Applet; |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
35 |
import java.awt.BorderLayout; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
36 |
import java.awt.Dialog; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
37 |
import java.awt.Frame; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
38 |
import java.awt.Point; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
39 |
import java.awt.Robot; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
40 |
import java.awt.TextArea; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
41 |
import java.awt.Toolkit; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
42 |
import java.awt.event.InputEvent; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
43 |
import javax.swing.JFrame; |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
44 |
import test.java.awt.regtesthelpers.Util; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
45 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
46 |
public class FrameJumpingToMouse extends Applet |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
47 |
{ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
48 |
JFrame frame = new JFrame("Test jumping frame"); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
49 |
Robot robot = Util.createRobot(); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
50 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
51 |
public static void main(String[] args) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
52 |
FrameJumpingToMouse test = new FrameJumpingToMouse(); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
53 |
test.init(); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
54 |
test.start(); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
55 |
} |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
56 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
57 |
public void init() { |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
58 |
frame.setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
59 |
frame.setBounds(100, 100, 100, 100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
60 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
61 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
62 |
public void start() { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
63 |
frame.setVisible(true); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
64 |
Util.waitTillShown(frame); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
65 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
66 |
Point loc = frame.getLocationOnScreen(); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
67 |
robot.mouseMove(loc.x + frame.getWidth() / 4, loc.y + frame.getInsets().top / 2); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
68 |
robot.delay(50); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
69 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
70 |
robot.delay(50); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
71 |
robot.mouseMove(loc.x + 100, loc.y + 50); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
72 |
robot.delay(50); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
73 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
74 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
75 |
Util.waitForIdle(robot); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
76 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
77 |
loc = frame.getLocation(); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
78 |
robot.mouseMove(loc.x + frame.getWidth() / 2, loc.y + frame.getHeight() / 2); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
79 |
Util.waitForIdle(robot); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
80 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
81 |
if (!(frame.getLocation().equals(loc))) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
82 |
throw new RuntimeException("Test failed: frame is moving to mouse with grab!"); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
83 |
} |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
84 |
System.out.println("Test passed."); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
85 |
} |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
86 |
} |