<?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 fo:character in a RTL writing-mode context.
    </p>
  </info>
  <fo>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simple" page-height="5in" page-width="5in">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simple">
        <fo:flow flow-name="xsl-region-body">
          <fo:block-container writing-mode="lr-tb">
            <fo:block><fo:character character="1"/><fo:character character="2"/><fo:character character="3"/><fo:character character="4"/></fo:block>
          </fo:block-container>
          <fo:block-container writing-mode="rl-tb">
            <fo:block><fo:bidi-override unicode-bidi="bidi-override" direction="rtl"><fo:character character="1"/><fo:character character="2"/><fo:character character="3"/><fo:character character="4"/></fo:bidi-override></fo:block>
          </fo:block-container>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </fo>
  <checks>
    <!--  left-to-right context -->
    <eval expected="6672" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[1]/@ipd"/>
    <eval expected="1" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[1]/word[1]"/>
    <true xpath="not(boolean(//flow/block[1]/block[1]/block[1]/lineArea/text[1]/word[1]/@level))"/>
    <eval expected="6672" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[2]/@ipd"/>
    <eval expected="2" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[2]/word[1]"/>
    <true xpath="not(boolean(//flow/block[1]/block[1]/block[1]/lineArea/text[2]/word[1]/@level))"/>
    <eval expected="6672" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[3]/@ipd"/>
    <eval expected="3" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[3]/word[1]"/>
    <true xpath="not(boolean(//flow/block[1]/block[1]/block[1]/lineArea/text[3]/word[1]/@level))"/>
    <eval expected="6672" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[4]/@ipd"/>
    <eval expected="4" xpath="//flow/block[1]/block[1]/block[1]/lineArea/text[4]/word[1]"/>
    <true xpath="not(boolean(//flow/block[1]/block[1]/block[1]/lineArea/text[4]/word[1]/@level))"/>
    <!--  right-to-left context, with bidi override of rtl -->
    <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/@ipd"/>
    <eval expected="4" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]"/>
    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@level"/>
    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[1]/word[1]/@reversed"/>
    <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/@ipd"/>
    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]"/>
    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]/@level"/>
    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[2]/word[1]/@reversed"/>
    <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/@ipd"/>
    <eval expected="2" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]"/>
    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@level"/>
    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[3]/word[1]/@reversed"/>
    <eval expected="6672" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/@ipd"/>
    <eval expected="1" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]"/>
    <eval expected="3" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@level"/>
    <eval expected="" xpath="//flow/block[2]/block[1]/block[1]/lineArea/inlineparent/text[4]/word[1]/@reversed"/>
  </checks>
</testcase>
