1 description("Test SVGStitchOptions/TurbulenceType enumeration animations");
5 var defs
= createSVGElement("defs");
6 rootSVGElement
.appendChild(defs
);
8 var filter
= createSVGElement("filter");
9 filter
.setAttribute("id", "filter");
10 filter
.setAttribute("filterUnits", "userSpaceOnUse");
11 filter
.setAttribute("x", "0");
12 filter
.setAttribute("y", "0");
13 filter
.setAttribute("width", "700");
14 filter
.setAttribute("height", "200");
15 defs
.appendChild(filter
);
17 var turbulence
= createSVGElement("feTurbulence");
18 turbulence
.setAttribute("in", "foo");
19 turbulence
.setAttribute("baseFrequency", "0.05");
20 turbulence
.setAttribute("numOctaves", "3");
21 turbulence
.setAttribute("seed", "5");
22 turbulence
.setAttribute("stitchTiles", "stitch");
23 turbulence
.setAttribute("type", "fractalNoise");
24 filter
.appendChild(turbulence
);
26 var rect
= createSVGElement("rect");
27 rect
.setAttribute("id", "rect");
28 rect
.setAttribute("width", "100");
29 rect
.setAttribute("height", "100");
30 rect
.setAttribute("fill", "#408067");
31 rect
.setAttribute("filter", "url(#filter)");
32 rect
.setAttribute("onclick", "executeTest()");
33 rootSVGElement
.appendChild(rect
);
35 var animate1
= createSVGElement("animate");
36 animate1
.setAttribute("id", "animation");
37 animate1
.setAttribute("attributeName", "type");
38 animate1
.setAttribute("begin", "rect.click");
39 animate1
.setAttribute("dur", "4s");
40 animate1
.setAttribute("from", "fractalNoise");
41 animate1
.setAttribute("to", "turbulence");
42 turbulence
.appendChild(animate1
);
44 var animate2
= createSVGElement("animate");
45 animate2
.setAttribute("attributeName", "stitchTiles");
46 animate2
.setAttribute("begin", "rect.click");
47 animate2
.setAttribute("dur", "4s");
48 animate2
.setAttribute("from", "stitch");
49 animate2
.setAttribute("to", "noStitch");
50 turbulence
.appendChild(animate2
);
52 // Setup animation test
54 shouldBe("turbulence.type.animVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE");
55 shouldBe("turbulence.type.baseVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE");
57 shouldBe("turbulence.stitchTiles.animVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH");
58 shouldBe("turbulence.stitchTiles.baseVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH");
62 shouldBe("turbulence.type.animVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_TURBULENCE");
63 shouldBe("turbulence.type.baseVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE");
65 shouldBe("turbulence.stitchTiles.animVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_NOSTITCH");
66 shouldBe("turbulence.stitchTiles.baseVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH");
69 function executeTest() {
70 const expectedValues
= [
71 // [animationId, time, sampleCallback]
72 ["animation", 0.0, sample1
],
73 ["animation", 1.999, sample1
],
74 ["animation", 2.001, sample2
],
75 ["animation", 3.999, sample2
],
76 ["animation", 4.001, sample1
]
79 runAnimationTest(expectedValues
);
82 var successfullyParsed
= true;