OLD | NEW |
1 description("Test 'by' animation on path. You should see a green 100x100 path an
d only PASS messages"); | 1 description("Test 'by' animation on path. You should see a green 100x100 path an
d only 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 40 40 L 60 40 L 60 60 L 40 60 z"); | 7 path.setAttribute("d", "M 40 40 L 60 40 L 60 60 L 40 60 z"); |
8 path.setAttribute("fill", "green"); | 8 path.setAttribute("fill", "green"); |
9 path.setAttribute("onclick", "executeTest()"); | 9 path.setAttribute("onclick", "executeTest()"); |
10 | 10 |
11 var animate = createSVGElement("animate"); | 11 var animate = createSVGElement("animate"); |
12 animate.setAttribute("id", "animation"); | 12 animate.setAttribute("id", "animation"); |
13 animate.setAttribute("attributeName", "d"); | 13 animate.setAttribute("attributeName", "d"); |
14 animate.setAttribute("from", "M 40 40 L 60 40 L 60 60 L 40 60 z"); | 14 animate.setAttribute("from", "M 40 40 L 60 40 L 60 60 L 40 60 z"); |
15 animate.setAttribute("by", "M 0 0 L 100 0 L 100 100 L 0 100 z"); | 15 animate.setAttribute("by", "M 0 0 L 100 0 L 100 100 L 0 100 z"); |
16 animate.setAttribute("begin", "click"); | 16 animate.setAttribute("begin", "click"); |
17 animate.setAttribute("fill", "freeze"); | 17 animate.setAttribute("fill", "freeze"); |
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", "5"); | |
25 shouldBeEqualToString("path.pathSegList.getItem(0).pathSegTypeAsLetter", "M"
); | |
26 shouldBe("path.pathSegList.getItem(0).x", "40"); | |
27 shouldBe("path.pathSegList.getItem(0).y", "40"); | |
28 shouldBeEqualToString("path.pathSegList.getItem(1).pathSegTypeAsLetter", "L"
); | |
29 shouldBe("path.pathSegList.getItem(1).x", "60"); | |
30 shouldBe("path.pathSegList.getItem(1).y", "40"); | |
31 shouldBeEqualToString("path.pathSegList.getItem(2).pathSegTypeAsLetter", "L"
); | |
32 shouldBe("path.pathSegList.getItem(2).x", "60"); | |
33 shouldBe("path.pathSegList.getItem(2).y", "60"); | |
34 shouldBeEqualToString("path.pathSegList.getItem(3).pathSegTypeAsLetter", "L"
); | |
35 shouldBe("path.pathSegList.getItem(3).x", "40"); | |
36 shouldBe("path.pathSegList.getItem(3).y", "60"); | |
37 shouldBeEqualToString("path.pathSegList.getItem(4).pathSegTypeAsLetter", "Z"
); | |
38 } | |
39 | |
40 function sample1() { | 23 function sample1() { |
41 shouldBe("path.animatedPathSegList.numberOfItems", "5"); | 24 shouldBeEqualToString("path.getAttribute('d')", "M 40 40 L 60 40 L 60 60 L 4
0 60 z"); |
42 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
43 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "40"); | |
44 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "40"); | |
45 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "L"); | |
46 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "60"); | |
47 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "40"); | |
48 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "L"); | |
49 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "60"); | |
50 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "60"); | |
51 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "L"); | |
52 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "40"); | |
53 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).y", "60"); | |
54 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett
er", "Z"); | |
55 checkBaseVal(); | |
56 } | 25 } |
57 | 26 |
58 function sample2() { | 27 function sample2() { |
59 shouldBe("path.animatedPathSegList.numberOfItems", "5"); | 28 shouldBeEqualToString("path.getAttribute('d')", "M 40 40 L 109.975 40 L 109.
975 109.975 L 40 109.975 Z"); |
60 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
61 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "40"); | |
62 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "40"); | |
63 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "L"); | |
64 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "110"); | |
65 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "40"); | |
66 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "L"); | |
67 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "110"); | |
68 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "110"); | |
69 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "L"); | |
70 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "40"); | |
71 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).y", "110"); | |
72 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett
er", "Z"); | |
73 checkBaseVal(); | |
74 } | 29 } |
75 | 30 |
76 function sample3() { | 31 function sample3() { |
77 shouldBe("path.animatedPathSegList.numberOfItems", "5"); | 32 shouldBeEqualToString("path.getAttribute('d')", "M 40 40 L 110.025 40 L 110.
025 110.025 L 40 110.025 Z"); |
78 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
79 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "40"); | |
80 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "40"); | |
81 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "L"); | |
82 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "160"); | |
83 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "40"); | |
84 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "L"); | |
85 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "160"); | |
86 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "160"); | |
87 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "L"); | |
88 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).x", "40"); | |
89 shouldBeCloseEnough("path.animatedPathSegList.getItem(3).y", "160"); | |
90 shouldBeEqualToString("path.animatedPathSegList.getItem(4).pathSegTypeAsLett
er", "Z"); | |
91 checkBaseVal(); | |
92 } | 33 } |
| 34 |
| 35 function sample4() { |
| 36 shouldBeEqualToString("path.getAttribute('d')", "M 40 40 L 159.975 40 L 159.
975 159.975 L 40 159.975 Z"); |
| 37 } |
| 38 |
| 39 function sample5() { |
| 40 shouldBeEqualToString("path.getAttribute('d')", "M 40 40 L 160 40 L 160 160
L 40 160 Z"); |
| 41 } |
| 42 |
93 function executeTest() { | 43 function executeTest() { |
94 const expectedValues = [ | 44 const expectedValues = [ |
95 // [animationId, time, sampleCallback] | 45 // [animationId, time, sampleCallback] |
96 ["animation", 0.0, sample1], | 46 ["animation", 0.0, sample1], |
97 ["animation", 1.999, sample2], | 47 ["animation", 1.999, sample2], |
98 ["animation", 2.001, sample2], | 48 ["animation", 2.001, sample3], |
99 ["animation", 3.999, sample3], | 49 ["animation", 3.999, sample4], |
100 ["animation", 4.001, sample3] | 50 ["animation", 4.001, sample5] |
101 ]; | 51 ]; |
102 | 52 |
103 runAnimationTest(expectedValues); | 53 runAnimationTest(expectedValues); |
104 } | 54 } |
105 | 55 |
106 var successfullyParsed = true; | 56 var successfullyParsed = true; |
OLD | NEW |