author | serb |
Wed, 27 Feb 2019 18:46:55 -0800 | |
changeset 54231 | e4813eded7cb |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
1 |
/* |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. |
21596 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
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. |
|
22 |
*/ |
|
423
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 |
import java.awt.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
25 |
import java.awt.event.*; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
26 |
|
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
27 |
/* |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
28 |
@test |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
29 |
@key headful |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
30 |
@bug 4411534 4517274 |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
31 |
@summary ensures that user's requestFocus() during applet initialization |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
32 |
is not ignored |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
33 |
@library ../../regtesthelpers |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
34 |
@build Util |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
35 |
@run main AppletInitialFocusTest1 |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
36 |
*/ |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
37 |
public class AppletInitialFocusTest1 extends Frame implements FocusListener { |
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 |
Button button1 = new Button("Button1"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
40 |
Button button2 = new Button("Button2"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
41 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
42 |
Object lock = new Object(); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
43 |
|
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
44 |
public static void main(final String[] args) throws Exception { |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
45 |
AppletInitialFocusTest1 app = new AppletInitialFocusTest1(); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
46 |
app.init(); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
47 |
Thread.sleep(10000); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
48 |
} |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
49 |
|
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
50 |
public void init() { |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
51 |
setSize(200, 200); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
52 |
setLocationRelativeTo(null); |
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
53 |
setLayout(new FlowLayout()); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
54 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
55 |
Component parent = this; |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
56 |
while (parent != null && !(parent instanceof Window)) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
57 |
parent = parent.getParent(); |
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 |
/* |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
60 |
* This applet is designed to be run only with appletviewer, |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
61 |
* so there always should be a toplevel frame. |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
62 |
*/ |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
63 |
if (parent == null) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
64 |
synchronized (lock) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
65 |
System.err.println("appletviewer not running"); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
66 |
System.exit(3); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
67 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
68 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
69 |
button1.addFocusListener(this); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
70 |
button2.addFocusListener(this); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
71 |
add(button1); |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
72 |
add(button2); |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
73 |
setVisible(true); |
423
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
74 |
button2.requestFocus(); |
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 |
public void focusGained(FocusEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
78 |
if (e.getSource() == button1) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
79 |
synchronized (lock) { |
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
80 |
throw new RuntimeException("failed: focus on the wrong button"); |
423
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 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
83 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
84 |
|
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
85 |
public void focusLost(FocusEvent e) { |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
86 |
} |
1c607ab74068
6680135: A number of test/closed/java/awt/Focus/* tests should be opened
ant
parents:
diff
changeset
|
87 |
} |