diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-06-19 03:04:44 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-06-19 14:46:58 +0200 |
commit | bb0ea2f8e7d8fffa575b291004e4426138c7bb1a (patch) | |
tree | 2000ab2d200aaa174432b53d93d59078156b61ac /qpdf | |
parent | 87412eb05be3148e812310128f361f79922baad8 (diff) | |
download | qpdf-bb0ea2f8e7d8fffa575b291004e4426138c7bb1a.tar.zst |
Add qpdfjob_register_progress_reporter
Diffstat (limited to 'qpdf')
-rw-r--r-- | qpdf/qpdfjob-ctest.c | 18 | ||||
-rw-r--r-- | qpdf/qtest/qpdf/qpdfjob-ctest.out | 3 | ||||
-rw-r--r-- | qpdf/qtest/qpdfjob.test | 3 |
3 files changed, 20 insertions, 4 deletions
diff --git a/qpdf/qpdfjob-ctest.c b/qpdf/qpdfjob-ctest.c index 8d5e374e..f3272aef 100644 --- a/qpdf/qpdfjob-ctest.c +++ b/qpdf/qpdfjob-ctest.c @@ -21,17 +21,29 @@ wide_test() #endif // QPDF_NO_WCHAR_T static void +custom_progress(int progress, void* data) +{ + printf("%s: write progress: %d%%\n", (char const*)data, progress); +} + +static void run_tests() { /* Be sure to use a different output file for each test. */ + qpdfjob_handle j = NULL; - char const* argv[5]; + char const* argv[6]; argv[0] = "qpdfjob"; argv[1] = "minimal.pdf"; argv[2] = "a.pdf"; argv[3] = "--deterministic-id"; - argv[4] = NULL; - assert(qpdfjob_run_from_argv(argv) == 0); + argv[4] = "--progress"; + argv[5] = NULL; + j = qpdfjob_init(); + qpdfjob_register_progress_reporter(j, custom_progress, (void*)"potato"); + assert(qpdfjob_initialize_from_argv(j, argv) == 0); + assert(qpdfjob_run(j) == 0); + qpdfjob_cleanup(&j); printf("argv test passed\n"); assert(qpdfjob_run_from_json("{\n\ diff --git a/qpdf/qtest/qpdf/qpdfjob-ctest.out b/qpdf/qtest/qpdf/qpdfjob-ctest.out index ac2959f2..22d431de 100644 --- a/qpdf/qtest/qpdf/qpdfjob-ctest.out +++ b/qpdf/qtest/qpdf/qpdfjob-ctest.out @@ -1,3 +1,6 @@ +potato: write progress: 0% +....other write progress.... +potato: write progress: 100% argv test passed json test passed WARNING: xref-with-short-size.pdf (xref stream, offset 16227): Cross-reference stream data has the wrong size; expected = 52; actual = 56 diff --git a/qpdf/qtest/qpdfjob.test b/qpdf/qtest/qpdfjob.test index 1c14a884..0724ba9f 100644 --- a/qpdf/qtest/qpdfjob.test +++ b/qpdf/qtest/qpdfjob.test @@ -100,7 +100,8 @@ $td->runtest("json output from job", $td->NORMALIZE_NEWLINES); $td->runtest("C job API", - {$td->COMMAND => "qpdfjob-ctest"}, + {$td->COMMAND => "qpdfjob-ctest", + $td->FILTER => "perl filter-progress.pl"}, {$td->FILE => "qpdfjob-ctest.out", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); foreach my $i (['a.pdf', 1], ['b.pdf', 2], ['c.pdf', 3]) |