| OLD | NEW |
| (Empty) |
| 1 description("Test calcMode=discrete animation on SVGAnimateTransform."); | |
| 2 createSVGTestCase(); | |
| 3 | |
| 4 // Setup test document | |
| 5 var rect = createSVGElement("rect"); | |
| 6 rect.setAttribute("id", "rect"); | |
| 7 rect.setAttribute("width", "100"); | |
| 8 rect.setAttribute("height", "100"); | |
| 9 rect.setAttribute("x", "0"); | |
| 10 rect.setAttribute("y", "0"); | |
| 11 rect.setAttribute("fill", "green"); | |
| 12 rect.setAttribute("onclick", "executeTest()"); | |
| 13 | |
| 14 var animate = createSVGElement("animateTransform"); | |
| 15 animate.setAttribute("id", "animation"); | |
| 16 animate.setAttribute("attributeName", "transform"); | |
| 17 animate.setAttribute("type", "translate"); | |
| 18 animate.setAttribute("from", "100,100"); | |
| 19 animate.setAttribute("to", "0,0"); | |
| 20 animate.setAttribute("type", "translate"); | |
| 21 animate.setAttribute("calcMode", "discrete"); | |
| 22 animate.setAttribute("begin", "click"); | |
| 23 animate.setAttribute("dur", "4s"); | |
| 24 rect.appendChild(animate); | |
| 25 rootSVGElement.appendChild(rect); | |
| 26 | |
| 27 // Setup animation test | |
| 28 | |
| 29 function sample1() { | |
| 30 // Check initial/end conditions | |
| 31 shouldBe("rect.transform.animVal.numberOfItems", "0"); | |
| 32 shouldBeCloseEnough("document.defaultView.getComputedStyle(rect).getProperty
Value('x')", "0", 0.01); | |
| 33 shouldBeCloseEnough("document.defaultView.getComputedStyle(rect).getProperty
Value('y')", "0", 0.01); | |
| 34 } | |
| 35 | |
| 36 function sample2() { | |
| 37 // Check initial/end conditions | |
| 38 shouldBe("rect.transform.animVal.numberOfItems", "1"); | |
| 39 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFO
RM_TRANSLATE"); | |
| 40 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.e", "100", 0.0
1); | |
| 41 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.f", "100", 0.0
1); | |
| 42 } | |
| 43 | |
| 44 function sample3() { | |
| 45 shouldBe("rect.transform.animVal.numberOfItems", "1"); | |
| 46 shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFO
RM_TRANSLATE"); | |
| 47 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.e", "0", 0.01)
; | |
| 48 shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.f", "0", 0.01)
; | |
| 49 } | |
| 50 | |
| 51 function executeTest() { | |
| 52 const expectedValues = [ | |
| 53 // [animationId, time, elementId, sampleCallback] | |
| 54 ["animation", 0.0, "rect", sample1], | |
| 55 ["animation", 0.001, "rect", sample2], | |
| 56 ["animation", 1.0, "rect", sample2], | |
| 57 ["animation", 3.0, "rect", sample3], | |
| 58 ["animation", 3.9999, "rect", sample3], | |
| 59 ]; | |
| 60 | |
| 61 runAnimationTest(expectedValues); | |
| 62 } | |
| 63 | |
| 64 // Begin test async | |
| 65 window.setTimeout("triggerUpdate(50, 50)", 0); | |
| 66 var successfullyParsed = true; | |
| OLD | NEW |