Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JOptionPane/6428694/bug6428694.java
41155 views
1
/*
2
* Copyright (c) 2011, 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
* @test
25
* @key headful
26
* @bug 6428694
27
* @summary Checks that double click closes JOptionPane's input dialog.
28
* @library /lib/client
29
* @build ExtendedRobot
30
* @author Mikhail Lapshin
31
* @run main bug6428694
32
*/
33
34
import javax.swing.JFrame;
35
import javax.swing.SwingUtilities;
36
import javax.swing.JOptionPane;
37
import java.awt.*;
38
import java.awt.event.InputEvent;
39
40
public class bug6428694 {
41
private static JFrame frame;
42
private static boolean mainIsWaitingForDialogClosing;
43
private static ExtendedRobot robot;
44
private static volatile boolean testPassed;
45
46
public static void main(String[] args) throws Exception {
47
robot = new ExtendedRobot();
48
try {
49
SwingUtilities.invokeLater(new Runnable() {
50
public void run() {
51
bug6428694.setupUI();
52
}
53
});
54
robot.waitForIdle();
55
test();
56
} finally {
57
stopEDT();
58
}
59
60
if (testPassed) {
61
System.out.println("Test passed");
62
} else {
63
throw new RuntimeException("JOptionPane doesn't close input dialog " +
64
"by double click!");
65
}
66
}
67
68
private static void setupUI() {
69
frame = new JFrame("bug6428694 test");
70
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
71
frame.setVisible(true);
72
73
Object[] selectedItems = new Object[40];
74
for (int i = 0; i < 39; i++) {
75
selectedItems[i] = ("item: " + i);
76
}
77
JOptionPane.showInputDialog(frame,
78
"Double click on selected item then click cancel",
79
"Test Option Dialog", JOptionPane.WARNING_MESSAGE, null,
80
selectedItems, selectedItems[0]);
81
82
// We are here if double click has closed the dialog
83
// or when the EDT is stopping
84
testPassed = mainIsWaitingForDialogClosing;
85
}
86
87
private static void test() {
88
89
mainIsWaitingForDialogClosing = true;
90
91
// Perform double click on an item
92
int frameLeftX = frame.getLocationOnScreen().x;
93
int frameUpperY = frame.getLocationOnScreen().y;
94
robot.mouseMove(frameLeftX + 150, frameUpperY + 120);
95
robot.waitForIdle();
96
robot.delay(100);
97
robot.setAutoDelay(50);
98
robot.mousePress(InputEvent.BUTTON1_MASK);
99
robot.mouseRelease(InputEvent.BUTTON1_MASK);
100
robot.mousePress(InputEvent.BUTTON1_MASK);
101
robot.mouseRelease(InputEvent.BUTTON1_MASK);
102
103
// Wait for the input dialog closing
104
robot.waitForIdle();
105
robot.delay(2000);
106
107
mainIsWaitingForDialogClosing = false;
108
}
109
110
private static void stopEDT() {
111
if (frame != null) {
112
frame.dispose();
113
}
114
}
115
}
116
117