]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix MONITOR-PRINTER-STATE directive.
authorMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 7 Apr 2021 23:24:32 +0000 (19:24 -0400)
committerMichael R Sweet <michael.r.sweet@gmail.com>
Wed, 7 Apr 2021 23:24:32 +0000 (19:24 -0400)
examples/Makefile
examples/print-job-media-needed.test [new file with mode: 0644]
tools/ipptool.c

index 09cfa328d1a599960c61183f8607cef5faead9b4..aade8e11f6d74a602125de9f0c3885c6d30511a6 100644 (file)
@@ -1,6 +1,7 @@
 #
 # Example files makefile for CUPS.
 #
+# Copyright © 2021 by OpenPrinting.
 # Copyright © 2007-2019 by Apple Inc.
 # Copyright © 2002-2005 by Easy Software Products.
 #
@@ -87,6 +88,7 @@ TESTFILES     =       \
                        ipp-2.2.test \
                        ipp-backend.test \
                        ipp-everywhere.test \
+                       print-job.test \
                        print-job-and-wait.test \
                        print-job-deflate.test \
                        print-job-gzip.test \
@@ -94,8 +96,8 @@ TESTFILES     =       \
                        print-job-letter.test \
                        print-job-manual.test \
                        print-job-media-col.test \
+                       print-job-media-needed.test \
                        print-job-password.test \
-                       print-job.test \
                        print-uri.test \
                        set-attrs-hold.test \
                        validate-job.test
diff --git a/examples/print-job-media-needed.test b/examples/print-job-media-needed.test
new file mode 100644 (file)
index 0000000..cc77174
--- /dev/null
@@ -0,0 +1,49 @@
+# Print a test page, expecting the printer to run out of media
+{
+    PAUSE "Remove Paper"
+
+    NAME "Print file expecting media-empty"
+    OPERATION Print-Job
+    GROUP operation-attributes-tag
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+       ATTR name requesting-user-name $user
+       ATTR mimeMediaType document-format $filetype
+    FILE $filename
+    STATUS successful-ok
+
+    MONITOR-PRINTER-STATE $uri {
+        EXPECT printer-state-reasons WITH-VALUE "/^media-needed/" DEFINE-MATCH HAVE_MEDIA_NEEDED
+    }
+}
+
+{
+    PASS-IF-DEFINED HAVE_MEDIA_NEEDED
+
+    NAME "Wait for media-empty"
+    OPERATION Get-Printer-Attributes
+    GROUP operation-attributes-tag
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+       ATTR name requesting-user-name $user
+        ATTR keyword requested-attributes printer-state-reasons
+    STATUS successful-ok
+    EXPECT printer-state-reasons WITH-VALUE "/^media-needed/" REPEAT-NO-MATCH
+}
+
+{
+    PAUSE "Load Paper"
+
+    NAME "Wait for no media-empty"
+    OPERATION Get-Printer-Attributes
+    GROUP operation-attributes-tag
+       ATTR charset attributes-charset utf-8
+       ATTR language attributes-natural-language en
+       ATTR uri printer-uri $uri
+       ATTR name requesting-user-name $user
+        ATTR keyword requested-attributes printer-state-reasons
+    STATUS successful-ok
+    EXPECT printer-state-reasons WITH-VALUE "/^media-needed/" REPEAT-MATCH
+}
index 5cfdaab342b864b1bcf447ce79ec5e26cfed1f3d..2162f7b1cf9ebc214b70f63d0f4cbae3cbfc56ac 100644 (file)
@@ -2690,7 +2690,8 @@ parse_monitor_printer_state(
   if (strcmp(temp, "{"))
   {
     // Got a printer URI so copy it...
-    data->monitor_uri = strdup(temp);
+    _ippVarsExpand(data->vars, value, temp, sizeof(value));
+    data->monitor_uri = strdup(value);
 
     // Then see if we have an opening brace...
     if (!_ippFileReadToken(f, temp, sizeof(temp)) || strcmp(temp, "{"))