2011-02-15 Dirk Schulze <krit@webkit.org>
[WebKit-https.git] / LayoutTests / svg / animations / script-tests / animate-currentColor.js
1 description("Tests animation on 'currentColor'.");
2 createSVGTestCase();
3
4 // Setup test document
5 var rect = createSVGElement("rect");
6 rect.setAttribute("id", "rect");
7 rect.setAttribute("width", "100px");
8 rect.setAttribute("height", "100px");
9 rect.setAttribute("fill", "red");
10 rect.setAttribute("color", "green");
11
12 var animateCurrentColor = createSVGElement("animateColor");
13 animateCurrentColor.setAttribute("id", "animateCurrentColor");
14 animateCurrentColor.setAttribute("attributeName", "fill");
15 animateCurrentColor.setAttribute("from", "red");
16 animateCurrentColor.setAttribute("to", "currentColor");
17 animateCurrentColor.setAttribute("dur", "3s");
18 animateCurrentColor.setAttribute("begin", "click");
19 animateCurrentColor.setAttribute("fill", "freeze");
20 rect.appendChild(animateCurrentColor);
21 rootSVGElement.appendChild(rect);
22
23 // Setup animation test
24 function sample1() {
25     // Check initial/end conditions
26     shouldBe("rect.style.fill", "'#FF0000'");
27 }
28
29 function sample2() {
30     // Check half-time conditions
31     shouldBe("rect.style.fill", "'#804000'");
32 }
33
34 function sample3() {
35     // Check half-time conditions
36     shouldBe("rect.style.fill", "'#008000'");
37 }
38
39 function executeTest() {
40     const expectedValues = [
41         // [animationId, time, elementId, sampleCallback]
42         ["animateCurrentColor", 0.0,    "rect", sample1],
43         ["animateCurrentColor", 1.5,    "rect", sample2],
44         ["animateCurrentColor", 3.0,    "rect", sample3]
45     ];
46
47     runAnimationTest(expectedValues);
48 }
49
50 // Begin test async
51 rect.setAttribute("onclick", "executeTest()");
52 window.setTimeout("triggerUpdate(50, 50)", 0);
53 var successfullyParsed = true;
54