diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-05-12 20:29:39 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-05-12 20:38:28 -0400 |
commit | e47322ee43304f5962db007277e8dea87716f5cd (patch) | |
tree | 24cf563d77710c27ddcccbe19083429c4aa77da9 | |
parent | b24f6fa928ca9e17943fc29c46ea300d1467b00a (diff) | |
download | gtk+-e47322ee43304f5962db007277e8dea87716f5cd.tar.gz |
Add tests for rtl icons and lookup orderwip/css-icons
Add tests for GTK_ICON_LOOKUP_DIR_RTL/LTR and tests that
verify the expected lookup order between -symbolic,
-rtl/-ltr and generic fallback.
-rw-r--r-- | gtk/gtkicontheme.c | 5 | ||||
-rw-r--r-- | testsuite/gtk/icons/16x16/bar-baz.png | bin | 0 -> 174 bytes | |||
-rw-r--r-- | testsuite/gtk/icons/16x16/bar-rtl.png | bin | 0 -> 174 bytes | |||
-rw-r--r-- | testsuite/gtk/icons/16x16/foo.png | bin | 0 -> 174 bytes | |||
-rw-r--r-- | testsuite/gtk/icontheme.c | 102 |
5 files changed, 107 insertions, 0 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index 1ad6953c65..dd0627404a 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -1643,6 +1643,11 @@ real_choose_icon (GtkIconTheme *icon_theme, use_builtin = flags & GTK_ICON_LOOKUP_USE_BUILTIN; + /* This is used in the icontheme unit test */ + GTK_NOTE (ICONTHEME, + for (i = 0; icon_names[i]; i++) + g_print ("\tlookup name: %s\n", icon_names[i])); + /* for symbolic icons, do a search in all registered themes first; * a theme that inherits them from a parent theme might provide * an alternative highcolor version, but still expect the symbolic icon diff --git a/testsuite/gtk/icons/16x16/bar-baz.png b/testsuite/gtk/icons/16x16/bar-baz.png Binary files differnew file mode 100644 index 0000000000..91824f9750 --- /dev/null +++ b/testsuite/gtk/icons/16x16/bar-baz.png diff --git a/testsuite/gtk/icons/16x16/bar-rtl.png b/testsuite/gtk/icons/16x16/bar-rtl.png Binary files differnew file mode 100644 index 0000000000..91824f9750 --- /dev/null +++ b/testsuite/gtk/icons/16x16/bar-rtl.png diff --git a/testsuite/gtk/icons/16x16/foo.png b/testsuite/gtk/icons/16x16/foo.png Binary files differnew file mode 100644 index 0000000000..91824f9750 --- /dev/null +++ b/testsuite/gtk/icons/16x16/foo.png diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c index 1b1c039dcb..20eef66edb 100644 --- a/testsuite/gtk/icontheme.c +++ b/testsuite/gtk/icontheme.c @@ -99,6 +99,106 @@ test_symbolic_fallback (void) assert_icon_lookup ("foo-bar-symbolic", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_REGULAR, "/icons/16x16/foo.png"); } +static void +test_rtl (void) +{ + assert_icon_lookup ("simple-foo", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_DIR_RTL, "/icons/16x16/simple.png"); + assert_icon_lookup ("bar-baz", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_RTL, "/icons/16x16/bar-baz.png"); +} + +static GList *lookups = NULL; + +static void +print_func (const gchar *string) +{ + if (g_str_has_prefix (string, "\tlookup name: ")) + { + gchar *s; + s = g_strchomp (g_strdup (string + strlen ("\tlookup name: "))); + lookups = g_list_append (lookups, s); + } +} + +static void +assert_lookup_order (const char *icon_name, + gint size, + GtkIconLookupFlags flags, + const char *first, + ...) +{ + guint debug_flags; + GPrintFunc old_print_func; + va_list args; + const gchar *s; + GtkIconInfo *info; + GList *l; + + debug_flags = gtk_get_debug_flags (); + gtk_set_debug_flags (debug_flags | GTK_DEBUG_ICONTHEME); + old_print_func = g_set_print_handler (print_func); + + g_assert (lookups == NULL); + + info = gtk_icon_theme_lookup_icon (get_test_icontheme (), icon_name, size, flags); + if (info) + g_object_unref (info); + + va_start (args, first); + s = first; + l = lookups; + while (s != NULL) + { + g_assert (l != NULL); + g_assert_cmpstr (s, ==, l->data); + s = va_arg (args, gchar*); + l = l->next; + } + g_assert (l == NULL); + va_end (args); + + g_list_free_full (lookups, g_free); + lookups = NULL; + + g_set_print_handler (old_print_func); + gtk_set_debug_flags (debug_flags); +} + +static void +test_lookup_order (void) +{ + assert_lookup_order ("foo-bar-baz", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK, + "foo-bar-baz", + "foo-bar", + "foo", + NULL); + assert_lookup_order ("bla-bla", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC, + "bla-bla-symbolic", + "bla-symbolic", + "bla-bla", + "bla", + NULL); + assert_lookup_order ("bar-baz", 16, GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_RTL, + "bar-baz-symbolic-rtl", + "bar-baz-symbolic", + "bar-symbolic-rtl", + "bar-symbolic", + "bar-baz-rtl", + "bar-baz", + "bar-rtl", + "bar", + NULL); + assert_lookup_order ("bar-baz", 16, GTK_ICON_LOOKUP_FORCE_SYMBOLIC|GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_DIR_LTR, + "bar-baz-symbolic-ltr", + "bar-baz-symbolic", + "bar-symbolic-ltr", + "bar-symbolic", + "bar-baz-ltr", + "bar-baz", + "bar-ltr", + "bar", + NULL); +} + int main (int argc, char *argv[]) { @@ -108,6 +208,8 @@ main (int argc, char *argv[]) g_test_add_func ("/icontheme/fallback", test_fallback); g_test_add_func ("/icontheme/symbolic", test_symbolic); g_test_add_func ("/icontheme/symbolic-fallback", test_symbolic_fallback); + g_test_add_func ("/icontheme/rtl", test_rtl); + g_test_add_func ("/icontheme/lookup-order", test_lookup_order); return g_test_run(); } |