author | serb |
Tue, 12 Nov 2013 20:24:25 +0400 | |
changeset 21596 | 0e3a39f29dbc |
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 |
/* |
5506 | 2 |
* Copyright (c) 2008, 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 |
*/ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
23 |
|
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 |
424
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
26 |
@bug 4041703 4096228 4025223 4260929 |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
27 |
@summary Ensures that appletviewer sets a reasonable default focus for an Applet on start |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
28 |
@author das area=appletviewer |
424
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
29 |
@run applet AppletInitialFocusTest.html |
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.applet.Applet; |
424
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
33 |
import java.awt.Button; |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
34 |
import java.awt.Component; |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
35 |
import java.awt.Robot; |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
36 |
import java.awt.Window; |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
37 |
import test.java.awt.regtesthelpers.Util; |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
38 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
39 |
public class AppletInitialFocusTest extends Applet { |
424
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
40 |
Robot robot = Util.createRobot(); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
41 |
Button button = new Button("Button"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
42 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
43 |
public void init() { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
44 |
add(button); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
45 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
46 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
47 |
public void start() { |
424
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
48 |
new Thread(new Runnable() { |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
49 |
public void run() { |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
50 |
Util.waitTillShown(button); |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
51 |
robot.delay(1000); // delay the thread to let EDT to start dispatching focus events |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
52 |
Util.waitForIdle(robot); |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
53 |
if (!button.hasFocus()) { |
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
54 |
throw new RuntimeException("Appletviewer doesn't set default focus correctly."); |
423
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 |
} |
424
c090ad2f18f2
6609607: test/closed/java/awt/Focus/AppletInitialFocusTest should be rewritten
ant
parents:
423
diff
changeset
|
57 |
}).start(); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
58 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
59 |
} |