diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-06-14 15:06:57 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-06-14 15:10:49 -0400 |
commit | 84cf748eae1f21e2b78b8e330a53ee12a308e32f (patch) | |
tree | dea9489f0f02840403adc97101627e7880cb4810 | |
parent | fd53732035f4633d4c4e81e1be1a76b4dd40a8b5 (diff) | |
download | gtk+-84cf748eae1f21e2b78b8e330a53ee12a308e32f.tar.gz |
Add more icontheme tests
This test is focused on svgs, and how we scale them when
loading.
-rw-r--r-- | testsuite/gtk/icons/16x16/twosize-fixed.svg | 56 | ||||
-rw-r--r-- | testsuite/gtk/icons/16x16s/twosize.svg | 56 | ||||
-rw-r--r-- | testsuite/gtk/icons/32x32/twosize-fixed.svg | 4 | ||||
-rw-r--r-- | testsuite/gtk/icons/32x32s/twosize.svg | 4 | ||||
-rw-r--r-- | testsuite/gtk/icons/index.theme | 20 | ||||
-rw-r--r-- | testsuite/gtk/icontheme.c | 53 |
6 files changed, 186 insertions, 7 deletions
diff --git a/testsuite/gtk/icons/16x16/twosize-fixed.svg b/testsuite/gtk/icons/16x16/twosize-fixed.svg new file mode 100644 index 0000000000..3bb8881269 --- /dev/null +++ b/testsuite/gtk/icons/16x16/twosize-fixed.svg @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="32" + height="32" + version="1.1" + id="svg3033" + inkscape:version="0.48.4 r9939" + sodipodi:docname="only32-svg.svg"> + <metadata + id="metadata3041"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs3039" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="640" + inkscape:window-height="480" + id="namedview3037" + showgrid="false" + inkscape:zoom="11.313708" + inkscape:cx="16" + inkscape:cy="16.526174" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="0" + inkscape:current-layer="svg3033" /> + <text + x="16" + y="24" + font-size="24" + id="text3035" + style="font-size:24px;text-anchor:middle">16</text> +</svg> diff --git a/testsuite/gtk/icons/16x16s/twosize.svg b/testsuite/gtk/icons/16x16s/twosize.svg new file mode 100644 index 0000000000..3bb8881269 --- /dev/null +++ b/testsuite/gtk/icons/16x16s/twosize.svg @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="32" + height="32" + version="1.1" + id="svg3033" + inkscape:version="0.48.4 r9939" + sodipodi:docname="only32-svg.svg"> + <metadata + id="metadata3041"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs3039" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="640" + inkscape:window-height="480" + id="namedview3037" + showgrid="false" + inkscape:zoom="11.313708" + inkscape:cx="16" + inkscape:cy="16.526174" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="0" + inkscape:current-layer="svg3033" /> + <text + x="16" + y="24" + font-size="24" + id="text3035" + style="font-size:24px;text-anchor:middle">16</text> +</svg> diff --git a/testsuite/gtk/icons/32x32/twosize-fixed.svg b/testsuite/gtk/icons/32x32/twosize-fixed.svg new file mode 100644 index 0000000000..45b553cb11 --- /dev/null +++ b/testsuite/gtk/icons/32x32/twosize-fixed.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" standalone="no"?> +<svg width="32" height="32" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <text x="16" y="24" text-anchor="middle" font-size="24">32</text> +</svg> diff --git a/testsuite/gtk/icons/32x32s/twosize.svg b/testsuite/gtk/icons/32x32s/twosize.svg new file mode 100644 index 0000000000..45b553cb11 --- /dev/null +++ b/testsuite/gtk/icons/32x32s/twosize.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" standalone="no"?> +<svg width="32" height="32" version="1.1" xmlns="http://www.w3.org/2000/svg"> + <text x="16" y="24" text-anchor="middle" font-size="24">32</text> +</svg> diff --git a/testsuite/gtk/icons/index.theme b/testsuite/gtk/icons/index.theme index cecd974868..20c53bb7c0 100644 --- a/testsuite/gtk/icons/index.theme +++ b/testsuite/gtk/icons/index.theme @@ -3,7 +3,7 @@ Name=Icons Comment=Testing of the Icon theme code Example=16x16/simple.png -Directories=16x16,32x32,scalable +Directories=16x16,16x16s,32x32,32x32s,scalable [16x16] Context=16x16 icons @@ -15,9 +15,23 @@ Context=32x32 icons Size=32 Type=Fixed +[16x16s] +Context=scalable 16x16 icons +Size=16 +MinSize=12 +MaxSize=24 +Type=Scalable + +[32x32s] +Context=scalable 32x32 icons +Size=32 +MinSize=24 +MaxSize=48 +Type=Scalable + [scalable] Context=scalable icons Type=Scalable Size=128 -Min-Size=1 -Max-Size=256 +MinSize=1 +MaxSize=256 diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c index 17fe6a04e2..01eac235e5 100644 --- a/testsuite/gtk/icontheme.c +++ b/testsuite/gtk/icontheme.c @@ -45,10 +45,11 @@ lookup_flags_to_string (GtkIconLookupFlags flags) } static void -assert_icon_lookup (const char *icon_name, - gint size, - GtkIconLookupFlags flags, - const char *filename) +assert_icon_lookup_size (const char *icon_name, + gint size, + GtkIconLookupFlags flags, + const char *filename, + gint pixbuf_size) { GtkIconInfo *info; @@ -68,10 +69,30 @@ assert_icon_lookup (const char *icon_name, return; } + if (pixbuf_size > 0) + { + GdkPixbuf *pixbuf; + GError *error = NULL; + + pixbuf = gtk_icon_info_load_icon (info, &error); + g_assert_no_error (error); + g_assert_cmpint (gdk_pixbuf_get_width (pixbuf), ==, pixbuf_size); + g_object_unref (pixbuf); + } + g_object_unref (info); } static void +assert_icon_lookup (const char *icon_name, + gint size, + GtkIconLookupFlags flags, + const char *filename) +{ + assert_icon_lookup_size (icon_name, size, flags, filename, -1); +} + +static void assert_icon_lookup_fails (const char *icon_name, gint size, GtkIconLookupFlags flags) @@ -424,6 +445,29 @@ test_symbolic_single_size (void) "/icons/32x32/only32-symbolic.svg"); } +static void +test_svg_size (void) +{ + /* To understand these results, keep in mind that we never allow upscaling, + * and don't respect min/max size for scaling (though we do take it into + * account for choosing). + */ + /* Check we properly load a svg icon from a sized directory */ + assert_icon_lookup_size ("twosize-fixed", 48, 0, "/icons/32x32/twosize-fixed.svg", 32); + assert_icon_lookup_size ("twosize-fixed", 32, 0, "/icons/32x32/twosize-fixed.svg", 32); + assert_icon_lookup_size ("twosize-fixed", 20, 0, "/icons/32x32/twosize-fixed.svg", 32); + assert_icon_lookup_size ("twosize-fixed", 16, 0, "/icons/16x16/twosize-fixed.svg", 16); + + /* Check that we still properly load it even if a different size is requested */ + assert_icon_lookup_size ("twosize", 64, 0, "/icons/32x32s/twosize.svg", 64); + assert_icon_lookup_size ("twosize", 48, 0, "/icons/32x32s/twosize.svg", 48); + assert_icon_lookup_size ("twosize", 32, 0, "/icons/32x32s/twosize.svg", 32); + assert_icon_lookup_size ("twosize", 24, 0, "/icons/32x32s/twosize.svg", 24); + assert_icon_lookup_size ("twosize", 16, 0, "/icons/16x16s/twosize.svg", 16); + assert_icon_lookup_size ("twosize", 12, 0, "/icons/16x16s/twosize.svg", 12); + assert_icon_lookup_size ("twosize", 8, 0, "/icons/16x16s/twosize.svg", 8); +} + int main (int argc, char *argv[]) { @@ -436,6 +480,7 @@ main (int argc, char *argv[]) g_test_add_func ("/icontheme/force-regular", test_force_regular); g_test_add_func ("/icontheme/rtl", test_rtl); g_test_add_func ("/icontheme/symbolic-single-size", test_symbolic_single_size); + g_test_add_func ("/icontheme/svg-size", test_svg_size); return g_test_run(); } |