Debian Codegraph @

test_non_regression/fail/na/script/struct-svg-02-f.svg

raw
1 <svg id="svg-root" width="100%" height="100%"
2 viewBox="0 0 480 360" xmlns="http://www.w3.org/2000/svg"
3 xmlns:xlink="http://www.w3.org/1999/xlink">
4 <!--======================================================================-->
5 <!--= Copyright 2008 World Wide Web Consortium, (Massachusetts =-->
6 <!--= Institute of Technology, European Research Consortium for =-->
7 <!--= Informatics and Mathematics (ERCIM), Keio University). =-->
8 <!--= All Rights Reserved. =-->
9 <!--= See http://www.w3.org/Consortium/Legal/. =-->
10 <!--======================================================================-->
11 <d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
12 template-version="1.4" reviewer="CM" author="ED" status="reviewed"
13 version="$Revision: 1.5 $" testname="$RCSfile: struct-svg-02-f.svg,v $">
14 <d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/struct.html#SVGElement">
15 <p>
16 Testing various interactions on the width attribute on an svg element.
17 The width attribute defaults to "100%" if it's not specified.
18 </p>
19 </d:testDescription>
20 <d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
21 <p>
22 Run the test. No interaction required.
23 </p>
24 </d:operatorScript>
25 <d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
26 <p>
27 The test is passed if the testframe is filled with green, and there's no red.
28 </p>
29 </d:passCriteria>
30 </d:SVGTestCase>
31 <title id="test-title">$RCSfile: struct-svg-02-f.svg,v $</title>
32 <defs>
33 <font-face
34 font-family="SVGFreeSansASCII"
35 unicode-range="U+0-7F">
36 <font-face-src>
37 <font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
38 </font-face-src>
39 </font-face>
40 </defs>
41 <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
42 <script type="text/ecmascript" xlink:href="../resources/testharness.js"/>
43
44 <!-- The testroot is here only to get a predictable 480x360 viewport -->
45 <svg id="testroot" width="480" height="360">
46 <svg id="testSVG1" />
47 <svg id="testSVG2" />
48 <svg id="subSVG" width="300" height="175"/>
49 </svg>
50
51 <g id="testoutput"/>
52
53 <!-- Cover the whole testframe with a simple visual result -->
54 <rect id="status" width="100%" height="100%" fill="none"/>
55
56 <script type="text/javascript"><![CDATA[
57 var passes = 0;
58 var ypos = 50;
59
60 function verify(str, result)
61 {
62 var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
63 var r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
64 var t = document.createElementNS("http://www.w3.org/2000/svg", "text");
65 var tc = document.createTextNode(str);
66 t.appendChild(tc);
67 t.setAttribute("class", "result");
68 t.setAttribute("font-family", "monospace");
69 t.setAttribute("font-size", "9px");
70 t.setAttribute("fill", "black");
71 t.setAttribute("x", "10");
72 t.setAttribute("y", "7");
73 r.setAttribute("y", "1");
74 r.setAttribute("width", "5");
75 r.setAttribute("height", "5");
76 g.setAttribute("class", result ? "passed" : "failed");
77 g.setAttribute("fill", result ? "lime" : "red");
78 g.appendChild(r);
79 g.appendChild(t);
80 g.setAttribute("transform", "translate(10 " + ypos + ")");
81 ypos += 10;
82 document.getElementById("testoutput").appendChild(g);
83
84 if (result)
85 passes++;
86 }
87
88 try
89 {
90 var testSVG = document.getElementById("testSVG1");
91 var subSVG = document.getElementById("subSVG");
92 var status = document.getElementById("status");
93
94 var base = testSVG.width.baseVal;
95
96 verify("value: " + base.value, base.value == 480);
97 test(function() {assert_equals(base.value, 480)}, "Assert that the width baseVal is 100% computed to user units.");
98
99 verify("valueInSpecifiedUnits: " + base.valueInSpecifiedUnits, base.valueInSpecifiedUnits == 100);
100 test(function() {assert_equals(base.value, 100)}, "Assert that the default width baseVal is 100.");
101
102 // set the value in user units and then read it back
103 base.value = 240;
104 verify("value: " + base.value, base.value == 240);
105 test(function() {assert_equals(base.value, 240)}, "Assert that the width baseVal is 240 after setting it.");
106 verify("valueInSpecifiedUnits: " + base.valueInSpecifiedUnits, base.valueInSpecifiedUnits == 50);
107 test(function() {assert_equals(base.valueInSpecifiedUnits, 50)}, "Assert that the value in specified units is now 50.");
108
109 // move the svg to be child of another viewport and read values again
110 subSVG.appendChild(testSVG);
111 verify("value: " + base.value, base.value == 150);
112 test(function() {assert_equals(base.value, 150)}, "Assert that the value changes to 150 after being moved to a new viewport.");
113 verify("valueInSpecifiedUnits: " + base.valueInSpecifiedUnits, base.valueInSpecifiedUnits == 50);
114 test(function() {assert_equals(base.valueInSpecifiedUnits, 50)}, "Assert that the value in specified units is still 50 after being moved to a new viewport.");
115
116 // move an svg that hasn't been modified to another viewport and read values
117 testSVG = document.getElementById("testSVG2");
118 subSVG.appendChild(testSVG);
119 base = testSVG.width.baseVal;
120 verify("value: " + base.value, base.value == 300);
121 test(function() {assert_equals(base.value, 300)}, "Assert that the width baseVal is 300 user units after being moved to a new viewport.");
122 }
123 catch(ex)
124 {
125 }
126
127 status.setAttribute("fill", passes == 7 ? "lime" : "red");
128 test(function() {assert_equals(passes,7)}, "Assert that all subtests passed.");
129 ]]></script>
130
131 </g>
132 <g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
133 <text id="revision" x="10" y="340" stroke="none"
134 fill="black">$Revision: 1.5 $</text>
135 </g>
136 <rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
137 <!-- comment out this watermark once the test is approved -->
138 <g id="draft-watermark">
139 <rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
140 <text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
141 text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
142 </g>
143 </svg>