Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Modal/ToFront/DialogToFrontModelessTest.java
41153 views
1
/*
2
* Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
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
*/
23
24
import java.awt.*;
25
26
public class DialogToFrontModelessTest {
27
28
private volatile TestDialog dialog, leftDialog;
29
private volatile TestFrame rightFrame;
30
private volatile Frame parent;
31
32
private static final int delay = 500;
33
private final ExtendedRobot robot;
34
35
private boolean isModeless;
36
37
public DialogToFrontModelessTest(boolean modeless) throws Exception {
38
isModeless = modeless;
39
robot = new ExtendedRobot();
40
EventQueue.invokeLater(this::createGUI);
41
}
42
43
public DialogToFrontModelessTest() throws Exception { this(true); }
44
45
private void createGUI() {
46
47
parent = new Frame();
48
49
leftDialog = new TestDialog(parent);
50
leftDialog.setSize(200, 100);
51
leftDialog.setLocation(50, 50);
52
leftDialog.setVisible(true);
53
54
dialog = new TestDialog(leftDialog);
55
56
if (isModeless) { dialog.setModalityType(Dialog.ModalityType.MODELESS); }
57
58
dialog.setSize(200, 100);
59
dialog.setLocation(150, 50);
60
61
rightFrame = new TestFrame();
62
rightFrame.setSize(200, 100);
63
rightFrame.setLocation(250, 50);
64
65
dialog.setVisible(true);
66
rightFrame.setVisible(true);
67
}
68
69
public void doTest() throws Exception {
70
71
try {
72
robot.waitForIdle(delay);
73
74
rightFrame.clickCloseButton(robot);
75
robot.waitForIdle(delay);
76
77
EventQueue.invokeAndWait(() -> { leftDialog.toFront(); });
78
robot.waitForIdle(delay);
79
80
leftDialog.clickDummyButton(robot, 7, false,
81
"Calling toFront method for the parent left dialog " +
82
"brought it to the top of the child dialog.");
83
robot.waitForIdle(delay);
84
85
rightFrame.clickDummyButton(robot);
86
robot.waitForIdle(delay);
87
88
String msg = "The " + (isModeless ? "modeless" : "non-modal") +
89
" dialog still on top of the right frame" +
90
" even after a button on the frame is clicked.";
91
dialog.clickDummyButton(robot, 7, false, msg);
92
robot.waitForIdle(delay);
93
94
} finally {
95
EventQueue.invokeAndWait(this::closeAll);
96
}
97
}
98
99
private void closeAll() {
100
if (dialog != null) { dialog.dispose(); }
101
if (parent != null) { parent.dispose(); }
102
if (leftDialog != null) { leftDialog.dispose(); }
103
if (rightFrame != null) { rightFrame.dispose(); }
104
}
105
}
106
107