Commit b2b2a175c49c0a68018e329ee7637424d1ba3218

Authored by Jay Berkenbilt
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.
libqpdf/qpdf-c.cc
... ... @@ -828,6 +828,7 @@ void qpdf_register_progress_reporter(
828 828 void (*report_progress)(int percent, void* data),
829 829 void* data)
830 830 {
  831 + QTC::TC("qpdf", "qpdf-c registered progress reporter");
831 832 qpdf->qpdf_writer->registerProgressReporter(
832 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 117 fclose(f);
118 118 }
119 119  
  120 +static void count_progress(int percent, void* data)
  121 +{
  122 + ++(*(int*)data);
  123 +}
  124 +
120 125 static void test01(char const* infile,
121 126 char const* password,
122 127 char const* outfile,
... ... @@ -201,11 +206,15 @@ static void test05(char const* infile,
201 206 char const* outfile,
202 207 char const* outfile2)
203 208 {
  209 + int count = 0;
204 210 qpdf_read(qpdf, infile, password);
205 211 qpdf_init_write(qpdf, outfile);
  212 + qpdf_register_progress_reporter(qpdf, count_progress, (void*)&count);
206 213 qpdf_set_static_ID(qpdf, QPDF_TRUE);
207 214 qpdf_set_linearization(qpdf, QPDF_TRUE);
208 215 qpdf_write(qpdf);
  216 + /* make sure progress reporter was called */
  217 + assert(count > 0);
209 218 report_errors();
210 219 }
211 220  
... ...
qpdf/qpdf.testcov
... ... @@ -601,3 +601,4 @@ qpdf overlay page with no resources 0
601 601 QPDFObjectHandle check ownership 0
602 602 qpdf weak crypto warning 0
603 603 qpdf-c called qpdf_oh_is_initialized 0
  604 +qpdf-c registered progress reporter 0
... ...