Skip to content
Permalink
Browse files
8263887: Re-create default icons
Reviewed-by: almatvee, asemenyuk
  • Loading branch information
Andy Herrick committed Mar 24, 2021
1 parent 133a63b commit 70d34017b506222910b0b50459e2c6483c46278a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
@@ -42,7 +42,7 @@ public LauncherIconVerifier setExpectedIcon(Path v) {
}

public LauncherIconVerifier setExpectedDefaultIcon() {
expectedIcon = getDefaultIcon();
expectedDefault = true;
return this;
}

@@ -60,34 +60,20 @@ public void applyTo(JPackageCommand cmd) throws IOException {
Path iconPath = cmd.appLayout().destktopIntegrationDirectory().resolve(
curLauncherName + TKit.ICON_SUFFIX);

if (expectedIcon == null) {
if (expectedDefault) {
TKit.assertPathExists(iconPath, true);
} else if (expectedIcon == null) {
TKit.assertPathExists(iconPath, false);
return;
}

TKit.assertFileExists(iconPath);
TKit.assertTrue(-1 == Files.mismatch(expectedIcon, iconPath),
String.format(
"Check icon file [%s] of %s launcher is a copy of source icon file [%s]",
iconPath, label, expectedIcon));
}

public static Path getDefaultIcon() {
final String[] components;
if (TKit.isOSX()) {
components = new String[] { "macosx", "JavaApp.icns" };
} else if (TKit.isLinux()) {
components = new String[] { "linux", "JavaApp.png" };
} else if (TKit.isWindows()) {
components = new String[] { "windows", "JavaApp.ico" };
} else {
throw TKit.throwUnknownPlatformError();
TKit.assertFileExists(iconPath);
TKit.assertTrue(-1 == Files.mismatch(expectedIcon, iconPath),
String.format(
"Check icon file [%s] of %s launcher is a copy of source icon file [%s]",
iconPath, label, expectedIcon));
}

return TKit.SRC_ROOT.resolve(Path.of(components[0],
"classes/jdk/jpackage/internal/resources", components[1]));
}

private String launcherName;
private Path expectedIcon;
private boolean expectedDefault;
}
@@ -220,7 +220,7 @@ private static TKit.TextStreamVerifier createConsoleOutputVerifier(
case DefaultIcon:
lookupString = String.format(
"Using default package resource %s [icon] (add %s%s to the resource-dir to customize)",
LauncherIconVerifier.getDefaultIcon().getFileName(),
"JavaApp" + TKit.ICON_SUFFIX,
launcherName, TKit.ICON_SUFFIX);
break;

0 comments on commit 70d3401

Please sign in to comment.