[gnome-software] appstream: Use a special metadata key for controlling the not-launchable quirk
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] appstream: Use a special metadata key for controlling the not-launchable quirk
- Date: Mon, 18 Sep 2017 12:03:48 +0000 (UTC)
commit e6eb51bef96bf5ab73d01ebf235f8f02e0b693e8
Author: Joaquim Rocha <jrocha endlessm com>
Date: Mon Sep 18 13:52:19 2017 +0200
appstream: Use a special metadata key for controlling the not-launchable quirk
The key is GnomeSoftware::quirks::not-launchable and is useful if we
want to override this quirk more directly than using the component type
and the inexistence of the launchable tag.
plugins/core/gs-appstream.c | 9 ++++++
plugins/dummy/gs-self-test.c | 59 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 87440c9..9259150 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -554,6 +554,15 @@ gs_appstream_refine_app (GsPlugin *plugin,
break;
}
+ /* check if the special metadata affects the not-launchable quirk */
+ tmp = gs_app_get_metadata_item (app, "GnomeSoftware::quirks::not-launchable");
+ if (tmp != NULL) {
+ if (g_strcmp0 (tmp, "true") == 0)
+ gs_app_add_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
+ else if (g_strcmp0 (tmp, "false") == 0)
+ gs_app_remove_quirk (app, AS_APP_QUIRK_NOT_LAUNCHABLE);
+ }
+
/* set management plugin automatically */
gs_refine_item_management_plugin (plugin, app, item);
diff --git a/plugins/dummy/gs-self-test.c b/plugins/dummy/gs-self-test.c
index 4943e01..a8ea380 100644
--- a/plugins/dummy/gs-self-test.c
+++ b/plugins/dummy/gs-self-test.c
@@ -148,6 +148,60 @@ gs_plugins_dummy_refine_func (GsPluginLoader *plugin_loader)
}
static void
+gs_plugins_dummy_metadata_quirks (GsPluginLoader *plugin_loader)
+{
+ gboolean ret;
+ g_autoptr(GsApp) app = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GsPluginJob) plugin_job = NULL;
+
+ /* get the extra bits */
+ app = gs_app_new ("chiron.desktop");
+ gs_app_set_management_plugin (app, "dummy");
+ plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
+ "app", app,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION,
+ NULL);
+ ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error);
+ gs_test_flush_main_context ();
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_assert_cmpstr (gs_app_get_description (app), !=, NULL);
+
+ /* check the not-launchable quirk */
+
+ g_assert (!gs_app_has_quirk(app, AS_APP_QUIRK_NOT_LAUNCHABLE));
+
+ gs_app_set_metadata (app, "GnomeSoftware::quirks::not-launchable", "true");
+
+ plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
+ "app", app,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION,
+ NULL);
+ ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error);
+ gs_test_flush_main_context ();
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_assert (gs_app_has_quirk(app, AS_APP_QUIRK_NOT_LAUNCHABLE));
+
+ gs_app_set_metadata (app, "GnomeSoftware::quirks::not-launchable", NULL);
+ gs_app_set_metadata (app, "GnomeSoftware::quirks::not-launchable", "false");
+
+ plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
+ "app", app,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION,
+ NULL);
+ ret = gs_plugin_loader_job_action (plugin_loader, plugin_job, NULL, &error);
+ gs_test_flush_main_context ();
+ g_assert_no_error (error);
+ g_assert (ret);
+
+ g_assert (!gs_app_has_quirk(app, AS_APP_QUIRK_NOT_LAUNCHABLE));
+}
+
+static void
gs_plugins_dummy_key_colors_func (GsPluginLoader *plugin_loader)
{
GPtrArray *array;
@@ -766,7 +820,10 @@ main (int argc, char **argv)
g_test_add_data_func ("/gnome-software/plugins/dummy/purchase",
plugin_loader,
(GTestDataFunc) gs_plugins_dummy_purchase_func);
-;
+ g_test_add_data_func ("/gnome-software/plugins/dummy/metadata-quirks",
+ plugin_loader,
+ (GTestDataFunc) gs_plugins_dummy_metadata_quirks);
+
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]