author | vlivanov |
Wed, 02 Mar 2016 15:42:03 +0300 | |
changeset 36349 | 6cc8e6f596b2 |
parent 15635 | 1bb3df084c72 |
child 46151 | 5fa789776f7d |
permissions | -rw-r--r-- |
12175 | 1 |
/* |
15635
1bb3df084c72
7161759: TEST_BUG: java/awt/Frame/WindowDragTest/WindowDragTest.java fails to compile, should be modified
kshefov
parents:
12175
diff
changeset
|
2 |
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
12175 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
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. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
@test |
|
15635
1bb3df084c72
7161759: TEST_BUG: java/awt/Frame/WindowDragTest/WindowDragTest.java fails to compile, should be modified
kshefov
parents:
12175
diff
changeset
|
26 |
@bug 7128738 7161759 |
12175 | 27 |
@summary dragged dialog freezes system on dispose |
28 |
@author Oleg Pekhovskiy: area=awt.toplevel |
|
29 |
@library ../../regtesthelpers |
|
15635
1bb3df084c72
7161759: TEST_BUG: java/awt/Frame/WindowDragTest/WindowDragTest.java fails to compile, should be modified
kshefov
parents:
12175
diff
changeset
|
30 |
@build Util |
12175 | 31 |
@run main WindowDragTest |
32 |
*/ |
|
33 |
||
34 |
import java.awt.Frame; |
|
35 |
import java.awt.event.InputEvent; |
|
36 |
import java.awt.AWTException; |
|
37 |
import test.java.awt.regtesthelpers.Util; |
|
38 |
import java.awt.Robot; |
|
39 |
import java.awt.Point; |
|
40 |
import java.awt.Dimension; |
|
41 |
import java.awt.event.MouseAdapter; |
|
42 |
import java.awt.event.MouseEvent; |
|
43 |
||
44 |
public class WindowDragTest { |
|
45 |
||
46 |
static boolean passed = false; |
|
47 |
||
48 |
public static void main(String[] args) { |
|
49 |
try { |
|
50 |
Robot robot = new Robot(); |
|
51 |
robot.setAutoDelay(1000); |
|
52 |
||
53 |
Frame frame1 = new Frame(); |
|
54 |
frame1.setBounds(50, 50, 300, 200); |
|
55 |
frame1.setVisible(true); |
|
56 |
frame1.toFront(); |
|
57 |
frame1.addMouseListener(new MouseAdapter() { |
|
58 |
@Override |
|
59 |
public void mouseClicked(MouseEvent e) { |
|
60 |
// Clicking frame1 succeeded - mouse is not captured |
|
61 |
passed = true; |
|
62 |
} |
|
63 |
}); |
|
64 |
robot.delay(1000); |
|
65 |
||
66 |
Frame frame2 = new Frame(); |
|
67 |
frame2.setBounds(100, 100, 300, 200); |
|
68 |
frame2.setVisible(true); |
|
69 |
frame2.toFront(); |
|
70 |
robot.delay(1000); |
|
71 |
||
72 |
Point p = frame2.getLocationOnScreen(); |
|
73 |
Dimension d = frame2.getSize(); |
|
74 |
||
75 |
// Move cursor to frame2 title bar to drag |
|
76 |
robot.mouseMove(p.x + (int)(d.getWidth() / 2), p.y + (int)frame2.getInsets().top / 2); |
|
77 |
Util.waitForIdle(robot); |
|
78 |
||
79 |
// Start window dragging |
|
80 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
|
81 |
Util.waitForIdle(robot); |
|
82 |
||
83 |
// Dispose window being dragged |
|
84 |
frame2.dispose(); |
|
85 |
Util.waitForIdle(robot); |
|
86 |
||
87 |
// Release mouse button to be able to get MOUSE_CLICKED event on Util.clickOnComp() |
|
88 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
|
89 |
Util.waitForIdle(robot); |
|
90 |
||
91 |
// Click frame1 to check whether mouse is not captured by frame2 |
|
92 |
Util.clickOnComp(frame1, robot); |
|
93 |
Util.waitForIdle(robot); |
|
94 |
||
95 |
frame1.dispose(); |
|
96 |
if (passed) { |
|
97 |
System.out.println("Test passed."); |
|
98 |
} |
|
99 |
else { |
|
100 |
System.out.println("Test failed."); |
|
101 |
throw new RuntimeException("Test failed."); |
|
102 |
} |
|
103 |
} |
|
104 |
catch (AWTException e) { |
|
105 |
throw new RuntimeException("AWTException occurred - problem creating robot!"); |
|
106 |
} |
|
107 |
} |
|
108 |
} |