#
# PWG 5100.8-2003: IPP "-actual" Attributes
#
# https://ftp.pwg.org/pub/pwg/candidates/cs-ippactuals10-20030313-5100.8.pdf
#
# Copyright © 2018-2024 by OpenPrinting.
#
# Licensed under Apache License v2.0.  See the file "LICENSE" for more
# information.
#
# Usage:
#
#   ./ipptool [OPTIONS] -f FILENAME -t PRINTER-URI pwg5100.8.test
#
# Options:
#
#   -d NOPRINT=1              Disable the print tests.
#   -d REQUIRE_ACTUALS=1      Require support for the ACTUALS specification.
#

{
    NAME "Get Printer Capabilities"
    OPERATION Print-Job
    GROUP operation-attributes-tag
    ATTR charset attributes-charset utf-8
    ATTR naturalLanguage attributes-natural-language en
    ATTR uri printer-uri $uri
    ATTR name requesting-user-name $user

    STATUS successful-ok

    EXPECT copies-supported OF-TYPE rangeOfInteger IN-GROUP printer-attributes-tag COUNT 1 WITH-VALUE >1 DEFINE-MATCH PRINTER_HAS_COPIES
    EXPECT finishings-supported OF-TYPE enum IN-GROUP printer-attributes-tag WITH-VALUE >3 DEFINE-MATCH PRINTER_HAS_FINISHINGS
    EXPECT media-col-supported OF-TYPE keyword IN-GROUP printer-attributes-tag DEFINE-MATCH PRINTER_HAS_MEDIA_COL
    EXPECT output-bin-supported OF-TYPE keyword|name IN-GROUP printer-attributes-tag DEFINE-MATCH PRINTER_HAS_OUTPUT_BIN
    EXPECT quality-supported OF-TYPE enum IN-GROUP printer-attributes-tag DEFINE-MATCH PRINTER_HAS_PRINT_QUALITY
    EXPECT sides-supported OF-TYPE keyword IN-GROUP printer-attributes-tag WITH-VALUE "/^two-sided/" DEFINE-MATCH PRINTER_HAS_SIDES

}

{
    SKIP-IF-DEFINED NOPRINT

    NAME "Print Actuals Test Job"
    OPERATION Print-Job
    GROUP operation-attributes-tag
    ATTR charset attributes-charset utf-8
    ATTR naturalLanguage attributes-natural-language en
    ATTR uri printer-uri $uri
    ATTR name requesting-user-name $user
    ATTR name job-name "Actuals Test"
    ATTR boolean ipp-attribute-fidelity false
    ATTR name document-name $filename
    ATTR keyword compression none
    ATTR mimeMediaType document-format $filetype
    FILE $filename

    STATUS successful-ok
    STATUS server-error-busy REPEAT-MATCH REPEAT-LIMIT 30

    EXPECT job-uri OF-TYPE uri COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE "/^(ipp|ipps):/"
    EXPECT job-id OF-TYPE integer COUNT 1 IN-GROUP job-attributes-tag WITH-VALUE >0
    EXPECT job-state OF-TYPE enum COUNT 1 IN-GROUP job-attributes-tag
    EXPECT job-state-reasons OF-TYPE keyword IN-GROUP job-attributes-tag
    EXPECT ?job-state-message OF-TYPE text IN-GROUP job-attributes-tag
    EXPECT ?number-of-intervening-jobs OF-TYPE integer IN-GROUP job-attributes-tag WITH-VALUE >-1
}

{
    SKIP-IF-DEFINED NOPRINT

    NAME "Wait for Actuals Test Job to Complete"
    OPERATION Get-Job-Attributes
    GROUP operation-attributes-tag
    ATTR charset attributes-charset utf-8
    ATTR naturalLanguage attributes-natural-language en
    ATTR uri printer-uri $uri
    ATTR integer job-id $job-id
    ATTR name requesting-user-name $user

    STATUS successful-ok

    DISPLAY job-state

    EXPECT job-state OF-TYPE enum IN-GROUP job-attributes-tag COUNT 1 WITH-VALUE <7 REPEAT-MATCH REPEAT-LIMIT 30
}

{
    SKIP-IF-DEFINED NOPRINT

    NAME "Verify Actuals Test Job Attributes"
    OPERATION Get-Job-Attributes
    GROUP operation-attributes-tag
    ATTR charset attributes-charset utf-8
    ATTR naturalLanguage attributes-natural-language en
    ATTR uri printer-uri $uri
    ATTR integer job-id $job-id
    ATTR name requesting-user-name $user

    STATUS successful-ok

    EXPECT ?copies-actual OF-TYPE integer(0:MAX)|unknown IN-GROUP job-attributes-tag
    EXPECT copies-actual IF-DEFINED PRINTER_HAS_COPIES IF-DEFINED REQUIRE_ACTUALS

    EXPECT ?finishings-actual OF-TYPE enum|unknown IN-GROUP job-attributes-tag
    EXPECT finishings-actual IF-DEFINED PRINTER_HAS_FINISHINGS IF-DEFINED REQUIRE_ACTUALS

    EXPECT ?media-actual OF-TYPE keyword|name|unknown IN-GROUP job-attributes-tag
    EXPECT media-actual IF-DEFINED REQUIRE_ACTUALS

    EXPECT ?media-col-actual OF-TYPE collection|unknown IN-GROUP job-attributes-tag
    EXPECT media-col-actual IF-DEFINED PRINTER_HAS_MEDIA_COL IF-DEFINED REQUIRE_ACTUALS

    EXPECT ?output-bin-actual OF-TYPE keyword|name|unknown IN-GROUP job-attributes-tag
    EXPECT output-bin-actual IF-DEFINED PRINTER_HAS_OUTPUT_BIN IF-DEFINED REQUIRE_ACTUALS

    EXPECT ?print-quality-actual OF-TYPE enum|unknown IN-GROUP job-attributes-tag
    EXPECT print-quality-actual IF-DEFINED PRINTER_HAS_PRINT_QUALITY IF-DEFINED REQUIRE_ACTUALS

    EXPECT ?sides-actual OF-TYPE keyword|unknown IN-GROUP job-attributes-tag WITH-VALUE
    EXPECT sides-actual IF-DEFINED PRINTER_HAS_SIDES IF-DEFINED REQUIRE_ACTUALS
}
