diff options
-rw-r--r-- | testsuite/gtk/Makefile.am | 1 | ||||
-rw-r--r-- | testsuite/gtk/icons/scalable/nonsquare-symbolic.svg | 12 | ||||
-rw-r--r-- | testsuite/gtk/icontheme.c | 55 |
3 files changed, 68 insertions, 0 deletions
diff --git a/testsuite/gtk/Makefile.am b/testsuite/gtk/Makefile.am index ea828ce5ac..9a3809e4f4 100644 --- a/testsuite/gtk/Makefile.am +++ b/testsuite/gtk/Makefile.am @@ -153,6 +153,7 @@ test_icontheme = \ icons/scalable/everything-justsymbolic-symbolic.svg \ icons/scalable/everything.svg \ icons/scalable/everything-symbolic.svg \ + icons/scalable/nonsquare-symbolic.svg \ icons/15/size-test.png \ icons/16-22/size-test.png \ icons/25+/size-test.svg \ diff --git a/testsuite/gtk/icons/scalable/nonsquare-symbolic.svg b/testsuite/gtk/icons/scalable/nonsquare-symbolic.svg new file mode 100644 index 0000000000..2df92d0f20 --- /dev/null +++ b/testsuite/gtk/icons/scalable/nonsquare-symbolic.svg @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+ width="12px" height="18px" viewBox="-0.5 0.5 12 18" enable-background="new -0.5 0.5 12 18" xml:space="preserve">
+<g id="Captions">
+</g>
+<path d="M9.5,11.5h-7l-3-3v3v5c0,1.105,0.895,2,2,2h8c1.105,0,2-0.895,2-2v-3C11.5,12.395,10.605,11.5,9.5,11.5z M9.5,16.5h-8v-1h8
+ V16.5z M9.5,14.5h-8v-1h8V14.5z"/>
+<path d="M9.5,0.5h-8c-1.105,0-2,0.895-2,2v3c0,1.105,0.895,2,2,2h7l3,3v-3v-5C11.5,1.395,10.605,0.5,9.5,0.5z M9.5,5.5h-8v-1h8V5.5z
+ M9.5,3.5h-8v-1h8V3.5z"/>
+</svg>
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c index de895c29d3..7fcb1609f1 100644 --- a/testsuite/gtk/icontheme.c +++ b/testsuite/gtk/icontheme.c @@ -698,6 +698,60 @@ test_inherit (void) "/icons2/scalable/one-two-symbolic-rtl.svg"); } +static void +test_nonsquare_symbolic (void) +{ + gint width, height; + GtkIconTheme *icon_theme; + GtkIconInfo *info; + GFile *file; + GIcon *icon; + GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 }; + gboolean was_symbolic = FALSE; + GError *error = NULL; + gchar *path = g_build_filename (g_test_get_dir (G_TEST_DIST), + "icons", + "scalable", + "nonsquare-symbolic.svg", + NULL); + + /* load the original image for reference */ + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, &error); + g_assert_no_error (error); + g_assert_nonnull (pixbuf); + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + g_assert_cmpint (width, !=, height); + + /* now load it through GtkIconTheme */ + icon_theme = gtk_icon_theme_get_default (); + file = g_file_new_for_path (path); + icon = g_file_icon_new (file); + info = gtk_icon_theme_lookup_by_gicon_for_scale (icon_theme, icon, + height, 1, 0); + g_assert_nonnull (info); + + g_object_unref (pixbuf); + pixbuf = gtk_icon_info_load_symbolic (info, &black, NULL, NULL, NULL, + &was_symbolic, &error); + + /* we are loaded successfully */ + g_assert_no_error (error); + g_assert_nonnull (pixbuf); + g_assert_true (was_symbolic); + + /* the original dimensions have been preserved */ + g_assert_cmpint (gdk_pixbuf_get_width (pixbuf), ==, width); + g_assert_cmpint (gdk_pixbuf_get_height (pixbuf), ==, height); + + g_free (path); + g_object_unref (pixbuf); + g_object_unref (file); + g_object_unref (icon); + g_object_unref (info); +} + int main (int argc, char *argv[]) { @@ -716,6 +770,7 @@ main (int argc, char *argv[]) g_test_add_func ("/icontheme/list", test_list); g_test_add_func ("/icontheme/async", test_async); g_test_add_func ("/icontheme/inherit", test_inherit); + g_test_add_func ("/icontheme/nonsquare-symbolic", test_nonsquare_symbolic); return g_test_run(); } |