blob: 0159e2290986c1c4b5afc92e12036e9d31d240b8 [file] [log] [blame]
zimmermann@webkit.orgea6d2b72012-04-03 09:39:17 +00001<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html>
3<head>
mark.lam@apple.com1ca737d2013-09-08 05:29:22 +00004<script src="../../resources/js-test-pre.js"></script>
zimmermann@webkit.orgea6d2b72012-04-03 09:39:17 +00005<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
6<script src="resources/SVGAnimationTestCase.js"></script>
7</head>
8<body onload="runSMILTest()">
9<h1>SVG 1.1 dynamic animation tests</h1>
10<p id="description"></p>
11<div id="console"></div>
ap@apple.com92352d02017-05-24 22:53:00 +000012<script>
13description("Test SVGStitchOptions/TurbulenceType enumeration animations");
14createSVGTestCase();
15
16// Setup test document
17var defs = createSVGElement("defs");
18rootSVGElement.appendChild(defs);
19
20var filter = createSVGElement("filter");
21filter.setAttribute("id", "filter");
22filter.setAttribute("filterUnits", "userSpaceOnUse");
23filter.setAttribute("x", "0");
24filter.setAttribute("y", "0");
25filter.setAttribute("width", "700");
26filter.setAttribute("height", "200");
27defs.appendChild(filter);
28
29var turbulence = createSVGElement("feTurbulence");
30turbulence.setAttribute("in", "foo");
31turbulence.setAttribute("baseFrequency", "0.05");
32turbulence.setAttribute("numOctaves", "3");
33turbulence.setAttribute("seed", "5");
34turbulence.setAttribute("stitchTiles", "stitch");
35turbulence.setAttribute("type", "fractalNoise");
36filter.appendChild(turbulence);
37
38var rect = createSVGElement("rect");
39rect.setAttribute("id", "rect");
40rect.setAttribute("width", "100");
41rect.setAttribute("height", "100");
42rect.setAttribute("fill", "#408067");
43rect.setAttribute("filter", "url(#filter)");
44rect.setAttribute("onclick", "executeTest()");
45rootSVGElement.appendChild(rect);
46
47var animate1 = createSVGElement("animate");
48animate1.setAttribute("id", "animation");
49animate1.setAttribute("attributeName", "type");
50animate1.setAttribute("begin", "rect.click");
51animate1.setAttribute("dur", "4s");
52animate1.setAttribute("from", "fractalNoise");
53animate1.setAttribute("to", "turbulence");
54turbulence.appendChild(animate1);
55
56var animate2 = createSVGElement("animate");
57animate2.setAttribute("attributeName", "stitchTiles");
58animate2.setAttribute("begin", "rect.click");
59animate2.setAttribute("dur", "4s");
60animate2.setAttribute("from", "stitch");
61animate2.setAttribute("to", "noStitch");
62turbulence.appendChild(animate2);
63
64// Setup animation test
65function sample1() {
66 shouldBe("turbulence.type.animVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE");
67 shouldBe("turbulence.type.baseVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE");
68
69 shouldBe("turbulence.stitchTiles.animVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH");
70 shouldBe("turbulence.stitchTiles.baseVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH");
71}
72
73function sample2() {
74 shouldBe("turbulence.type.animVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_TURBULENCE");
75 shouldBe("turbulence.type.baseVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE");
76
77 shouldBe("turbulence.stitchTiles.animVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_NOSTITCH");
78 shouldBe("turbulence.stitchTiles.baseVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH");
79}
80
81function executeTest() {
82 const expectedValues = [
83 // [animationId, time, sampleCallback]
84 ["animation", 0.0, sample1],
85 ["animation", 1.999, sample1],
86 ["animation", 2.001, sample2],
87 ["animation", 3.999, sample2],
88 ["animation", 4.001, sample1]
89 ];
90
91 runAnimationTest(expectedValues);
92}
93
94var successfullyParsed = true;
95</script>
zimmermann@webkit.orgea6d2b72012-04-03 09:39:17 +000096</body>
97</html>