summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHiroyuki Ikezoe <poincare@ikezoe.net>2010-04-14 15:39:28 +0900
committerHiroyuki Ikezoe <poincare@ikezoe.net>2010-04-14 15:39:28 +0900
commit53f13337cd3d46bd8fb5197c6cea457618e9252c (patch)
tree8b98372ba3f3b98b55d0c0f736350886efd64557 /tests
parentcb6172513b9ff3446c97629dc5f9de3d76ff6440 (diff)
downloadlibrsvg-53f13337cd3d46bd8fb5197c6cea457618e9252c.tar.gz
tests for CSS selectors.
Fix for bug #614866.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/fixtures/styles/bug338160.svg58
-rw-r--r--tests/fixtures/styles/bug379629.svg45
-rw-r--r--tests/fixtures/styles/bug418823.svg12
-rw-r--r--tests/fixtures/styles/bug592207.svg13
-rw-r--r--tests/fixtures/styles/bug614606.svg133
-rw-r--r--tests/fixtures/styles/bug614704.svg11
-rw-r--r--tests/fixtures/styles/order.svg25
-rw-r--r--tests/fixtures/styles/svg-class.svg14
-rw-r--r--tests/styles.c116
10 files changed, 429 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 368f212d..4a78217d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,8 @@ SUBDIRS=pdiff .
TESTS = \
rsvg-test \
- dimensions
+ dimensions \
+ styles
LDADD = $(top_builddir)/librsvg-2.la \
$(top_builddir)/tests/pdiff/libpdiff.la
diff --git a/tests/fixtures/styles/bug338160.svg b/tests/fixtures/styles/bug338160.svg
new file mode 100644
index 00000000..f71860ae
--- /dev/null
+++ b/tests/fixtures/styles/bug338160.svg
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="128" height="128" id="etiquette-icon">
+ <style type="text/css">
+<!--really this stuff should in a be external css file -->
+<![CDATA[
+/* PLEASE PLEASE PLEASE PLEASE FIX OH THIS RSVG GODS .... you're my only hope */
+
+ #computer-monitor path{stroke: #000; stroke-width: 2px; fill-opacity: 0.55;}
+
+/* non contextural Styles that work well in rsvg*/
+
+ .skyblue3 {fill:#204a87;}
+ .black {fill:#000000;}
+ .white {fill:#ffffff;}
+ .aluminium1 {fill:#eeeeec;}
+ .low-shade {opacity:0.25;}
+ .specularity {opacity:0.5;}
+ .high-shade {opacity:0.75;}
+ .full-shade {opacity:1;}
+ .low-specularity {opacity:0.25;}
+ .specularity {opacity:0.5;}
+ .high-specularity {opacity:0.75;}
+ .full-specularity {opacity:1;}
+ .stroke-black {stroke:#000000;}
+ .stroke-white {stroke:#ffffff;}
+ .aluminium4 {fill:#888a85;}
+
+]]>
+ </style>
+ <defs id="definitions">
+ <linearGradient id="WhiteTransparent"><stop style="stop-color:white;stop-opacity:1" offset="0" /><stop style="stop-color:white;stop-opacity:0" offset="1" /></linearGradient>
+ <linearGradient id="BlackTransparent"><stop style="stop-color:black;stop-opacity:1" offset="0" /><stop style="stop-color:black;stop-opacity:0" offset="1" /></linearGradient>
+ <radialGradient cx="40.31" cy="479.61" r="66.26" fx="40.31" fy="479.61" id="radialGradient6330" xlink:href="#BlackTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.97,0,0,0.23,24.91,-9.95e-2)" />
+ <linearGradient x1="57.70" y1="21.05" x2="57.70" y2="93.67" id="linearGradient6341" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.18,0,0,0.65,7.28,6.28)" />
+ <linearGradient x1="61" y1="103" x2="61" y2="16" id="linearGradient6344" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.15,0,0,0.79,2.02,2.17)" />
+ <linearGradient x1="75.97" y1="99.13" x2="75.97" y2="87.68" id="linearGradient6347" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.08,0,0,0.86,6.29,-7.90)" />
+ <linearGradient x1="64.00" y1="97.70" x2="64.00" y2="4.53" id="linearGradient6352" xlink:href="#BlackTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.95,0,0,0.95,3.23,3.22)" />
+ <linearGradient x1="36.93" y1="225.90" x2="36.93" y2="184.39" id="linearGradient6358" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.82,0,0,0.46,3.18,5.37)" />
+ </defs>
+ <g id="computer-monitor">
+
+ <path d="M 127.78,110.55 C 127.78,118.81 99.23,125.50 64.00,125.50 C 28.77,125.50 0.22,118.81 0.22,110.55 C 0.22,102.30 28.77,95.61 64.00,95.61 C 92.89,95.61 117.29,100.11 125.13,106.28 C 126.85,107.64 127.78,109.07 127.78,110.55 z " style="opacity:0.25;fill:url(#radialGradient6330)" id="base_shadow" />
+ <g id="monitor-stand" >
+ <path d="M 47.62,93.47 L 47.62,101.85 C 47.62,107.48 32.30,104.25 32.30,109.87 L 32.30,112.32 L 95.46,112.32 L 95.46,109.23 C 95.46,103.61 80.09,107.48 80.09,101.85 L 80.09,93.47 L 47.62,93.47 z " class="aluminium4" />
+ <path d="M 47.59,101.94 C 47.59,107.01 33.36102,104.6073 32.432943,109.2 L 95.594366,109.2 C 95.594366,103.73809 80.12,107.326 80.12,102 C 70,96.162436 57.357567,96.304 47.59,101.94375 z " class="high-specularity" style="fill:url(#linearGradient6358)" />
+ </g>
+ <g id="computer-screen" >
+ <path d="M 8.00,11.04 C 8.00,9.16 9.69,8.05 11.57,8.05 L 116.61,8.05 C 118.48,8.05 120.00,10.16 120.00,12.05 L 120.00,92.36 C 120.00,94.25 118.24,96.00 116.37,96.00 L 11.69,96.00 C 9.82,96.00 8.00,94.48 8.00,92.60 L 8.00,11.04 z " class="aluminium1" />
+ <path d="M 8.00,11.04 C 8.00,9.16 9.69,8.05 11.57,8.05 L 116.61,8.05 C 118.48,8.05 120.00,10.16 120.00,12.05 L 120.00,92.36 C 120.00,94.25 118.24,96.00 116.37,96.00 L 11.69,96.00 C 9.82,96.00 8.00,94.48 8.00,92.60 L 8.00,11.04 z " class="low-shade" style="fill:url(#linearGradient6352);" />
+ <path d="M 17.19,17.34 L 110.52,17.34 L 110.52,81.61 L 17.19,81.61 L 17.19,17.34 z " class="skyblue3" />
+
+ <path d="M 107.38,65.19 L 107.38,78.62 L 85.56,78.62 L 41.92,78.62 L 20.10,78.62 L 20.10,65.19 L 107.38,65.19 z " class="low-specularity" style="fill:url(#linearGradient6347)" />
+ <path d="M 15.70,16.08 L 111.67,16.08 L 111.67,82.69 L 15.70,82.69 L 15.70,16.08 z " class="high-specularity" style="fill:none;stroke:url(#linearGradient6344);" />
+ <path d="M 20.04,19.52 L 107.45,19.52 L 107.45,32.73 C 67.64,33.66 37.09,50.64 20.04,67.62 L 20.04,19.52 z " class="specularity" style="fill:url(#linearGradient6341)" />
+ </g>
+ </g>
+</svg>
diff --git a/tests/fixtures/styles/bug379629.svg b/tests/fixtures/styles/bug379629.svg
new file mode 100644
index 00000000..058210d6
--- /dev/null
+++ b/tests/fixtures/styles/bug379629.svg
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" width="128" height="128" id="etiquette-icon">
+ <style type="text/css">
+<!--really this stuff should in a be external css file -->
+<![CDATA[
+/* PLEASE PLEASE PLEASE PLEASE FIX OH THIS RSVG GODS .... you're my only hope */
+
+
+
+/* non contextural Styles that work well in rsvg*/
+path {stroke: white; stroke-width:1pt;}
+path {stroke: pink !important;stroke-width:5pt !important;}
+
+
+]]>
+ </style>
+ <defs id="definitions">
+ <linearGradient id="WhiteTransparent"><stop style="stop-color:white;stop-opacity:1" offset="0" /><stop style="stop-color:white;stop-opacity:0" offset="1" /></linearGradient>
+ <linearGradient id="BlackTransparent"><stop style="stop-color:black;stop-opacity:1" offset="0" /><stop style="stop-color:black;stop-opacity:0" offset="1" /></linearGradient>
+ <radialGradient cx="40.31" cy="479.61" r="66.26" fx="40.31" fy="479.61" id="radialGradient6330" xlink:href="#BlackTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.97,0,0,0.23,24.91,-9.95e-2)" />
+ <linearGradient x1="57.70" y1="21.05" x2="57.70" y2="93.67" id="linearGradient6341" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.18,0,0,0.65,7.28,6.28)" />
+ <linearGradient x1="61" y1="103" x2="61" y2="16" id="linearGradient6344" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.15,0,0,0.79,2.02,2.17)" />
+ <linearGradient x1="75.97" y1="99.13" x2="75.97" y2="87.68" id="linearGradient6347" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.08,0,0,0.86,6.29,-7.90)" />
+ <linearGradient x1="64.00" y1="97.70" x2="64.00" y2="4.53" id="linearGradient6352" xlink:href="#BlackTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(0.95,0,0,0.95,3.23,3.22)" />
+ <linearGradient x1="36.93" y1="225.90" x2="36.93" y2="184.39" id="linearGradient6358" xlink:href="#WhiteTransparent" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.82,0,0,0.46,3.18,5.37)" />
+ </defs>
+ <g id="computer-monitor">
+
+ <path d="M 127.78,110.55 C 127.78,118.81 99.23,125.50 64.00,125.50 C 28.77,125.50 0.22,118.81 0.22,110.55 C 0.22,102.30 28.77,95.61 64.00,95.61 C 92.89,95.61 117.29,100.11 125.13,106.28 C 126.85,107.64 127.78,109.07 127.78,110.55 z " style="opacity:0.25;fill:url(#radialGradient6330)" id="base_shadow" />
+ <g id="monitor-stand" >
+ <path d="M 47.62,93.47 L 47.62,101.85 C 47.62,107.48 32.30,104.25 32.30,109.87 L 32.30,112.32 L 95.46,112.32 L 95.46,109.23 C 95.46,103.61 80.09,107.48 80.09,101.85 L 80.09,93.47 L 47.62,93.47 z " class="aluminium4" />
+ <path d="M 47.59,101.94 C 47.59,107.01 33.36102,104.6073 32.432943,109.2 L 95.594366,109.2 C 95.594366,103.73809 80.12,107.326 80.12,102 C 70,96.162436 57.357567,96.304 47.59,101.94375 z " class="high-specularity" style="fill:url(#linearGradient6358)" />
+ </g>
+ <g id="computer-screen" >
+ <path d="M 8.00,11.04 C 8.00,9.16 9.69,8.05 11.57,8.05 L 116.61,8.05 C 118.48,8.05 120.00,10.16 120.00,12.05 L 120.00,92.36 C 120.00,94.25 118.24,96.00 116.37,96.00 L 11.69,96.00 C 9.82,96.00 8.00,94.48 8.00,92.60 L 8.00,11.04 z " class="aluminium1" />
+ <path d="M 8.00,11.04 C 8.00,9.16 9.69,8.05 11.57,8.05 L 116.61,8.05 C 118.48,8.05 120.00,10.16 120.00,12.05 L 120.00,92.36 C 120.00,94.25 118.24,96.00 116.37,96.00 L 11.69,96.00 C 9.82,96.00 8.00,94.48 8.00,92.60 L 8.00,11.04 z " class="low-shade" style="fill:url(#linearGradient6352);" />
+ <path d="M 17.19,17.34 L 110.52,17.34 L 110.52,81.61 L 17.19,81.61 L 17.19,17.34 z " class="skyblue3" />
+
+ <path d="M 107.38,65.19 L 107.38,78.62 L 85.56,78.62 L 41.92,78.62 L 20.10,78.62 L 20.10,65.19 L 107.38,65.19 z " class="low-specularity" style="fill:url(#linearGradient6347)" />
+ <path d="M 15.70,16.08 L 111.67,16.08 L 111.67,82.69 L 15.70,82.69 L 15.70,16.08 z " class="high-specularity" style="fill:none;stroke:url(#linearGradient6344);" />
+ <path d="M 20.04,19.52 L 107.45,19.52 L 107.45,32.73 C 67.64,33.66 37.09,50.64 20.04,67.62 L 20.04,19.52 z " class="specularity" style="fill:url(#linearGradient6341)" />
+ </g>
+ </g>
+</svg>
diff --git a/tests/fixtures/styles/bug418823.svg b/tests/fixtures/styles/bug418823.svg
new file mode 100644
index 00000000..043a3f1f
--- /dev/null
+++ b/tests/fixtures/styles/bug418823.svg
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100" height="100" version="1.0">
+
+<defs>
+ <style type="text/css">
+ path { fill: #ff0000 }
+ #bla { fill: #00ff00 }
+ </style>
+</defs>
+
+<path id="bla" d="M 50,20 L 20,80 L 80,80 z " />
+</svg>
diff --git a/tests/fixtures/styles/bug592207.svg b/tests/fixtures/styles/bug592207.svg
new file mode 100644
index 00000000..b7281ad4
--- /dev/null
+++ b/tests/fixtures/styles/bug592207.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg width="100px" height="100px" xmlns="http://www.w3.org/2000/svg"
+xmlns:xlink="http://www.w3.org/1999/xlink">
+<defs>
+ <style type="text/css"><![CDATA[
+ rect { fill: #ff0000; }
+ .class1 { stroke: #0000ff; }
+]]>
+ </style>
+</defs>
+<rect id="target" x="20" y="20" width="50" height="50" class="class1"/>
+</svg>
diff --git a/tests/fixtures/styles/bug614606.svg b/tests/fixtures/styles/bug614606.svg
new file mode 100644
index 00000000..19ac0892
--- /dev/null
+++ b/tests/fixtures/styles/bug614606.svg
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- <?xml-stylesheet type="text/css" href="inject.css" ?> -->
+
+<!-- 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:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ version="1.1"
+ width="16"
+ height="16"
+ id="svg7384"
+ inkscape:version="0.47+devel r9222 custom"
+ sodipodi:docname="battery-critical-charging-symbolic.svg">
+<style type="text/css">
+<![CDATA[rect,path {
+ fill:#000000 !important;
+ /* fill-opacity:1 !important; */
+}
+
+.critical {
+ fill: red !important;
+ }]]>
+</style>
+
+ <metadata
+ id="metadata84369">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <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="namedview84367"
+ showgrid="false"
+ inkscape:zoom="21.125"
+ inkscape:cx="8"
+ inkscape:cy="8"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="0"
+ inkscape:current-layer="svg7384" />
+ <title
+ id="title9167">Moblin Icon Theme</title>
+ <defs
+ id="defs7386" />
+ <g
+ transform="translate(-179.99975,-236.00025)"
+ id="layer3"
+ style="display:inline">
+ <path
+ d="m 182.99975,247 0,2 3.00025,0 0,-2 -3.00025,0 z"
+ id="path6306"
+ style="fill:#bebebe;fill-opacity:1;stroke:none"
+ class="critical"
+ inkscape:label="crit" />
+ <path
+ d="m 183.46875,236.03125 c -0.49033,0 -0.79607,0.22845 -1.03125,0.46875 -0.23518,0.2403 -0.4375,0.55851 -0.4375,1.03125 l 0,0.46875 -1,0 -1,0 0,1 0,12 0,1 1,0 7,0 0,-2 -6,0 0,-10 1,0 1,0 0,-1 0,-0.96875 3,0 0,0.96875 0,1 1,0 1,0 0,3 2,0 0,-4 0,-1 -1,0 -1,0 0,-0.34375 0,-0.0312 c -0.0239,-0.4306 -0.17024,-0.75229 -0.40625,-1.03125 -0.22373,-0.26444 -0.62669,-0.52931 -1.15625,-0.53125 l 0,-0.0312 -0.0625,0 -3.90625,0 z"
+ id="path6308"
+ style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Abandoned Bitplane;-inkscape-font-specification:Abandoned Bitplane" />
+ <path
+ d="m 190.875,244 a 1.0001,1.0001 0 0 0 -0.59375,0.28125 l -3,3 A 1.0001,1.0001 0 0 0 188,249 l 2.5625,0 -1.28125,1.28125 a 1.016466,1.016466 0 1 0 1.4375,1.4375 l 3,-3 A 1.0001,1.0001 0 0 0 193,247 l -2.5625,0 1.28125,-1.28125 A 1.0001,1.0001 0 0 0 190.875,244 z"
+ id="path6312"
+ style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Abandoned Bitplane;-inkscape-font-specification:Abandoned Bitplane" />
+ <rect
+ width="1"
+ height="1"
+ x="193"
+ y="247"
+ id="rect6314"
+ style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ width="1"
+ height="1"
+ x="187"
+ y="248"
+ id="rect6316"
+ style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ width="1"
+ height="1"
+ x="191"
+ y="244"
+ id="rect6318"
+ style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <rect
+ width="1"
+ height="1"
+ x="189"
+ y="251"
+ id="rect6320"
+ style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ <path
+ d="m 190.15625,244.4375 -2,3 1.6875,1.125 2,-3 -1.6875,-1.125 z"
+ id="path6322"
+ style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Abandoned Bitplane;-inkscape-font-specification:Abandoned Bitplane" />
+ <path
+ d="m 191.15625,247.4375 -2,3 1.6875,1.125 2,-3 -1.6875,-1.125 z"
+ id="path6324"
+ style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Abandoned Bitplane;-inkscape-font-specification:Abandoned Bitplane" />
+ <path
+ d="m 189,244 2,-2 -2,0 0,2 z"
+ id="path6326"
+ style="color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+ </g>
+ <g
+ transform="translate(-179.99975,-236.00025)"
+ id="layer2" />
+ <g
+ transform="translate(-179.99975,-236.00025)"
+ id="layer1">
+ </g>
+</svg>
diff --git a/tests/fixtures/styles/bug614704.svg b/tests/fixtures/styles/bug614704.svg
new file mode 100644
index 00000000..22a2b147
--- /dev/null
+++ b/tests/fixtures/styles/bug614704.svg
@@ -0,0 +1,11 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="5cm" height="2.5cm" viewBox="0 0 1000 500"
+ xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <style format="text/css">
+ .blue { fill: blue; }
+ </style>
+ <rect fill="red" class="blue" id="blue-rect" x="200" y="100" width="600" height="400"/>
+</svg>
+
diff --git a/tests/fixtures/styles/order.svg b/tests/fixtures/styles/order.svg
new file mode 100644
index 00000000..778eb5e6
--- /dev/null
+++ b/tests/fixtures/styles/order.svg
@@ -0,0 +1,25 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="5cm" height="2.5cm" viewBox="0 0 1000 500"
+ xmlns="http://www.w3.org/2000/svg" version="1.1">
+ <style format="text/css">
+ rect { fille: black; }
+ .blue { fill: blue; }
+ #green { fill: green; }
+ rect#pink { fill: pink; }
+ .blue#yellow { fill: yellow; }
+ rect.blue#white { fill: white; }
+ #brown { fill: brown; }
+ </style>
+ <rect class="blue" id="red" style="fill:red;" x="100" y="100" width="100" height="100"/>
+ <rect class="blue" id="green" x="200" y="100" width="100" height="100"/>
+ <rect class="blue" id="pink" x="300" y="100" width="100" height="100"/>
+ <rect class="blue" id="yellow" x="400" y="100" width="100" height="100"/>
+ <rect class="blue" id="white" x="500" y="100" width="100" height="100"/>
+ <rect class="none" id="black" x="100" y="200" width="100" height="100"/>
+ <rect class="blue" id="blue" x="200" y="200" width="100" height="100"/>
+ <rect class="none" id="brown" x="300" y="200" width="100" height="100"/>
+ <rect class="none" id="gray" style="fill:gray;" x="400" y="200" width="100" height="100"/>
+</svg>
+
diff --git a/tests/fixtures/styles/svg-class.svg b/tests/fixtures/styles/svg-class.svg
new file mode 100644
index 00000000..e28a6b32
--- /dev/null
+++ b/tests/fixtures/styles/svg-class.svg
@@ -0,0 +1,14 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="200" height="200"
+ xmlns="http://www.w3.org/2000/svg" version="1.1" class="svg">
+<style type="text/css">
+<![CDATA[
+.svg {
+ fill:blue;
+}
+]]>
+</style>
+ <rect id="target" x="100" y="100" width="100" height="100"/>
+</svg>
diff --git a/tests/styles.c b/tests/styles.c
new file mode 100644
index 00000000..e103a8d3
--- /dev/null
+++ b/tests/styles.c
@@ -0,0 +1,116 @@
+/* vim: set ts=4 nowrap ai expandtab sw=4: */
+
+#include <glib.h>
+#include "rsvg.h"
+#include "rsvg-private.h"
+#include "rsvg-defs.h"
+#include "rsvg-styles.h"
+#include "rsvg-paint-server.h"
+
+union Expected {
+ guint color;
+ RsvgLength length;
+};
+
+typedef struct _FixtureData
+{
+ const gchar *test_name;
+ const gchar *bug_id;
+ const gchar *file_path;
+ const gchar *id;
+ const gchar *target_name;
+ union Expected expected;
+} FixtureData;
+
+static void
+assert_equal_color (guint expected, guint actual)
+{
+ g_assert_cmphex (expected, ==, actual);
+}
+
+static void
+assert_equal_length (RsvgLength *expected, RsvgLength *actual)
+{
+ g_assert_cmpfloat (expected->length, ==, actual->length);
+ g_assert_cmpint (expected->factor, ==, actual->factor);
+}
+
+static void
+assert_equal_value (FixtureData *fixture, RsvgNode *node)
+{
+ if (g_str_equal (fixture->target_name, "stroke"))
+ assert_equal_color (fixture->expected.color, node->state->stroke->core.colour->rgb);
+ else if (g_str_equal (fixture->target_name, "fill"))
+ assert_equal_color (fixture->expected.color, node->state->fill->core.colour->rgb);
+ else if (g_str_equal (fixture->target_name, "stroke-width"))
+ assert_equal_length (&fixture->expected.length, &node->state->stroke_width);
+ else
+ g_assert_not_reached ();
+}
+
+static void
+test_value (FixtureData *fixture)
+{
+ RsvgHandle *handle;
+ RsvgNode *node;
+ GError *error = NULL;
+
+ if (fixture->bug_id)
+ g_test_bug (fixture->bug_id);
+
+ handle = rsvg_handle_new_from_file (fixture->file_path, &error);
+ g_assert_no_error (error);
+
+ node = rsvg_defs_lookup (handle->priv->defs, fixture->id);
+ g_assert (node);
+ g_assert (node->state);
+
+ assert_equal_value (fixture, node);
+
+ g_object_unref (handle);
+}
+
+#define POINTS_PER_INCH (72.0)
+#define POINTS_LENGTH(x) ((x) / POINTS_PER_INCH)
+
+static const FixtureData fixtures[] =
+{
+ {"/styles/selectors/type", NULL, "fixtures/styles/order.svg", "#black", "fill", .expected.color = 0x000000},
+ {"/styles/selectors/class", NULL, "fixtures/styles/order.svg", "#blue", "fill", .expected.color = 0x0000ff},
+ {"/styles/selectors/#id", NULL, "fixtures/styles/order.svg", "#brown", "fill", .expected.color = 0xa52a2a},
+ {"/styles/selectors/style", NULL, "fixtures/styles/order.svg", "#gray", "fill", .expected.color = 0x808080},
+ {"/styles/selectors/style property prior than class", NULL, "fixtures/styles/order.svg", "#red", "fill", .expected.color = 0xff0000},
+ {"/styles/selectors/#id prior than class", NULL, "fixtures/styles/order.svg", "#green", "fill", .expected.color = 0x008000},
+ {"/styles/selectors/type#id prior than class", NULL, "fixtures/styles/order.svg", "#pink", "fill", .expected.color = 0xffc0cb},
+ {"/styles/selectors/class#id prior than class", NULL, "fixtures/styles/order.svg", "#yellow", "fill", .expected.color = 0xffff00},
+ {"/styles/selectors/type.class#id prior than class", NULL, "fixtures/styles/order.svg", "#white", "fill", .expected.color = 0xffffff},
+ {"/styles/selectors/#id prior than type", "418823", "fixtures/styles/bug418823.svg", "#bla", "fill", .expected.color = 0x00ff00},
+ {"/styles/override presentation attribute", "614704", "fixtures/styles/bug614704.svg", "#blue-rect", "fill", .expected.color = 0x0000ff},
+ {"/styles/selectors/2 or more selectors (fill)", "592207", "fixtures/styles/bug592207.svg", "#target", "fill", .expected.color = 0xff0000},
+ {"/styles/selectors/2 or more selectors (stroke)", "592207", "fixtures/styles/bug592207.svg", "#target", "stroke", .expected.color = 0x0000ff},
+ {"/styles/!important", "379629", "fixtures/styles/bug379629.svg", "#base_shadow", "stroke", .expected.color = 0xffc0cb /* pink */},
+ {"/styles/!important", "379629", "fixtures/styles/bug379629.svg", "#base_shadow", "stroke-width", .expected.length = {POINTS_LENGTH(5.), 'i'}},
+ {"/styles/!important/class", "614606", "fixtures/styles/bug614606.svg", "#path6306", "fill", .expected.color = 0xff0000 /* red */ },
+ {"/styles/!important/element", "614606", "fixtures/styles/bug614606.svg", "#path6308", "fill", .expected.color = 0x000000},
+ {"/styles/selectors/descendant", "338160", "fixtures/styles/bug338160.svg", "#base_shadow", "stroke-width", .expected.length = {2., '\0'}},
+};
+static const gint n_fixtures = G_N_ELEMENTS (fixtures);
+
+int
+main (int argc, char *argv[])
+{
+ gint i;
+ int result;
+
+ rsvg_init ();
+ g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("https://bugzilla.gnome.org/show_bug.cgi?id=");
+
+ for (i = 0; i < n_fixtures; i++)
+ g_test_add_data_func (fixtures[i].test_name, &fixtures[i], (void*)test_value);
+
+ result = g_test_run ();
+ rsvg_term ();
+
+ return result;
+}