wiki:TestingXSLFO/FOP

FOP Layout Engine Tests

FOP’s layout engine tests are integrated with other JUnit tests that are run in the FOP build process. Each test includes a complete FO document, and assertions are made (and checked) about the FOP-specific area-tree that results from formatting the FO document with FOP.

The following is the example test document from  http://wiki.apache.org/xmlgraphics-fop/HowToCreateLayoutEngineTests:

<testcase>
  <info>
    <p>
      This test checks <something>.....
    </p>
  </info>
  <variables>
    <img>../../resources/images/bgimg300dpi.jpg</img>
  </variables>
  <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
      <fo:layout-master-set>
        <!-- etc. etc. -->
        <fo:block-container background-image="##img">
        <!-- etc. etc. -->
    </fo:root>
  </fo>
  <checks>
    <eval expected="0 0 360000 360000" xpath="/areaTree/pageSequence/pageViewport/@bounds" desc="page size"/>
    <true xpath="/areaTree/pageSequence/pageViewport/page[1]"/>
    <true xpath="not(/areaTree/pageSequence/pageViewport/page[2])"/>
    <eval expected="0 0 360000 360000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/@rect" desc="region body area"/>
  </checks>
</testcase>