mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8364560: The default value of --linux-menu-group option is invalid
8356574: Test --linux-menu-group option Reviewed-by: almatvee
This commit is contained in:
parent
155d7df555
commit
0d8b5188bb
@ -84,9 +84,9 @@ final class LinuxPackageBuilder {
|
||||
private LinuxPackage create(Package pkg) throws ConfigException {
|
||||
return LinuxPackage.create(pkg, new LinuxPackageMixin.Stub(
|
||||
Optional.ofNullable(menuGroupName).orElseGet(DEFAULTS::menuGroupName),
|
||||
Optional.ofNullable(category),
|
||||
category(),
|
||||
Optional.ofNullable(additionalDependencies),
|
||||
Optional.ofNullable(release),
|
||||
release(),
|
||||
pkg.asStandardPackageType().map(LinuxPackageArch::getValue).orElseThrow()));
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ final class LinuxPackageBuilder {
|
||||
|
||||
private final PackageBuilder pkgBuilder;
|
||||
|
||||
private static final Defaults DEFAULTS = new Defaults(I18N.getString(
|
||||
"param.menu-group.default"));
|
||||
|
||||
// Should be one of https://specifications.freedesktop.org/menu/latest/category-registry.html#main-category-registry
|
||||
// The category is an ID, not a localizable string
|
||||
private static final Defaults DEFAULTS = new Defaults("Utility");
|
||||
}
|
||||
|
||||
@ -34,6 +34,12 @@ public interface LinuxPackageMixin {
|
||||
/**
|
||||
* Gets the name of the start menu group where to create shortcuts for
|
||||
* application launchers of this package.
|
||||
* <p>
|
||||
* It sets the value of the "Categories" property in .desktop files of the
|
||||
* package.
|
||||
* <p>
|
||||
* Should be one of the values from <a href=
|
||||
* "https://specifications.freedesktop.org/menu/latest/category-registry.html">https://specifications.freedesktop.org/menu/latest/category-registry.html</a>
|
||||
*
|
||||
* @return the name of the start menu group where to create shortcuts for
|
||||
* application launchers of this package
|
||||
@ -44,6 +50,13 @@ public interface LinuxPackageMixin {
|
||||
|
||||
/**
|
||||
* Gets the category of this package.
|
||||
* <p>
|
||||
* For RPM packages this is the value of the optional "Group" property.
|
||||
* <p>
|
||||
* For DEB packages this is the value of the mandatory "Section" property.
|
||||
* <a href=
|
||||
* "https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">The
|
||||
* present list of recognized values.</a>
|
||||
*
|
||||
* @return the category of this package
|
||||
*/
|
||||
@ -62,7 +75,7 @@ public interface LinuxPackageMixin {
|
||||
* Gets the release of this package. Returns an empty {@link Optional} instance
|
||||
* if this package doesn't have a release.
|
||||
* <p>
|
||||
* For RPM packages, this is the value of a "Release" property in spec file. RPM
|
||||
* For RPM packages, this is the value of the "Release" property in spec file. RPM
|
||||
* packages always have a release.
|
||||
* <p>
|
||||
* For DEB packages, this is an optional {@code debian_revision} component of a
|
||||
|
||||
@ -28,7 +28,6 @@ deb.bundler.name=DEB Bundle
|
||||
rpm.bundler.name=RPM Bundle
|
||||
|
||||
param.license-type.default=Unknown
|
||||
param.menu-group.default=Unknown
|
||||
|
||||
resource.deb-control-file=DEB control file
|
||||
resource.deb-preinstall-script=DEB preinstall script
|
||||
|
||||
@ -564,7 +564,8 @@ public final class LinuxHelper {
|
||||
for (var e : List.of(
|
||||
Map.entry("Type", "Application"),
|
||||
Map.entry("Terminal", "false"),
|
||||
Map.entry("Comment", launcherDescription)
|
||||
Map.entry("Comment", launcherDescription),
|
||||
Map.entry("Categories", Optional.ofNullable(cmd.getArgumentValue("--linux-menu-group")).orElse("Utility"))
|
||||
)) {
|
||||
String key = e.getKey();
|
||||
TKit.assertEquals(e.getValue(), data.find(key).orElseThrow(), String.format(
|
||||
|
||||
@ -26,13 +26,15 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import jdk.jpackage.test.AdditionalLauncher;
|
||||
import jdk.jpackage.test.Annotations.Parameter;
|
||||
import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.FileAssociations;
|
||||
import jdk.jpackage.test.PackageType;
|
||||
import jdk.jpackage.test.PackageTest;
|
||||
import jdk.jpackage.test.TKit;
|
||||
import jdk.jpackage.test.JPackageCommand;
|
||||
import jdk.jpackage.test.LinuxHelper;
|
||||
import jdk.jpackage.test.Annotations.Test;
|
||||
import jdk.jpackage.test.PackageTest;
|
||||
import jdk.jpackage.test.PackageType;
|
||||
import jdk.jpackage.test.RunnablePackageTest.Action;
|
||||
import jdk.jpackage.test.TKit;
|
||||
|
||||
/**
|
||||
* Test --linux-shortcut parameter. Output of the test should be
|
||||
@ -179,4 +181,18 @@ public class ShortcutHintTest {
|
||||
.apply(Files.readAllLines(desktopFile));
|
||||
}).run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test "--linux-menu-group" option.
|
||||
*
|
||||
* @param menuGroup value of "--linux-menu-group" option
|
||||
*/
|
||||
@Test
|
||||
// Values from https://specifications.freedesktop.org/menu/latest/category-registry.html#main-category-registry
|
||||
@Parameter("Development")
|
||||
public static void testMenuGroup(String menuGroup) {
|
||||
createTest().addInitializer(JPackageCommand::setFakeRuntime).addInitializer(cmd -> {
|
||||
cmd.addArgument("--linux-shortcut").setArgumentValue("--linux-menu-group", menuGroup);
|
||||
}).run(Action.CREATE_AND_UNPACK);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user