<?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 floats.
    </p>
  </info>
  <fo>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <fo:layout-master-set>
    <fo:simple-page-master margin="50pt" master-name="page" page-height="800pt" page-width="600pt">
      <fo:region-body background-color="yellow" />
    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="page">
    <fo:flow flow-name="xsl-region-body">
      <fo:block>
        <fo:table table-layout="fixed" width="100%">
          <fo:table-body>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C11</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C12</fo:block>
              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C21</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C22</fo:block>
              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C31</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C32</fo:block>
              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C41</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C42</fo:block>
              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C51</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C52</fo:block>
              </fo:table-cell>
            </fo:table-row>
          </fo:table-body>
        </fo:table>
      </fo:block>
      <fo:block>
        Put some content before the float but enough to make the float go to the third line of this block. Just enought content to place the float in the second line is not desirable. <fo:inline color="red">This is the last content before the float and the float is right now.</fo:inline>
        <fo:float float="start">
          <fo:block border="1pt solid red" padding="10pt" color="blue" end-indent="0pt" start-indent="0pt">
            <fo:block-container inline-progression-dimension="110pt">
              <fo:block background-color="green">
                This is a normal block that is confined to the block container inside a side float. The background is green.
              </fo:block>
            </fo:block-container>
          </fo:block>
        </fo:float>
        <fo:inline color="blue">This is the first content after the float.</fo:inline> This paragraph contains a side float and the content of the paragraph needs to be wrapped around the float... this is very complicated but the current implementation can handle the simpler cases.
      </fo:block>
      <fo:block>
        <fo:table table-layout="fixed" width="100%">
          <fo:table-body>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C11</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C12</fo:block>
              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C21</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C22</fo:block>
              </fo:table-cell>
            </fo:table-row>
            <fo:table-row>
              <fo:table-cell>
                <fo:block>C31</fo:block>
              </fo:table-cell>
              <fo:table-cell>
                <fo:block>C32</fo:block>
              </fo:table-cell>
            </fo:table-row>
          </fo:table-body>
        </fo:table>
      </fo:block>
      <fo:block>Content after the table. Floats cannot be handled if next to a table, unless the table starts and ends between the start and the end of the float. Tables before or after floats are not a problem.</fo:block>
      <fo:block>
        Put some content before the float but enough to make the float go to the third line of this block. Just enought content to place the float in the second line is not desirable. <fo:inline color="red">This is the last content before the float and the float is right now.</fo:inline>
        <fo:float float="end">
          <fo:block border="1pt solid red" padding="10pt" color="blue" end-indent="0pt" start-indent="0pt">
            <fo:block-container inline-progression-dimension="110pt">
              <fo:block background-color="orange">
                This is a normal block that is confined to the block container inside a side float. The background is orange.
              </fo:block>
            </fo:block-container>
          </fo:block>
        </fo:float>
        <fo:inline color="blue">This is the first content after the float.</fo:inline> This paragraph contains a side float and the content of the paragraph needs to be wrapped around the float... this is very complicated but the current implementation can handle the simpler cases.
      </fo:block>
      <fo:block>
        <fo:list-block>
          <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
              <fo:block>(a)</fo:block>
            </fo:list-item-label>
            <fo:list-item-body start-indent="body-start()">
              <fo:block>
                here is text in the list item body and lets make sure the text is enought to wrap at the edge of the float
              </fo:block>
            </fo:list-item-body>
          </fo:list-item>
          <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
              <fo:block>(b)</fo:block>
            </fo:list-item-label>
            <fo:list-item-body start-indent="body-start()">
              <fo:block>
                here is text in the list item body
              </fo:block>
            </fo:list-item-body>
          </fo:list-item>
        </fo:list-block>
      </fo:block>
      <fo:block>Content after the list. Floats cannot be handled if next to a list, unless the list starts and ends between the start and the end of the float. Lists before or after a float are not a problem.</fo:block>
      <fo:block>
        <fo:list-block >
          <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
              <fo:block>(a)</fo:block>
            </fo:list-item-label>
            <fo:list-item-body start-indent="body-start()">
              <fo:block>
                here is text in the list item body
              </fo:block>
            </fo:list-item-body>
          </fo:list-item>
          <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
              <fo:block>(b)</fo:block>
            </fo:list-item-label>
            <fo:list-item-body start-indent="body-start()">
              <fo:block>
                here is text in the list item body
              </fo:block>
            </fo:list-item-body>
          </fo:list-item>
          <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
              <fo:block>(c)</fo:block>
            </fo:list-item-label>
            <fo:list-item-body start-indent="body-start()">
              <fo:block>
                here is text in the list item body
              </fo:block>
            </fo:list-item-body>
          </fo:list-item>
          <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
              <fo:block>(d)</fo:block>
            </fo:list-item-label>
            <fo:list-item-body start-indent="body-start()">
              <fo:block>
                here is text in the list item body
              </fo:block>
            </fo:list-item-body>
          </fo:list-item>
        </fo:list-block>
      </fo:block>
    </fo:flow>
  </fo:page-sequence>
</fo:root>
  </fo>
  <checks>
    <!-- first float -->
    <eval expected="132000" xpath="//pageViewport[1]/page/regionViewport[1]//flow[1]/block[5]/@left-offset" />
    <eval expected="C11" xpath="//pageViewport[1]/page/regionViewport[1]//flow[1]/block[5]/block[1]/block[1]/block[1]/lineArea[1]" />
    <eval expected="379000" xpath="//pageViewport[1]/page/regionViewport[1]//flow[1]/block[9]/@left-offset" />
    <eval expected="here is text in the list item body and lets make sure the text is" xpath="//pageViewport[1]/page/regionViewport[1]//flow[1]/block[11]/block[1]/block[1]/block[2]/block[1]/lineArea[1]" />
  </checks>
</testcase>
