77 lines
2.3 KiB
HTML
77 lines
2.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
|
<html>
|
|
<head>
|
|
<script src="../../resources/js-test-pre.js"></script>
|
|
<script src="../dynamic-updates/resources/SVGTestCase.js"></script>
|
|
<script src="resources/SVGAnimationTestCase.js"></script>
|
|
</head>
|
|
<body onload="runSMILTest()">
|
|
<h1>SVG 1.1 dynamic animation tests</h1>
|
|
<p id="description"></p>
|
|
<div id="console"></div>
|
|
<script>
|
|
description("Tests from-to animation of points on polygons.");
|
|
createSVGTestCase();
|
|
|
|
// Setup test document
|
|
var poly = createSVGElement("polygon");
|
|
poly.setAttribute("id", "poly");
|
|
poly.setAttribute("fill", "green");
|
|
poly.setAttribute("points", "0,0 200,0 200,200 0,200");
|
|
poly.setAttribute("onclick", "executeTest()");
|
|
|
|
var animate = createSVGElement("animate");
|
|
animate.setAttribute("id", "animation");
|
|
animate.setAttribute("attributeName", "points");
|
|
animate.setAttribute("from", "0,0 200,0 200,200 0,200");
|
|
animate.setAttribute("to", "0,0 100,0 100,100 0,100");
|
|
animate.setAttribute("begin", "click");
|
|
animate.setAttribute("dur", "4s");
|
|
poly.appendChild(animate);
|
|
rootSVGElement.appendChild(poly);
|
|
|
|
// Setup animation test
|
|
function sample1() {
|
|
// Check initial/end conditions
|
|
shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "200");
|
|
shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "200");
|
|
|
|
shouldBe("poly.points.getItem(2).x", "200");
|
|
shouldBe("poly.points.getItem(2).y", "200");
|
|
}
|
|
|
|
function sample2() {
|
|
// Check half-time conditions
|
|
shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "150");
|
|
shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "150");
|
|
|
|
shouldBe("poly.points.getItem(2).x", "200");
|
|
shouldBe("poly.points.getItem(2).y", "200");
|
|
}
|
|
|
|
function sample3() {
|
|
// Check just before-end conditions
|
|
shouldBeCloseEnough("poly.animatedPoints.getItem(2).x", "100");
|
|
shouldBeCloseEnough("poly.animatedPoints.getItem(2).y", "100");
|
|
|
|
shouldBe("poly.points.getItem(2).x", "200");
|
|
shouldBe("poly.points.getItem(2).y", "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>
|