zimmermann@webkit.org | ea6d2b7 | 2012-04-03 09:39:17 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 | <html> |
| 3 | <head> |
mark.lam@apple.com | 1ca737d | 2013-09-08 05:29:22 +0000 | [diff] [blame] | 4 | <script src="../../resources/js-test-pre.js"></script> |
zimmermann@webkit.org | ea6d2b7 | 2012-04-03 09:39:17 +0000 | [diff] [blame] | 5 | <script src="../dynamic-updates/resources/SVGTestCase.js"></script> |
| 6 | <script src="resources/SVGAnimationTestCase.js"></script> |
| 7 | </head> |
| 8 | <body onload="runSMILTest()"> |
| 9 | <h1>SVG 1.1 dynamic animation tests</h1> |
| 10 | <p id="description"></p> |
| 11 | <div id="console"></div> |
ap@apple.com | 92352d0 | 2017-05-24 22:53:00 +0000 | [diff] [blame] | 12 | <script> |
| 13 | description("Test SVGStitchOptions/TurbulenceType enumeration animations"); |
| 14 | createSVGTestCase(); |
| 15 | |
| 16 | // Setup test document |
| 17 | var defs = createSVGElement("defs"); |
| 18 | rootSVGElement.appendChild(defs); |
| 19 | |
| 20 | var filter = createSVGElement("filter"); |
| 21 | filter.setAttribute("id", "filter"); |
| 22 | filter.setAttribute("filterUnits", "userSpaceOnUse"); |
| 23 | filter.setAttribute("x", "0"); |
| 24 | filter.setAttribute("y", "0"); |
| 25 | filter.setAttribute("width", "700"); |
| 26 | filter.setAttribute("height", "200"); |
| 27 | defs.appendChild(filter); |
| 28 | |
| 29 | var turbulence = createSVGElement("feTurbulence"); |
| 30 | turbulence.setAttribute("in", "foo"); |
| 31 | turbulence.setAttribute("baseFrequency", "0.05"); |
| 32 | turbulence.setAttribute("numOctaves", "3"); |
| 33 | turbulence.setAttribute("seed", "5"); |
| 34 | turbulence.setAttribute("stitchTiles", "stitch"); |
| 35 | turbulence.setAttribute("type", "fractalNoise"); |
| 36 | filter.appendChild(turbulence); |
| 37 | |
| 38 | var rect = createSVGElement("rect"); |
| 39 | rect.setAttribute("id", "rect"); |
| 40 | rect.setAttribute("width", "100"); |
| 41 | rect.setAttribute("height", "100"); |
| 42 | rect.setAttribute("fill", "#408067"); |
| 43 | rect.setAttribute("filter", "url(#filter)"); |
| 44 | rect.setAttribute("onclick", "executeTest()"); |
| 45 | rootSVGElement.appendChild(rect); |
| 46 | |
| 47 | var animate1 = createSVGElement("animate"); |
| 48 | animate1.setAttribute("id", "animation"); |
| 49 | animate1.setAttribute("attributeName", "type"); |
| 50 | animate1.setAttribute("begin", "rect.click"); |
| 51 | animate1.setAttribute("dur", "4s"); |
| 52 | animate1.setAttribute("from", "fractalNoise"); |
| 53 | animate1.setAttribute("to", "turbulence"); |
| 54 | turbulence.appendChild(animate1); |
| 55 | |
| 56 | var animate2 = createSVGElement("animate"); |
| 57 | animate2.setAttribute("attributeName", "stitchTiles"); |
| 58 | animate2.setAttribute("begin", "rect.click"); |
| 59 | animate2.setAttribute("dur", "4s"); |
| 60 | animate2.setAttribute("from", "stitch"); |
| 61 | animate2.setAttribute("to", "noStitch"); |
| 62 | turbulence.appendChild(animate2); |
| 63 | |
| 64 | // Setup animation test |
| 65 | function sample1() { |
| 66 | shouldBe("turbulence.type.animVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE"); |
| 67 | shouldBe("turbulence.type.baseVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE"); |
| 68 | |
| 69 | shouldBe("turbulence.stitchTiles.animVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH"); |
| 70 | shouldBe("turbulence.stitchTiles.baseVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH"); |
| 71 | } |
| 72 | |
| 73 | function sample2() { |
| 74 | shouldBe("turbulence.type.animVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_TURBULENCE"); |
| 75 | shouldBe("turbulence.type.baseVal", "SVGFETurbulenceElement.SVG_TURBULENCE_TYPE_FRACTALNOISE"); |
| 76 | |
| 77 | shouldBe("turbulence.stitchTiles.animVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_NOSTITCH"); |
| 78 | shouldBe("turbulence.stitchTiles.baseVal", "SVGFETurbulenceElement.SVG_STITCHTYPE_STITCH"); |
| 79 | } |
| 80 | |
| 81 | function executeTest() { |
| 82 | const expectedValues = [ |
| 83 | // [animationId, time, sampleCallback] |
| 84 | ["animation", 0.0, sample1], |
| 85 | ["animation", 1.999, sample1], |
| 86 | ["animation", 2.001, sample2], |
| 87 | ["animation", 3.999, sample2], |
| 88 | ["animation", 4.001, sample1] |
| 89 | ]; |
| 90 | |
| 91 | runAnimationTest(expectedValues); |
| 92 | } |
| 93 | |
| 94 | var successfullyParsed = true; |
| 95 | </script> |
zimmermann@webkit.org | ea6d2b7 | 2012-04-03 09:39:17 +0000 | [diff] [blame] | 96 | </body> |
| 97 | </html> |