format::desktop_entry: Test all recognized keys

This commit is contained in:
Sasha Koshka 2024-10-22 13:39:40 -04:00
parent 2033df5335
commit 6ff4624dd8
2 changed files with 44 additions and 8 deletions

View File

@ -4,7 +4,7 @@ use locale;
use os;
@test fn parse() void = {
let file = os::open("format/desktop_entry/test_data/foo.desktop")!;
let file = os::open("format/desktop_entry/test_data/foo_full.desktop")!;
defer io::close(file)!;
let file = parse(file)!;
defer file_finish(&file);
@ -14,7 +14,10 @@ use os;
assert(locale_string_equal(file.name, [
(locale::c, "Foo Viewer"),
]));
assert(locale_string_equal(file.generic_name, [])); // TODO
assert(locale_string_equal(file.generic_name, [
(locale::c, "Foo Viewer"),
(locale::parse("xx_XX.UTF-8")!, "Sneep glorp"),
]));
assert(file.no_display == false);
assert(locale_string_equal(file.comment, [
(locale::c, "The best viewer for Foo objects available!"),
@ -23,17 +26,22 @@ use os;
(locale::c, "fooview"),
]));
assert(file.hidden == false);
assert(strings_equal(file.only_show_in, [])); // TODO
assert(strings_equal(file.not_show_in, [])); // TODO
assert(strings_equal(file.only_show_in, ["MATE", "KDE"]));
assert(strings_equal(file.not_show_in, ["GNOME"]));
assert(file.dbus_activatable == false);
assert(file.try_exec == "fooview");
assert(file.exec == "fooview %F");
assert(file.path == "");
assert(file.terminal == false);
assert(strings_equal(file.mime_type, ["image/x-foo"]));
assert(strings_equal(file.categories, [])); // TODO
assert(strings_equal(file.implements, [])); // TODO
assert(locale_strings_equal(file.keywords, [])); // TODO
assert(strings_equal(file.categories, ["Graphics", "Utility"]));
assert(strings_equal(file.implements, [
"com.example.Example",
"com.example.OtherExample",
]));
assert(locale_strings_equal(file.keywords, [
(locale::c, ["foo", "image", "view", "viewer"]),
]));
assert(file.startup_notify == false);
assert(file.url == "");
assert(file.prefers_non_default_gpu == false);
@ -44,7 +52,7 @@ use os;
assert(locale_string_equal(actio.name, [
(locale::c, "Browse Gallery"),
]));
assert(locale_string_equal(actio.icon, [])); // TODO
assert(locale_string_equal(actio.icon, []));
assert(actio.exec == "fooview --gallery");
case "Create" =>
assert(locale_string_equal(actio.name, [

View File

@ -0,0 +1,28 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Foo Viewer
GenericName=Foo Viewer
GenericName[xx_XX.UTF-8]=Sneep glorp
Comment=The best viewer for Foo objects available!
TryExec=fooview
Exec=fooview %F
Icon=fooview
MimeType=image/x-foo;
Actions=Gallery;Create;
OnlyShowIn=MATE;KDE;
NotShowIn=GNOME
Categories=Graphics;Utility
Implements=com.example.Example;com.example.OtherExample
Keywords=foo;image;view;viewer
[Desktop Action Gallery]
Exec=fooview --gallery
Name=Browse Gallery
[Desktop Action Create]
Exec=fooview --create-new
Name=Create a new Foo!
Name[en_US]=Create a new Foo!
Name[xx_XX.UTF-8]=Zweep zoop flooble glorp
Icon=fooview-new