<?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 for the correct behaviour of multiple breaks at the same break possibility.
    </p>
  </info>
  <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="page" page-height="5in" page-width="5in" margin="20pt">
          <fo:region-body/>
          <fo:region-after extent="1.2em"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="page" id="ps1" initial-page-number="1" force-page-count="no-force">
        <fo:static-content flow-name="xsl-region-after">
          <fo:block>page: <fo:page-number/></fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <fo:block id="b1">Before the break</fo:block>
          <fo:block break-before="page" break-after="column">
            <fo:block id="b2" break-before="page">
              This text should be on page 2.
            </fo:block>
            <fo:block>
              <fo:block id="b3" break-after="page">
                Inner block with break-after.
              </fo:block>
            </fo:block>  
          </fo:block>
          <fo:block id="b4">This text should be on page 3.</fo:block>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="page" id="ps2" initial-page-number="1" force-page-count="no-force">
        <fo:static-content flow-name="xsl-region-after">
          <fo:block>page: <fo:page-number/></fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <fo:block id="b11">Before the break</fo:block>
          <fo:block-container break-before="page" break-after="column">
            <fo:block-container break-before="page">
              <fo:block id="b12">This text should be on page 2.</fo:block>
            </fo:block-container>
            <fo:block>
              <fo:block id="b13" break-after="page">
                Inner block with break-after.
              </fo:block>
            </fo:block>  
          </fo:block-container>
          <fo:block id="b14">This text should be on page 3.</fo:block>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="page" id="ps3" initial-page-number="1" force-page-count="no-force">
        <fo:static-content flow-name="xsl-region-after">
          <fo:block>page: <fo:page-number/></fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <fo:block id="b21">Before the break</fo:block>
          <fo:block break-before="page" break-after="column">
            <fo:table table-layout="fixed" width="100%" break-before="page">
              <fo:table-column column-width="proportional-column-width(1)"/>
              <fo:table-body>
                <fo:table-row>
                  <fo:table-cell>
                    <fo:block id="b22">This text should be on page 2.</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-body>
            </fo:table>
            <fo:block>
              <fo:table table-layout="fixed" width="100%" break-after="page">
                <fo:table-column column-width="proportional-column-width(1)"/>
                <fo:table-body>
                  <fo:table-row>
                    <fo:table-cell>
                      <fo:block id="b23">Inner block in table with break-after.</fo:block>
                    </fo:table-cell>
                  </fo:table-row>
                </fo:table-body>
              </fo:table>
            </fo:block>  
          </fo:block>
          <fo:block id="b24">This text should be on page 3.</fo:block>
        </fo:flow>
      </fo:page-sequence>
      <fo:page-sequence master-reference="page" id="ps4" initial-page-number="1" force-page-count="no-force">
        <fo:static-content flow-name="xsl-region-after">
          <fo:block>page: <fo:page-number/></fo:block>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <fo:block id="b31">Before the break</fo:block>
          <fo:block break-before="page" break-after="column">
            <fo:list-block break-before="page">
              <fo:list-item>
                <fo:list-item-label end-indent="label-end()">
                  <fo:block>+</fo:block>
                </fo:list-item-label>
                <fo:list-item-body start-indent="body-start()">
                  <fo:block id="b32">This text should be on page 2.</fo:block>
                </fo:list-item-body>
              </fo:list-item>
              <fo:list-item break-after="page">
                <fo:list-item-label end-indent="label-end()">
                  <fo:block>+</fo:block>
                </fo:list-item-label>
                <fo:list-item-body start-indent="body-start()">
                  <fo:block id="b33">Inner block in list-item with break-after.</fo:block>
                </fo:list-item-body>
              </fo:list-item>
            </fo:list-block>
          </fo:block>
          <fo:block id="b34">This text should be on page 3.</fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </fo>
  <checks>
    <eval expected="1" xpath="//block[@prod-id = 'b1']/ancestor::pageViewport/@nr"/>
    <eval expected="2" xpath="//block[@prod-id = 'b2']/ancestor::pageViewport/@nr"/>
    <eval expected="2" xpath="//block[@prod-id = 'b3']/ancestor::pageViewport/@nr"/>
    <eval expected="3" xpath="//block[@prod-id = 'b4']/ancestor::pageViewport/@nr"/>

    <eval expected="1" xpath="//block[@prod-id = 'b11']/ancestor::pageViewport/@nr"/>
    <eval expected="2" xpath="//block[@prod-id = 'b12']/ancestor::pageViewport/@nr"/>
    <eval expected="2" xpath="//block[@prod-id = 'b13']/ancestor::pageViewport/@nr"/>
    <eval expected="3" xpath="//block[@prod-id = 'b14']/ancestor::pageViewport/@nr"/>

    <eval expected="1" xpath="//block[@prod-id = 'b21']/ancestor::pageViewport/@nr"/>
    <eval expected="2" xpath="//block[@prod-id = 'b22']/ancestor::pageViewport/@nr"/>
    <eval expected="2" xpath="//block[@prod-id = 'b23']/ancestor::pageViewport/@nr"/>
    <eval expected="3" xpath="//block[@prod-id = 'b24']/ancestor::pageViewport/@nr"/>
  </checks>
</testcase>
