From 6ff4624dd8ddb8ee0b0031b27df2584195f95154 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Tue, 22 Oct 2024 13:39:40 -0400 Subject: [PATCH] format::desktop_entry: Test all recognized keys --- format/desktop_entry/desktop_entry_test.ha | 24 ++++++++++------ .../desktop_entry/test_data/foo_full.desktop | 28 +++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 format/desktop_entry/test_data/foo_full.desktop diff --git a/format/desktop_entry/desktop_entry_test.ha b/format/desktop_entry/desktop_entry_test.ha index 87fe8c7..6587bf8 100644 --- a/format/desktop_entry/desktop_entry_test.ha +++ b/format/desktop_entry/desktop_entry_test.ha @@ -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, [ diff --git a/format/desktop_entry/test_data/foo_full.desktop b/format/desktop_entry/test_data/foo_full.desktop new file mode 100644 index 0000000..b4bf52c --- /dev/null +++ b/format/desktop_entry/test_data/foo_full.desktop @@ -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