Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/FileDialog/DeleteInsideFileDialog/DeleteInsideFileDialogTest.java
41153 views
1
/*
2
* Copyright (c) 2016, 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
@bug 8075516
27
@requires os.family=="windows"
28
@summary Deleting a file from either the open or save java.awt.FileDialog
29
hangs.
30
@run main/manual DeleteInsideFileDialogTest
31
*/
32
33
import java.awt.*;
34
import java.nio.file.Files;
35
import java.nio.file.Path;
36
import java.nio.file.Paths;
37
38
public class DeleteInsideFileDialogTest {
39
40
private static Path dir;
41
private static Path file1;
42
private static Path file2;
43
private static Frame f;
44
private static FileDialog fd;
45
46
public static void main(String[] args) throws Exception {
47
48
String instructions =
49
"1) Delete file deleteMe.tst in the opened File Dialog window" +
50
" using the right click popup menu\n" +
51
"2) Select thenSelectMe.tst file in the File Dialog and press" +
52
" Open (if this is not possible the test fails)\n";
53
dir = Files.createTempDirectory("Test");
54
file1 = Files.createFile(Paths.get(dir.toString(), "deleteMe.tst"));
55
file2 = Files.createFile(Paths.get(dir.toString(), "thenSelectMe.tst"));
56
try {
57
f = new Frame("Instructions");
58
f.add(new TextArea(instructions, 6, 60, TextArea.SCROLLBARS_NONE));
59
f.pack();
60
f.setLocation(100, 500);
61
f.setVisible(true);
62
63
fd = new FileDialog((Frame)null);
64
fd.setDirectory(dir.toString());
65
fd.setVisible(true);
66
if (fd.getFile() == null) {
67
throw new RuntimeException("Failed");
68
}
69
} finally {
70
if (fd != null) {
71
fd.dispose();
72
}
73
if (f != null) {
74
f.dispose();
75
}
76
Files.deleteIfExists(file1);
77
Files.deleteIfExists(file2);
78
Files.deleteIfExists(dir);
79
}
80
}
81
}
82
83