author | herrick |
Fri, 12 Jun 2009 14:56:32 -0400 | |
changeset 3111 | fefdeafb7ab9 |
parent 425 | 89b44fab010f |
child 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 |
/* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
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 |
* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
21 |
* have any questions. |
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 |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
26 |
@bug 4452384 |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
27 |
@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
|
28 |
@author Denis.Mikhalkin: area=awt.focus |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
29 |
@run main NoEventsTest |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
30 |
*/ |
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 |
import java.awt.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
33 |
import java.awt.event.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
34 |
import java.util.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
35 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
36 |
public class NoEventsTest extends Frame { |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
37 |
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
|
38 |
DEF_HEIGHT = 300, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
39 |
DEF_TOP = 1, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
40 |
DEF_LEFT = 100, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
41 |
DEF_ROW = 0, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
42 |
DEF_COL = 0; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
43 |
static boolean automatic = true; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
44 |
static Window[] windows; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
45 |
static Frame main_frame, jumpingFrame; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
46 |
static Button focus_button; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
47 |
static Robot robot; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
48 |
static void pause(int timeout) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
49 |
Toolkit.getDefaultToolkit().sync(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
50 |
robot.waitForIdle(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
51 |
robot.delay(100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
52 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
53 |
static GlobalListener listener; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
54 |
public static void main(String[] args) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
55 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
56 |
listener = new GlobalListener(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
57 |
Toolkit.getDefaultToolkit().addAWTEventListener(listener, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
58 |
AWTEvent.FOCUS_EVENT_MASK | |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
59 |
AWTEvent.WINDOW_EVENT_MASK); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
60 |
try{ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
61 |
robot = new Robot(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
62 |
} catch(Exception e) {} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
63 |
// 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
|
64 |
// 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
|
65 |
main_frame = new Frame("focusable frame"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
66 |
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
|
67 |
main_frame.add(focus_button); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
68 |
main_frame.pack(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
69 |
main_frame.setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
70 |
main_frame.setLocation(10, 600); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
71 |
main_frame.addWindowListener(new WindowAdapter() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
72 |
public void windowClosing(WindowEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
73 |
listener.report(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
74 |
System.exit(0); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
75 |
} |
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 |
jumpingFrame = new Frame("Jumping frame"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
79 |
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
|
80 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
81 |
windows = new Window[7]; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
82 |
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
|
83 |
//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
|
84 |
windows[2] = new NoEventsTest(1, 0, false, true); |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
85 |
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
|
86 |
//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
|
87 |
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
|
88 |
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
|
89 |
if (!automatic) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
90 |
int windowInd; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
91 |
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
|
92 |
if (windows[windowInd] != null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
93 |
windows[windowInd].setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
94 |
} |
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 |
// Run the test |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
98 |
// 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
|
99 |
// 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
|
100 |
if (automatic) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
101 |
int windowInd; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
102 |
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
|
103 |
if (windows[windowInd] != null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
104 |
windows[windowInd].setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
105 |
focus_button.requestFocus(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
106 |
pause(1000); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
107 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
108 |
// 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
|
109 |
performFocusClick(windows[windowInd]); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
110 |
focus_button.requestFocus(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
111 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
112 |
performActionClick(windows[windowInd]); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
113 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
114 |
// 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
|
115 |
jumpingFrame.setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
116 |
pause(1000); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
117 |
jumpingFrame.toBack(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
118 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
119 |
jumpingFrame.toFront(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
120 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
121 |
windows[windowInd].toBack(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
122 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
123 |
windows[windowInd].toFront(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
124 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
125 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
126 |
// Verify that iconifiyng/deiconfiying and |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
127 |
// 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
|
128 |
// window to become active |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
129 |
if (windows[windowInd] instanceof Frame) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
130 |
Frame toTest = (Frame)windows[windowInd]; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
131 |
// Deiconification currently doesn't work! |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
132 |
// toTest.setExtendedState(Frame.ICONIFIED); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
133 |
// pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
134 |
// toTest.setExtendedState(Frame.NORMAL); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
135 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
136 |
toTest.setExtendedState(Frame.MAXIMIZED_BOTH); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
137 |
pause(500); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
138 |
toTest.setExtendedState(Frame.NORMAL); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
139 |
} |
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 |
windows[windowInd].dispose(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
142 |
jumpingFrame.dispose(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
143 |
} |
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 |
pause(1000); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
146 |
System.err.println("Test finished."); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
147 |
if (!listener.report()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
148 |
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
|
149 |
} |
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 |
static void performFocusClick(Window parent) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
153 |
if (parent == null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
154 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
155 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
156 |
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
|
157 |
Component child = parent.getComponent(compInd); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
158 |
if (child instanceof TestPanel) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
159 |
TestPanel pan = (TestPanel)child; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
160 |
pan.performFocusClicks(robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
161 |
pause(100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
162 |
} |
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 |
static void performActionClick(Window parent) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
166 |
if (parent == null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
167 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
168 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
169 |
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
|
170 |
Component child = parent.getComponent(compInd); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
171 |
if (child instanceof TestPanel) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
172 |
TestPanel pan = (TestPanel)child; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
173 |
pan.performActionClicks(robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
174 |
pause(100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
175 |
} |
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 |
} |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
178 |
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
|
179 |
super("Frame" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
180 |
TestPanel panel = new TestPanel(row, col); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
181 |
if (NoEventsTest.automatic) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
182 |
row = NoEventsTest.DEF_ROW; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
183 |
col = NoEventsTest.DEF_COL; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
184 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
185 |
setName(getTitle()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
186 |
add("Center", panel); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
187 |
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
|
188 |
", " + (resizable?"resizable":"non-resizable")); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
189 |
l.setBackground(Color.green); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
190 |
add("North", l); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
191 |
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
|
192 |
if (!focusable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
193 |
setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
194 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
195 |
if (!resizable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
196 |
setResizable(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
197 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
198 |
// setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
199 |
} |
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 |
class TestWindow extends Window { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
202 |
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
|
203 |
super(owner); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
204 |
setName("Window" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
205 |
TestPanel panel = new TestPanel(row, col); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
206 |
if (NoEventsTest.automatic) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
207 |
row = NoEventsTest.DEF_ROW; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
208 |
col = NoEventsTest.DEF_COL; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
209 |
} |
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 |
add("Center", panel); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
212 |
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
|
213 |
", " + (false?"resizable":"non-resizable")); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
214 |
l.setBackground(Color.green); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
215 |
add("North", l); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
216 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
217 |
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
|
218 |
if (!focusable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
219 |
setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
220 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
221 |
// setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
222 |
} |
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 |
class TestDialog extends Dialog { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
225 |
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
|
226 |
super(owner); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
227 |
setName("Dialog" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
228 |
TestPanel panel = new TestPanel(row, col); |
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
229 |
if (NoEventsTest.automatic) { |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
230 |
row = NoEventsTest.DEF_ROW; |
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
231 |
col = NoEventsTest.DEF_COL; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
232 |
} |
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 |
add("Center", panel); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
235 |
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
|
236 |
", " + (resizable?"resizable":"non-resizable")); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
237 |
l.setBackground(Color.green); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
238 |
add("North", l); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
239 |
|
425
89b44fab010f
6616792: five AWT focus regression tests should be fixed
ant
parents:
423
diff
changeset
|
240 |
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
|
241 |
if (!focusable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
242 |
setFocusableWindowState(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
243 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
244 |
if (!resizable) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
245 |
setResizable(false); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
246 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
247 |
// setVisible(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
248 |
} |
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 |
class TestPanel extends Panel { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
252 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
253 |
void clickComponent(Component comp, Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
254 |
if (comp instanceof Choice) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
255 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
256 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
257 |
Point compLoc = comp.getLocationOnScreen(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
258 |
Dimension size = comp.getSize(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
259 |
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
|
260 |
robot.mousePress(InputEvent.BUTTON1_MASK); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
261 |
robot.mouseRelease(InputEvent.BUTTON1_MASK); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
262 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
263 |
void performFocusClicks(Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
264 |
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
|
265 |
performFocusClick(getComponent(childInd), robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
266 |
} |
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 |
void performFocusClick(Component comp, Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
269 |
clickComponent(comp, robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
270 |
} |
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 |
void performActionClicks(Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
273 |
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
|
274 |
performActionClick(getComponent(childInd), robot); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
275 |
} |
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 |
void performActionClick(Component comp, Robot robot) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
278 |
} |
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 |
public TestPanel(int row, int col) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
281 |
setLayout(new FlowLayout()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
282 |
Button b; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
283 |
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
|
284 |
b.setName(b.getLabel()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
285 |
// b.addMouseListener(new MouseAdapter() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
286 |
// public void mousePressed(MouseEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
287 |
// System.err.println(e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
288 |
// } |
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 |
TextField t; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
291 |
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
|
292 |
t.setName(t.getText()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
293 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
294 |
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
|
295 |
add(list); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
296 |
list.setName("list"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
297 |
list.add("one"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
298 |
list.add("two"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
299 |
list.add("three"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
300 |
list.setMultipleMode(true); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
301 |
list.setName("list" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
302 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
303 |
Checkbox check = new Checkbox("checker"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
304 |
add(check); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
305 |
check.setName("check" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
306 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
307 |
Choice choice = new Choice(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
308 |
choice.add("one"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
309 |
choice.add("two"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
310 |
choice.add("three"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
311 |
add(choice); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
312 |
choice.setName("choice" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
313 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
314 |
Canvas can = new Canvas() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
315 |
public Dimension getPreferredSize() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
316 |
return new Dimension(10, 10); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
317 |
} |
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 |
can.setBackground(Color.blue); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
320 |
add(can); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
321 |
can.setName("canvas" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
322 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
323 |
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
|
324 |
add(ta); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
325 |
ta.setName("textarea" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
326 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
327 |
Scrollbar bar = new Scrollbar(Scrollbar.HORIZONTAL); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
328 |
add(bar); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
329 |
bar.setName("scrollbar" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
330 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
331 |
CheckboxGroup group = new CheckboxGroup(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
332 |
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
|
333 |
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
|
334 |
add(ch1); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
335 |
add(ch2); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
336 |
ch1.setName("checkbox1 " + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
337 |
ch2.setName("checkbox2 " + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
338 |
|
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 |
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
|
341 |
add(pane); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
342 |
Button bigButton = new Button("abc") { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
343 |
public Dimension getPreferredSize() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
344 |
return new Dimension(100, 100); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
345 |
} |
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 |
pane.add(bigButton); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
348 |
bigButton.setName("bigbutton" + row + "" + col); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
349 |
} |
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 |
class GlobalListener implements AWTEventListener { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
353 |
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
|
354 |
public boolean report() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
355 |
if (errors.size() != 0) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
356 |
System.err.println("Test FAILED"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
357 |
} else { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
358 |
System.err.println("Test PASSED"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
359 |
return true; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
360 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
361 |
ListIterator iter = errors.listIterator(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
362 |
while (iter.hasNext()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
363 |
System.err.println(iter.next()); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
364 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
365 |
return false; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
366 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
367 |
public GlobalListener() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
368 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
369 |
Window getWindowParent(Component comp) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
370 |
while (comp != null && !(comp instanceof Window)) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
371 |
comp = comp.getParent(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
372 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
373 |
return (Window)comp; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
374 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
375 |
void reportError(AWTEvent e, String message) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
376 |
String error = "ERROR: " + message + " : " + e; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
377 |
errors.add(error); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
378 |
System.err.println(error); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
379 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
380 |
public void eventDispatched(AWTEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
381 |
Component comp = (Component)e.getSource(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
382 |
Window parent = getWindowParent(comp); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
383 |
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
|
384 |
System.err.println("Strange event " + e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
385 |
} |
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 |
// Skip WINDOW_OPENED |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
388 |
if (e.getID() == WindowEvent.WINDOW_CLOSING) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
389 |
System.err.println(e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
390 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
391 |
switch (e.getID()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
392 |
case WindowEvent.WINDOW_OPENED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
393 |
case WindowEvent.WINDOW_CLOSING: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
394 |
case WindowEvent.WINDOW_CLOSED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
395 |
case WindowEvent.WINDOW_ICONIFIED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
396 |
case WindowEvent.WINDOW_DEICONIFIED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
397 |
case WindowEvent.WINDOW_STATE_CHANGED: |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
398 |
return; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
399 |
case WindowEvent.WINDOW_LOST_FOCUS: { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
400 |
WindowEvent we = (WindowEvent)e; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
401 |
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
|
402 |
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
|
403 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
404 |
break; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
405 |
} |
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 |
// Check that Window owner is focusable |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
408 |
if (!parent.getFocusableWindowState()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
409 |
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
|
410 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
411 |
if (!comp.isFocusable()) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
412 |
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
|
413 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
414 |
// 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
|
415 |
// // System.err.println(e); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
416 |
// } |
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 |
} |