author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 36511 | 9d0388c6b336 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
36511
diff
changeset
|
2 |
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. |
2 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
@test |
|
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
36511
diff
changeset
|
26 |
@key headful |
2 | 27 |
@bug 6359129 |
28 |
@summary REGRESSION: Popup menus dont respond to selections when extend outside Applet |
|
29 |
@author oleg.sukhodolsky area=awt.grab |
|
31660
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
28087
diff
changeset
|
30 |
@modules java.desktop/java.awt.peer |
1a4e2e5c15e1
8130125: [TEST_BUG] add @modules to the several client tests unaffected by the automated bulk update
yan
parents:
28087
diff
changeset
|
31 |
java.desktop/sun.awt |
36511 | 32 |
@library /java/awt/patchlib ../../regtesthelpers |
33 |
@build java.desktop/java.awt.Helper |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
34 |
@build Util UtilInternal |
2 | 35 |
@run main EmbeddedFrameTest1 |
36 |
*/ |
|
37 |
||
38 |
/** |
|
39 |
* EmbeddedFrameTest1.java |
|
40 |
* |
|
41 |
* summary: REGRESSION: Popup menus dont respond to selections when extend outside Applet |
|
42 |
*/ |
|
43 |
||
44 |
import java.awt.BorderLayout; |
|
45 |
import java.awt.Dialog; |
|
46 |
import java.awt.Frame; |
|
47 |
import java.awt.Panel; |
|
48 |
import java.awt.Robot; |
|
49 |
import java.awt.TextArea; |
|
50 |
import java.awt.Toolkit; |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
51 |
import java.awt.AWTException; |
2 | 52 |
|
53 |
import java.awt.event.ActionEvent; |
|
54 |
import java.awt.event.ActionListener; |
|
55 |
||
56 |
import javax.swing.JButton; |
|
57 |
import javax.swing.JPopupMenu; |
|
58 |
||
59 |
import test.java.awt.regtesthelpers.Util; |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
60 |
import test.java.awt.regtesthelpers.UtilInternal; |
2 | 61 |
|
62 |
public class EmbeddedFrameTest1 |
|
63 |
{ |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
64 |
public static void main( String args[] ) throws AWTException |
2 | 65 |
{ |
66 |
try { |
|
67 |
final Frame frame = new Frame("AWT Frame"); |
|
68 |
frame.pack(); |
|
69 |
frame.setSize(200,200); |
|
70 |
||
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
71 |
final Frame embedded_frame = UtilInternal.createEmbeddedFrame(frame); |
2 | 72 |
embedded_frame.setSize(200, 200); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
73 |
System.out.println("embedded_frame = " + embedded_frame); |
2 | 74 |
|
75 |
final JPopupMenu menu = new JPopupMenu(); |
|
76 |
JButton item = new JButton("A button in popup"); |
|
77 |
item.addActionListener(new ActionListener() { |
|
78 |
public void actionPerformed(ActionEvent e) { |
|
79 |
System.out.println("Button pressed"); |
|
80 |
} |
|
81 |
}); |
|
82 |
||
83 |
menu.add(item); |
|
84 |
||
85 |
final JButton btn = new JButton("Press me to see popup"); |
|
86 |
btn.addActionListener(new ActionListener() { |
|
87 |
public void actionPerformed(ActionEvent e) { |
|
88 |
menu.show(btn, 0, btn.getHeight()); |
|
89 |
} |
|
90 |
}); |
|
91 |
final Panel p = new Panel(); |
|
92 |
p.setLayout(new BorderLayout()); |
|
93 |
embedded_frame.add(p,BorderLayout.CENTER); |
|
94 |
embedded_frame.validate(); |
|
95 |
p.add(btn); |
|
96 |
p.validate(); |
|
97 |
frame.setVisible(true); |
|
98 |
Robot robot = new Robot(); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
99 |
robot.waitForIdle(); |
2 | 100 |
Util.clickOnComp(btn, robot); |
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
101 |
robot.waitForIdle(); |
2 | 102 |
|
103 |
Util.clickOnComp(item, robot); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
104 |
robot.waitForIdle(); |
2 | 105 |
if (item.getMousePosition() == null) { |
106 |
throw new RuntimeException("Popup was not closed (mouse above it)"); |
|
107 |
} |
|
108 |
embedded_frame.remove(p); |
|
109 |
embedded_frame.dispose(); |
|
110 |
frame.dispose(); |
|
111 |
} catch (Throwable thr) { |
|
112 |
thr.printStackTrace(); |
|
28087
622b2f420bc3
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents:
5506
diff
changeset
|
113 |
throw new RuntimeException("TEST FAILED: " + thr); |
2 | 114 |
} |
115 |
} |
|
116 |
} |