Commit b2b2a175c49c0a68018e329ee7637424d1ba3218
1 parent
09f37372
Add missing unit test for register progress reporter in C API
It was exercised in the pdf-linearize example but not in qpdf-ctest.
Showing
3 changed files
with
11 additions
and
0 deletions
libqpdf/qpdf-c.cc
| @@ -828,6 +828,7 @@ void qpdf_register_progress_reporter( | @@ -828,6 +828,7 @@ void qpdf_register_progress_reporter( | ||
| 828 | void (*report_progress)(int percent, void* data), | 828 | void (*report_progress)(int percent, void* data), |
| 829 | void* data) | 829 | void* data) |
| 830 | { | 830 | { |
| 831 | + QTC::TC("qpdf", "qpdf-c registered progress reporter"); | ||
| 831 | qpdf->qpdf_writer->registerProgressReporter( | 832 | qpdf->qpdf_writer->registerProgressReporter( |
| 832 | new ProgressReporter(report_progress, data)); | 833 | new ProgressReporter(report_progress, data)); |
| 833 | } | 834 | } |
qpdf/qpdf-ctest.c
| @@ -117,6 +117,11 @@ static void read_file_into_memory(char const* filename, | @@ -117,6 +117,11 @@ static void read_file_into_memory(char const* filename, | ||
| 117 | fclose(f); | 117 | fclose(f); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | +static void count_progress(int percent, void* data) | ||
| 121 | +{ | ||
| 122 | + ++(*(int*)data); | ||
| 123 | +} | ||
| 124 | + | ||
| 120 | static void test01(char const* infile, | 125 | static void test01(char const* infile, |
| 121 | char const* password, | 126 | char const* password, |
| 122 | char const* outfile, | 127 | char const* outfile, |
| @@ -201,11 +206,15 @@ static void test05(char const* infile, | @@ -201,11 +206,15 @@ static void test05(char const* infile, | ||
| 201 | char const* outfile, | 206 | char const* outfile, |
| 202 | char const* outfile2) | 207 | char const* outfile2) |
| 203 | { | 208 | { |
| 209 | + int count = 0; | ||
| 204 | qpdf_read(qpdf, infile, password); | 210 | qpdf_read(qpdf, infile, password); |
| 205 | qpdf_init_write(qpdf, outfile); | 211 | qpdf_init_write(qpdf, outfile); |
| 212 | + qpdf_register_progress_reporter(qpdf, count_progress, (void*)&count); | ||
| 206 | qpdf_set_static_ID(qpdf, QPDF_TRUE); | 213 | qpdf_set_static_ID(qpdf, QPDF_TRUE); |
| 207 | qpdf_set_linearization(qpdf, QPDF_TRUE); | 214 | qpdf_set_linearization(qpdf, QPDF_TRUE); |
| 208 | qpdf_write(qpdf); | 215 | qpdf_write(qpdf); |
| 216 | + /* make sure progress reporter was called */ | ||
| 217 | + assert(count > 0); | ||
| 209 | report_errors(); | 218 | report_errors(); |
| 210 | } | 219 | } |
| 211 | 220 |
qpdf/qpdf.testcov
| @@ -601,3 +601,4 @@ qpdf overlay page with no resources 0 | @@ -601,3 +601,4 @@ qpdf overlay page with no resources 0 | ||
| 601 | QPDFObjectHandle check ownership 0 | 601 | QPDFObjectHandle check ownership 0 |
| 602 | qpdf weak crypto warning 0 | 602 | qpdf weak crypto warning 0 |
| 603 | qpdf-c called qpdf_oh_is_initialized 0 | 603 | qpdf-c called qpdf_oh_is_initialized 0 |
| 604 | +qpdf-c registered progress reporter 0 |