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