mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
Avoid g_log_set_writer_func in tests
It is not usable anymore since GLib 2.72.
This commit is contained in:
parent
38ec040fce
commit
73dc741a82
@ -136,6 +136,7 @@ assert_icon_lookup_fails (const char *icon_name,
|
||||
}
|
||||
|
||||
static GList *lookups = NULL;
|
||||
static gboolean collecting_lookups = FALSE;
|
||||
|
||||
static GLogWriterOutput
|
||||
log_writer (GLogLevelFlags log_level,
|
||||
@ -147,6 +148,9 @@ log_writer (GLogLevelFlags log_level,
|
||||
const char *msg = NULL;
|
||||
int i;
|
||||
|
||||
if (!collecting_lookups)
|
||||
return g_log_writer_default (log_level, fields, n_fields, user_data);
|
||||
|
||||
for (i = 0; i < n_fields; i++)
|
||||
{
|
||||
if (strcmp (fields[i].key, "GLIB_DOMAIN") == 0)
|
||||
@ -177,22 +181,13 @@ assert_lookup_order (const char *icon_name,
|
||||
const char *first,
|
||||
...)
|
||||
{
|
||||
guint debug_flags;
|
||||
va_list args;
|
||||
const char *s;
|
||||
GtkIconPaintable *info;
|
||||
GList *l;
|
||||
|
||||
/* this hack is only usable in debug builds */
|
||||
#ifndef G_ENABLE_DEBUG
|
||||
g_assert_not_reached ();
|
||||
#endif
|
||||
|
||||
debug_flags = gtk_get_debug_flags ();
|
||||
gtk_set_debug_flags (debug_flags | GTK_DEBUG_ICONTHEME);
|
||||
g_log_set_writer_func (log_writer, NULL, NULL);
|
||||
|
||||
g_assert_null (lookups);
|
||||
collecting_lookups = TRUE;
|
||||
|
||||
if (fallbacks)
|
||||
{
|
||||
@ -208,7 +203,9 @@ assert_lookup_order (const char *icon_name,
|
||||
|
||||
if (info)
|
||||
g_object_unref (info);
|
||||
|
||||
|
||||
collecting_lookups = FALSE;
|
||||
|
||||
va_start (args, first);
|
||||
s = first;
|
||||
l = lookups;
|
||||
@ -224,9 +221,6 @@ assert_lookup_order (const char *icon_name,
|
||||
|
||||
g_list_free_full (lookups, g_free);
|
||||
lookups = NULL;
|
||||
|
||||
g_log_set_writer_func (g_log_writer_default, NULL, NULL);
|
||||
gtk_set_debug_flags (debug_flags);
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
@ -237,6 +231,136 @@ assert_lookup_order (const char *icon_name,
|
||||
return;
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_lookup_order (void)
|
||||
{
|
||||
require_debug ();
|
||||
|
||||
if (g_test_subprocess ())
|
||||
{
|
||||
guint debug_flags;
|
||||
|
||||
debug_flags = gtk_get_debug_flags ();
|
||||
gtk_set_debug_flags (debug_flags | GTK_DEBUG_ICONTHEME);
|
||||
|
||||
g_log_set_writer_func (log_writer, NULL, NULL);
|
||||
|
||||
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_NONE, 0, TRUE,
|
||||
"foo-bar-baz",
|
||||
"foo-bar",
|
||||
"foo",
|
||||
"foo-bar-baz-symbolic",
|
||||
"foo-bar-symbolic",
|
||||
"foo-symbolic",
|
||||
NULL);
|
||||
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0, TRUE,
|
||||
"foo-bar-baz-rtl",
|
||||
"foo-bar-baz",
|
||||
"foo-bar-rtl",
|
||||
"foo-bar",
|
||||
"foo-rtl",
|
||||
"foo",
|
||||
"foo-bar-baz-symbolic-rtl",
|
||||
"foo-bar-baz-symbolic",
|
||||
"foo-bar-symbolic-rtl",
|
||||
"foo-bar-symbolic",
|
||||
"foo-symbolic-rtl",
|
||||
"foo-symbolic",
|
||||
NULL);
|
||||
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0, FALSE,
|
||||
"foo-bar-baz-rtl",
|
||||
"foo-bar-baz",
|
||||
NULL);
|
||||
assert_lookup_order ("foo-bar-baz-symbolic", 16, GTK_TEXT_DIR_NONE, 0, TRUE,
|
||||
"foo-bar-baz-symbolic",
|
||||
"foo-bar-symbolic",
|
||||
"foo-symbolic",
|
||||
"foo-bar-baz",
|
||||
"foo-bar",
|
||||
"foo",
|
||||
NULL);
|
||||
|
||||
assert_lookup_order ("bla-bla", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bla-bla-symbolic",
|
||||
"bla-symbolic",
|
||||
"bla-bla-symbolic", /* awkward */
|
||||
"bla-symbolic", /* awkward */
|
||||
"bla-bla",
|
||||
"bla",
|
||||
NULL);
|
||||
assert_lookup_order ("bla-bla-symbolic", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bla-bla-symbolic",
|
||||
"bla-symbolic",
|
||||
"bla-bla-symbolic", /* awkward */
|
||||
"bla-symbolic", /* awkward */
|
||||
"bla-bla",
|
||||
"bla",
|
||||
NULL);
|
||||
|
||||
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-rtl",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-rtl",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-rtl", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-rtl", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-rtl",
|
||||
"bar-baz",
|
||||
"bar-rtl",
|
||||
"bar",
|
||||
NULL);
|
||||
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-rtl",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-rtl",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-rtl", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-rtl", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-rtl",
|
||||
"bar-baz",
|
||||
"bar-rtl",
|
||||
"bar",
|
||||
NULL);
|
||||
|
||||
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-ltr",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-ltr",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-ltr", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-ltr", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-ltr",
|
||||
"bar-baz",
|
||||
"bar-ltr",
|
||||
"bar",
|
||||
NULL);
|
||||
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-ltr",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-ltr",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-ltr", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-ltr", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-ltr",
|
||||
"bar-baz",
|
||||
"bar-ltr",
|
||||
"bar",
|
||||
NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_test_trap_subprocess (NULL, 0, 0);
|
||||
g_test_trap_has_passed ();
|
||||
}
|
||||
|
||||
static void
|
||||
test_basics (void)
|
||||
@ -245,122 +369,6 @@ test_basics (void)
|
||||
assert_icon_lookup ("simple", 16, GTK_TEXT_DIR_NONE, 0, FALSE, "/icons/16x16/simple.png");
|
||||
}
|
||||
|
||||
static void
|
||||
test_lookup_order (void)
|
||||
{
|
||||
require_debug ();
|
||||
|
||||
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_NONE, 0, TRUE,
|
||||
"foo-bar-baz",
|
||||
"foo-bar",
|
||||
"foo",
|
||||
"foo-bar-baz-symbolic",
|
||||
"foo-bar-symbolic",
|
||||
"foo-symbolic",
|
||||
NULL);
|
||||
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0, TRUE,
|
||||
"foo-bar-baz-rtl",
|
||||
"foo-bar-baz",
|
||||
"foo-bar-rtl",
|
||||
"foo-bar",
|
||||
"foo-rtl",
|
||||
"foo",
|
||||
"foo-bar-baz-symbolic-rtl",
|
||||
"foo-bar-baz-symbolic",
|
||||
"foo-bar-symbolic-rtl",
|
||||
"foo-bar-symbolic",
|
||||
"foo-symbolic-rtl",
|
||||
"foo-symbolic",
|
||||
NULL);
|
||||
assert_lookup_order ("foo-bar-baz", 16, GTK_TEXT_DIR_RTL, 0, FALSE,
|
||||
"foo-bar-baz-rtl",
|
||||
"foo-bar-baz",
|
||||
NULL);
|
||||
assert_lookup_order ("foo-bar-baz-symbolic", 16, GTK_TEXT_DIR_NONE, 0, TRUE,
|
||||
"foo-bar-baz-symbolic",
|
||||
"foo-bar-symbolic",
|
||||
"foo-symbolic",
|
||||
"foo-bar-baz",
|
||||
"foo-bar",
|
||||
"foo",
|
||||
NULL);
|
||||
|
||||
assert_lookup_order ("bla-bla", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bla-bla-symbolic",
|
||||
"bla-symbolic",
|
||||
"bla-bla-symbolic", /* awkward */
|
||||
"bla-symbolic", /* awkward */
|
||||
"bla-bla",
|
||||
"bla",
|
||||
NULL);
|
||||
assert_lookup_order ("bla-bla-symbolic", 16, GTK_TEXT_DIR_NONE, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bla-bla-symbolic",
|
||||
"bla-symbolic",
|
||||
"bla-bla-symbolic", /* awkward */
|
||||
"bla-symbolic", /* awkward */
|
||||
"bla-bla",
|
||||
"bla",
|
||||
NULL);
|
||||
|
||||
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-rtl",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-rtl",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-rtl", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-rtl", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-rtl",
|
||||
"bar-baz",
|
||||
"bar-rtl",
|
||||
"bar",
|
||||
NULL);
|
||||
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_RTL, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-rtl",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-rtl",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-rtl", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-rtl", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-rtl",
|
||||
"bar-baz",
|
||||
"bar-rtl",
|
||||
"bar",
|
||||
NULL);
|
||||
|
||||
assert_lookup_order ("bar-baz", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-ltr",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-ltr",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-ltr", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-ltr", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-ltr",
|
||||
"bar-baz",
|
||||
"bar-ltr",
|
||||
"bar",
|
||||
NULL);
|
||||
assert_lookup_order ("bar-baz-symbolic", 16, GTK_TEXT_DIR_LTR, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, TRUE,
|
||||
"bar-baz-symbolic-ltr",
|
||||
"bar-baz-symbolic",
|
||||
"bar-symbolic-ltr",
|
||||
"bar-symbolic",
|
||||
"bar-baz-symbolic-ltr", /* awkward */
|
||||
"bar-baz-symbolic", /* awkward */
|
||||
"bar-symbolic-ltr", /* awkward */
|
||||
"bar-symbolic", /* awkward */
|
||||
"bar-baz-ltr",
|
||||
"bar-baz",
|
||||
"bar-ltr",
|
||||
"bar",
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
test_generic_fallback (void)
|
||||
{
|
||||
@ -804,7 +812,6 @@ main (int argc, char *argv[])
|
||||
gtk_test_init (&argc, &argv);
|
||||
|
||||
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);
|
||||
g_test_add_func ("/icontheme/force-symbolic", test_force_symbolic);
|
||||
g_test_add_func ("/icontheme/force-regular", test_force_regular);
|
||||
@ -815,6 +822,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/icontheme/list", test_list);
|
||||
g_test_add_func ("/icontheme/inherit", test_inherit);
|
||||
g_test_add_func ("/icontheme/nonsquare-symbolic", test_nonsquare_symbolic);
|
||||
g_test_add_func ("/icontheme/lookup-order", test_lookup_order);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
@ -1049,30 +1049,26 @@ specific_bug_77977 (void)
|
||||
g_object_unref (tree_store);
|
||||
}
|
||||
|
||||
static GLogWriterOutput
|
||||
log_writer_drop_warnings (GLogLevelFlags log_level,
|
||||
const GLogField *fields,
|
||||
gsize n_fields,
|
||||
gpointer user_data)
|
||||
{
|
||||
return G_LOG_WRITER_HANDLED;
|
||||
}
|
||||
|
||||
static void
|
||||
specific_bug_698396 (void)
|
||||
{
|
||||
GtkTreeStore *tree_store;
|
||||
int new_order[1] = { 0 };
|
||||
|
||||
/*http://bugzilla.gnome.org/show_bug.cgi?id=698396 */
|
||||
|
||||
tree_store = gtk_tree_store_new (1, G_TYPE_STRING);
|
||||
if (g_test_subprocess ())
|
||||
{
|
||||
GtkTreeStore *tree_store;
|
||||
int new_order[1] = { 0 };
|
||||
|
||||
g_log_set_writer_func (log_writer_drop_warnings, NULL, NULL);
|
||||
gtk_tree_store_reorder (tree_store, NULL, new_order);
|
||||
g_log_set_writer_func (g_log_writer_default, NULL, NULL);
|
||||
tree_store = gtk_tree_store_new (1, G_TYPE_STRING);
|
||||
gtk_tree_store_reorder (tree_store, NULL, new_order);
|
||||
g_object_unref (tree_store);
|
||||
|
||||
g_object_unref (tree_store);
|
||||
return;
|
||||
}
|
||||
|
||||
g_test_trap_subprocess (NULL, 0, 0);
|
||||
g_test_trap_assert_stderr ("*Cannot reorder, parent has no children*");
|
||||
g_test_trap_assert_failed ();
|
||||
}
|
||||
|
||||
/* main */
|
||||
|
Loading…
Reference in New Issue
Block a user