author | herrick |
Fri, 18 Oct 2019 14:14:37 -0400 | |
branch | JDK-8200758-branch |
changeset 58696 | 61c44899b4eb |
parent 58648 | 3bf53ffa9ae7 |
child 58994 | b09ba68c6a19 |
permissions | -rw-r--r-- |
57307 | 1 |
/* |
2 |
* Copyright (c) 2018, 2019, 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 |
||
58648 | 24 |
import java.io.IOException; |
57307 | 25 |
import java.nio.file.Files; |
58416 | 26 |
import java.nio.file.Path; |
58648 | 27 |
import java.nio.file.StandardCopyOption; |
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58648
diff
changeset
|
28 |
import jdk.jpackage.internal.IOUtils; |
58416 | 29 |
import jdk.jpackage.test.TKit; |
30 |
import jdk.jpackage.test.Functional; |
|
58648 | 31 |
import jdk.jpackage.test.Annotations.*; |
58416 | 32 |
import jdk.jpackage.test.JPackageCommand; |
57307 | 33 |
|
34 |
/* |
|
35 |
* @test |
|
58648 | 36 |
* @summary jpackage create image with custom icon |
57307 | 37 |
* @library ../helpers |
58416 | 38 |
* @build jdk.jpackage.test.* |
39 |
* @modules jdk.jpackage/jdk.jpackage.internal |
|
58648 | 40 |
* @compile IconTest.java |
41 |
* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main |
|
42 |
* --jpt-run=IconTest |
|
57307 | 43 |
*/ |
58648 | 44 |
|
57446 | 45 |
public class IconTest { |
58648 | 46 |
@Test |
47 |
public static void testResourceDir() throws IOException { |
|
48 |
TKit.withTempDirectory("resources", tempDir -> { |
|
49 |
JPackageCommand cmd = JPackageCommand.helloAppImage() |
|
50 |
.addArguments("--resource-dir", tempDir); |
|
51 |
||
52 |
Files.copy(GOLDEN_ICON, tempDir.resolve(appIconFileName(cmd)), |
|
53 |
StandardCopyOption.REPLACE_EXISTING); |
|
54 |
||
55 |
testIt(cmd); |
|
56 |
}); |
|
57 |
} |
|
57307 | 58 |
|
58648 | 59 |
@Test |
60 |
@Parameter("true") |
|
61 |
@Parameter("false") |
|
62 |
public static void testParameter(boolean relativePath) throws IOException { |
|
63 |
final Path iconPath; |
|
64 |
if (relativePath) { |
|
65 |
iconPath = TKit.createRelativePathCopy(GOLDEN_ICON); |
|
66 |
} else { |
|
67 |
iconPath = GOLDEN_ICON; |
|
68 |
} |
|
69 |
||
70 |
testIt(JPackageCommand.helloAppImage().addArguments("--icon", iconPath)); |
|
71 |
} |
|
57307 | 72 |
|
58648 | 73 |
private static String appIconFileName(JPackageCommand cmd) { |
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58648
diff
changeset
|
74 |
return IOUtils.replaceSuffix(cmd.appLauncherPath().getFileName(), |
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58648
diff
changeset
|
75 |
TKit.ICON_SUFFIX).toString(); |
58648 | 76 |
} |
77 |
||
78 |
private static void testIt(JPackageCommand cmd) throws IOException { |
|
79 |
cmd.executeAndAssertHelloAppImageCreated(); |
|
80 |
||
81 |
Path iconPath = cmd.appLayout().destktopIntegrationDirectory().resolve( |
|
82 |
appIconFileName(cmd)); |
|
83 |
||
84 |
TKit.assertFileExists(iconPath); |
|
85 |
TKit.assertTrue(-1 == Files.mismatch(GOLDEN_ICON, iconPath), |
|
86 |
String.format( |
|
87 |
"Check application icon file [%s] is a copy of source icon file [%s]", |
|
88 |
iconPath, GOLDEN_ICON)); |
|
57307 | 89 |
} |
90 |
||
58416 | 91 |
private final static Path GOLDEN_ICON = TKit.TEST_SRC_ROOT.resolve(Path.of( |
58696
61c44899b4eb
8223325: Improve wix sources generated by jpackage
herrick
parents:
58648
diff
changeset
|
92 |
"resources", "icon" + TKit.ICON_SUFFIX)); |
57307 | 93 |
} |