Support brotli in pdfium_test This CL updates pdfium_test.cc to support /BrotliDecode with the --enable-brotli flag. Enabling this flag sets the use_brotli option to true instead of being false by default and calls FPDF_SetBrotliDecodeEnabled() before loading the document. Bug: 475855993 Change-Id: I5056f77b832ba4bb8d0a415a29b9fb6ab0604c53 Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/150930 Reviewed-by: Andy Phan <andyphan@chromium.org> Commit-Queue: Aryan Krishnan <aryankrishnan4b@gmail.com> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/testing/pdfium_test.cc b/testing/pdfium_test.cc index b9f4f71..9a27e72 100644 --- a/testing/pdfium_test.cc +++ b/testing/pdfium_test.cc
@@ -195,6 +195,9 @@ #endif // PDF_ENABLE_V8 bool pages = false; bool md5 = false; +#ifdef PDF_ENABLE_BROTLI + bool enable_brotli = false; +#endif // PDF_ENABLE_BROTLI #ifdef ENABLE_CALLGRIND bool callgrind_delimiters = false; #endif @@ -590,6 +593,10 @@ options->disable_xfa = true; #endif // PDF_ENABLE_XFA #endif // PDF_ENABLE_V8 +#ifdef PDF_ENABLE_BROTLI + } else if (cur_arg == "--enable-brotli") { + options->enable_brotli = true; +#endif // PDF_ENABLE_BROTLI #ifdef ENABLE_CALLGRIND } else if (cur_arg == "--callgrind-delim") { options->callgrind_delimiters = true; @@ -1909,6 +1916,10 @@ " --disable-xfa - do not process XFA forms\n" #endif // PDF_ENABLE_XFA #endif // PDF_ENABLE_V8 +#ifdef PDF_ENABLE_BROTLI + " --enable-brotli - Enable support for the experimental PDF 2.0 " + "/BrotliDecode filter.\n" +#endif // PDF_ENABLE_BROTLI #ifdef ENABLE_CALLGRIND " --callgrind-delim - delimit interesting section when using " "callgrind\n" @@ -1988,12 +1999,17 @@ } FPDF_LIBRARY_CONFIG config; - config.version = 5; + config.version = 6; config.m_pUserFontPaths = nullptr; config.m_pIsolate = nullptr; config.m_v8EmbedderSlot = 0; config.m_pPlatform = nullptr; config.m_FontLibraryType = FPDF_FONTBACKENDTYPE_FREETYPE; +#ifdef PDF_ENABLE_BROTLI + config.m_BrotliEnabled = options.enable_brotli; +#else + config.m_BrotliEnabled = false; +#endif // PDF_ENABLE_BROTLI switch (options.use_renderer_type) { case RendererType::kDefault: