| 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" onload="test()"> |
| 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="[reviewer]" author="ED" status="empty" |
| 13 |
version="$Revision: 1.4 $" testname="$RCSfile: struct-dom-13-f.svg,v $"> |
| 14 |
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/[chapter]#[section]"> |
| 15 |
<p> |
| 16 |
Test for checkIntersection and getIntersectionList. |
| 17 |
</p> |
| 18 |
</d:testDescription> |
| 19 |
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml"> |
| 20 |
<p> |
| 21 |
Run the test. No interaction required. |
| 22 |
</p> |
| 23 |
</d:operatorScript> |
| 24 |
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml"> |
| 25 |
<p> |
| 26 |
The test passes if 17 green rectangles are displayed and if the legend indicates PASSED. |
| 27 |
</p> |
| 28 |
</d:passCriteria> |
| 29 |
</d:SVGTestCase> |
| 30 |
<title id="test-title">$RCSfile: struct-dom-13-f.svg,v $</title> |
| 31 |
<defs> |
| 32 |
<font-face |
| 33 |
font-family="SVGFreeSansASCII" |
| 34 |
unicode-range="U+0-7F"> |
| 35 |
<font-face-src> |
| 36 |
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/> |
| 37 |
</font-face-src> |
| 38 |
</font-face> |
| 39 |
</defs> |
| 40 |
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18"> |
| 41 |
<defs> |
| 42 |
<style type="text/css"> |
| 43 |
.passed { fill: lime } |
| 44 |
.failed { fill: red } |
| 45 |
.result { font: 9px monospace; fill: black } |
| 46 |
</style> |
| 47 |
</defs> |
| 48 |
|
| 49 |
<g visibility="hidden"> |
| 50 |
<circle id="c1" cx="40" cy="40" r="10" fill="blue" stroke="lime"/> |
| 51 |
<circle id="c2" cx="10" cy="50" r="10" fill="red" stroke="lime"/> |
| 52 |
<circle id="c3" cx="20" cy="20" r="20" fill="green" stroke="lime"/> |
| 53 |
<line id="l1" x1="5" y1="5" x2="40" y2="20" stroke="black"/> |
| 54 |
<line id="l2" x1="20" y1="20" x2="40" y2="30" stroke="red"/> |
| 55 |
|
| 56 |
<rect id="r1" x="10" y="10" width="50" height="50" fill="none" stroke="red"/> |
| 57 |
|
| 58 |
<circle id="c4" cx="80" cy="50" r="10" fill="yellow"/> |
| 59 |
</g> |
| 60 |
|
| 61 |
<script><![CDATA[ |
| 62 |
var ypos = 100; |
| 63 |
|
| 64 |
function verify(str, result) |
| 65 |
{ |
| 66 |
var g = document.createElementNS("http://www.w3.org/2000/svg", "g"); |
| 67 |
var r = document.createElementNS("http://www.w3.org/2000/svg", "rect"); |
| 68 |
var t = document.createElementNS("http://www.w3.org/2000/svg", "text"); |
| 69 |
t.textContent = str + ": " + (result ? "PASSED" : "FAILED"); |
| 70 |
t.setAttribute("class", "result"); |
| 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.appendChild(r); |
| 78 |
g.appendChild(t); |
| 79 |
g.setAttribute("transform", "translate(280 " + ypos + ")"); |
| 80 |
ypos += 10; |
| 81 |
document.getElementById("test-body-content").appendChild(g); |
| 82 |
} |
| 83 |
|
| 84 |
function test() |
| 85 |
{ |
| 86 |
var root = document.documentElement; //document.getElementById("test-root"); |
| 87 |
var rect = root.createSVGRect(); |
| 88 |
rect.x = 10; |
| 89 |
rect.y = 10; |
| 90 |
rect.width = 50; |
| 91 |
rect.height = 50; |
| 92 |
|
| 93 |
var tests = { "c1" : true, "c2" : true, "c3" : true, "l1" : true, "l2" : true, "r1" : true, "c4" : false }; |
| 94 |
|
| 95 |
verify("checkIntersection", root.checkIntersection); |
| 96 |
|
| 97 |
if(root.checkIntersection) |
| 98 |
{ |
| 99 |
for(var test in tests) |
| 100 |
{ |
| 101 |
try |
| 102 |
{ |
| 103 |
var elm = document.getElementById(test); |
| 104 |
var result = root.checkIntersection(elm, rect); |
| 105 |
|
| 106 |
verify(test, result == tests[test]); |
| 107 |
} |
| 108 |
catch(e) |
| 109 |
{ |
| 110 |
verify(test, false); |
| 111 |
} |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
verify("getIntersectionList", root.getIntersectionList); |
| 116 |
|
| 117 |
if(root.getIntersectionList) |
| 118 |
{ |
| 119 |
var expected = [ "c1", "c2", "c3", "l1", "l2", "r1" ]; |
| 120 |
try |
| 121 |
{ |
| 122 |
var list = root.getIntersectionList(rect, null); |
| 123 |
verify("call", true); |
| 124 |
} |
| 125 |
catch(e) |
| 126 |
{ |
| 127 |
verify("call", false); |
| 128 |
} |
| 129 |
|
| 130 |
try |
| 131 |
{ |
| 132 |
verify("length", expected.length == list.length); |
| 133 |
} |
| 134 |
catch(e) |
| 135 |
{ |
| 136 |
verify("length", false); |
| 137 |
} |
| 138 |
|
| 139 |
for(var i = 0; i < expected.length; i++) |
| 140 |
{ |
| 141 |
var elm = document.getElementById(expected[i]); |
| 142 |
try |
| 143 |
{ |
| 144 |
verify("has " + expected[i], elm === list.item(i)) |
| 145 |
} |
| 146 |
catch(e) |
| 147 |
{ |
| 148 |
verify("has " + expected[i], false); |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
]]></script> |
| 155 |
</g> |
| 156 |
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32"> |
| 157 |
<text id="revision" x="10" y="340" stroke="none" |
| 158 |
fill="black">$Revision: 1.4 $</text> |
| 159 |
</g> |
| 160 |
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/> |
| 161 |
<!-- comment out this watermark once the test is approved --> |
| 162 |
<g id="draft-watermark"> |
| 163 |
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/> |
| 164 |
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240" |
| 165 |
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text> |
| 166 |
</g> |
| 167 |
</svg> |