Add an embedder test for rendering texts with FPDF_NO_NATIVETEXT flag.
Since flag FPDF_NO_NATIVETEXT only affects macOS, the Linux-only
embedder test FPDFViewEmbedderTest.RenderHelloWorldWithFlags cannot
fully test the functionality for rendering with no native text.
Additionally, AGG renders hello_world.pdf (contains Helvetica and
Times-Roman) the same with or without native text support on macOS.
Need to use a different font that can demonstrate the rendering result
changes caused by the flag on macOS.
This CL adds a new embedder test RenderBug664284WithNoNativeText for
rendering Arial font with FPDF_NO_NATIVETEXT on all platforms, and
removes the old test from RenderHelloWorldWithFlags, since the new test
provides better test coverage and demonstrate how FPDF_NO_NATIVETEXT
affects the rendering result on macOS.
Bug: pdfium:1500
Change-Id: I81d7751236720dc8c6fc1807eef4665b0aec3123
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69312
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp
index 2a937ab..81145f0 100644
--- a/fpdfsdk/fpdf_view_embeddertest.cpp
+++ b/fpdfsdk/fpdf_view_embeddertest.cpp
@@ -1103,6 +1103,29 @@
}
}
+TEST_F(FPDFViewEmbedderTest, RenderBug664284WithNoNativeText) {
+// FPDF_NO_NATIVETEXT flag disables native text support on macOS, therefore
+// Windows and Linux rendering results remain the same as rendering with no
+// flag, while the expected hash value for macOS rendering result is no longer
+// "41ada106c6133b52ea45280eaaa38ae1"(hash value for rendering with no flag).
+#if defined(OS_WIN)
+ static const char kNoNativeTextChecksum[] =
+ "4671643caf99a1f4b6c0117ccb7bc9e7";
+#else
+ static const char kNoNativeTextChecksum[] =
+ "d64d6b0fc39a8cefc43de39da5c60b17";
+#endif
+
+ ASSERT_TRUE(OpenDocument("bug_664284.pdf"));
+ FPDF_PAGE page = LoadPage(0);
+ ASSERT_TRUE(page);
+
+ TestRenderPageBitmapWithFlags(page, FPDF_NO_NATIVETEXT,
+ kNoNativeTextChecksum);
+
+ UnloadPage(page);
+}
+
// TODO(crbug.com/pdfium/11): Fix this test and enable.
#if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
#define MAYBE_RenderManyRectanglesWithFlags \
@@ -1183,7 +1206,6 @@
TestRenderPageBitmapWithFlags(page, 0, kHelloWorldChecksum);
TestRenderPageBitmapWithFlags(page, FPDF_ANNOT, kHelloWorldChecksum);
TestRenderPageBitmapWithFlags(page, FPDF_LCD_TEXT, kLcdTextMD5);
- TestRenderPageBitmapWithFlags(page, FPDF_NO_NATIVETEXT, kHelloWorldChecksum);
TestRenderPageBitmapWithFlags(page, FPDF_GRAYSCALE, kHelloWorldChecksum);
TestRenderPageBitmapWithFlags(page, FPDF_RENDER_LIMITEDIMAGECACHE,
kHelloWorldChecksum);