krit@webkit.org | d2350ce | 2011-07-03 20:22:22 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
mark.lam@apple.com | 1ca737d | 2013-09-08 05:29:22 +0000 | [diff] [blame] | 4 | <script src="../../resources/js-test-pre.js"></script> |
krit@webkit.org | d2350ce | 2011-07-03 20:22:22 +0000 | [diff] [blame] | 5 | <script src="../dynamic-updates/resources/SVGTestCase.js"></script> |
| 6 | <script src="resources/SVGAnimationTestCase.js"></script> |
| 7 | </head> |
zimmermann@webkit.org | ed2734b | 2012-02-14 08:41:30 +0000 | [diff] [blame] | 8 | <body onload="runSMILTest()"> |
krit@webkit.org | d2350ce | 2011-07-03 20:22:22 +0000 | [diff] [blame] | 9 | <h1>SVG 1.1 dynamic animation tests</h1> |
| 10 | <p id="description"></p> |
| 11 | <div id="console"></div> |
ap@apple.com | 92352d0 | 2017-05-24 22:53:00 +0000 | [diff] [blame] | 12 | <script> |
| 13 | description("Test accumulate=sum animation on SVGAnimateTransform."); |
| 14 | createSVGTestCase(); |
| 15 | |
| 16 | // Setup test document |
| 17 | var rect = createSVGElement("rect"); |
| 18 | rect.setAttribute("id", "rect"); |
| 19 | rect.setAttribute("width", "100"); |
| 20 | rect.setAttribute("height", "100"); |
| 21 | rect.setAttribute("fill", "green"); |
| 22 | rect.setAttribute("onclick", "executeTest()"); |
| 23 | |
| 24 | var animate = createSVGElement("animateTransform"); |
| 25 | animate.setAttribute("id", "animation"); |
| 26 | animate.setAttribute("attributeName", "transform"); |
| 27 | animate.setAttribute("type", "scale"); |
| 28 | animate.setAttribute("from", "0,0"); |
| 29 | animate.setAttribute("to", "2,2"); |
| 30 | animate.setAttribute("type", "scale"); |
| 31 | animate.setAttribute("fill", "freeze"); |
| 32 | animate.setAttribute("accumulate", "sum"); |
| 33 | animate.setAttribute("repeatCount", "3"); |
| 34 | animate.setAttribute("additive", "sum"); |
| 35 | animate.setAttribute("begin", "click"); |
| 36 | animate.setAttribute("dur", "4s"); |
| 37 | rect.appendChild(animate); |
| 38 | rootSVGElement.appendChild(rect); |
| 39 | |
| 40 | // Setup animation test |
| 41 | function sample1() { |
| 42 | // Check initial/end conditions |
| 43 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 44 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 45 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "0"); |
| 46 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "0"); |
| 47 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 48 | } |
| 49 | |
| 50 | function sample2() { |
| 51 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 52 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 53 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "1"); |
| 54 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "1"); |
| 55 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 56 | } |
| 57 | |
| 58 | function sample3() { |
| 59 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 60 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 61 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "2"); |
| 62 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "2"); |
| 63 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 64 | } |
| 65 | |
| 66 | function sample4() { |
| 67 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 68 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 69 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "3"); |
| 70 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "3"); |
| 71 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 72 | } |
| 73 | |
| 74 | function sample5() { |
| 75 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 76 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 77 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "4"); |
| 78 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "4"); |
| 79 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 80 | } |
| 81 | |
| 82 | function sample6() { |
| 83 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 84 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 85 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "5"); |
| 86 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "5"); |
| 87 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 88 | } |
| 89 | |
| 90 | function sample7() { |
| 91 | shouldBe("rect.transform.animVal.numberOfItems", "1"); |
| 92 | shouldBe("rect.transform.animVal.getItem(0).type", "SVGTransform.SVG_TRANSFORM_SCALE"); |
| 93 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.a", "6"); |
| 94 | shouldBeCloseEnough("rect.transform.animVal.getItem(0).matrix.d", "6"); |
| 95 | shouldBe("rect.transform.baseVal.numberOfItems", "0"); |
| 96 | } |
| 97 | |
| 98 | function executeTest() { |
| 99 | const expectedValues = [ |
| 100 | // [animationId, time, sampleCallback] |
| 101 | ["animation", 0.001, sample1], |
| 102 | ["animation", 2.0, sample2], |
| 103 | ["animation", 3.999, sample3], |
| 104 | ["animation", 4.001, sample3], |
| 105 | ["animation", 6.0, sample4], |
| 106 | ["animation", 7.999, sample5], |
| 107 | ["animation", 8.001, sample5], |
| 108 | ["animation", 10.0, sample6], |
| 109 | ["animation", 11.999, sample7], |
| 110 | ["animation", 12.001, sample7], |
| 111 | ["animation", 14.0, sample7], |
| 112 | ["animation", 60.0, sample7] |
| 113 | ]; |
| 114 | |
| 115 | runAnimationTest(expectedValues); |
| 116 | } |
| 117 | |
| 118 | var successfullyParsed = true; |
| 119 | </script> |
krit@webkit.org | d2350ce | 2011-07-03 20:22:22 +0000 | [diff] [blame] | 120 | </body> |
| 121 | </html> |