equal
deleted
inserted
replaced
23 |
23 |
24 import java.io.IOException; |
24 import java.io.IOException; |
25 import java.nio.file.Files; |
25 import java.nio.file.Files; |
26 import java.nio.file.Path; |
26 import java.nio.file.Path; |
27 import java.nio.file.StandardCopyOption; |
27 import java.nio.file.StandardCopyOption; |
|
28 import jdk.jpackage.internal.IOUtils; |
28 import jdk.jpackage.test.TKit; |
29 import jdk.jpackage.test.TKit; |
29 import jdk.jpackage.test.Functional; |
30 import jdk.jpackage.test.Functional; |
30 import jdk.jpackage.test.Annotations.*; |
31 import jdk.jpackage.test.Annotations.*; |
31 import jdk.jpackage.test.JPackageCommand; |
32 import jdk.jpackage.test.JPackageCommand; |
32 |
33 |
68 |
69 |
69 testIt(JPackageCommand.helloAppImage().addArguments("--icon", iconPath)); |
70 testIt(JPackageCommand.helloAppImage().addArguments("--icon", iconPath)); |
70 } |
71 } |
71 |
72 |
72 private static String appIconFileName(JPackageCommand cmd) { |
73 private static String appIconFileName(JPackageCommand cmd) { |
73 return cmd.appLauncherPath().getFileName().toString().replaceAll( |
74 return IOUtils.replaceSuffix(cmd.appLauncherPath().getFileName(), |
74 "\\.[^.]*$", "") + ICON_SUFFIX; |
75 TKit.ICON_SUFFIX).toString(); |
75 } |
76 } |
76 |
77 |
77 private static void testIt(JPackageCommand cmd) throws IOException { |
78 private static void testIt(JPackageCommand cmd) throws IOException { |
78 cmd.executeAndAssertHelloAppImageCreated(); |
79 cmd.executeAndAssertHelloAppImageCreated(); |
79 |
80 |
85 String.format( |
86 String.format( |
86 "Check application icon file [%s] is a copy of source icon file [%s]", |
87 "Check application icon file [%s] is a copy of source icon file [%s]", |
87 iconPath, GOLDEN_ICON)); |
88 iconPath, GOLDEN_ICON)); |
88 } |
89 } |
89 |
90 |
90 private final static String ICON_SUFFIX = Functional.identity(() -> { |
|
91 if (TKit.isOSX()) { |
|
92 return ".icns"; |
|
93 } |
|
94 |
|
95 if (TKit.isLinux()) { |
|
96 return ".png"; |
|
97 } |
|
98 |
|
99 if (TKit.isWindows()) { |
|
100 return ".ico"; |
|
101 } |
|
102 |
|
103 throw TKit.throwUnknownPlatformError(); |
|
104 }).get(); |
|
105 |
|
106 private final static Path GOLDEN_ICON = TKit.TEST_SRC_ROOT.resolve(Path.of( |
91 private final static Path GOLDEN_ICON = TKit.TEST_SRC_ROOT.resolve(Path.of( |
107 "resources", "icon" + ICON_SUFFIX)); |
92 "resources", "icon" + TKit.ICON_SUFFIX)); |
108 } |
93 } |