[gtk+/wip/css-icons] Add tests for rtl icons and lookup order
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css-icons] Add tests for rtl icons and lookup order
- Date: Tue, 13 May 2014 00:39:19 +0000 (UTC)
commit e47322ee43304f5962db007277e8dea87716f5cd
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 12 20:29:39 2014 -0400
Add tests for rtl icons and lookup order
Add tests for GTK_ICON_LOOKUP_DIR_RTL/LTR and tests that
verify the expected lookup order between -symbolic,
-rtl/-ltr and generic fallback.
gtk/gtkicontheme.c | 5 ++
testsuite/gtk/icons/16x16/bar-baz.png | Bin 0 -> 174 bytes
testsuite/gtk/icons/16x16/bar-rtl.png | Bin 0 -> 174 bytes
testsuite/gtk/icons/16x16/foo.png | Bin 0 -> 174 bytes
testsuite/gtk/icontheme.c | 102 +++++++++++++++++++++++++++++++++
5 files changed, 107 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 1ad6953..dd06274 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
new file mode 100644
index 0000000..91824f9
Binary files /dev/null and b/testsuite/gtk/icons/16x16/bar-baz.png differ
diff --git a/testsuite/gtk/icons/16x16/bar-rtl.png b/testsuite/gtk/icons/16x16/bar-rtl.png
new file mode 100644
index 0000000..91824f9
Binary files /dev/null and b/testsuite/gtk/icons/16x16/bar-rtl.png differ
diff --git a/testsuite/gtk/icons/16x16/foo.png b/testsuite/gtk/icons/16x16/foo.png
new file mode 100644
index 0000000..91824f9
Binary files /dev/null and b/testsuite/gtk/icons/16x16/foo.png differ
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index 1b1c039..20eef66 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();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]