1 // Copyright 2019 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <utility>
6
7 #include "build/build_config.h"
8 #include "core/fxcrt/fx_system.h"
9 #include "core/fxge/dib/fx_dib.h"
10 #include "public/fpdf_progressive.h"
11 #include "testing/embedder_test.h"
12 #include "testing/embedder_test_constants.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace {
16
17 constexpr FX_ARGB kBlack = 0xFF000000;
18 constexpr FX_ARGB kBlue = 0xFF0000FF;
19 constexpr FX_ARGB kGreen = 0xFF00FF00;
20 constexpr FX_ARGB kRed = 0xFFFF0000;
21 constexpr FX_ARGB kWhite = 0xFFFFFFFF;
22
23 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
24 #if defined(OS_LINUX) || defined(OS_CHROMEOS)
25 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
26 "fbd62f1df1cae1fd2fbf5a24bed6b4cd";
27 #else
28 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
29 "44e6dd3c36d8bbfb38d306b442e61241";
30 #endif // defined(OS_LINUX) || defined(OS_CHROMEOS)
31 #else
32 #if defined(OS_WIN)
33 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
34 "649d6792ea50faf98c013c2d81710595";
35 #elif defined(OS_APPLE)
36 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
37 "83e9f5222c4c959b0b63a5cd24f773a1";
38 #else
39 static constexpr char kAnnotationStampWithApBaseContentChecksum[] =
40 "a24edc7740f1d6f76899652dcf825dea";
41 #endif
42 #endif // defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
43
44 } // namespace
45
46 class FPDFProgressiveRenderEmbedderTest : public EmbedderTest {
47 public:
48 class FakePause : public IFSDK_PAUSE {
49 public:
FakePause(bool should_pause)50 explicit FakePause(bool should_pause) : should_pause_(should_pause) {
51 IFSDK_PAUSE::version = 1;
52 IFSDK_PAUSE::user = nullptr;
53 IFSDK_PAUSE::NeedToPauseNow = Pause_NeedToPauseNow;
54 }
55 ~FakePause() = default;
Pause_NeedToPauseNow(IFSDK_PAUSE * param)56 static FPDF_BOOL Pause_NeedToPauseNow(IFSDK_PAUSE* param) {
57 return static_cast<FakePause*>(param)->should_pause_;
58 }
59
60 private:
61 const bool should_pause_;
62 };
63
64 // StartRenderPageWithFlags() with no flags.
65 // The call returns true if the rendering is complete.
66 bool StartRenderPage(FPDF_PAGE page, IFSDK_PAUSE* pause);
67
68 // Start rendering of |page| into a bitmap with the ability to |pause| the
69 // rendering with the specified rendering |flags|.
70 // The call returns true if the rendering is complete.
71 //
72 // See public/fpdfview.h for a list of page rendering flags.
73 bool StartRenderPageWithFlags(FPDF_PAGE page, IFSDK_PAUSE* pause, int flags);
74
75 // Start rendering of |page| into a bitmap with the ability to pause the
76 // rendering with the specified rendering |flags| and the specified
77 // |color_scheme|. This also takes in the |background_color| for the bitmap.
78 // The call returns true if the rendering is complete.
79 //
80 // See public/fpdfview.h for the list of page rendering flags and
81 // the list of colors in the scheme.
82 bool StartRenderPageWithColorSchemeAndBackground(
83 FPDF_PAGE page,
84 IFSDK_PAUSE* pause,
85 int flags,
86 const FPDF_COLORSCHEME* color_scheme,
87 uint32_t background_color);
88
89 // Continue rendering of |page| into the bitmap created in
90 // StartRenderPageWithFlags().
91 // The call returns true if the rendering is complete.
92 bool ContinueRenderPage(FPDF_PAGE page, IFSDK_PAUSE* pause);
93
94 // Simplified form of FinishRenderPageWithForms() with no form handle.
95 ScopedFPDFBitmap FinishRenderPage(FPDF_PAGE page);
96
97 // Finish rendering of |page| into the bitmap created in
98 // StartRenderPageWithFlags(). This also renders the forms associated with
99 // the page. The form handle associated with |page| should be passed in via
100 // |handle|. If |handle| is nullptr, then forms on the page will not be
101 // rendered.
102 // This returns the bitmap generated by the progressive render calls.
103 ScopedFPDFBitmap FinishRenderPageWithForms(FPDF_PAGE page,
104 FPDF_FORMHANDLE handle);
105
106 // Convert the |page| into a bitmap with a |background_color|, using the
107 // color scheme render API with the specific |flags| and |color_scheme|.
108 // The form handle associated with |page| should be passed in via |handle|.
109 // If |handle| is nullptr, then forms on the page will not be rendered.
110 // This returns the bitmap generated by the progressive render calls.
111 //
112 // See public/fpdfview.h for a list of page rendering flags and
113 // the color scheme that can be applied for rendering.
114 ScopedFPDFBitmap RenderPageWithForcedColorScheme(
115 FPDF_PAGE page,
116 FPDF_FORMHANDLE handle,
117 int flags,
118 const FPDF_COLORSCHEME* color_scheme,
119 FX_ARGB background_color);
120
121 protected:
122 // Utility method to render the |page_num| of the currently loaded Pdf
123 // using RenderPageWithForcedColorScheme() passing in the render options
124 // and expected values for bitmap verification.
125 void VerifyRenderingWithColorScheme(int page_num,
126 int flags,
127 const FPDF_COLORSCHEME* color_scheme,
128 FX_ARGB background_color,
129 int bitmap_width,
130 int bitmap_height,
131 const char* md5);
132
133 private:
134 // Keeps the bitmap used for progressive rendering alive until
135 // FPDF_RenderPage_Close() is called after which the bitmap is returned
136 // to the caller.
137 ScopedFPDFBitmap progressive_render_bitmap_;
138 int progressive_render_flags_ = 0;
139 };
140
StartRenderPage(FPDF_PAGE page,IFSDK_PAUSE * pause)141 bool FPDFProgressiveRenderEmbedderTest::StartRenderPage(FPDF_PAGE page,
142 IFSDK_PAUSE* pause) {
143 return StartRenderPageWithFlags(page, pause, 0);
144 }
145
StartRenderPageWithFlags(FPDF_PAGE page,IFSDK_PAUSE * pause,int flags)146 bool FPDFProgressiveRenderEmbedderTest::StartRenderPageWithFlags(
147 FPDF_PAGE page,
148 IFSDK_PAUSE* pause,
149 int flags) {
150 int width = static_cast<int>(FPDF_GetPageWidth(page));
151 int height = static_cast<int>(FPDF_GetPageHeight(page));
152 progressive_render_flags_ = flags;
153 int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
154 progressive_render_bitmap_ =
155 ScopedFPDFBitmap(FPDFBitmap_Create(width, height, alpha));
156 FPDF_DWORD fill_color = alpha ? 0x00000000 : 0xFFFFFFFF;
157 FPDFBitmap_FillRect(progressive_render_bitmap_.get(), 0, 0, width, height,
158 fill_color);
159 int rv = FPDF_RenderPageBitmap_Start(progressive_render_bitmap_.get(), page,
160 0, 0, width, height, 0,
161 progressive_render_flags_, pause);
162 return rv != FPDF_RENDER_TOBECONTINUED;
163 }
164
165 bool FPDFProgressiveRenderEmbedderTest::
StartRenderPageWithColorSchemeAndBackground(FPDF_PAGE page,IFSDK_PAUSE * pause,int flags,const FPDF_COLORSCHEME * color_scheme,uint32_t background_color)166 StartRenderPageWithColorSchemeAndBackground(
167 FPDF_PAGE page,
168 IFSDK_PAUSE* pause,
169 int flags,
170 const FPDF_COLORSCHEME* color_scheme,
171 uint32_t background_color) {
172 int width = static_cast<int>(FPDF_GetPageWidth(page));
173 int height = static_cast<int>(FPDF_GetPageHeight(page));
174 progressive_render_flags_ = flags;
175 int alpha = FPDFPage_HasTransparency(page) ? 1 : 0;
176 progressive_render_bitmap_ =
177 ScopedFPDFBitmap(FPDFBitmap_Create(width, height, alpha));
178 ASSERT(progressive_render_bitmap_);
179 FPDFBitmap_FillRect(progressive_render_bitmap_.get(), 0, 0, width, height,
180 background_color);
181 int rv = FPDF_RenderPageBitmapWithColorScheme_Start(
182 progressive_render_bitmap_.get(), page, 0, 0, width, height, 0,
183 progressive_render_flags_, color_scheme, pause);
184 return rv != FPDF_RENDER_TOBECONTINUED;
185 }
186
ContinueRenderPage(FPDF_PAGE page,IFSDK_PAUSE * pause)187 bool FPDFProgressiveRenderEmbedderTest::ContinueRenderPage(FPDF_PAGE page,
188 IFSDK_PAUSE* pause) {
189 ASSERT(progressive_render_bitmap_);
190
191 int rv = FPDF_RenderPage_Continue(page, pause);
192 return rv != FPDF_RENDER_TOBECONTINUED;
193 }
194
FinishRenderPage(FPDF_PAGE page)195 ScopedFPDFBitmap FPDFProgressiveRenderEmbedderTest::FinishRenderPage(
196 FPDF_PAGE page) {
197 return FinishRenderPageWithForms(page, /*handle=*/nullptr);
198 }
199
FinishRenderPageWithForms(FPDF_PAGE page,FPDF_FORMHANDLE handle)200 ScopedFPDFBitmap FPDFProgressiveRenderEmbedderTest::FinishRenderPageWithForms(
201 FPDF_PAGE page,
202 FPDF_FORMHANDLE handle) {
203 ASSERT(progressive_render_bitmap_);
204
205 int width = static_cast<int>(FPDF_GetPageWidth(page));
206 int height = static_cast<int>(FPDF_GetPageHeight(page));
207 FPDF_FFLDraw(handle, progressive_render_bitmap_.get(), page, 0, 0, width,
208 height, 0, progressive_render_flags_);
209 FPDF_RenderPage_Close(page);
210 return std::move(progressive_render_bitmap_);
211 }
212
213 ScopedFPDFBitmap
RenderPageWithForcedColorScheme(FPDF_PAGE page,FPDF_FORMHANDLE handle,int flags,const FPDF_COLORSCHEME * color_scheme,FX_ARGB background_color)214 FPDFProgressiveRenderEmbedderTest::RenderPageWithForcedColorScheme(
215 FPDF_PAGE page,
216 FPDF_FORMHANDLE handle,
217 int flags,
218 const FPDF_COLORSCHEME* color_scheme,
219 FX_ARGB background_color) {
220 FakePause pause(true);
221 bool render_done = StartRenderPageWithColorSchemeAndBackground(
222 page, &pause, flags, color_scheme, background_color) ==
223 FPDF_RENDER_TOBECONTINUED;
224 EXPECT_FALSE(render_done);
225
226 while (!render_done) {
227 render_done = ContinueRenderPage(page, &pause);
228 }
229 return FinishRenderPageWithForms(page, form_handle_);
230 }
231
TEST_F(FPDFProgressiveRenderEmbedderTest,RenderWithoutPause)232 TEST_F(FPDFProgressiveRenderEmbedderTest, RenderWithoutPause) {
233 // Test rendering of page content using progressive render APIs
234 // without pausing the rendering.
235 ASSERT_TRUE(OpenDocument("annotation_stamp_with_ap.pdf"));
236 FPDF_PAGE page = LoadPage(0);
237 ASSERT_TRUE(page);
238 FakePause pause(false);
239 EXPECT_TRUE(StartRenderPage(page, &pause));
240 ScopedFPDFBitmap bitmap = FinishRenderPage(page);
241 CompareBitmap(bitmap.get(), 595, 842,
242 kAnnotationStampWithApBaseContentChecksum);
243 UnloadPage(page);
244 }
245
TEST_F(FPDFProgressiveRenderEmbedderTest,RenderWithPause)246 TEST_F(FPDFProgressiveRenderEmbedderTest, RenderWithPause) {
247 // Test rendering of page content using progressive render APIs
248 // with pause in rendering.
249 ASSERT_TRUE(OpenDocument("annotation_stamp_with_ap.pdf"));
250 FPDF_PAGE page = LoadPage(0);
251 ASSERT_TRUE(page);
252 FakePause pause(true);
253 bool render_done = StartRenderPage(page, &pause);
254 EXPECT_FALSE(render_done);
255
256 while (!render_done) {
257 render_done = ContinueRenderPage(page, &pause);
258 }
259 ScopedFPDFBitmap bitmap = FinishRenderPage(page);
260 CompareBitmap(bitmap.get(), 595, 842,
261 kAnnotationStampWithApBaseContentChecksum);
262 UnloadPage(page);
263 }
264
TEST_F(FPDFProgressiveRenderEmbedderTest,RenderAnnotWithPause)265 TEST_F(FPDFProgressiveRenderEmbedderTest, RenderAnnotWithPause) {
266 // Test rendering of the page with annotations using progressive render APIs
267 // with pause in rendering.
268 ASSERT_TRUE(OpenDocument("annotation_stamp_with_ap.pdf"));
269 FPDF_PAGE page = LoadPage(0);
270 ASSERT_TRUE(page);
271 FakePause pause(true);
272 bool render_done = StartRenderPageWithFlags(page, &pause, FPDF_ANNOT);
273 EXPECT_FALSE(render_done);
274
275 while (!render_done) {
276 render_done = ContinueRenderPage(page, &pause);
277 }
278 ScopedFPDFBitmap bitmap = FinishRenderPage(page);
279 CompareBitmap(bitmap.get(), 595, 842, pdfium::kAnnotationStampWithApChecksum);
280 UnloadPage(page);
281 }
282
TEST_F(FPDFProgressiveRenderEmbedderTest,RenderFormsWithPause)283 TEST_F(FPDFProgressiveRenderEmbedderTest, RenderFormsWithPause) {
284 // Test rendering of the page with forms using progressive render APIs
285 // with pause in rendering.
286 ASSERT_TRUE(OpenDocument("text_form.pdf"));
287 FPDF_PAGE page = LoadPage(0);
288 ASSERT_TRUE(page);
289 FakePause pause(true);
290 bool render_done = StartRenderPage(page, &pause);
291 EXPECT_FALSE(render_done);
292
293 while (!render_done) {
294 render_done = ContinueRenderPage(page, &pause);
295 }
296 ScopedFPDFBitmap bitmap = FinishRenderPageWithForms(page, form_handle_);
297 CompareBitmap(bitmap.get(), 300, 300, pdfium::kTextFormChecksum);
298 UnloadPage(page);
299 }
300
VerifyRenderingWithColorScheme(int page_num,int flags,const FPDF_COLORSCHEME * color_scheme,FX_ARGB background_color,int bitmap_width,int bitmap_height,const char * md5)301 void FPDFProgressiveRenderEmbedderTest::VerifyRenderingWithColorScheme(
302 int page_num,
303 int flags,
304 const FPDF_COLORSCHEME* color_scheme,
305 FX_ARGB background_color,
306 int bitmap_width,
307 int bitmap_height,
308 const char* md5) {
309 ASSERT_TRUE(document_);
310
311 FPDF_PAGE page = LoadPage(page_num);
312 ASSERT_TRUE(page);
313
314 ScopedFPDFBitmap bitmap = RenderPageWithForcedColorScheme(
315 page, form_handle_, flags, color_scheme, background_color);
316 ASSERT_TRUE(bitmap);
317 CompareBitmap(bitmap.get(), bitmap_width, bitmap_height, md5);
318 UnloadPage(page);
319 }
320
321 // TODO(crbug.com/pdfium/11): Fix this test and enable.
322 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
323 #define MAYBE_RenderTextWithColorScheme DISABLED_RenderTextWithColorScheme
324 #else
325 #define MAYBE_RenderTextWithColorScheme RenderTextWithColorScheme
326 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderTextWithColorScheme)327 TEST_F(FPDFProgressiveRenderEmbedderTest, MAYBE_RenderTextWithColorScheme) {
328 // Test rendering of text with forced color scheme on.
329 #if defined(OS_WIN)
330 static constexpr char kMD5ContentWithText[] =
331 "4245f32cc11748a00fd69852a5e5808d";
332 #elif defined(OS_APPLE)
333 static constexpr char kMD5ContentWithText[] =
334 "754a742f10ce0926b766dc3dd47d1f64";
335 #else
336 static constexpr char kMD5ContentWithText[] =
337 "f14d3caba5a973a28be8653aac9e4df3";
338 #endif
339
340 ASSERT_TRUE(OpenDocument("hello_world.pdf"));
341
342 FPDF_COLORSCHEME color_scheme{kBlack, kWhite, kWhite, kWhite};
343 VerifyRenderingWithColorScheme(/*page_num=*/0, /*flags=*/0, &color_scheme,
344 kBlack, 200, 200, kMD5ContentWithText);
345 }
346
347 // TODO(crbug.com/pdfium/11): Fix this test and enable.
348 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
349 #define MAYBE_RenderPathWithColorScheme DISABLED_RenderPathWithColorScheme
350 #else
351 #define MAYBE_RenderPathWithColorScheme RenderPathWithColorScheme
352 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderPathWithColorScheme)353 TEST_F(FPDFProgressiveRenderEmbedderTest, MAYBE_RenderPathWithColorScheme) {
354 // Test rendering of paths with forced color scheme on.
355 static const char kMD5Rectangles[] = "249f59b0d066c4f6bd89782a80822219";
356
357 ASSERT_TRUE(OpenDocument("rectangles.pdf"));
358
359 FPDF_COLORSCHEME color_scheme{kWhite, kRed, kBlue, kBlue};
360 VerifyRenderingWithColorScheme(/*page_num=*/0, /*flags=*/0, &color_scheme,
361 kBlack, 200, 300, kMD5Rectangles);
362 }
363
364 // TODO(crbug.com/pdfium/11): Fix this test and enable.
365 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
366 #define MAYBE_RenderPathWithColorSchemeAndConvertFillToStroke \
367 DISABLED_RenderPathWithColorSchemeAndConvertFillToStroke
368 #else
369 #define MAYBE_RenderPathWithColorSchemeAndConvertFillToStroke \
370 RenderPathWithColorSchemeAndConvertFillToStroke
371 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderPathWithColorSchemeAndConvertFillToStroke)372 TEST_F(FPDFProgressiveRenderEmbedderTest,
373 MAYBE_RenderPathWithColorSchemeAndConvertFillToStroke) {
374 // Test rendering of paths with forced color scheme on and conversion from
375 // fill to stroke enabled. The fill paths should be rendered as stroke.
376 static const char kMD5Rectangles[] = "0ebcc11e617635eca1fa9ce475383a80";
377
378 ASSERT_TRUE(OpenDocument("rectangles.pdf"));
379
380 FPDF_COLORSCHEME color_scheme{kWhite, kRed, kBlue, kBlue};
381 VerifyRenderingWithColorScheme(/*page_num=*/0, FPDF_CONVERT_FILL_TO_STROKE,
382 &color_scheme, kBlack, 200, 300,
383 kMD5Rectangles);
384 }
385
386 // TODO(crbug.com/pdfium/11): Fix this test and enable.
387 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
388 #define MAYBE_RenderHighlightWithColorScheme \
389 DISABLED_RenderHighlightWithColorScheme
390 #else
391 #define MAYBE_RenderHighlightWithColorScheme RenderHighlightWithColorScheme
392 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderHighlightWithColorScheme)393 TEST_F(FPDFProgressiveRenderEmbedderTest,
394 MAYBE_RenderHighlightWithColorScheme) {
395 // Test rendering of highlight with forced color scheme on.
396 //
397 // Note: The fill color rendered for highlight is different from the normal
398 // path since highlights have Multiply blend mode, while the other path has
399 // Normal blend mode.
400 #if defined(OS_APPLE)
401 static constexpr char kMD5ContentWithHighlightFill[] =
402 "a820afec9b99d3d3f2e9e9382bbad7c1";
403 #else
404 static constexpr char kMD5ContentWithHighlightFill[] =
405 "a08a0639f89446f66f3689ee8e08b9fe";
406 #endif
407
408 ASSERT_TRUE(OpenDocument("annotation_highlight_square_with_ap.pdf"));
409
410 FPDF_COLORSCHEME color_scheme{kRed, kGreen, kWhite, kWhite};
411 VerifyRenderingWithColorScheme(/*page_num=*/0, FPDF_ANNOT, &color_scheme,
412 kBlue, 612, 792, kMD5ContentWithHighlightFill);
413 }
414
415 // TODO(crbug.com/pdfium/11): Fix this test and enable.
416 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
417 #define MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke \
418 DISABLED_RenderHighlightWithColorSchemeAndConvertFillToStroke
419 #else
420 #define MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke \
421 RenderHighlightWithColorSchemeAndConvertFillToStroke
422 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke)423 TEST_F(FPDFProgressiveRenderEmbedderTest,
424 MAYBE_RenderHighlightWithColorSchemeAndConvertFillToStroke) {
425 // Test rendering of highlight with forced color and converting fill to
426 // stroke. The highlight should be rendered as a stroke of the rect.
427 //
428 // Note: The stroke color rendered for highlight is different from the normal
429 // path since highlights have Multiply blend mode, while the other path has
430 // Normal blend mode.
431 #if defined(OS_APPLE)
432 static constexpr char kMD5ContentWithHighlight[] =
433 "8837bea0b3520164b1784e513c882a2d";
434 #else
435 static constexpr char kMD5ContentWithHighlight[] =
436 "3dd8c02f5c06bac85e0d2c8bf37d1dc4";
437 #endif
438
439 ASSERT_TRUE(OpenDocument("annotation_highlight_square_with_ap.pdf"));
440
441 FPDF_COLORSCHEME color_scheme{kRed, kGreen, kWhite, kWhite};
442 VerifyRenderingWithColorScheme(
443 /*page_num=*/0, FPDF_ANNOT | FPDF_CONVERT_FILL_TO_STROKE, &color_scheme,
444 kBlue, 612, 792, kMD5ContentWithHighlight);
445 }
446
447 // TODO(crbug.com/pdfium/11): Fix this test and enable.
448 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
449 #define MAYBE_RenderInkWithColorScheme DISABLED_RenderInkWithColorScheme
450 #else
451 #define MAYBE_RenderInkWithColorScheme RenderInkWithColorScheme
452 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderInkWithColorScheme)453 TEST_F(FPDFProgressiveRenderEmbedderTest, MAYBE_RenderInkWithColorScheme) {
454 // Test rendering of multiple ink with forced color scheme on.
455 #if defined(OS_WIN)
456 static constexpr char kMD5ContentWithInk[] =
457 "1933e4ab19b9108ddcecd1a6abb20c85";
458 #else
459 static constexpr char kMD5ContentWithInk[] =
460 "797bce7dc6c50ee86b095405df9fe5aa";
461 #endif
462
463 ASSERT_TRUE(OpenDocument("annotation_ink_multiple.pdf"));
464
465 FPDF_COLORSCHEME color_scheme{kBlack, kGreen, kRed, kRed};
466 VerifyRenderingWithColorScheme(/*page_num=*/0, FPDF_ANNOT, &color_scheme,
467 kBlack, 612, 792, kMD5ContentWithInk);
468 }
469
470 // TODO(crbug.com/pdfium/11): Fix this test and enable.
471 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
472 #define MAYBE_RenderStampWithColorScheme DISABLED_RenderStampWithColorScheme
473 #else
474 #define MAYBE_RenderStampWithColorScheme RenderStampWithColorScheme
475 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderStampWithColorScheme)476 TEST_F(FPDFProgressiveRenderEmbedderTest, MAYBE_RenderStampWithColorScheme) {
477 // Test rendering of static annotation with forced color scheme on.
478 #if defined(OS_WIN)
479 static constexpr char kMD5ContentWithStamp[] =
480 "71dce8f1221e1d2fe59d74258c3afd54";
481 #elif defined(OS_APPLE)
482 static constexpr char kMD5ContentWithStamp[] =
483 "e2d9bef817d366021e5727d9350bde43";
484 #else
485 static constexpr char kMD5ContentWithStamp[] =
486 "d5518b1d9765fa62897a24d12244080f";
487 #endif
488
489 ASSERT_TRUE(OpenDocument("annotation_stamp_with_ap.pdf"));
490
491 FPDF_COLORSCHEME color_scheme{kBlue, kGreen, kRed, kRed};
492 VerifyRenderingWithColorScheme(/*page_num=*/0, FPDF_ANNOT, &color_scheme,
493 kWhite, 595, 842, kMD5ContentWithStamp);
494 }
495
496 // TODO(crbug.com/pdfium/11): Fix this test and enable.
497 #if defined(_SKIA_SUPPORT_) || defined(_SKIA_SUPPORT_PATHS_)
498 #define MAYBE_RenderFormWithColorScheme DISABLED_RenderFormWithColorScheme
499 #else
500 #define MAYBE_RenderFormWithColorScheme RenderFormWithColorScheme
501 #endif
TEST_F(FPDFProgressiveRenderEmbedderTest,MAYBE_RenderFormWithColorScheme)502 TEST_F(FPDFProgressiveRenderEmbedderTest, MAYBE_RenderFormWithColorScheme) {
503 // Test rendering of form does not change with forced color scheme on.
504 static constexpr char kMD5ContentWithForm[] =
505 "080f7a4381606659301440e1b14dca35";
506
507 ASSERT_TRUE(OpenDocument("annotiter.pdf"));
508
509 FPDF_COLORSCHEME color_scheme{kGreen, kGreen, kRed, kRed};
510 VerifyRenderingWithColorScheme(/*page_num=*/0, FPDF_ANNOT, &color_scheme,
511 kWhite, 612, 792, kMD5ContentWithForm);
512
513 // Verify that the MD5 hash matches when rendered without |color_scheme|.
514 VerifyRenderingWithColorScheme(/*page_num=*/0, FPDF_ANNOT,
515 /*color_scheme=*/nullptr, kWhite, 612, 792,
516 kMD5ContentWithForm);
517 }
518