Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/tools/jpackage/share/AppImagePackageTest.java
41149 views
1
/*
2
* Copyright (c) 2018, 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.nio.file.Files;
26
import java.io.IOException;
27
import java.util.List;
28
import jdk.jpackage.test.Annotations.Parameter;
29
import jdk.jpackage.test.TKit;
30
import jdk.jpackage.test.JPackageCommand;
31
import jdk.jpackage.test.PackageTest;
32
import jdk.jpackage.test.RunnablePackageTest.Action;
33
import jdk.jpackage.test.Annotations.Test;
34
35
/**
36
* Test --app-image parameter. The output installer should provide the same
37
* functionality as the default installer (see description of the default
38
* installer in SimplePackageTest.java)
39
*/
40
41
/*
42
* @test
43
* @summary jpackage with --app-image
44
* @key jpackagePlatformPackage
45
* @library ../helpers
46
* @requires (jpackage.test.SQETest == null)
47
* @build jdk.jpackage.test.*
48
* @modules jdk.jpackage/jdk.jpackage.internal
49
* @compile AppImagePackageTest.java
50
* @run main/othervm/timeout=540 -Xmx512m jdk.jpackage.test.Main
51
* --jpt-run=AppImagePackageTest
52
*/
53
public class AppImagePackageTest {
54
55
@Test
56
public static void test() {
57
Path appimageOutput = TKit.workDir().resolve("appimage");
58
59
JPackageCommand appImageCmd = JPackageCommand.helloAppImage()
60
.setArgumentValue("--dest", appimageOutput);
61
62
new PackageTest()
63
.addRunOnceInitializer(() -> appImageCmd.execute())
64
.addInitializer(cmd -> {
65
cmd.addArguments("--app-image", appImageCmd.outputBundle());
66
cmd.removeArgumentWithValue("--input");
67
}).addBundleDesktopIntegrationVerifier(false).run();
68
}
69
70
@Test
71
@Parameter("true")
72
@Parameter("false")
73
public static void testEmpty(boolean withIcon) throws IOException {
74
final String name = "EmptyAppImagePackageTest";
75
final String imageName = name + (TKit.isOSX() ? ".app" : "");
76
Path appImageDir = TKit.createTempDirectory(null).resolve(imageName);
77
78
Files.createDirectories(appImageDir.resolve("bin"));
79
Path libDir = Files.createDirectories(appImageDir.resolve("lib"));
80
TKit.createTextFile(libDir.resolve("README"),
81
List.of("This is some arbitrary text for the README file\n"));
82
83
new PackageTest()
84
.addInitializer(cmd -> {
85
cmd.addArguments("--app-image", appImageDir);
86
if (withIcon) {
87
cmd.addArguments("--icon", iconPath("icon"));
88
}
89
cmd.removeArgumentWithValue("--input");
90
91
// on mac, with --app-image and without --mac-package-identifier,
92
// will try to infer it from the image, so foreign image needs it.
93
if (TKit.isOSX()) {
94
cmd.addArguments("--mac-package-identifier", name);
95
}
96
}).run(Action.CREATE, Action.UNPACK);
97
// default: {CREATE, UNPACK, VERIFY}, but we can't verify foreign image
98
}
99
100
private static Path iconPath(String name) {
101
return TKit.TEST_SRC_ROOT.resolve(Path.of("resources", name
102
+ TKit.ICON_SUFFIX));
103
}
104
}
105
106