[PDF Ink Signatures] Move CheckPdfRendering() into helpers

Move the CheckPdfRendering() helper function out of
pdf_ink_module_unittest.cc and into test_helpers.cc, so that it is
available for use by other tests.

Change-Id: Ifbf9f211b15d1327696e7fe22df7bf7be9840354
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5963119
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1376304}
diff --git a/pdf/BUILD.gn b/pdf/BUILD.gn
index 58b9ba79..a616f17 100644
--- a/pdf/BUILD.gn
+++ b/pdf/BUILD.gn
@@ -399,6 +399,7 @@
       "//base",
       "//cc:test_support",
       "//pdf/loader",
+      "//printing",
       "//testing/gmock",
       "//testing/gtest",
       "//third_party/blink/public:blink",
diff --git a/pdf/pdfium/pdfium_ink_writer_unittest.cc b/pdf/pdfium/pdfium_ink_writer_unittest.cc
index 30798f15..46cc4ff 100644
--- a/pdf/pdfium/pdfium_ink_writer_unittest.cc
+++ b/pdf/pdfium/pdfium_ink_writer_unittest.cc
@@ -10,31 +10,22 @@
 #include <string_view>
 #include <vector>
 
-#include "base/containers/span.h"
 #include "base/files/file_path.h"
 #include "base/time/time.h"
 #include "pdf/pdf_ink_brush.h"
 #include "pdf/pdfium/pdfium_engine.h"
-#include "pdf/pdfium/pdfium_engine_exports.h"
 #include "pdf/pdfium/pdfium_page.h"
 #include "pdf/pdfium/pdfium_test_base.h"
 #include "pdf/test/pdf_ink_test_helpers.h"
 #include "pdf/test/test_client.h"
 #include "pdf/test/test_helpers.h"
-#include "printing/units.h"
 #include "third_party/ink/src/ink/strokes/input/stroke_input.h"
 #include "third_party/ink/src/ink/strokes/input/stroke_input_batch.h"
 #include "third_party/ink/src/ink/strokes/stroke.h"
 #include "third_party/pdfium/public/fpdf_edit.h"
 #include "third_party/pdfium/public/fpdfview.h"
-#include "third_party/skia/include/core/SkAlphaType.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/skia/include/core/SkColorType.h"
-#include "third_party/skia/include/core/SkImage.h"
-#include "third_party/skia/include/core/SkImageInfo.h"
 #include "ui/gfx/geometry/point_f.h"
 #include "ui/gfx/geometry/size.h"
-#include "ui/gfx/geometry/skia_conversions.h"
 
 namespace chrome_pdf {
 
@@ -87,34 +78,6 @@
       .AppendASCII(test_filename);
 }
 
-// Takes `pdf_data` and loads it using PDFium. Then renders the page at
-// `page_index` to a bitmap of `size_in_points` and checks if it matches
-// `expected_png_file`.
-void CheckPdfRendering(base::span<const uint8_t> pdf_data,
-                       int page_index,
-                       const gfx::Size& size_in_points,
-                       const base::FilePath& expected_png_file) {
-  const gfx::Rect page_rect(size_in_points);
-  SkBitmap page_bitmap;
-  page_bitmap.allocPixels(
-      SkImageInfo::Make(gfx::SizeToSkISize(page_rect.size()),
-                        kBGRA_8888_SkColorType, kPremul_SkAlphaType));
-
-  PDFiumEngineExports::RenderingSettings settings(
-      gfx::Size(printing::kPointsPerInch, printing::kPointsPerInch), page_rect,
-      /*fit_to_bounds=*/false,
-      /*stretch_to_bounds=*/false,
-      /*keep_aspect_ratio=*/true,
-      /*center_in_bounds=*/false,
-      /*autorotate=*/false, /*use_color=*/true, /*render_for_printing=*/false);
-
-  PDFiumEngineExports exports;
-  ASSERT_TRUE(exports.RenderPDFPageToBitmap(pdf_data, page_index, settings,
-                                            page_bitmap.getPixels()));
-
-  EXPECT_TRUE(MatchesPngFile(page_bitmap.asImage().get(), expected_png_file));
-}
-
 }  // namespace
 
 using PDFiumInkWriterTest = PDFiumTestBase;
diff --git a/pdf/test/test_helpers.cc b/pdf/test/test_helpers.cc
index 86b3c56..10ff0b3 100644
--- a/pdf/test/test_helpers.cc
+++ b/pdf/test/test_helpers.cc
@@ -9,14 +9,20 @@
 #include "base/path_service.h"
 #include "cc/test/pixel_comparator.h"
 #include "cc/test/pixel_test_utils.h"
+#include "pdf/pdfium/pdfium_engine_exports.h"
+#include "printing/units.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkBitmap.h"
 #include "third_party/skia/include/core/SkCanvas.h"
 #include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkColorType.h"
 #include "third_party/skia/include/core/SkImage.h"
+#include "third_party/skia/include/core/SkImageInfo.h"
 #include "third_party/skia/include/core/SkRefCnt.h"
 #include "third_party/skia/include/core/SkSurface.h"
+#include "ui/gfx/geometry/rect.h"
 #include "ui/gfx/geometry/size.h"
+#include "ui/gfx/geometry/skia_conversions.h"
 
 namespace chrome_pdf {
 
@@ -66,6 +72,31 @@
   return MatchesPngFileImpl(actual_image, expected_png_file, comparator);
 }
 
+void CheckPdfRendering(base::span<const uint8_t> pdf_data,
+                       int page_index,
+                       const gfx::Size& size_in_points,
+                       const base::FilePath& expected_png_file) {
+  const gfx::Rect page_rect(size_in_points);
+  SkBitmap page_bitmap;
+  page_bitmap.allocPixels(
+      SkImageInfo::Make(gfx::SizeToSkISize(page_rect.size()),
+                        kBGRA_8888_SkColorType, kPremul_SkAlphaType));
+
+  PDFiumEngineExports::RenderingSettings settings(
+      gfx::Size(printing::kPointsPerInch, printing::kPointsPerInch), page_rect,
+      /*fit_to_bounds=*/false,
+      /*stretch_to_bounds=*/false,
+      /*keep_aspect_ratio=*/true,
+      /*center_in_bounds=*/false,
+      /*autorotate=*/false, /*use_color=*/true, /*render_for_printing=*/false);
+
+  PDFiumEngineExports exports;
+  ASSERT_TRUE(exports.RenderPDFPageToBitmap(pdf_data, page_index, settings,
+                                            page_bitmap.getPixels()));
+
+  EXPECT_TRUE(MatchesPngFile(page_bitmap.asImage().get(), expected_png_file));
+}
+
 sk_sp<SkSurface> CreateSkiaSurfaceForTesting(const gfx::Size& size,
                                              SkColor color) {
   auto surface = SkSurfaces::Raster(
diff --git a/pdf/test/test_helpers.h b/pdf/test/test_helpers.h
index eb32c2b5..f62ba6f 100644
--- a/pdf/test/test_helpers.h
+++ b/pdf/test/test_helpers.h
@@ -5,6 +5,7 @@
 #ifndef PDF_TEST_TEST_HELPERS_H_
 #define PDF_TEST_TEST_HELPERS_H_
 
+#include "base/containers/span.h"
 #include "base/files/file_path.h"
 #include "testing/gtest/include/gtest/gtest.h"
 #include "third_party/skia/include/core/SkColor.h"
@@ -35,6 +36,14 @@
     const SkImage* actual_image,
     const base::FilePath& expected_png_file);
 
+// Takes `pdf_data` and loads it using PDFium. Then renders the page at
+// `page_index` to a bitmap of `size_in_points` and checks if it matches
+// `expected_png_file`.
+void CheckPdfRendering(base::span<const uint8_t> pdf_data,
+                       int page_index,
+                       const gfx::Size& size_in_points,
+                       const base::FilePath& expected_png_file);
+
 // Creates a Skia surface with dimensions `size` and filled with `color`.
 sk_sp<SkSurface> CreateSkiaSurfaceForTesting(const gfx::Size& size,
                                              SkColor color);