[gtk+/wip/css-icons] Add tests for symbolic icon lookup
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/css-icons] Add tests for symbolic icon lookup
- Date: Mon, 12 May 2014 22:35:07 +0000 (UTC)
commit 090bfb023d05a4ce5083c1f38d3ed79d018225a1
Author: Matthias Clasen <mclasen redhat com>
Date: Mon May 12 18:34:48 2014 -0400
Add tests for symbolic icon lookup
testsuite/gtk/icons/index.theme | 8 +++-
testsuite/gtk/icons/scalable/foo-symbolic.svg | 66 +++++++++++++++++++++++++
testsuite/gtk/icontheme.c | 33 +++++++++++-
3 files changed, 103 insertions(+), 4 deletions(-)
---
diff --git a/testsuite/gtk/icons/index.theme b/testsuite/gtk/icons/index.theme
index 79ecb17..0080bcc 100644
--- a/testsuite/gtk/icons/index.theme
+++ b/testsuite/gtk/icons/index.theme
@@ -3,10 +3,16 @@ Name=Icons
Comment=Testing of the Icon theme code
Example=16x16/simple.png
-Directories=16x16
+Directories=16x16,scalable
[16x16]
Context=16x16 icons
Size=16
Type=Fixed
+[scalable]
+Context=scalable icons
+Size=16
+MinSize=8
+MaxSize=512
+Type=Scalable
diff --git a/testsuite/gtk/icons/scalable/foo-symbolic.svg b/testsuite/gtk/icons/scalable/foo-symbolic.svg
new file mode 100644
index 0000000..0e218c5
--- /dev/null
+++ b/testsuite/gtk/icons/scalable/foo-symbolic.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<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="16"
+ height="16"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="drawing.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.979899"
+ inkscape:cx="18.642857"
+ inkscape:cy="40.492631"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="694"
+ inkscape:window-height="523"
+ inkscape:window-x="794"
+ inkscape:window-y="155"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata7">
+ <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 />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-1036.3622)">
+ <path
+ sodipodi:type="arc"
+
style="fill:#ff0000;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2985"
+ sodipodi:cx="354.28571"
+ sodipodi:cy="460.93362"
+ sodipodi:rx="145.71428"
+ sodipodi:ry="137.14285"
+ d="m 499.99998,460.93362 a 145.71428,137.14285 0 1 1 -291.42855,0 145.71428,137.14285 0 1 1
291.42855,0 z"
+ transform="matrix(0.05010986,0,0,0.04597959,-8.9396748,1023.1031)" />
+ </g>
+</svg>
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index 2f84616..1b1c039 100644
--- a/testsuite/gtk/icontheme.c
+++ b/testsuite/gtk/icontheme.c
@@ -6,15 +6,16 @@ static GtkIconTheme *
get_test_icontheme (void)
{
static GtkIconTheme *icon_theme = NULL;
- const char *current_dir;
+ const gchar *search_path[2];
if (icon_theme)
return icon_theme;
icon_theme = gtk_icon_theme_new ();
gtk_icon_theme_set_custom_theme (icon_theme, "icons");
- current_dir = g_get_current_dir ();
- gtk_icon_theme_set_search_path (icon_theme, ¤t_dir, 1);
+ search_path[0] = g_get_current_dir ();
+ search_path[1] = "/usr/share/icons";
+ gtk_icon_theme_set_search_path (icon_theme, search_path, 2);
return icon_theme;
}
@@ -75,12 +76,38 @@ test_basics (void)
assert_icon_lookup ("simple", 16, 0, "/icons/16x16/simple.png");
}
+static void
+test_fallback (void)
+{
+ assert_icon_lookup ("simple-foo-bar", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK, "/icons/16x16/simple.png");
+ assert_icon_lookup ("simple-foo-bar-symbolic", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK,
"/icons/16x16/simple.png");
+}
+
+static void
+test_symbolic (void)
+{
+ assert_icon_lookup ("foo", 16, 0, "/icons/16x16/foo.png");
+ assert_icon_lookup ("foo-symbolic", 16, 0, "/icons/scalable/foo-symbolic.svg");
+ assert_icon_lookup ("foo", 16, GTK_ICON_LOOKUP_FORCE_SYMBOLIC, "/icons/scalable/foo-symbolic.svg");
+ assert_icon_lookup ("foo-symbolic", 16, GTK_ICON_LOOKUP_FORCE_REGULAR, "/icons/16x16/foo.png");
+}
+
+static void
+test_symbolic_fallback (void)
+{
+ assert_icon_lookup ("foo-bar", 16, GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_SYMBOLIC,
"/icons/scalable/foo-symbolic.svg");
+ assert_icon_lookup ("foo-bar-symbolic", 16,
GTK_ICON_LOOKUP_GENERIC_FALLBACK|GTK_ICON_LOOKUP_FORCE_REGULAR, "/icons/16x16/foo.png");
+}
+
int
main (int argc, char *argv[])
{
gtk_test_init (&argc, &argv);
g_test_add_func ("/icontheme/basics", test_basics);
+ 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);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]