aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qtest/qpdf/filter-progress.pl7
-rw-r--r--qpdf/qtest/qpdf/job-api.out7
-rw-r--r--qpdf/qtest/qpdfjob.test3
-rw-r--r--qpdf/test_driver.cc21
4 files changed, 36 insertions, 2 deletions
diff --git a/qpdf/qtest/qpdf/filter-progress.pl b/qpdf/qtest/qpdf/filter-progress.pl
index 97453fcb..943929af 100644
--- a/qpdf/qtest/qpdf/filter-progress.pl
+++ b/qpdf/qtest/qpdf/filter-progress.pl
@@ -4,10 +4,15 @@ use warnings;
my $seen = 0;
while (<>)
{
- if (m/write progress: (?:10)?0\%/)
+ if (m/write progress: 0\%/)
{
print;
}
+ elsif (m/write progress: 100\%/)
+ {
+ print;
+ $seen = 0;
+ }
elsif (m/write progress: /)
{
if (! $seen)
diff --git a/qpdf/qtest/qpdf/job-api.out b/qpdf/qtest/qpdf/job-api.out
index d69b2ac9..7ef99171 100644
--- a/qpdf/qtest/qpdf/job-api.out
+++ b/qpdf/qtest/qpdf/job-api.out
@@ -1,4 +1,11 @@
normal
+qpdf: a.pdf: write progress: 0%
+....other write progress....
+qpdf: a.pdf: write progress: 100%
+custom progress reporter
+custom write progress: 0%
+....other write progress....
+custom write progress: 100%
error caught by check
finished config
usage: an input file name is required
diff --git a/qpdf/qtest/qpdfjob.test b/qpdf/qtest/qpdfjob.test
index f6f40755..1c14a884 100644
--- a/qpdf/qtest/qpdfjob.test
+++ b/qpdf/qtest/qpdfjob.test
@@ -87,7 +87,8 @@ $td->runtest("QPDFJob json partial",
{$td->FILE => "job-partial-json.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("QPDFJob API",
- {$td->COMMAND => "test_driver 84 -"},
+ {$td->COMMAND => "test_driver 84 -",
+ $td->FILTER => "perl filter-progress.pl"},
{$td->FILE => "job-api.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("check output",
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 106f5f99..2384ddef 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -2937,6 +2937,27 @@ test_84(QPDF& pdf, char const* arg2)
->qdf()
->deterministicId()
->objectStreams("preserve")
+ ->progress()
+ ->checkConfiguration();
+ j.run();
+ assert(j.getExitCode() == 0);
+ assert(!j.hasWarnings());
+ assert(j.getEncryptionStatus() == 0);
+ }
+
+ std::cout << "custom progress reporter" << std::endl;
+ {
+ QPDFJob j;
+ j.registerProgressReporter([](int p) {
+ std::cout << "custom write progress: " << p << "%" << std::endl;
+ });
+ j.config()
+ ->inputFile("minimal.pdf")
+ ->outputFile("a.pdf")
+ ->qdf()
+ ->deterministicId()
+ ->objectStreams("preserve")
+ ->progress()
->checkConfiguration();
j.run();
assert(j.getExitCode() == 0);