Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.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.AdditionalLauncher;
27
import jdk.jpackage.test.PackageTest;
28
import jdk.jpackage.test.PackageType;
29
import jdk.jpackage.test.TKit;
30
import jdk.jpackage.test.Annotations.Test;
31
import jdk.jpackage.test.JPackageCommand;
32
33
/**
34
* Test multiple launchers in two phases. First test creates app image and then
35
* creates installer from this image. Output of the test should be
36
* MultiLauncherTwoPhaseTest*.* installer. The output installer should be basic
37
* installer with 3 launcher MultiLauncherTwoPhaseTest, bar and foo. On Windows
38
* we should have start menu integration under MultiLauncherTwoPhaseTest and
39
* desktop shortcuts for all 3 launchers. Linux should also create shortcuts for
40
* all launchers.
41
*/
42
43
/*
44
* @test
45
* @summary Multiple launchers in two phases
46
* @library ../helpers
47
* @library /test/lib
48
* @key jpackagePlatformPackage
49
* @build jdk.jpackage.test.*
50
* @modules jdk.jpackage/jdk.jpackage.internal
51
* @compile MultiLauncherTwoPhaseTest.java
52
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main
53
* --jpt-run=MultiLauncherTwoPhaseTest
54
*/
55
56
public class MultiLauncherTwoPhaseTest {
57
58
@Test
59
public static void test() throws IOException {
60
Path appimageOutput = TKit.createTempDirectory("appimage");
61
62
JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
63
.setArgumentValue("--dest", appimageOutput);
64
65
AdditionalLauncher launcher1 = new AdditionalLauncher("bar");
66
launcher1.setDefaultArguments().applyTo(appImageCmd);
67
68
AdditionalLauncher launcher2 = new AdditionalLauncher("foo");
69
launcher2.applyTo(appImageCmd);
70
71
PackageTest packageTest = new PackageTest()
72
.addLauncherName("bar") // Add launchers name for verification
73
.addLauncherName("foo")
74
.addRunOnceInitializer(() -> appImageCmd.execute())
75
.addBundleDesktopIntegrationVerifier(true)
76
.addInitializer(cmd -> {
77
cmd.addArguments("--app-image", appImageCmd.outputBundle());
78
cmd.removeArgumentWithValue("--input");
79
})
80
.forTypes(PackageType.WINDOWS)
81
.addInitializer(cmd -> {
82
cmd.addArguments("--win-shortcut", "--win-menu",
83
"--win-menu-group", "MultiLauncherTwoPhaseTest");
84
})
85
.forTypes(PackageType.LINUX)
86
.addInitializer(cmd -> {
87
cmd.addArguments("--linux-shortcut");
88
});
89
90
packageTest.run();
91
}
92
}
93
94