| OLD | NEW |
| (Empty) |
| 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", "currentColor"); | |
| 10 rect.setAttribute("color", "red"); | |
| 11 | |
| 12 var animateColor = createSVGElement("animateColor"); | |
| 13 animateColor.setAttribute("id", "animateColor"); | |
| 14 animateColor.setAttribute("attributeName", "color"); | |
| 15 animateColor.setAttribute("from", "red"); | |
| 16 animateColor.setAttribute("to", "green"); | |
| 17 animateColor.setAttribute("dur", "3s"); | |
| 18 animateColor.setAttribute("begin", "click"); | |
| 19 animateColor.setAttribute("fill", "freeze"); | |
| 20 rect.appendChild(animateColor); | |
| 21 rootSVGElement.appendChild(rect); | |
| 22 | |
| 23 function checkFillColor(red, green, blue, hex) { | |
| 24 shouldBeEqualToString("document.defaultView.getComputedStyle(rect).getProper
tyValue('fill')", hex); | |
| 25 | |
| 26 try { | |
| 27 shouldBeEqualToString("(fillPaint = document.defaultView.getComputedStyl
e(rect).getPropertyCSSValue('fill')).toString()", "[object SVGPaint]"); | |
| 28 shouldBe("fillPaint.paintType", "SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR"); | |
| 29 shouldBeEqualToString("fillPaint.uri", ""); | |
| 30 shouldBe("fillPaint.colorType", "SVGColor.SVG_COLORTYPE_CURRENTCOLOR"); | |
| 31 shouldBeEqualToString("(fillColor = fillPaint.rgbColor).toString()", "[o
bject RGBColor]"); | |
| 32 shouldBe("fillColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", ""
+ red); | |
| 33 shouldBe("fillColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)",
"" + green); | |
| 34 shouldBe("fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "
" + blue); | |
| 35 } catch(e) { | |
| 36 // Opera doesn't support getPropertyCSSValue - no way to compare to thei
r SVGPaint/SVGColor objects :( | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 // Setup animation test | |
| 41 function sample1() { | |
| 42 debug(""); | |
| 43 debug("Initial condition:"); | |
| 44 checkFillColor(255, 0, 0, "#ff0000"); | |
| 45 } | |
| 46 | |
| 47 function sample2() { | |
| 48 debug(""); | |
| 49 debug("Half-time condition:"); | |
| 50 checkFillColor(128, 64, 0, "#804000"); | |
| 51 } | |
| 52 | |
| 53 function sample3() { | |
| 54 debug(""); | |
| 55 debug("End condition:"); | |
| 56 checkFillColor(0, 128, 0, "#008000"); | |
| 57 } | |
| 58 | |
| 59 function executeTest() { | |
| 60 const expectedValues = [ | |
| 61 // [animationId, time, elementId, sampleCallback] | |
| 62 ["animateColor", 0.0, "rect", sample1], | |
| 63 ["animateColor", 1.5, "rect", sample2], | |
| 64 ["animateColor", 3.0, "rect", sample3] | |
| 65 ]; | |
| 66 | |
| 67 runAnimationTest(expectedValues); | |
| 68 } | |
| 69 | |
| 70 // Begin test async | |
| 71 rect.setAttribute("onclick", "executeTest()"); | |
| 72 window.setTimeout("triggerUpdate(50, 50)", 0); | |
| 73 | |
| 74 var successfullyParsed = true; | |
| OLD | NEW |