blob: 06ae512a06f904fb0e50812e7fac683799153e6d [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/SVGTestCase.js"></script>
<script src="resources/SVGAnimationTestCase.js"></script>
</head>
<body onload="scheduleTest()">
<h1>SVG 1.1 dynamic animation tests</h1>
<p id="description"></p>
<div id="console"></div>
<script>
function scheduleTest() {
if (window.testRunner)
testRunner.waitUntilDone();
setTimeout(startTest, 0);
}
function startTest() {
description("Test for animation on elements inserted programmatically. Should result in a 200x200 rect and only PASS messages");
createSVGTestCase();
// Setup test document
var rect = createSVGElement("rect");
rect.setAttribute("id", "rect");
rect.setAttribute("width", "200");
rect.setAttribute("height", "200");
rect.setAttribute("fill", "green");
rect.setAttribute("onclick", "executeTest()");
var animate = createSVGElement("animate");
animate.setAttribute("id", "animation");
animate.setAttribute("attributeName", "width");
animate.setAttribute("from", "200");
animate.setAttribute("to", "100");
animate.setAttribute("begin", "click");
animate.setAttribute("dur", "4s");
rect.appendChild(animate);
rootSVGElement.appendChild(rect);
runSMILTest();
}
function sample1() {
// Check initial/end conditions
shouldBeCloseEnough("rect.width.animVal.value", "200");
shouldBe("rect.width.baseVal.value", "200");
}
function sample2() {
// Check half-time conditions
shouldBeCloseEnough("rect.width.animVal.value", "150");
shouldBe("rect.width.baseVal.value", "200");
}
function sample3() {
// Check just before-end conditions
shouldBeCloseEnough("rect.width.animVal.value", "100");
shouldBe("rect.width.baseVal.value", "200");
}
function executeTest() {
const expectedValues = [
// [animationId, time, sampleCallback]
["animation", 0.0, sample1],
["animation", 2.0, sample2],
["animation", 3.999, sample3],
["animation", 4.001, sample1]
];
runAnimationTest(expectedValues);
}
var successfullyParsed = true;
</script>
</body>
</html>