Skip to content

Commit

Permalink
8263887: Re-create default icons
Browse files Browse the repository at this point in the history
Reviewed-by: almatvee, asemenyuk
  • Loading branch information
Andy Herrick committed Mar 24, 2021
1 parent 133a63b commit 70d3401
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public LauncherIconVerifier setExpectedIcon(Path v) {
}

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

Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion test/jdk/tools/jpackage/share/IconTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

1 comment on commit 70d3401

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.