Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / svg / animations / script-tests / animate-keySplines.js
1 description("Testing correct parsing of keySplines.");
2 createSVGTestCase();
3
4 // Setup test document
5 var rect = createSVGElement("rect");
6 rect.setAttribute("id", "rect");
7 rect.setAttribute("fill", "green");
8 rect.setAttribute("x", "0");
9 rect.setAttribute("y", "0");
10 rect.setAttribute("width", "100");
11 rect.setAttribute("height", "100");
12 rect.setAttribute("onclick", "executeTest()");
13
14 var animate = createSVGElement("animate");
15 animate.setAttribute("id", "animation");
16 animate.setAttribute("attributeName", "height");
17 animate.setAttribute("calcMode", "spline");
18 animate.setAttribute("keySplines", "0 ,0  1 , 1  ;   0 0 , 1 ,    1;  .75 , 0 , 0 , .75;");
19 animate.setAttribute("values", "200;167;111;0");
20 animate.setAttribute("begin", "click");
21 animate.setAttribute("dur", "9s");
22 rect.appendChild(animate);
23 rootSVGElement.appendChild(rect);
24
25 // Setup animation test
26 function sample1() {
27     // Check initial/end conditions
28     shouldBeCloseEnough("rect.height.animVal.value", "167");
29     shouldBe("rect.height.baseVal.value", "100");
30 }
31
32 function sample2() {
33     // Check half-time conditions
34     shouldBeCloseEnough("rect.height.animVal.value", "111");
35     shouldBe("rect.height.baseVal.value", "100");
36 }
37
38 function sample3() {
39     // Check just before-end conditions
40     shouldBeCloseEnough("rect.height.animVal.value", "0");
41     shouldBe("rect.height.baseVal.value", "100");
42 }
43
44 function sample4() {
45     // Check end conditions
46     shouldBeCloseEnough("rect.height.animVal.value", "100");
47     shouldBe("rect.height.baseVal.value", "100");
48 }
49
50 function executeTest() {
51     const expectedValues = [
52         // [animationId, time, sampleCallback]
53         ["animation", 3.0,   sample1],
54         ["animation", 6.0,   sample2],
55         ["animation", 8.999, sample3],
56         ["animation", 9.001, sample4]
57     ];
58
59     runAnimationTest(expectedValues);
60 }
61
62 var successfullyParsed = true;