Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/windows/WinUrlTest.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.util.ArrayList;
25
import jdk.jpackage.test.PackageTest;
26
import jdk.jpackage.test.JPackageCommand;
27
import jdk.jpackage.test.Annotations.Test;
28
import jdk.jpackage.test.Annotations.Parameters;
29
import java.util.List;
30
import java.util.Objects;
31
import java.util.stream.Stream;
32
import jdk.jpackage.test.PackageType;
33
34
/**
35
* Test all possible combinations of --about-url, --win-update-url and
36
* --win-help-url parameters.
37
*/
38
39
/*
40
* @test
41
* @summary jpackage with --about-url, --win-update-url and --win-help-url
42
* parameters
43
* @library ../helpers
44
* @key jpackagePlatformPackage
45
* @build jdk.jpackage.test.*
46
* @build WinUrlTest
47
* @requires (os.family == "windows")
48
* @modules jdk.jpackage/jdk.jpackage.internal
49
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
50
* --jpt-run=WinUrlTest
51
*/
52
public class WinUrlTest {
53
54
static enum URL {
55
About("--about-url"),
56
Update("--win-update-url"),
57
Help("--win-help-url");
58
59
URL(String cliOption) {
60
this.cliOption = cliOption;
61
}
62
63
final String cliOption;
64
}
65
66
public WinUrlTest(Boolean withAboutURL, Boolean withUpdateURL,
67
Boolean withHelpURL) {
68
urls = Stream.of(
69
withAboutURL ? URL.About : null,
70
withUpdateURL ? URL.Update : null,
71
withHelpURL ? URL.Help : null
72
).filter(Objects::nonNull).toList();
73
}
74
75
@Parameters
76
public static List<Object[]> data() {
77
List<Object[]> data = new ArrayList<>();
78
for (var withAboutURL : List.of(Boolean.TRUE, Boolean.FALSE)) {
79
for (var withUpdateURL : List.of(Boolean.TRUE, Boolean.FALSE)) {
80
for (var withHelpURL : List.of(Boolean.TRUE, Boolean.FALSE)) {
81
var args = new Object[]{withAboutURL, withUpdateURL, withHelpURL};
82
if (Stream.of(args).anyMatch(Boolean.TRUE::equals)) {
83
data.add(args);
84
}
85
}
86
}
87
}
88
89
return data;
90
}
91
92
@Test
93
public void test() {
94
PackageTest test = new PackageTest()
95
.forTypes(PackageType.WINDOWS)
96
.configureHelloApp();
97
98
test.addInitializer(JPackageCommand::setFakeRuntime);
99
test.addInitializer(this::setPackageName);
100
101
urls.forEach(url -> {
102
test.addInitializer(cmd -> cmd.addArguments(url.cliOption,
103
"http://localhost/" + url.name().toLowerCase()));
104
});
105
106
test.run();
107
}
108
109
private void setPackageName(JPackageCommand cmd) {
110
StringBuilder sb = new StringBuilder(cmd.name());
111
sb.append("With");
112
urls.forEach(url -> sb.append(url.name()));
113
cmd.setArgumentValue("--name", sb.toString());
114
}
115
116
private final List<URL> urls;
117
}
118
119