animate-path-animation-Cc-Ss.tentative.html (2010B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>Path animation where coordinate modes of start and end differ (C-c and S-s)</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/SVGAnimationTestCase-testharness.js"></script> 7 <script src="support/animated-path-helpers.js"></script> 8 <svg></svg> 9 <script> 10 var rootSVGElement = document.querySelector("svg"); 11 12 // Setup test document 13 var path = createSVGElement("path"); 14 path.setAttribute("id", "path"); 15 path.setAttribute("d", "M -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 Z"); 16 path.setAttribute("fill", "green"); 17 path.setAttribute("transform", "translate(50, 50)"); 18 19 var animate = createSVGElement("animate"); 20 animate.setAttribute("id", "animation"); 21 animate.setAttribute("attributeName", "d"); 22 animate.setAttribute("from", "M -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 Z"); 23 animate.setAttribute("to", "M -20 -20 c 0 40 0 40 40 40 s 40 0 0 -40 z"); 24 animate.setAttribute("begin", "0s"); 25 animate.setAttribute("dur", "4s"); 26 path.appendChild(animate); 27 rootSVGElement.appendChild(path); 28 29 // Setup animation test 30 function sample1() { 31 // Check initial/end conditions 32 assert_animated_path_equals( 33 path, "M -20 -20 C 20 -20 20 -20 20 20 S 20 40 -20 20 Z"); 34 } 35 36 function sample2() { 37 assert_animated_path_equals( 38 path, "M -20 -20 c 30 10 30 10 40 40 s 10 15 -30 -10 Z"); 39 } 40 41 function sample3() { 42 assert_animated_path_equals( 43 path, "M -20 -20 c 10 30 10 30 40 40 s 30 5 -10 -30 Z"); 44 } 45 46 function sample4() { 47 assert_animated_path_equals( 48 path, "M -20 -20 c 0.00999832 39.99 0.00999832 39.99 40 40 s 39.99 0.00499916 -0.00999832 -39.99 Z"); 49 } 50 51 smil_async_test(t => { 52 const expectedValues = [ 53 // [animationId, time, sampleCallback] 54 ["animation", 0.0, sample1], 55 ["animation", 1.0, sample2], 56 ["animation", 3.0, sample3], 57 ["animation", 3.999, sample4], 58 ["animation", 4.001, sample1] 59 ]; 60 runAnimationTest(t, expectedValues); 61 }); 62 </script>