Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/share/MultiNameTwoPhaseTest.java
41149 views
1
/*
2
* Copyright (c) 2020, 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.io.IOException;
26
import jdk.jpackage.test.PackageTest;
27
import jdk.jpackage.test.PackageType;
28
import jdk.jpackage.test.TKit;
29
import jdk.jpackage.test.Annotations.Test;
30
import jdk.jpackage.test.Annotations.Parameter;
31
import jdk.jpackage.test.JPackageCommand;
32
33
/**
34
* Test creation of packages in tho phases with different names.
35
* The first phase creates and app image, and the second phase uses that image.
36
* If the first phase has no --name, it will derive name from main-class.
37
* If the second phase has no --name, will derive it from the app-image content.
38
* The resulting name may differ, and all should still work
39
*/
40
41
/*
42
* @test
43
* @summary Multiple names in two phases
44
* @library ../helpers
45
* @library /test/lib
46
* @key jpackagePlatformPackage
47
* @requires (jpackage.test.SQETest == null)
48
* @build jdk.jpackage.test.*
49
* @modules jdk.jpackage/jdk.jpackage.internal
50
* @compile MultiNameTwoPhaseTest.java
51
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
52
* --jpt-run=MultiNameTwoPhaseTest
53
*/
54
55
public class MultiNameTwoPhaseTest {
56
57
@Test
58
@Parameter({"MultiNameTest", "MultiNameTest"})
59
@Parameter({"MultiNameTest", "MultiNameTestInstaller"})
60
@Parameter({"MultiNameTest", ""})
61
@Parameter({"", "MultiNameTestInstaller"})
62
@Parameter({"", ""})
63
public static void test(String... testArgs) throws IOException {
64
String appName = testArgs[0];
65
String installName = testArgs[1];
66
67
Path appimageOutput = TKit.createTempDirectory("appimage");
68
69
JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
70
.setArgumentValue("--dest", appimageOutput)
71
.removeArgumentWithValue("--name");
72
if (!appName.isEmpty()) {
73
appImageCmd.addArguments("--name", appName);
74
}
75
76
PackageTest packageTest = new PackageTest()
77
.addRunOnceInitializer(() -> appImageCmd.execute())
78
.addBundleDesktopIntegrationVerifier(true)
79
.addInitializer(cmd -> {
80
cmd.addArguments("--app-image", appImageCmd.outputBundle());
81
cmd.removeArgumentWithValue("--input");
82
cmd.removeArgumentWithValue("--name");
83
if (!installName.isEmpty()) {
84
cmd.addArguments("--name", installName);
85
}
86
})
87
.forTypes(PackageType.WINDOWS)
88
.addInitializer(cmd -> {
89
cmd.addArguments("--win-shortcut", "--win-menu",
90
"--win-menu-group", "MultiNameTwoPhaseTest");
91
})
92
.forTypes(PackageType.LINUX)
93
.addInitializer(cmd -> {
94
cmd.addArguments("--linux-shortcut");
95
});
96
97
packageTest.run();
98
}
99
}
100
101