Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/windows/WinInstallerUiTest.java
41149 views
1
/*
2
* Copyright (c) 2021, 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.nio.file.Path;
25
import java.util.ArrayList;
26
import jdk.jpackage.test.PackageTest;
27
import jdk.jpackage.test.JPackageCommand;
28
import jdk.jpackage.test.Annotations.Test;
29
import jdk.jpackage.test.Annotations.Parameters;
30
import java.util.List;
31
import jdk.jpackage.test.PackageType;
32
import jdk.jpackage.test.TKit;
33
34
/**
35
* Test all possible combinations of --win-dir-chooser, --win-shortcut-prompt
36
* and --license parameters.
37
*/
38
39
/*
40
* @test
41
* @summary jpackage with --win-dir-chooser, --win-shortcut-prompt and --license parameters
42
* @library ../helpers
43
* @key jpackagePlatformPackage
44
* @build jdk.jpackage.test.*
45
* @build WinInstallerUiTest
46
* @requires (os.family == "windows")
47
* @modules jdk.jpackage/jdk.jpackage.internal
48
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
49
* --jpt-run=WinInstallerUiTest
50
*/
51
public class WinInstallerUiTest {
52
53
public WinInstallerUiTest(Boolean withDirChooser, Boolean withLicense,
54
Boolean withShortcutPrompt) {
55
this.withShortcutPrompt = withShortcutPrompt;
56
this.withDirChooser = withDirChooser;
57
this.withLicense = withLicense;
58
}
59
60
@Parameters
61
public static List<Object[]> data() {
62
List<Object[]> data = new ArrayList<>();
63
for (var withDirChooser : List.of(Boolean.TRUE, Boolean.FALSE)) {
64
for (var withLicense : List.of(Boolean.TRUE, Boolean.FALSE)) {
65
for (var withShortcutPrompt : List.of(Boolean.TRUE, Boolean.FALSE)) {
66
if (!withDirChooser && !withLicense && !withShortcutPrompt) {
67
// Duplicates SimplePackageTest
68
continue;
69
}
70
71
if (withDirChooser && !withLicense && !withShortcutPrompt) {
72
// Duplicates WinDirChooserTest
73
continue;
74
}
75
76
if (!withDirChooser && withLicense && !withShortcutPrompt) {
77
// Duplicates LicenseTest
78
continue;
79
}
80
81
data.add(new Object[]{withDirChooser, withLicense,
82
withShortcutPrompt});
83
}
84
}
85
}
86
87
return data;
88
}
89
90
@Test
91
public void test() {
92
PackageTest test = new PackageTest()
93
.forTypes(PackageType.WINDOWS)
94
.configureHelloApp();
95
96
test.addInitializer(JPackageCommand::setFakeRuntime);
97
test.addInitializer(this::setPackageName);
98
99
if (withDirChooser) {
100
test.addInitializer(cmd -> cmd.addArgument("--win-dir-chooser"));
101
}
102
103
if (withShortcutPrompt) {
104
test.addInitializer(cmd -> {
105
cmd.addArgument("--win-shortcut-prompt");
106
cmd.addArgument("--win-menu");
107
cmd.addArgument("--win-shortcut");
108
});
109
}
110
111
if (withLicense) {
112
test.addInitializer(cmd -> {
113
cmd.addArguments("--license-file", TKit.createRelativePathCopy(
114
TKit.TEST_SRC_ROOT.resolve(Path.of("resources",
115
"license.txt"))));
116
});
117
}
118
119
test.run();
120
}
121
122
private void setPackageName(JPackageCommand cmd) {
123
StringBuilder sb = new StringBuilder(cmd.name());
124
sb.append("With");
125
if (withDirChooser) {
126
sb.append("DirChooser");
127
}
128
if (withShortcutPrompt) {
129
sb.append("ShortcutPrompt");
130
}
131
if (withLicense) {
132
sb.append("License");
133
}
134
cmd.setArgumentValue("--name", sb.toString());
135
}
136
137
private final boolean withDirChooser;
138
private final boolean withLicense;
139
private final boolean withShortcutPrompt;
140
}
141
142