author | serb |
Wed, 27 Feb 2019 18:46:55 -0800 | |
changeset 54231 | e4813eded7cb |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
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. |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
4 |
* |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
8 |
* |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
13 |
* accompanied this code). |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
14 |
* |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
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. |
|
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
22 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
23 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
24 |
/* |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
25 |
@test |
39056
d99e63b6d962
8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents:
5506
diff
changeset
|
26 |
@key headful |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
27 |
@bug 6785058 |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
28 |
@summary Tests that an owner is activated on closing its owned dialog with the warning icon. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
29 |
@library ../../regtesthelpers |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
30 |
@build Util |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
31 |
@run main/othervm/policy=java.policy -Djava.security.manager CloseDialogActivateOwnerTest |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
32 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
33 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
34 |
import java.awt.*; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
35 |
import test.java.awt.regtesthelpers.Util; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
36 |
|
54231
e4813eded7cb
8213110: Remove the use of applets in automatic tests
serb
parents:
47216
diff
changeset
|
37 |
public class CloseDialogActivateOwnerTest { |
2472
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
38 |
Robot robot; |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
39 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
40 |
public static void main(String[] args) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
41 |
CloseDialogActivateOwnerTest app = new CloseDialogActivateOwnerTest(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
42 |
app.init(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
43 |
app.start(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
44 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
45 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
46 |
public void init() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
47 |
robot = Util.createRobot(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
48 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
49 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
50 |
public void start() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
51 |
final Frame frame = new Frame("Owner Frame"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
52 |
final Dialog dialog = new Dialog(frame, "Owned Dialog"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
53 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
54 |
frame.setSize(100, 100); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
55 |
dialog.setSize(100, 100); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
56 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
57 |
// Show the owner. Check that it's focused. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
58 |
if (!Util.trackWindowGainedFocus(frame, new Runnable() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
59 |
public void run() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
60 |
frame.setVisible(true); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
61 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
62 |
}, 2000, false)) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
63 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
64 |
throw new TestErrorException("the owner frame hasn't been activated on show"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
65 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
66 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
67 |
// Show the owned dialog. Check that it's focused. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
68 |
if (!Util.trackWindowGainedFocus(dialog, new Runnable() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
69 |
public void run() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
70 |
dialog.setVisible(true); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
71 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
72 |
}, 2000, true)) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
73 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
74 |
throw new TestErrorException("the owned dialog hasn't been activated on show"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
75 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
76 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
77 |
robot.delay(2000); // wait for the warning icon is shown |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
78 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
79 |
// Close the dialog. Check that the owner is activated. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
80 |
if (!Util.trackWindowGainedFocus(frame, new Runnable() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
81 |
public void run() { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
82 |
dialog.dispose(); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
83 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
84 |
}, 2000, false)) |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
85 |
{ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
86 |
throw new TestFailedException("the owner hasn't been activated on closing the owned dialog"); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
87 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
88 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
89 |
System.out.println("Test passed."); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
90 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
91 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
92 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
93 |
/** |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
94 |
* Thrown when the behavior being verified is found wrong. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
95 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
96 |
class TestFailedException extends RuntimeException { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
97 |
TestFailedException(String msg) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
98 |
super("Test failed: " + msg); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
99 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
100 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
101 |
|
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
102 |
/** |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
103 |
* Thrown when an error not related to the behavior being verified is encountered. |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
104 |
*/ |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
105 |
class TestErrorException extends Error { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
106 |
TestErrorException(String msg) { |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
107 |
super("Unexpected error: " + msg); |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
108 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
109 |
} |
b7aba00cabb6
6693253: Security Warning appearance requires enhancements
anthony
parents:
diff
changeset
|
110 |