summaryrefslogtreecommitdiff
path: root/testsuite/gtk
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2016-08-03 21:12:27 +0100
committerMatthias Clasen <mclasen@redhat.com>2016-08-06 17:13:25 -0400
commit76721e736e9605b3a7ec76d3676d8cb5f4172490 (patch)
treea921f55abda3a47c9b81d476ad17e222ec8a3e7c /testsuite/gtk
parent1306f780abc1aa928c140107eace3896e43535bb (diff)
downloadgtk+-76721e736e9605b3a7ec76d3676d8cb5f4172490.tar.gz
gtkicontheme: Don’t emit warning about fallback theme when in unit tests
In order to eliminate g_test_expect_message() (which doesn’t work with G_LOG_USE_STRUCTURED), make the warning about the fallback theme not existing be conditional on the icon theme search path containing a system path. Any application code which modifies the search path does so through appends and prepends, so this should not affect whether the warning is emitted in production. https://bugzilla.gnome.org/show_bug.cgi?id=769485
Diffstat (limited to 'testsuite/gtk')
-rw-r--r--testsuite/gtk/icontheme.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index a70f75b240..cf466471f3 100644
--- a/testsuite/gtk/icontheme.c
+++ b/testsuite/gtk/icontheme.c
@@ -201,15 +201,6 @@ test_basics (void)
{
/* just a basic boring lookup so we know everything works */
assert_icon_lookup ("simple", 16, 0, "/icons/16x16/simple.png");
-
- /* The first time an icon is looked up that doesn't exist, GTK spews a
- * warning.
- * We make that happen right here, so we can get rid of the warning
- * and do failing lookups in other tests.
- */
- g_test_expect_message ("Gtk", G_LOG_LEVEL_WARNING, "Could not find the icon*");
- assert_icon_lookup_fails ("this-icon-totally-does-not-exist", 16, 0);
- g_test_assert_expected_messages ();
}
static void
@@ -771,11 +762,33 @@ test_nonsquare_symbolic (void)
g_object_unref (info);
}
+static GLogWriterOutput
+log_writer_drop_warnings (GLogLevelFlags log_level,
+ const GLogField *fields,
+ gsize n_fields,
+ gpointer user_data)
+{
+ gboolean *ignore_warnings = user_data;
+
+ if (log_level == G_LOG_LEVEL_WARNING && *ignore_warnings)
+ return G_LOG_WRITER_HANDLED;
+
+ return g_log_writer_default (log_level, fields, n_fields, user_data);
+}
+
int
main (int argc, char *argv[])
{
+ gboolean ignore_warnings = TRUE;
+
gtk_test_init (&argc, &argv);
+ /* Ignore the one-time warning that the fallback icon theme can’t be found
+ * (because we’ve changed the search paths). */
+ g_log_set_writer_func (log_writer_drop_warnings, &ignore_warnings, NULL);
+ assert_icon_lookup_fails ("this-icon-totally-does-not-exist", 16, 0);
+ ignore_warnings = FALSE;
+
g_test_add_func ("/icontheme/basics", test_basics);
g_test_add_func ("/icontheme/lookup-order", test_lookup_order);
g_test_add_func ("/icontheme/generic-fallback", test_generic_fallback);