<!doctype html>
<meta charset="utf-8">
<title>Path animation where coordinate modes of start and end differ (M-m, A-a and Z)</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
<script src="support/animated-path-helpers.js"></script>
<svg></svg>
<script>
var rootSVGElement = document.querySelector("svg");

// Setup test document
var path = createSVGElement("path");
path.setAttribute("id", "path");
path.setAttribute("d", 'M -80 40 A 150 160 30 1 1 0 100 M 40 60 A 170 180 90 1 1 300 200 Z M 300 100');
path.setAttribute("fill", "green");
path.setAttribute("transform", "translate(50, 50)");

var animate = createSVGElement("animate");
animate.setAttribute("id", "animation");
animate.setAttribute("attributeName", "d");
animate.setAttribute("from", 'M -80 40 A 150 160 30 1 1 0 100 M 40 60 A 170 180 90 1 1 300 200 Z M 300 100');
animate.setAttribute("to", 'm -70 30 a 160 170 60 1 1 60 40 m 120 70 a 180 190 120 1 1 100 150 Z m 120 -60');
animate.setAttribute("begin", "0s");
animate.setAttribute("dur", "4s");
path.appendChild(animate);
rootSVGElement.appendChild(path);

// Setup animation test
function sample1() {
  // Check initial/end conditions
  assert_animated_path_equals(
    path, "M -80 40 A 150 160 30 1 1 0 100 M 40 60 A 170 180 90 1 1 300 200 Z M 300 100");
}

function sample2() {
  assert_animated_path_equals(
    path, "m -77.5 37.5 a 152.5 162.5 37.5 1 1 75 55 m 60 -12.5 a 172.5 182.5 97.5 1 1 220 142.5 Z m 225 15");
}

function sample3() {
  assert_animated_path_equals(
    path, "m -72.5 32.5 a 157.5 167.5 52.5 1 1 65 45 m 100 42.5 a 177.5 187.5 112.5 1 1 140 147.5 Z m 155 -35");
}

function sample4() {
  assert_animated_path_equals(
    path, "m -70.0025 30.0025 a 159.997 169.997 59.9925 1 1 60.005 40.005 m 119.98 69.9725 a 179.997 189.997 119.993 1 1 100.04 149.998 Z m 120.035 -59.975");
}

smil_async_test(t => {
  const expectedValues = [
    // [animationId, time, sampleCallback]
    ["animation", 0.0,   sample1],
    ["animation", 1.0,   sample2],
    ["animation", 3.0,   sample3],
    ["animation", 3.999, sample4],
    ["animation", 4.001, sample1]
  ];
  runAnimationTest(t, expectedValues);
});
</script>
