author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 31448 | 1066345d2a8a |
permissions | -rw-r--r-- |
4365 | 1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31448
diff
changeset
|
2 |
* Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. |
4365 | 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 |
* |
|
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. |
|
4365 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
@test |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
31448
diff
changeset
|
26 |
@key headful |
4365 | 27 |
@bug 4913324 |
28 |
@author Oleg Sukhodolsky: area=eventqueue |
|
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
7668
diff
changeset
|
29 |
@modules java.desktop/sun.awt |
4365 | 30 |
@run main/timeout=30 PushPopTest |
31 |
*/ |
|
32 |
||
33 |
import java.awt.*; |
|
34 |
import java.awt.event.*; |
|
35 |
import java.util.EmptyStackException; |
|
36 |
import sun.awt.SunToolkit; |
|
37 |
||
38 |
public class PushPopTest { |
|
39 |
||
40 |
public static Frame frame; |
|
41 |
public static void main(String[] args) { |
|
42 |
frame = new Frame(""); |
|
43 |
frame.pack(); |
|
44 |
||
45 |
Runnable dummy = new Runnable() { |
|
46 |
public void run() { |
|
47 |
System.err.println("Dummy is here."); |
|
5942
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
48 |
System.err.flush(); |
4365 | 49 |
} |
50 |
}; |
|
51 |
EventQueue seq = Toolkit.getDefaultToolkit().getSystemEventQueue(); |
|
52 |
MyEventQueue1 eq1 = new MyEventQueue1(); |
|
53 |
MyEventQueue2 eq2 = new MyEventQueue2(); |
|
54 |
EventQueue.invokeLater(dummy); |
|
55 |
||
56 |
seq.push(eq1); |
|
57 |
EventQueue.invokeLater(dummy); |
|
58 |
||
59 |
eq1.push(eq2); |
|
60 |
EventQueue.invokeLater(dummy); |
|
61 |
Runnable runnable = new Runnable() { |
|
62 |
public void run() { |
|
63 |
System.err.println("Dummy from SunToolkit"); |
|
5942
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
64 |
System.err.flush(); |
4365 | 65 |
} |
66 |
}; |
|
67 |
InvocationEvent ie = new InvocationEvent(eq2, runnable, null, false); |
|
5942
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
68 |
// System.err.println(ie); |
4365 | 69 |
SunToolkit.postEvent(SunToolkit.targetToAppContext(frame), ie); |
70 |
eq1.pop(); |
|
71 |
frame.dispose(); |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
class MyEventQueue1 extends EventQueue { |
|
76 |
||
5942
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
77 |
public void pop() { |
4365 | 78 |
super.pop(); |
79 |
} |
|
80 |
} |
|
81 |
||
82 |
class MyEventQueue2 extends EventQueue { |
|
83 |
||
5942
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
84 |
protected void pop() { |
4365 | 85 |
System.err.println("pop2()"); |
86 |
Thread.dumpStack(); |
|
87 |
try { |
|
88 |
EventQueue.invokeAndWait(new Runnable() { |
|
89 |
public void run() { |
|
90 |
Runnable runnable = new Runnable() { |
|
91 |
public void run() { |
|
5942
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
92 |
System.err.println("Dummy from pop"); |
287c421fb9b2
6424157: java.awt.EventQueue push/pop might cause threading issues
art
parents:
5506
diff
changeset
|
93 |
System.err.flush(); |
4365 | 94 |
} |
95 |
}; |
|
96 |
InvocationEvent ie = new InvocationEvent(MyEventQueue2.this, runnable, null, false); |
|
97 |
SunToolkit.postEvent(SunToolkit.targetToAppContext(PushPopTest.frame), ie); |
|
98 |
postEvent(ie); |
|
99 |
} |
|
100 |
}); |
|
101 |
} catch (InterruptedException ie) { |
|
102 |
ie.printStackTrace(); |
|
103 |
} catch (java.lang.reflect.InvocationTargetException ie) { |
|
104 |
ie.printStackTrace(); |
|
105 |
} |
|
106 |
super.pop(); |
|
107 |
} |
|
108 |
} |