Open SVG Test Suite 

Test suite structure

This page describes the structure of the test suite and the tests that it comprises.

Test suite

The test suite is simply an unordered collection of all of the contributed tests. Subsets of the test suite can be obtained by querying for tests that match particular tags.

Tests

Each test consists of

There are two ways a test can be specified. It can either be written as ECMAScript in the document, which performs the test and then informs the test engine whether the test was passed or failed, or it can be an automatic rendering comparison test. If the test document contains an ECMAScript function named runTest at the global scope, then this function is called by the test engine to perform the test. If the test has any unnamed associated reference renderings, then a rendering comparison test will be performed for each unique snapshot time on those reference renderings.

Each reference rendering is a PNG file and has an associated description, an optional name (so it can be identified by the snapshot function in script-based tests) and an optional snapshot time.

Script interface

The test engine exposes a host object named test that can be used by scripted tests to inform the test engine of the results of the test. The test object has these functions:

Examples

The test file format is described here by way of three examples. The first is a rendering comparison test for an animation.

Test description file: anim-circle-1.xml

<test xmlns="http://www.svgtest.org/2006/test"
      id="anim-circle-1" tags="svg11 anim anim.begin-dur anim.freeze anim.from-to">
  <title>Animated circle</title>
  <desc>
    This test document has a single circle whose radius is animated with linear
    interpolation.  The rendering is sampled at the beginning, middle and end.
  </desc>
  <rendering file="ref1.png" snapshotTime="0s">
    <desc>
      Snapshot at 0s.  Canvas is blank since the animation has not yet started.
    </desc>
  </rendering>
  <rendering file="ref2.png" snapshotTime="5s">
    <desc>
      Snapshot at 5s.  The circle has a radius of 25 units.
    </desc>
  </rendering>
  <rendering file="ref3.png" snapshotTime="12s">
    <desc>
      Snapshot at 12s.  The animation has become inactive but is frozen,
      so the circle remains with a radius of 50 units.
    </desc>
  </rendering>
</test>

Test document: anim-circle-1.svg

<svg xmlns="http://www.w3.org/2000/svg"
     version="1.1" width="200" height="200" viewBox="0 0 200 200">
  <circle cx="100" cy="100" r="0" fill="red">
    <animate attributeName="r" begin="0s" dur="10s" fill="freeze"
             from="0" to="50"/>
  </circle>
</svg>

Reference rendering 1, snapshot time = 0s:

Reference rendering 1, no circle

Reference rendering 2, snapshot time = 5s:

Reference rendering 2, circle with radius 25 units

Reference rendering 3, snapshot time = 12s:

Reference rendering 3, circle with radius 50 units

This second example demonstrates using script to perform testing of an aspect of the SVG DOM.

Test description file: svgpoint-transform-1.xml

<test xmlns="http://www.svgtest.org/2006/test"
      id="svgpoint-transform-1" tags="svg11 dom SVGPoint SVGPoint.matrixTransform">
  <title>SVGPoint.matrixTransform test 1</title>
  <desc>
    This test creates an SVGMatrix containing a translation transformation
    and transforms an SVGPoint.
  </desc>
</test>

Test document: svgpoint-transform-1.svg

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <script type="text/ecmascript"><![CDATA[
    function runTest() {
      var svg = document.documentElement;
      var m = svg.createSVGMatrix().translate(3, -2);
      var p = svg.createSVGPoint();
      p.x = 5;
      p.y = 10;
      p.matrixTransform(m);
      if (p.x == 8 && p.y == 8) {
        test.pass();
      } else {
        test.fail("Point transformation returns (" + p.x + ", " + p.y + "), expected (8, 8)");
      }
    }
  ]]></script>
</svg>