Skip to content

Commit

Permalink
Move recently translated tests to WPT
Browse files Browse the repository at this point in the history
Move tests that can be wp-tests to
the corresponding folder.

The tests should stay exactly the same.

Bug: 985335
Change-Id: I61b76803c935c6dd4cc69241d7de76720eaf668e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1730457
Commit-Queue: Edvard Thörnros <edvardt@opera.com>
Auto-Submit: Edvard Thörnros <edvardt@opera.com>
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683582}
  • Loading branch information
Edvard Thörnros authored and Commit Bot committed Aug 2, 2019
1 parent 3d4843c commit 0c68351
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// NOTE(edvardt):
// This file is a slimmed down wrapper for the Chromium SVGAnimationTestCase.js,
// it has some convenience functions and should not be used for new tests.
// New tests should not build on this API as it's just meant to keep things
// working.

// Helper functions
const xlinkNS = "http://www.w3.org/1999/xlink"

function expectFillColor(element, red, green, blue) {
let color = window.getComputedStyle(element, null).fill;
var re = new RegExp("rgba?\\(([^, ]*), ([^, ]*), ([^, ]*)(?:, )?([^, ]*)\\)");
rgb = re.exec(color);
assert_approx_equals(Number(rgb[1]), red, 2.0);
assert_approx_equals(Number(rgb[2]), green, 2.0);
assert_approx_equals(Number(rgb[3]), blue, 2.0);
}

function expectColor(element, red, green, blue, property) {
if (typeof property != "string")
color = getComputedStyle(element).getPropertyValue("color");
else
color = getComputedStyle(element).getPropertyValue(property);
var re = new RegExp("rgba?\\(([^, ]*), ([^, ]*), ([^, ]*)(?:, )?([^, ]*)\\)");
rgb = re.exec(color);
assert_approx_equals(Number(rgb[1]), red, 2.0);
assert_approx_equals(Number(rgb[2]), green, 2.0);
assert_approx_equals(Number(rgb[3]), blue, 2.0);
}

function createSVGElement(type) {
return document.createElementNS("http://www.w3.org/2000/svg", type);
}

function moveAnimationTimelineAndSample(index) {
var animationId = expectedResults[index][0];
var time = expectedResults[index][1];
var sampleCallback = expectedResults[index][2];
var animation = rootSVGElement.ownerDocument.getElementById(animationId);

// If we want to sample the animation end, add a small delta, to reliable point past the end of the animation.
newTime = time;

// The sample time is relative to the start time of the animation, take that into account.
rootSVGElement.setCurrentTime(newTime);

// NOTE(edvardt):
// This is a dumb hack, some of the old tests sampled before the animation start, this
// isn't technically part of the animation tests and is "impossible" to translate since
// tests start automatically. Thus I solved it by skipping it.
if (time != 0.0)
sampleCallback();
}

var currentTest = 0;
var expectedResults;

function sampleAnimation(t) {
if (currentTest == expectedResults.length) {
t.done();
return;
}

moveAnimationTimelineAndSample(currentTest);
++currentTest;

step_timeout(t.step_func(function () { sampleAnimation(t); }), 0);
}

function runAnimationTest(t, expected) {
if (!expected)
throw("Expected results are missing!");
if (currentTest > 0)
throw("Not allowed to call runAnimationTest() twice");

expectedResults = expected;
testCount = expectedResults.length;
currentTest = 0;

step_timeout(t.step_func(function () { sampleAnimation(this); }), 50);
}

function smil_async_test(func) {
async_test(t => {
window.onload = t.step_func(function () {
// Pause animations, we'll drive them manually.
// This also ensures that the timeline is paused before
// it starts. This should make the instance time of the below
// 'click' (for instance) 0, and hence minimize rounding
// errors for the addition in moveAnimationTimelineAndSample.
rootSVGElement.pauseAnimations();

// If eg. an animation is running with begin="0s", and
// we want to sample the first time, before the animation
// starts, then we can't delay the testing by using an
// onclick event, as the animation would be past start time.
func(t);
});
});
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Test 'by' animation of SVGNumberOptionalNumber.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -90,4 +89,4 @@
window.clickX = 60;
window.clickY = 60;

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Test 'by' animation on path. You should see a green 100x100 path and only PASS messages</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -65,4 +64,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Tests from-to animation of points on polygons.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -70,4 +69,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Tests from-by animation of points on polygons.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -70,4 +69,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Test from-to SVGRect animation.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -83,4 +82,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Tests from-by SVGRect animation.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -83,4 +82,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Test animVal support for SVGAnimatedString animations.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -64,4 +63,4 @@

window.animationStartsImmediately = true;

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Tests fallback to calcMode='discrete' on animation of SVGString with 'values'.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -60,4 +59,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Test accumulate=sum animation on SVGAnimateTransform.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -115,4 +114,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<!doctype html>
<!-- THIS HAS BEEN TRANSLATED BY A SCRIPT, THERE MIGHT BE ERRORS -->
<html>
<title>Test calcMode=discrete animation on SVGAnimateTransform.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="resources/SVGAnimationTestCase-testharness.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>

<svg>
</svg>
Expand Down Expand Up @@ -72,4 +71,4 @@
runAnimationTest(t, expectedValues);
});

</script>
</script>

0 comments on commit 0c68351

Please sign in to comment.