OLD | NEW |
1 description("Test path animation where coordinate modes of start and end differ.
You should see PASS messages"); | 1 description("Test path animation where coordinate modes of start and end differ.
You should see PASS messages"); |
2 createSVGTestCase(); | 2 createSVGTestCase(); |
3 | 3 |
4 // Setup test document | 4 // Setup test document |
5 var path = createSVGElement("path"); | 5 var path = createSVGElement("path"); |
6 path.setAttribute("id", "path"); | 6 path.setAttribute("id", "path"); |
7 path.setAttribute("d", "M -30 -30 Q 30 -30 30 0 T -30 30 Z"); | 7 path.setAttribute("d", "M -30 -30 Q 30 -30 30 0 T -30 30 Z"); |
8 path.setAttribute("fill", "green"); | 8 path.setAttribute("fill", "green"); |
9 path.setAttribute("onclick", "executeTest()"); | 9 path.setAttribute("onclick", "executeTest()"); |
10 path.setAttribute("transform", "translate(50, 50)"); | 10 path.setAttribute("transform", "translate(50, 50)"); |
11 | 11 |
12 var animate = createSVGElement("animate"); | 12 var animate = createSVGElement("animate"); |
13 animate.setAttribute("id", "animation"); | 13 animate.setAttribute("id", "animation"); |
14 animate.setAttribute("attributeName", "d"); | 14 animate.setAttribute("attributeName", "d"); |
15 animate.setAttribute("from", "M -30 -30 Q 30 -30 30 0 T -30 30 Z"); | 15 animate.setAttribute("from", "M -30 -30 Q 30 -30 30 0 T -30 30 Z"); |
16 animate.setAttribute("to", "M -30 -30 q 30 0 30 30 t -30 30 z"); | 16 animate.setAttribute("to", "M -30 -30 q 30 0 30 30 t -30 30 z"); |
17 animate.setAttribute("begin", "click"); | 17 animate.setAttribute("begin", "click"); |
18 animate.setAttribute("dur", "4s"); | 18 animate.setAttribute("dur", "4s"); |
19 path.appendChild(animate); | 19 path.appendChild(animate); |
20 rootSVGElement.appendChild(path); | 20 rootSVGElement.appendChild(path); |
21 | 21 |
22 // Setup animation test | 22 // Setup animation test |
23 function checkBaseVal() { | |
24 shouldBe("path.pathSegList.numberOfItems", "4"); | |
25 shouldBeEqualToString("path.pathSegList.getItem(0).pathSegTypeAsLetter", "M"
); | |
26 shouldBe("path.pathSegList.getItem(0).x", "-30"); | |
27 shouldBe("path.pathSegList.getItem(0).y", "-30"); | |
28 shouldBeEqualToString("path.pathSegList.getItem(1).pathSegTypeAsLetter", "Q"
); | |
29 shouldBe("path.pathSegList.getItem(1).x", "30"); | |
30 shouldBe("path.pathSegList.getItem(1).y", "0"); | |
31 shouldBe("path.pathSegList.getItem(1).x1", "30"); | |
32 shouldBe("path.pathSegList.getItem(1).y1", "-30"); | |
33 shouldBeEqualToString("path.pathSegList.getItem(2).pathSegTypeAsLetter", "T"
); | |
34 shouldBe("path.pathSegList.getItem(2).x", "-30"); | |
35 shouldBe("path.pathSegList.getItem(2).y", "30"); | |
36 shouldBeEqualToString("path.pathSegList.getItem(3).pathSegTypeAsLetter", "Z"
); | |
37 } | |
38 | |
39 function sample1() { | 23 function sample1() { |
40 // Check initial/end conditions | 24 // Check initial/end conditions |
41 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 25 shouldBeEqualToString("path.getAttribute('d')", "M -30 -30 Q 30 -30 30 0 T -
30 30 Z"); |
42 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
43 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-30"); | |
44 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-30"); | |
45 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "Q"); | |
46 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "30"); | |
47 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0"); | |
48 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "30"); | |
49 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "-30"); | |
50 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "T"); | |
51 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-30"); | |
52 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "30"); | |
53 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
54 checkBaseVal(); | |
55 } | 26 } |
56 | 27 |
57 function sample2() { | 28 function sample2() { |
58 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 29 shouldBeEqualToString("path.getAttribute('d')", "M -30 -30 Q 22.5 -30 22.5 0
T -30 30 Z"); |
59 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
60 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-30"); | |
61 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-30"); | |
62 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "Q"); | |
63 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "22.5"); | |
64 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0"); | |
65 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "22.5"); | |
66 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "-30"); | |
67 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "T"); | |
68 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-30"); | |
69 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "30"); | |
70 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
71 checkBaseVal(); | |
72 } | 30 } |
73 | 31 |
74 function sample3() { | 32 function sample3() { |
75 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 33 shouldBeEqualToString("path.getAttribute('d')", "M -30 -30 q 37.5 0 37.5 30
t -37.5 30 Z"); |
76 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
77 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-30"); | |
78 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-30"); | |
79 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "q"); | |
80 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "37.5"); | |
81 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "30"); | |
82 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "37.5"); | |
83 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "0"); | |
84 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "t"); | |
85 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-37.5"); | |
86 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "30"); | |
87 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
88 checkBaseVal(); | |
89 } | 34 } |
90 | 35 |
91 function sample4() { | 36 function sample4() { |
92 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 37 shouldBeEqualToString("path.getAttribute('d')", "M -30 -30 q 30.0075 0 30.00
75 30 t -30.0075 30 Z"); |
93 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
94 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-30"); | |
95 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-30"); | |
96 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "q"); | |
97 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "30"); | |
98 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "30"); | |
99 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "30"); | |
100 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "0"); | |
101 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "t"); | |
102 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-30"); | |
103 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "30"); | |
104 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
105 checkBaseVal(); | |
106 } | 38 } |
107 | 39 |
108 function executeTest() { | 40 function executeTest() { |
109 const expectedValues = [ | 41 const expectedValues = [ |
110 // [animationId, time, sampleCallback] | 42 // [animationId, time, sampleCallback] |
111 ["animation", 0.0, sample1], | 43 ["animation", 0.0, sample1], |
112 ["animation", 1.0, sample2], | 44 ["animation", 1.0, sample2], |
113 ["animation", 3.0, sample3], | 45 ["animation", 3.0, sample3], |
114 ["animation", 3.999, sample4], | 46 ["animation", 3.999, sample4], |
115 ["animation", 4.001, sample1] | 47 ["animation", 4.001, sample1] |
116 ]; | 48 ]; |
117 | 49 |
118 runAnimationTest(expectedValues); | 50 runAnimationTest(expectedValues); |
119 } | 51 } |
120 | 52 |
121 var successfullyParsed = true; | 53 var successfullyParsed = true; |
OLD | NEW |