Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java
41153 views
1
/*
2
* Copyright (c) 2016, 2017, 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
/*
25
* @test
26
* @key headful
27
* @bug 8169589 8171909
28
* @summary Activating a dialog puts to back another dialog owned by the same frame
29
* @author Dmitry Markov
30
* @library ../../regtesthelpers
31
* @build Util
32
* @run main DialogAboveFrameTest
33
*/
34
35
import java.awt.Color;
36
import java.awt.Dialog;
37
import java.awt.Frame;
38
import java.awt.Point;
39
import java.awt.Robot;
40
41
import test.java.awt.regtesthelpers.Util;
42
43
public class DialogAboveFrameTest {
44
public static void main(String[] args) {
45
Robot robot = Util.createRobot();
46
47
Frame frame = new Frame("Frame");
48
frame.setBackground(Color.BLUE);
49
frame.setBounds(200, 50, 300, 300);
50
frame.setVisible(true);
51
52
Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
53
dialog1.setBackground(Color.RED);
54
dialog1.setBounds(100, 100, 200, 200);
55
dialog1.setVisible(true);
56
57
Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
58
dialog2.setBackground(Color.GREEN);
59
dialog2.setBounds(400, 100, 200, 200);
60
dialog2.setVisible(true);
61
62
Util.waitForIdle(robot);
63
64
Util.clickOnComp(dialog2, robot);
65
Util.waitForIdle(robot);
66
67
Point point = dialog1.getLocationOnScreen();
68
int x = point.x + (int)(dialog1.getWidth() * 0.9);
69
int y = point.y + (int)(dialog1.getHeight() * 0.9);
70
71
try {
72
if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
73
throw new RuntimeException("Test FAILED: Dialog is behind the frame");
74
}
75
} finally {
76
frame.dispose();
77
dialog1.dispose();
78
dialog2.dispose();
79
}
80
}
81
}
82
83
84