author | vlivanov |
Wed, 02 Mar 2016 15:42:03 +0300 | |
changeset 36349 | 6cc8e6f596b2 |
parent 26344 | 68c0e8209883 |
child 40128 | e635645d2a8a |
permissions | -rw-r--r-- |
26344
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
1 |
/* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
2 |
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
4 |
* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
8 |
* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
13 |
* accompanied this code). |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
14 |
* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
18 |
* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
21 |
* questions. |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
22 |
*/ |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
23 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
24 |
/* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
25 |
* @test |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
26 |
* @summary To make sure Undecorated Frame triggers correct windows events while closing |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
27 |
* @author Jitender(jitender.singh@eng.sun.com) area=AWT* |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
28 |
* @author yan |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
29 |
* @library ../../../../lib/testlibrary |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
30 |
* @build ExtendedRobot |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
31 |
* @run main FrameCloseTest |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
32 |
*/ |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
33 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
34 |
import java.awt.*; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
35 |
import java.awt.event.*; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
36 |
import javax.swing.JFrame; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
37 |
import javax.swing.JButton; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
38 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
39 |
public class FrameCloseTest { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
40 |
private static int delay = 150; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
41 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
42 |
private Frame frame, frame2; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
43 |
private Component button, dummyButton; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
44 |
private int eventType, eventType1, eventType2; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
45 |
private ExtendedRobot robot; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
46 |
private Object lock1 = new Object(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
47 |
private Object lock2 = new Object(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
48 |
private Object lock3 = new Object(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
49 |
private Object lock4 = new Object(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
50 |
private boolean passed = true; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
51 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
52 |
public static void main(String[] args) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
53 |
FrameCloseTest test = new FrameCloseTest(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
54 |
test.doTest(false); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
55 |
test.doTest(true); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
56 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
57 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
58 |
private void initializeGUI(boolean swingFrame) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
59 |
frame = swingFrame? new Frame() : new JFrame(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
60 |
frame.setLayout(new FlowLayout()); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
61 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
62 |
frame.setLocation(5, 20); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
63 |
frame.setSize(200, 200); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
64 |
frame.setUndecorated(true); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
65 |
frame.addWindowFocusListener(new WindowFocusListener() { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
66 |
public void windowGainedFocus(WindowEvent event) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
67 |
System.out.println("Frame Focus gained"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
68 |
synchronized (lock4) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
69 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
70 |
lock4.notifyAll(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
71 |
} catch (Exception ex) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
72 |
ex.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
73 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
74 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
75 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
76 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
77 |
public void windowLostFocus(WindowEvent event) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
78 |
System.out.println("Frame Focus lost"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
79 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
80 |
}); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
81 |
frame.addWindowListener(new WindowAdapter() { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
82 |
public void windowActivated(WindowEvent e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
83 |
eventType = WindowEvent.WINDOW_ACTIVATED; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
84 |
System.out.println("Undecorated Frame is activated"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
85 |
synchronized (lock1) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
86 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
87 |
lock1.notifyAll(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
88 |
} catch (Exception ex) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
89 |
ex.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
90 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
91 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
92 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
93 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
94 |
public void windowDeactivated(WindowEvent e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
95 |
eventType1 = WindowEvent.WINDOW_DEACTIVATED; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
96 |
System.out.println("Undecorated Frame got Deactivated"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
97 |
synchronized (lock2) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
98 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
99 |
lock2.notifyAll(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
100 |
} catch (Exception ex) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
101 |
ex.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
102 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
103 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
104 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
105 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
106 |
public void windowClosed(WindowEvent e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
107 |
eventType2 = WindowEvent.WINDOW_CLOSED; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
108 |
System.out.println("Undecorated Frame got closed"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
109 |
synchronized (lock3) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
110 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
111 |
lock3.notifyAll(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
112 |
} catch (Exception ex) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
113 |
ex.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
114 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
115 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
116 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
117 |
}); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
118 |
dummyButton = swingFrame? new JButton("Click me") : new Button("Click me"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
119 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
120 |
frame.setBackground(Color.green); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
121 |
frame.add((button = createButton(swingFrame, "Close me"))); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
122 |
frame.add(dummyButton); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
123 |
frame.setVisible(true); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
124 |
frame.toFront(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
125 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
126 |
private Component createButton(boolean swingControl, String txt) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
127 |
if(swingControl) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
128 |
JButton jbtn = new JButton(txt); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
129 |
jbtn.addActionListener(new ActionListener() { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
130 |
public void actionPerformed(ActionEvent e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
131 |
frame.dispose(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
132 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
133 |
}); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
134 |
return jbtn; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
135 |
}else { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
136 |
Button btn = new Button(txt); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
137 |
btn.addActionListener(new ActionListener() { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
138 |
public void actionPerformed(ActionEvent e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
139 |
frame.dispose(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
140 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
141 |
}); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
142 |
return btn; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
143 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
144 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
145 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
146 |
public void doTest(boolean swingControl) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
147 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
148 |
Toolkit.getDefaultToolkit().getSystemEventQueue().invokeAndWait(new Runnable() { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
149 |
public void run() { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
150 |
initializeGUI(swingControl); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
151 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
152 |
}); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
153 |
} catch (Exception e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
154 |
e.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
155 |
throw new RuntimeException("Interrupted or unexpected Exception occured"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
156 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
157 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
158 |
robot = new ExtendedRobot(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
159 |
robot.waitForIdle(1000); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
160 |
} catch (Exception e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
161 |
e.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
162 |
throw new RuntimeException("Cannot create robot"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
163 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
164 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
165 |
robot.mouseMove(dummyButton.getLocationOnScreen().x + dummyButton.getSize().width / 2, |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
166 |
dummyButton.getLocationOnScreen().y + dummyButton.getSize().height / 2); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
167 |
robot.waitForIdle(delay); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
168 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
169 |
robot.waitForIdle(delay); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
170 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
171 |
robot.waitForIdle(delay); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
172 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
173 |
eventType1 = -1; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
174 |
eventType = -1; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
175 |
eventType2 = -1; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
176 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
177 |
robot.mouseMove(button.getLocationOnScreen().x + button.getSize().width / 2, |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
178 |
button.getLocationOnScreen().y + button.getSize().height / 2); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
179 |
robot.waitForIdle(delay); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
180 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
181 |
robot.waitForIdle(delay); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
182 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
183 |
robot.waitForIdle(delay * 10); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
184 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
185 |
if (eventType2 != WindowEvent.WINDOW_CLOSED) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
186 |
synchronized (lock3) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
187 |
try { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
188 |
lock3.wait(delay * 10); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
189 |
} catch (Exception e) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
190 |
e.printStackTrace(); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
191 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
192 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
193 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
194 |
if (eventType2 != WindowEvent.WINDOW_CLOSED) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
195 |
passed = false; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
196 |
System.err.println("WINDOW_CLOSED event did not occur when the " + |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
197 |
"undecorated frame is closed!"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
198 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
199 |
if (eventType == WindowEvent.WINDOW_ACTIVATED) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
200 |
passed = false; |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
201 |
System.err.println("WINDOW_ACTIVATED event occured when the " + |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
202 |
"undecorated frame is closed!"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
203 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
204 |
|
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
205 |
if (!passed) { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
206 |
System.err.println("Test failed!"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
207 |
throw new RuntimeException("Test failed"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
208 |
} else { |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
209 |
System.out.println("Test passed"); |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
210 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
211 |
} |
68c0e8209883
8053657: [TEST_BUG] move some 5 tests related to undecorated Frame/JFrame to JDK
yan
parents:
diff
changeset
|
212 |
} |