Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / animations / script-tests / animate-calcMode-spline-values.js
blob9f4cc678eb1df82681a5083d482d62b468f42f35
1 description("Test calcMode spline with values animation. You should see a green 100x100 rect and only PASS messages");
2 createSVGTestCase();
4 // Setup test document
5 var rect = createSVGElement("rect");
6 rect.setAttribute("id", "rect");
7 rect.setAttribute("x", "100");
8 rect.setAttribute("width", "100");
9 rect.setAttribute("height", "100");
10 rect.setAttribute("fill", "green");
11 rect.setAttribute("onclick", "executeTest()");
13 var animate = createSVGElement("animate");
14 animate.setAttribute("id", "animation");
15 animate.setAttribute("attributeName", "x");
16 animate.setAttribute("values", "100;0");
17 animate.setAttribute("begin", "click");
18 animate.setAttribute("dur", "4s");
19 animate.setAttribute("keyTimes", "0;1");
20 animate.setAttribute("keySplines", "0.25 .5 .25 0.85");
21 animate.setAttribute("calcMode", "spline");
22 rect.appendChild(animate);
23 rootSVGElement.appendChild(rect);
25 // Setup animation test
26 function sample1() {
27 // Check initial/end conditions
28 shouldBeCloseEnough("rect.x.animVal.value", "100");
29 shouldBe("rect.x.baseVal.value", "100");
32 function sample2() {
33 // Check half-time conditions
34 shouldBeCloseEnough("rect.x.animVal.value", "18.8");
35 shouldBe("rect.x.baseVal.value", "100");
38 function sample3() {
39 // Check just before-end conditions
40 shouldBeCloseEnough("rect.x.animVal.value", "0");
41 shouldBe("rect.x.baseVal.value", "100");
44 function executeTest() {
45 const expectedValues = [
46 // [animationId, time, sampleCallback]
47 ["animation", 0.0, sample1],
48 ["animation", 2.0, sample2],
49 ["animation", 3.999, sample3],
50 ["animation", 4.001, sample1]
53 runAnimationTest(expectedValues);
56 window.clickX = 150;
57 var successfullyParsed = true;