[gnome-software] core: Add an override for icon lookup paths for tests
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] core: Add an override for icon lookup paths for tests
- Date: Fri, 15 May 2020 14:39:38 +0000 (UTC)
commit 2851b302d71cf4c142b6d74b0a71cf59ddb356df
Author: Philip Withnall <withnall endlessm com>
Date: Thu May 14 22:30:39 2020 +0100
core: Add an override for icon lookup paths for tests
Currently, in the tests, the icon paths are looked up from the system
icon theme using the standard XDG path values from the environment. An
upcoming commit will enable `G_TEST_OPTION_ISOLATE_DIRS`, which will
obliterate those environment variables, so we need some way to override
that for icon lookups during the tests.
Signed-off-by: Philip Withnall <withnall endlessm com>
plugins/core/gs-plugin-icons.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/plugins/core/gs-plugin-icons.c b/plugins/core/gs-plugin-icons.c
index 0abf79f1..f26f2ea6 100644
--- a/plugins/core/gs-plugin-icons.c
+++ b/plugins/core/gs-plugin-icons.c
@@ -26,15 +26,28 @@ struct GsPluginData {
GHashTable *icon_theme_paths;
};
+static void gs_plugin_icons_add_theme_path (GsPlugin *plugin, const gchar *path);
+
void
gs_plugin_initialize (GsPlugin *plugin)
{
GsPluginData *priv = gs_plugin_alloc_data (plugin, sizeof(GsPluginData));
+ const gchar *test_search_path;
+
priv->icon_theme = gtk_icon_theme_new ();
gtk_icon_theme_set_screen (priv->icon_theme, gdk_screen_get_default ());
priv->icon_theme_paths = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_mutex_init (&priv->icon_theme_lock);
+ test_search_path = g_getenv ("GS_SELF_TEST_ICON_THEME_PATH");
+ if (test_search_path != NULL) {
+ g_auto(GStrv) dirs = g_strsplit (test_search_path, ":", -1);
+
+ /* add_theme_path() prepends, so we have to iterate in reverse to preserve order */
+ for (gsize i = g_strv_length (dirs); i > 0; i--)
+ gs_plugin_icons_add_theme_path (plugin, dirs[i - 1]);
+ }
+
/* needs remote icons downloaded */
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "appstream");
gs_plugin_add_rule (plugin, GS_PLUGIN_RULE_RUN_AFTER, "epiphany");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]