author | goetz |
Tue, 14 Jun 2016 10:44:59 +0200 | |
changeset 39056 | d99e63b6d962 |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
1 |
/* |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
4 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
8 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
13 |
* accompanied this code). |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
14 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
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. |
|
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
22 |
*/ |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
23 |
|
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
24 |
/* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
25 |
@test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
5506
diff
changeset
|
26 |
@key headful |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
27 |
@bug 4452384 |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
28 |
@summary Tests that non-focusable windows doesn't generate any focus events when accessed. |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
29 |
@author Denis.Mikhalkin: area=awt.focus |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
30 |
@run main NoEventsTest |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
31 |
*/ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
32 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
33 |
import java.awt.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
34 |
import java.awt.event.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
35 |
import java.util.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
36 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
37 |
public class NoEventsTest extends Frame { |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
38 |
public static final int DEF_WIDTH = 400, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
39 |
DEF_HEIGHT = 300, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
40 |
DEF_TOP = 1, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
41 |
DEF_LEFT = 100, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
42 |
DEF_ROW = 0, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
43 |
DEF_COL = 0; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
44 |
static boolean automatic = true; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
45 |
static Window[] windows; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
46 |
static Frame main_frame, jumpingFrame; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
47 |
static Button focus_button; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
48 |
static Robot robot; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
49 |
static void pause(int timeout) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
50 |
Toolkit.getDefaultToolkit().sync(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
51 |
robot.waitForIdle(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
52 |
robot.delay(100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
53 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
54 |
static GlobalListener listener; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
55 |
public static void main(String[] args) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
56 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
57 |
listener = new GlobalListener(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
58 |
Toolkit.getDefaultToolkit().addAWTEventListener(listener, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
59 |
AWTEvent.FOCUS_EVENT_MASK | |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
60 |
AWTEvent.WINDOW_EVENT_MASK); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
61 |
try{ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
62 |
robot = new Robot(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
63 |
} catch(Exception e) {} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
64 |
// Create several pairs - focusable Frame with focusable component(button) and non-focusable: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
65 |
// window, resizable frame, non-resizable frame, dialog, non-resiable dialog |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
66 |
main_frame = new Frame("focusable frame"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
67 |
focus_button = new Button("button to focus"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
68 |
main_frame.add(focus_button); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
69 |
main_frame.pack(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
70 |
main_frame.setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
71 |
main_frame.setLocation(10, 600); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
72 |
main_frame.addWindowListener(new WindowAdapter() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
73 |
public void windowClosing(WindowEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
74 |
listener.report(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
75 |
System.exit(0); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
76 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
77 |
}); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
78 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
79 |
jumpingFrame = new Frame("Jumping frame"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
80 |
jumpingFrame.setBounds(DEF_LEFT, DEF_TOP, DEF_WIDTH, DEF_HEIGHT); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
81 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
82 |
windows = new Window[7]; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
83 |
windows[0] = new TestWindow(0, 0, false, main_frame); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
84 |
//windows[1] = new TestWindow(2, 1, true, main_frame); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
85 |
windows[2] = new NoEventsTest(1, 0, false, true); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
86 |
windows[3] = new NoEventsTest(2, 0, false, false); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
87 |
//windows[4] = new Test(3, 0, true, true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
88 |
windows[5] = new TestDialog(0, 1, false, true, main_frame); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
89 |
windows[6] = new TestDialog(1, 1, false, false, main_frame); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
90 |
if (!automatic) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
91 |
int windowInd; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
92 |
for (windowInd = 0; windowInd < windows.length; windowInd++) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
93 |
if (windows[windowInd] != null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
94 |
windows[windowInd].setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
95 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
96 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
97 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
98 |
// Run the test |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
99 |
// 1. Click on all controls, check for no focus events for non-focusable, right focus events for focusable |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
100 |
// 2. Perform some action with control, check if it works |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
101 |
if (automatic) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
102 |
int windowInd; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
103 |
for (windowInd = 0; windowInd < windows.length; windowInd++) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
104 |
if (windows[windowInd] != null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
105 |
windows[windowInd].setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
106 |
focus_button.requestFocus(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
107 |
pause(1000); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
108 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
109 |
// Verify that click on non-focusable window causes no focus lost on active window |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
110 |
performFocusClick(windows[windowInd]); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
111 |
focus_button.requestFocus(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
112 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
113 |
performActionClick(windows[windowInd]); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
114 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
115 |
// Verify that toFront, toBack doesn't cause non-focusable window to become active |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
116 |
jumpingFrame.setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
117 |
pause(1000); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
118 |
jumpingFrame.toBack(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
119 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
120 |
jumpingFrame.toFront(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
121 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
122 |
windows[windowInd].toBack(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
123 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
124 |
windows[windowInd].toFront(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
125 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
126 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
127 |
// Verify that iconifiyng/deiconfiying and |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
128 |
// zooming/unzooming doesn't cause non-focusable |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
129 |
// window to become active |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
130 |
if (windows[windowInd] instanceof Frame) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
131 |
Frame toTest = (Frame)windows[windowInd]; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
132 |
// Deiconification currently doesn't work! |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
133 |
// toTest.setExtendedState(Frame.ICONIFIED); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
134 |
// pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
135 |
// toTest.setExtendedState(Frame.NORMAL); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
136 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
137 |
toTest.setExtendedState(Frame.MAXIMIZED_BOTH); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
138 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
139 |
toTest.setExtendedState(Frame.NORMAL); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
140 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
141 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
142 |
windows[windowInd].dispose(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
143 |
jumpingFrame.dispose(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
144 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
145 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
146 |
pause(1000); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
147 |
System.err.println("Test finished."); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
148 |
if (!listener.report()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
149 |
throw new RuntimeException("Test Failed. See error stream output for details"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
150 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
151 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
152 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
153 |
static void performFocusClick(Window parent) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
154 |
if (parent == null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
155 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
156 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
157 |
for (int compInd = 0; compInd < parent.getComponentCount(); compInd++) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
158 |
Component child = parent.getComponent(compInd); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
159 |
if (child instanceof TestPanel) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
160 |
TestPanel pan = (TestPanel)child; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
161 |
pan.performFocusClicks(robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
162 |
pause(100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
163 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
164 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
165 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
166 |
static void performActionClick(Window parent) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
167 |
if (parent == null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
168 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
169 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
170 |
for (int compInd = 0; compInd < parent.getComponentCount(); compInd++) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
171 |
Component child = parent.getComponent(compInd); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
172 |
if (child instanceof TestPanel) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
173 |
TestPanel pan = (TestPanel)child; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
174 |
pan.performActionClicks(robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
175 |
pause(100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
176 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
177 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
178 |
} |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
179 |
public NoEventsTest(int row, int col, boolean focusable, boolean resizable) { |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
180 |
super("Frame" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
181 |
TestPanel panel = new TestPanel(row, col); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
182 |
if (NoEventsTest.automatic) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
183 |
row = NoEventsTest.DEF_ROW; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
184 |
col = NoEventsTest.DEF_COL; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
185 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
186 |
setName(getTitle()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
187 |
add("Center", panel); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
188 |
Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") + |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
189 |
", " + (resizable?"resizable":"non-resizable")); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
190 |
l.setBackground(Color.green); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
191 |
add("North", l); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
192 |
setBounds(NoEventsTest.DEF_LEFT + DEF_WIDTH*col, DEF_TOP + DEF_HEIGHT*row, DEF_WIDTH, DEF_HEIGHT); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
193 |
if (!focusable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
194 |
setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
195 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
196 |
if (!resizable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
197 |
setResizable(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
198 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
199 |
// setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
200 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
201 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
202 |
class TestWindow extends Window { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
203 |
public TestWindow(int row, int col, boolean focusable, Frame owner) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
204 |
super(owner); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
205 |
setName("Window" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
206 |
TestPanel panel = new TestPanel(row, col); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
207 |
if (NoEventsTest.automatic) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
208 |
row = NoEventsTest.DEF_ROW; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
209 |
col = NoEventsTest.DEF_COL; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
210 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
211 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
212 |
add("Center", panel); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
213 |
Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") + |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
214 |
", " + (false?"resizable":"non-resizable")); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
215 |
l.setBackground(Color.green); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
216 |
add("North", l); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
217 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
218 |
setBounds(NoEventsTest.DEF_LEFT + NoEventsTest.DEF_WIDTH*col, NoEventsTest.DEF_TOP + NoEventsTest.DEF_HEIGHT*row, NoEventsTest.DEF_WIDTH, NoEventsTest.DEF_HEIGHT); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
219 |
if (!focusable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
220 |
setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
221 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
222 |
// setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
223 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
224 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
225 |
class TestDialog extends Dialog { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
226 |
public TestDialog(int row, int col, boolean focusable, boolean resizable, Frame owner) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
227 |
super(owner); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
228 |
setName("Dialog" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
229 |
TestPanel panel = new TestPanel(row, col); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
230 |
if (NoEventsTest.automatic) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
231 |
row = NoEventsTest.DEF_ROW; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
232 |
col = NoEventsTest.DEF_COL; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
233 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
234 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
235 |
add("Center", panel); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
236 |
Label l = new Label(getClass().getSuperclass().getName() + ", " + (focusable?"focusable":"non-focusable") + |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
237 |
", " + (resizable?"resizable":"non-resizable")); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
238 |
l.setBackground(Color.green); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
239 |
add("North", l); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
240 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
241 |
setBounds(NoEventsTest.DEF_LEFT + NoEventsTest.DEF_WIDTH*col, NoEventsTest.DEF_TOP + NoEventsTest.DEF_HEIGHT*row, NoEventsTest.DEF_WIDTH, NoEventsTest.DEF_HEIGHT); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
242 |
if (!focusable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
243 |
setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
244 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
245 |
if (!resizable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
246 |
setResizable(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
247 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
248 |
// setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
249 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
250 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
251 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
252 |
class TestPanel extends Panel { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
253 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
254 |
void clickComponent(Component comp, Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
255 |
if (comp instanceof Choice) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
256 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
257 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
258 |
Point compLoc = comp.getLocationOnScreen(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
259 |
Dimension size = comp.getSize(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
260 |
robot.mouseMove(compLoc.x + size.width/2, compLoc.y + size.height/2); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
261 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
262 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
263 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
264 |
void performFocusClicks(Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
265 |
for (int childInd = 0; childInd < getComponentCount(); childInd++) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
266 |
performFocusClick(getComponent(childInd), robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
267 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
268 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
269 |
void performFocusClick(Component comp, Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
270 |
clickComponent(comp, robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
271 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
272 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
273 |
void performActionClicks(Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
274 |
for (int childInd = 0; childInd < getComponentCount(); childInd++) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
275 |
performActionClick(getComponent(childInd), robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
276 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
277 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
278 |
void performActionClick(Component comp, Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
279 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
280 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
281 |
public TestPanel(int row, int col) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
282 |
setLayout(new FlowLayout()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
283 |
Button b; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
284 |
add(b = new Button("press"+ row + "" + col)); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
285 |
b.setName(b.getLabel()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
286 |
// b.addMouseListener(new MouseAdapter() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
287 |
// public void mousePressed(MouseEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
288 |
// System.err.println(e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
289 |
// } |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
290 |
// }); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
291 |
TextField t; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
292 |
add(t = new TextField("text" + row + "" + col)); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
293 |
t.setName(t.getText()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
294 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
295 |
java.awt.List list = new java.awt.List(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
296 |
add(list); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
297 |
list.setName("list"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
298 |
list.add("one"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
299 |
list.add("two"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
300 |
list.add("three"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
301 |
list.setMultipleMode(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
302 |
list.setName("list" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
303 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
304 |
Checkbox check = new Checkbox("checker"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
305 |
add(check); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
306 |
check.setName("check" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
307 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
308 |
Choice choice = new Choice(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
309 |
choice.add("one"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
310 |
choice.add("two"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
311 |
choice.add("three"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
312 |
add(choice); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
313 |
choice.setName("choice" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
314 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
315 |
Canvas can = new Canvas() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
316 |
public Dimension getPreferredSize() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
317 |
return new Dimension(10, 10); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
318 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
319 |
}; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
320 |
can.setBackground(Color.blue); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
321 |
add(can); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
322 |
can.setName("canvas" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
323 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
324 |
TextArea ta = new TextArea("text\ntttt\naaaa\nwwwww\nqqqqqq\neeeeee\nrrrrrr\nyyyyyy\nuuuuu", 3, 5); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
325 |
add(ta); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
326 |
ta.setName("textarea" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
327 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
328 |
Scrollbar bar = new Scrollbar(Scrollbar.HORIZONTAL); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
329 |
add(bar); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
330 |
bar.setName("scrollbar" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
331 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
332 |
CheckboxGroup group = new CheckboxGroup(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
333 |
Checkbox ch1 = new Checkbox("one", group, true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
334 |
Checkbox ch2 = new Checkbox("two", group, false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
335 |
add(ch1); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
336 |
add(ch2); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
337 |
ch1.setName("checkbox1 " + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
338 |
ch2.setName("checkbox2 " + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
339 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
340 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
341 |
ScrollPane pane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
342 |
add(pane); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
343 |
Button bigButton = new Button("abc") { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
344 |
public Dimension getPreferredSize() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
345 |
return new Dimension(100, 100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
346 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
347 |
}; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
348 |
pane.add(bigButton); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
349 |
bigButton.setName("bigbutton" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
350 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
351 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
352 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
353 |
class GlobalListener implements AWTEventListener { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
354 |
java.util.List errors = new java.util.LinkedList(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
355 |
public boolean report() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
356 |
if (errors.size() != 0) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
357 |
System.err.println("Test FAILED"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
358 |
} else { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
359 |
System.err.println("Test PASSED"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
360 |
return true; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
361 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
362 |
ListIterator iter = errors.listIterator(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
363 |
while (iter.hasNext()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
364 |
System.err.println(iter.next()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
365 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
366 |
return false; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
367 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
368 |
public GlobalListener() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
369 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
370 |
Window getWindowParent(Component comp) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
371 |
while (comp != null && !(comp instanceof Window)) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
372 |
comp = comp.getParent(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
373 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
374 |
return (Window)comp; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
375 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
376 |
void reportError(AWTEvent e, String message) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
377 |
String error = "ERROR: " + message + " : " + e; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
378 |
errors.add(error); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
379 |
System.err.println(error); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
380 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
381 |
public void eventDispatched(AWTEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
382 |
Component comp = (Component)e.getSource(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
383 |
Window parent = getWindowParent(comp); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
384 |
if (!(e instanceof WindowEvent || e instanceof FocusEvent)) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
385 |
System.err.println("Strange event " + e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
386 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
387 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
388 |
// Skip WINDOW_OPENED |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
389 |
if (e.getID() == WindowEvent.WINDOW_CLOSING) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
390 |
System.err.println(e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
391 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
392 |
switch (e.getID()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
393 |
case WindowEvent.WINDOW_OPENED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
394 |
case WindowEvent.WINDOW_CLOSING: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
395 |
case WindowEvent.WINDOW_CLOSED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
396 |
case WindowEvent.WINDOW_ICONIFIED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
397 |
case WindowEvent.WINDOW_DEICONIFIED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
398 |
case WindowEvent.WINDOW_STATE_CHANGED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
399 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
400 |
case WindowEvent.WINDOW_LOST_FOCUS: { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
401 |
WindowEvent we = (WindowEvent)e; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
402 |
if (we.getOppositeWindow() != null && !we.getOppositeWindow().getFocusableWindowState()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
403 |
reportError(e, "frame lost focus because of non-focusable window"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
404 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
405 |
break; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
406 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
407 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
408 |
// Check that Window owner is focusable |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
409 |
if (!parent.getFocusableWindowState()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
410 |
reportError(e, "focus event for component in non-focusable window " + parent.getName()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
411 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
412 |
if (!comp.isFocusable()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
413 |
reportError(e, "focus event for non-focusable component"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
414 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
415 |
// if (e instanceof WindowEvent || e instanceof FocusEvent) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
416 |
// // System.err.println(e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
417 |
// } |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
418 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
419 |
} |