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