| 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 0 30 30 t -30 30 z"); | 7 path.setAttribute("d", "M -30 -30 q 30 0 30 30 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 0 30 30 t -30 30 z"); | 15 animate.setAttribute("from", "M -30 -30 q 30 0 30 30 t -30 30 Z"); |
| 16 animate.setAttribute("to", "M -30 -30 Q 30 -30 30 0 T -30 30 Z"); | 16 animate.setAttribute("to", "M -30 -30 Q 30 -30 30 0 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", "30"); | |
| 31 shouldBe("path.pathSegList.getItem(1).x1", "30"); | |
| 32 shouldBe("path.pathSegList.getItem(1).y1", "0"); | |
| 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 0 30 30 t -3
0 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", "30"); | |
| 48 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "30"); | |
| 49 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "0"); | |
| 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 37.5 0 37.5 30
t -37.5 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", "37.5"); | |
| 64 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "30"); | |
| 65 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "37.5"); | |
| 66 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "0"); | |
| 67 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "t"); | |
| 68 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-37.5"); | |
| 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 22.5 -30 22.5 0
T -30 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", "22.5"); | |
| 81 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y", "0"); | |
| 82 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "22.5"); | |
| 83 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "-30"); | |
| 84 shouldBeEqualToString("path.animatedPathSegList.getItem(2).pathSegTypeAsLett
er", "T"); | |
| 85 shouldBeCloseEnough("path.animatedPathSegList.getItem(2).x", "-30"); | |
| 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 29.9925 -30 29.
9925 0 T -30 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", "0"); | |
| 99 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).x1", "30"); | |
| 100 shouldBeCloseEnough("path.animatedPathSegList.getItem(1).y1", "-30"); | |
| 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 window.clickX = 40; | 53 window.clickX = 40; |
| 122 window.clickY = 70; | 54 window.clickY = 70; |
| 123 var successfullyParsed = true; | 55 var successfullyParsed = true; |
| OLD | NEW |