blob: 9a5db3bbda480ffc0d69786765bcc3cf06775254 [file] [log] [blame]
krit@webkit.orgd2350ce2011-07-03 20:22:22 +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>
krit@webkit.orgd2350ce2011-07-03 20:22:22 +00005<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
6<script src="resources/SVGAnimationTestCase.js"></script>
7</head>
zimmermann@webkit.orged2734b2012-02-14 08:41:30 +00008<body onload="runSMILTest()">
krit@webkit.orgd2350ce2011-07-03 20:22:22 +00009<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 accumulate=sum animation on SVGAnimateTransform.");
14createSVGTestCase();
15
16// Setup test document
17var rect = createSVGElement("rect");
18rect.setAttribute("id", "rect");
19rect.setAttribute("width", "100");
20rect.setAttribute("height", "100");
21rect.setAttribute("fill", "green");
22rect.setAttribute("onclick", "executeTest()");
23
24var animate = createSVGElement("animateTransform");
25animate.setAttribute("id", "animation");
26animate.setAttribute("attributeName", "transform");
27animate.setAttribute("type", "scale");
28animate.setAttribute("from", "0,0");
29animate.setAttribute("to", "2,2");
30animate.setAttribute("type", "scale");
31animate.setAttribute("fill", "freeze");
32animate.setAttribute("accumulate", "sum");
33animate.setAttribute("repeatCount", "3");
34animate.setAttribute("additive", "sum");
35animate.setAttribute("begin", "click");
36animate.setAttribute("dur", "4s");
37rect.appendChild(animate);
38rootSVGElement.appendChild(rect);
39
40// Setup animation test
41function sample1() {
42 // Check initial/end conditions
43 shouldBe("rect.transform.animVal.numberOfItems", "1");
44 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
45 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "0");
46 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "0");
47 shouldBe("rect.transform.baseVal.numberOfItems", "0");
48}
49
50function sample2() {
51 shouldBe("rect.transform.animVal.numberOfItems", "1");
52 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
53 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "1");
54 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "1");
55 shouldBe("rect.transform.baseVal.numberOfItems", "0");
56}
57
58function sample3() {
59 shouldBe("rect.transform.animVal.numberOfItems", "1");
60 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
61 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "2");
62 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "2");
63 shouldBe("rect.transform.baseVal.numberOfItems", "0");
64}
65
66function sample4() {
67 shouldBe("rect.transform.animVal.numberOfItems", "1");
68 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
69 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "3");
70 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "3");
71 shouldBe("rect.transform.baseVal.numberOfItems", "0");
72}
73
74function sample5() {
75 shouldBe("rect.transform.animVal.numberOfItems", "1");
76 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
77 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "4");
78 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "4");
79 shouldBe("rect.transform.baseVal.numberOfItems", "0");
80}
81
82function sample6() {
83 shouldBe("rect.transform.animVal.numberOfItems", "1");
84 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
85 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "5");
86 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "5");
87 shouldBe("rect.transform.baseVal.numberOfItems", "0");
88}
89
90function sample7() {
91 shouldBe("rect.transform.animVal.numberOfItems", "1");
92 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE");
93 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "6");
94 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "6");
95 shouldBe("rect.transform.baseVal.numberOfItems", "0");
96}
97
98function executeTest() {
99 const expectedValues = [
100 // [animationId, time, sampleCallback]
101 ["animation", 0.001, sample1],
102 ["animation", 2.0, sample2],
103 ["animation", 3.999, sample3],
104 ["animation", 4.001, sample3],
105 ["animation", 6.0, sample4],
106 ["animation", 7.999, sample5],
107 ["animation", 8.001, sample5],
108 ["animation", 10.0, sample6],
109 ["animation", 11.999, sample7],
110 ["animation", 12.001, sample7],
111 ["animation", 14.0, sample7],
112 ["animation", 60.0, sample7]
113 ];
114
115 runAnimationTest(expectedValues);
116}
117
118var successfullyParsed = true;
119</script>
krit@webkit.orgd2350ce2011-07-03 20:22:22 +0000120</body>
121</html>