Commit 9843fdce authored by Edvard Thörnros's avatar Edvard Thörnros Committed by Commit Bot

Update "animate-no-matching-end-value" test

Change the test to use Testharness.js, the test should
still work the same (although I've changed it to make it a bit
clearer).

This is purely a refactor and code health commit.

Bug: 986830
Change-Id: Ic26adf137097893d78c1b579fd26ef1b3b490c46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713520
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Auto-Submit: Edvard Thörnros <edvardt@opera.com>
Cr-Commit-Position: refs/heads/master@{#680424}
parent 67f8c88e
SVG 1.1 dynamic animation tests
Test animate intervals having begin-value without a matching end-value
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS rect1.x.animVal.value is 0
PASS rect1.x.baseVal.value is 0
PASS rect1.x.animVal.value is 100
PASS rect1.x.baseVal.value is 0
PASS rect1.x.animVal.value is 0
PASS rect1.x.baseVal.value is 0
PASS rect1.x.animVal.value is 100
PASS rect1.x.baseVal.value is 0
PASS rect1.x.animVal.value is 0
PASS rect1.x.baseVal.value is 0
PASS rect1.x.animVal.value is 0
PASS rect1.x.baseVal.value is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <title>Test animate intervals having begin-value without a matching end-value</title>
<html> <script src="../../resources/testharness.js"></script>
<head> <script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/js-test.js"></script> <script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="resources/SVGTestCase.js"></script> <svg>
<script src="resources/SVGAnimationTestCase.js"></script> <!-- No interval will be created at 5 s since the end attribute does
</head> not contain a rule to end an interval starting later than 4 s. -->
<body onload="runSMILTest()"> <rect x="0" y="0" width="50" height="50" fill="green">
<h1>SVG 1.1 dynamic animation tests</h1> <animate id="anim" attributeName="visibility" to="visible" begin="0s" dur="6s" />
<p id="description"></p> <animate attributeName="x" from="100" to="100" begin="1;3;5" end="2;4" />
<div id="console"></div> </rect>
<script src="script-tests/animate-no-matching-end-value.js"></script> </svg>
</body> <script>
</html> // Setup animation test
var rootSVGElement = document.querySelector("svg");
var rect1 = rootSVGElement.ownerDocument.getElementsByTagName("rect")[0];
var epsilon = 0.15;
function sample1() {
assert_equals(rect1.x.animVal.value, 0);
assert_equals(rect1.x.baseVal.value, 0);
}
function sample2() {
assert_equals(rect1.x.animVal.value, 100);
assert_equals(rect1.x.baseVal.value, 0);
}
smil_async_test(t => {
const expectedValues = [
// [animationId, time, sampleCallback]
["anim", 0.1, sample1],
["anim", 1.1, sample2],
["anim", 2.1, sample1],
["anim", 3.1, sample2],
["anim", 4.1, sample1],
["anim", 5.1, sample1]
];
runAnimationTest(t, expectedValues);
});
</script>
// Inspired by Layoutests/animations/animation-test-helpers.js // Inspired by Layoutests/animations/animation-test-helpers.js
function moveAnimationTimelineAndSample(index) { function moveAnimationTimelineAndSample(index) {
var animationId = expectedResults[index][0]; var animationId = expectedResults[index][0];
var time = expectedResults[index][1]; var time = expectedResults[index][1];
...@@ -8,7 +7,6 @@ function moveAnimationTimelineAndSample(index) { ...@@ -8,7 +7,6 @@ function moveAnimationTimelineAndSample(index) {
// If we want to sample the animation end, add a small delta, to reliable point past the end of the animation. // If we want to sample the animation end, add a small delta, to reliable point past the end of the animation.
newTime = time; newTime = time;
newTime += animation.getStartTime();
// The sample time is relative to the start time of the animation, take that into account. // The sample time is relative to the start time of the animation, take that into account.
rootSVGElement.setCurrentTime(newTime); rootSVGElement.setCurrentTime(newTime);
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- No interval will be created at 5 s since the end attribute does
not contain a rule to end an interval starting later than 4 s. -->
<rect x="0" y="0" width="50" height="50" fill="green">
<animate id="anim" attributeName="visibility" to="visible" begin="0s" dur="6s" />
<animate attributeName="x" from="100" to="100" begin="1;3;5" end="2;4" />
</rect>
</svg>
description("Test animate intervals having begin-value without a matching end-value");
embedSVGTestCase("resources/animate-no-matching-end-value.svg");
// Setup animation test
function sample1() {
shouldBeCloseEnough("rect1.x.animVal.value", "0");
shouldBe("rect1.x.baseVal.value", "0");
}
function sample2() {
shouldBeCloseEnough("rect1.x.animVal.value", "100");
shouldBe("rect1.x.baseVal.value", "0");
}
function executeTest() {
var rects = rootSVGElement.ownerDocument.getElementsByTagName("rect");
rect1 = rects[0];
const expectedValues = [
// [animationId, time, sampleCallback]
["anim", 0.0, sample1],
["anim", 1.0, sample2],
["anim", 2.0, sample1],
["anim", 3.0, sample2],
["anim", 4.0, sample1],
["anim", 5.0, sample1]
];
runAnimationTest(expectedValues);
}
window.animationStartsImmediately = true;
var successfullyParsed = true;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment