<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/pdf-form-001.xml"
        name="pdf-form-001.xml"
        expected="pass">
   <t:info>
      <t:title>pdf-form-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-06-12</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests that pdf-form works.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      name="main"
                      version="3.0">
         <p:import href="https://xmlcalabash.com/ext/library/pdf-steps.xpl"/>
         <p:output port="result"/>
         <cx:pdf-info form-details="true">
            <p:with-input port="source" href="../documents/libreoffice-form.pdf"/>
         </cx:pdf-info>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="cx" uri="http://xmlcalabash.com/ns/extensions"/>
         <s:ns prefix="f" uri="http://xmlcalabash.com/ns/acro-form"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="cx:pdf-info">Wrong document element&gt;</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/cx:pdf-info">
               <s:assert test="exists(f:acro-form)">Form is missing</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="f:acro-form">
               <s:assert test="f:text[@name='First Name'] = 'Alice'">First name is incorrect</s:assert>
               <s:assert test="f:text[@name='Last Name'] = ''">Last name is incorrect</s:assert>
               <s:assert test="f:radiobutton[@name='female'] = 'Off'">Radio button is wrong</s:assert>
               <s:assert test="f:checkbox[@name='gdpr'] = 'Off'">Check box is wrong</s:assert>
               <s:assert test="empty(f:combobox/f:value)">Combobox is wrong</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="pdf-form-001.xml">
      <cx:pdf-info xmlns:cx="http://xmlcalabash.com/ns/extensions"
                   href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/documents/libreoffice-form.pdf">
         <cx:version>1.5</cx:version>
         <cx:form>acro-form</cx:form>
         <f:acro-form xmlns:f="http://xmlcalabash.com/ns/acro-form">
            <f:text name="First Name" type="Tx">Alice</f:text>
            <f:text name="Last Name" type="Tx"/>
            <f:radiobutton name="female" type="Btn">Off</f:radiobutton>
            <f:text name="Birthday" type="Tx"/>
            <f:checkbox name="gdpr" type="Btn">Off</f:checkbox>
            <f:checkbox name="other" type="Btn">Off</f:checkbox>
            <f:text name="First Name_2" type="Tx">Bob</f:text>
            <f:combobox name="Nationality" type="Ch">
               <f:choice>Unknown</f:choice>
               <f:choice>German</f:choice>
               <f:choice>Indonesian</f:choice>
               <f:choice>US-American</f:choice>
               <f:choice>French</f:choice>
               <f:choice>Spanish</f:choice>
               <f:choice>Italian</f:choice>
            </f:combobox>
         </f:acro-form>
         <cx:pages>1</cx:pages>
         <cx:encrypted>false</cx:encrypted>
         <cx:page-size width="595" height="842" units="px">A4</cx:page-size>
         <cx:creator>Writer</cx:creator>
         <cx:producer>LibreOffice 6.4</cx:producer>
         <cx:creation-date>2022-06-26T08:58:43Z</cx:creation-date>
         <cx:file-size>34186</cx:file-size>
      </cx:pdf-info>
   </t:result>
</t:test>
