<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- $Id$ -->
<testcase>
  <info>
    <p>
      This test checks that a list can be relaid out when a change in ipd happens across pages.
    </p>
  </info>
  <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="narrow"
          page-height="300pt" page-width="400pt" margin="50pt">
          <fo:region-body background-color="#F0F0F0"/>
        </fo:simple-page-master>
        <fo:simple-page-master master-name="wide"
          page-height="300pt" page-width="600pt" margin="50pt">
          <fo:region-body background-color="#F0F0F0"/>
        </fo:simple-page-master>
        <fo:page-sequence-master master-name="pages">
          <fo:single-page-master-reference master-reference="narrow"/>
          <fo:repeatable-page-master-reference master-reference="wide"/>
        </fo:page-sequence-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="pages">
        <fo:flow flow-name="xsl-region-body" text-align="justify">
          <fo:block space-before="10pt" id="b1_1">In olden times when wishing still helped one, there 
            lived a king whose daughters were all beautiful, but the youngest was so beautiful that 
            the sun itself, which has seen so much, was astonished whenever it shone in her 
            face.</fo:block>
          <fo:block space-before="10pt" id="b1_2">In olden times when wishing still helped one, there 
            lived a king whose daughters were all beautiful, but the youngest was so beautiful that 
            the sun itself, which has seen so much, was astonished whenever it shone in her 
            face.</fo:block>
          <fo:table table-layout="fixed" width="100%" border="1pt solid black" space-before="10pt" 
            padding="2pt" border-collapse="separate">
            <fo:table-body>
              <fo:table-row>
                <fo:table-cell>
                  <fo:block space-before="10pt" id="b1_3">In olden times when wishing still helped 
                    one, there lived a king whose daughters were all beautiful, but the youngest was 
                    so beautiful that the sun itself, which has seen so much, was astonished 
                    whenever it shone in her face.</fo:block>
                  <fo:block space-before="10pt" id="b1_4">In olden times when wishing still helped 
                    one, there lived a king whose daughters were all beautiful, but the youngest was 
                    so beautiful that the sun itself, which has seen so much, was astonished 
                    whenever it shone in her face.</fo:block>
                </fo:table-cell>
              </fo:table-row>
            </fo:table-body>
          </fo:table>
          <fo:block space-before="10pt" id="b1_5" border-top="1pt solid red">In olden times when 
            wishing still helped one, there lived a king whose daughters were all beautiful, but the 
            youngest was so beautiful that the sun itself, which has seen so much, was astonished 
            whenever it shone in her face.</fo:block>
          <fo:block space-before="10pt" id="b1_6">In olden times when wishing still helped one, there 
            lived a king whose daughters were all beautiful, but the youngest was so beautiful that 
            the sun itself, which has seen so much, was astonished whenever it shone in her 
            face.</fo:block>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="pages">
        <fo:flow flow-name="xsl-region-body" text-align="justify">
          <fo:block space-before="10pt" id="b2_1">In olden times when wishing still helped one, there 
            lived a king whose daughters were all beautiful, but the youngest was so beautiful that 
            the sun itself, which has seen so much, was astonished whenever it shone in her 
            face.</fo:block>
          <fo:block space-before="10pt" id="b2_2">In olden times when wishing still helped one, there 
            lived a king whose daughters were all beautiful, but the youngest was so beautiful that 
            the sun itself, which has seen so much, was astonished whenever it shone in her 
            face.</fo:block>
          <fo:list-block space-before="10pt" provisional-distance-between-starts="0.5cm">
            <fo:list-item>
              <fo:list-item-label end-indent="label-end()">
                <fo:block start-indent="2pt">•</fo:block>
              </fo:list-item-label>
              <fo:list-item-body start-indent="body-start()">
                <fo:block space-before="10pt" id="b2_3">In olden times when wishing still helped 
                  one, there lived a king whose daughters were all beautiful, but the youngest was 
                  so beautiful that the sun itself, which has seen so much, was 
                  astonished…</fo:block>
              </fo:list-item-body>
            </fo:list-item>
            <fo:list-item>
              <fo:list-item-label end-indent="label-end()">
                <fo:block start-indent="2pt">•</fo:block>
              </fo:list-item-label>
              <fo:list-item-body start-indent="body-start()">
                <fo:block id="b2_4">In olden times when wishing still helped one, there lived a king 
                  whose daughters were all beautiful, but the youngest was so beautiful that the sun 
                  itself, which has seen so much, was astonished…</fo:block>
              </fo:list-item-body>
            </fo:list-item>
          </fo:list-block>
          <fo:block space-before="10pt" space-before.conditionality="retain" border-top="1pt solid 
            red" id="b2_5">In olden times when wishing still helped one, there lived a king whose 
            daughters were all beautiful, but the youngest was so beautiful that the sun itself, 
            which has seen so much, was astonished whenever it shone in her face.</fo:block>
          <fo:block space-before="10pt" id="b2_6">In olden times when wishing still helped one, there 
            lived a king whose daughters were all beautiful, but the youngest was so beautiful that 
            the sun itself, which has seen so much, was astonished whenever it shone in her 
            face.</fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </fo>
  <checks>
    <!-- First page sequence – table -->
    <eval expected="(solid,#000000,1000)"
                            xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]/@border-after"/>
    <eval expected="300000" xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]//lineArea[1]/@ipd"/>
    <eval expected="b1_4"   xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]/block/block/@prod-id"/>
    <eval expected="In"     xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]//lineArea[1]/text/word[1]"/>
    <eval expected="olden"  xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]//lineArea[1]/text/word[2]"/>
    <eval expected="her"    xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]//lineArea[4]/text/word[position()=last()-1]"/>
    <eval expected="face."  xpath="//pageSequence[1]/pageViewport[2]//flow/block[1]//lineArea[4]/text/word[position()=last()]"/>

    <eval expected="b1_5"   xpath="//pageSequence[1]/pageViewport[2]//flow/block[2]/@prod-id"/>
    <eval expected="500000" xpath="//pageSequence[1]/pageViewport[2]//flow/block[2]/@ipd"/>
    <eval expected="(solid,#ff0000,1000)"
                            xpath="//pageSequence[1]/pageViewport[2]//flow/block[2]/@border-before"/>
    <eval expected="In"     xpath="//pageSequence[1]/pageViewport[2]//flow/block[2]//lineArea[1]/text/word[1]"/>
    <eval expected="olden"  xpath="//pageSequence[1]/pageViewport[2]//flow/block[2]//lineArea[1]/text/word[2]"/>

    <!-- Second page sequence – list -->
    <eval expected="500000" xpath="//pageSequence[2]/pageViewport[2]//flow/block[1]/@ipd"/>
    <eval expected="b2_4"   xpath="//pageSequence[2]/pageViewport[2]//flow/block[1]/block/block[2]/block/@prod-id"/>
    <eval expected="In"     xpath="//pageSequence[2]/pageViewport[2]//flow/block[1]/block/block[2]/block/lineArea[1]/text/word[1]"/>
    <eval expected="olden"  xpath="//pageSequence[2]/pageViewport[2]//flow/block[1]/block/block[2]/block/lineArea[1]/text/word[2]"/>
    <eval expected="was"    xpath="//pageSequence[2]/pageViewport[2]//flow/block[1]/block/block[2]/block/lineArea[3]/text/word[position()=last()-1]"/>
    <eval expected="astonished…"
                            xpath="//pageSequence[2]/pageViewport[2]//flow/block[1]/block/block[2]/block/lineArea[3]/text/word[position()=last()]"/>

    <eval expected="b2_5"   xpath="//pageSequence[2]/pageViewport[2]//flow/block[2]/@prod-id"/>
    <eval expected="500000" xpath="//pageSequence[2]/pageViewport[2]//flow/block[2]/@ipd"/>
    <eval expected="10000"  xpath="//pageSequence[2]/pageViewport[2]//flow/block[2]/@space-before"/>
    <eval expected="(solid,#ff0000,1000)"
                            xpath="//pageSequence[2]/pageViewport[2]//flow/block[2]/@border-before"/>
    <eval expected="In"     xpath="//pageSequence[2]/pageViewport[2]//flow/block[2]//lineArea[1]/text/word[1]"/>
    <eval expected="olden"  xpath="//pageSequence[2]/pageViewport[2]//flow/block[2]//lineArea[1]/text/word[2]"/>
  </checks>
</testcase>
