| 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 -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 Z"); | 7 path.setAttribute("d", "M -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 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 -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 Z")
; | 15 animate.setAttribute("from", "M -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 Z")
; |
| 16 animate.setAttribute("to", "M -20 -20 c 0 40 0 40 40 40 s 40 0 0 -40 z"); | 16 animate.setAttribute("to", "M -20 -20 c 0 40 0 40 40 40 s 40 0 0 -40 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", "-20"); | |
| 27 shouldBe("path.pathSegList.getItem(0).y", "-20"); | |
| 28 shouldBeEqualToString("path.pathSegList.getItem(1).pathSegTypeAsLetter", "C"
); | |
| 29 shouldBe("path.pathSegList.getItem(1).x", "20"); | |
| 30 shouldBe("path.pathSegList.getItem(1).y", "20"); | |
| 31 shouldBe("path.pathSegList.getItem(1).x1", "20"); | |
| 32 shouldBe("path.pathSegList.getItem(1).y1", "-20"); | |
| 33 shouldBe("path.pathSegList.getItem(1).x2", "20"); | |
| 34 shouldBe("path.pathSegList.getItem(1).y2", "-20"); | |
| 35 shouldBeEqualToString("path.pathSegList.getItem(2).pathSegTypeAsLetter", "S"
); | |
| 36 shouldBe("path.pathSegList.getItem(2).x", "-20"); | |
| 37 shouldBe("path.pathSegList.getItem(2).y", "20"); | |
| 38 shouldBe("path.pathSegList.getItem(2).x2", "20"); | |
| 39 shouldBe("path.pathSegList.getItem(2).y2", "40"); | |
| 40 shouldBeEqualToString("path.pathSegList.getItem(3).pathSegTypeAsLetter", "Z"
); | |
| 41 } | |
| 42 | |
| 43 function sample1() { | 23 function sample1() { |
| 44 // Check initial/end conditions | 24 // Check initial/end conditions |
| 45 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 25 shouldBeEqualToString("path.getAttribute('d')", "M -20 -20 C 20 -20 20 -20 2
0 20 S 20 40 -20 20 Z"); |
| 46 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
| 47 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-20"); | |
| 48 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-20"); | |
| 49 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "C"); | |
| 50 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "20"); | |
| 51 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "20"); | |
| 52 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "20"); | |
| 53 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "-20"); | |
| 54 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x2", "20"); | |
| 55 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y2", "-20"); | |
| 56 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "S"); | |
| 57 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-20"); | |
| 58 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "20"); | |
| 59 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x2", "20"); | |
| 60 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y2", "40"); | |
| 61 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
| 62 checkBaseVal(); | |
| 63 } | 26 } |
| 64 | 27 |
| 65 function sample2() { | 28 function sample2() { |
| 66 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 29 shouldBeEqualToString("path.getAttribute('d')", "M -20 -20 C 10 -10 10 -10 2
0 20 S 30 35 -10 10 Z"); |
| 67 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
| 68 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-20"); | |
| 69 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-20"); | |
| 70 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "C"); | |
| 71 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "20"); | |
| 72 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "20"); | |
| 73 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "10"); | |
| 74 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "-10"); | |
| 75 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x2", "10"); | |
| 76 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y2", "-10"); | |
| 77 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "S"); | |
| 78 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-10"); | |
| 79 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "10"); | |
| 80 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x2", "30"); | |
| 81 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y2", "35"); | |
| 82 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
| 83 checkBaseVal(); | |
| 84 } | 30 } |
| 85 | 31 |
| 86 function sample3() { | 32 function sample3() { |
| 87 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 33 shouldBeEqualToString("path.getAttribute('d')", "M -20 -20 c 10 30 10 30 40
40 s 30 5 -10 -30 Z"); |
| 88 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
| 89 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-20"); | |
| 90 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-20"); | |
| 91 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "c"); | |
| 92 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "40"); | |
| 93 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "40"); | |
| 94 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "10"); | |
| 95 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "30"); | |
| 96 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x2", "10"); | |
| 97 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y2", "30"); | |
| 98 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "s"); | |
| 99 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-10"); | |
| 100 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "-30"); | |
| 101 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x2", "30"); | |
| 102 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y2", "5"); | |
| 103 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
| 104 checkBaseVal(); | |
| 105 } | 34 } |
| 106 | 35 |
| 107 function sample4() { | 36 function sample4() { |
| 108 shouldBe("path.animatedPathSegList.numberOfItems", "4"); | 37 shouldBeEqualToString("path.getAttribute('d')", "M -20 -20 c 0.00999832 39.9
9 0.00999832 39.99 40 40 s 39.99 0.00499916 -0.00999832 -39.99 Z"); |
| 109 shouldBeEqualToString("path.animatedPathSegList.getItem(0).pathSegTypeAsLett
er", "M"); | |
| 110 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).x", "-20"); | |
| 111 shouldBeCloseEnough("path.animatedPathSegList.getItem(0).y", "-20"); | |
| 112 shouldBeEqualToString("path.animatedPathSegList.getItem(1).pathSegTypeAsLett
er", "c"); | |
| 113 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x", "40"); | |
| 114 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "40"); | |
| 115 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "0"); | |
| 116 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "40"); | |
| 117 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x2", "0"); | |
| 118 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y2", "40"); | |
| 119 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "s"); | |
| 120 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-0"); | |
| 121 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y", "-40"); | |
| 122 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x2", "40"); | |
| 123 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).y2", "0"); | |
| 124 shouldBeEqualToString("path.animatedPathSegList.getItem(3).pathSegTypeAsLett
er", "Z"); | |
| 125 checkBaseVal(); | |
| 126 } | 38 } |
| 127 | 39 |
| 128 function executeTest() { | 40 function executeTest() { |
| 129 const expectedValues = [ | 41 const expectedValues = [ |
| 130 // [animationId, time, sampleCallback] | 42 // [animationId, time, sampleCallback] |
| 131 ["animation", 0.0, sample1], | 43 ["animation", 0.0, sample1], |
| 132 ["animation", 1.0, sample2], | 44 ["animation", 1.0, sample2], |
| 133 ["animation", 3.0, sample3], | 45 ["animation", 3.0, sample3], |
| 134 ["animation", 3.999, sample4], | 46 ["animation", 3.999, sample4], |
| 135 ["animation", 4.001, sample1] | 47 ["animation", 4.001, sample1] |
| 136 ]; | 48 ]; |
| 137 | 49 |
| 138 runAnimationTest(expectedValues); | 50 runAnimationTest(expectedValues); |
| 139 } | 51 } |
| 140 | 52 |
| 141 var successfullyParsed = true; | 53 var successfullyParsed = true; |
| OLD | NEW |