Use flag "pdf-use-skia-renderer" to switch PDF viewer's renderer
This is a reland for CL [1]. Link flag "pdf-use-skia-renderer" with PDFiumEngine so that it can actually switch the renderer type for the PDF viewer upon initialization. This CL also changes PDFiumTestBase and tests derived from it into parameterized tests so that they can be tested with Skia renderer enabled: - For the tests which involve image rendering results comparison, add the Skia expectations for them. - Test PDFiumPageImageDataTest.ImageData is currently skipped because it crashes when Skia renderer is in use. - Disable PDFiumPageThumbnailTest.GenerateThumbnail on macOS with ARM64. The test expectations need to be updated before it can be re-enabled. [1] https://chromium-review.googlesource.com/4000168 Bug: 1379872,1382257 Change-Id: I140e8769d7102bc9070cfa2f1c39b95e59c6e872 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4021705 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Nigi <nigi@chromium.org> Cr-Commit-Position: refs/heads/main@{#1070525}


@ -18,8 +18,8 @@ pdf_bundle_freetype_override = false
|
||||
# use it as the memory allocator instead of `malloc()`.
|
||||
pdf_use_partition_alloc_override = use_partition_alloc
|
||||
|
||||
# Disable use of Skia backend.
|
||||
pdf_use_skia_override = false
|
||||
# Allow to use Skia backend at run time.
|
||||
pdf_use_skia_override = true
|
||||
|
||||
# Disable use of Skia backend, paths only (experimental)
|
||||
pdf_use_skia_paths_override = false
|
||||
|
@ -41,7 +41,7 @@ double GetExpectedCharWidth(bool using_test_fonts, size_t i, double expected) {
|
||||
// update the GetExpected... functions above. If that becomes too much of a
|
||||
// burden, consider changing the checks to just make sure the font metrics look
|
||||
// sane.
|
||||
TEST_F(AccessibilityTest, GetAccessibilityPage) {
|
||||
TEST_P(AccessibilityTest, GetAccessibilityPage) {
|
||||
static constexpr size_t kExpectedTextRunCount = 2;
|
||||
struct {
|
||||
uint32_t len;
|
||||
@ -112,7 +112,7 @@ TEST_F(AccessibilityTest, GetAccessibilityPage) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, GetAccessibilityImageInfo) {
|
||||
TEST_P(AccessibilityTest, GetAccessibilityImageInfo) {
|
||||
static const AccessibilityImageInfo kExpectedImageInfo[] = {
|
||||
{"Image 1", 0, {380, 78, 67, 68}, {}},
|
||||
{"Image 2", 0, {380, 385, 27, 28}, {}},
|
||||
@ -144,7 +144,7 @@ TEST_F(AccessibilityTest, GetAccessibilityImageInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, GetUnderlyingTextRangeForRect) {
|
||||
TEST_P(AccessibilityTest, GetUnderlyingTextRangeForRect) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -203,7 +203,7 @@ class ScrollEnabledTestClient : public TestClient {
|
||||
gfx::Vector2d received_scroll_delta_;
|
||||
};
|
||||
|
||||
TEST_F(AccessibilityTest, ScrollIntoViewActionHandling) {
|
||||
TEST_P(AccessibilityTest, ScrollIntoViewActionHandling) {
|
||||
// This test checks that accessibility scroll action is passed
|
||||
// on to the ScrollEnabledTestClient implementation.
|
||||
ScrollEnabledTestClient client;
|
||||
@ -286,7 +286,7 @@ TEST_F(AccessibilityTest, ScrollIntoViewActionHandling) {
|
||||
EXPECT_EQ(gfx::Vector2d(-180, -300), client.GetScrollRequestDelta());
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, ScrollToNearestEdge) {
|
||||
TEST_P(AccessibilityTest, ScrollToNearestEdge) {
|
||||
ScrollEnabledTestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -325,7 +325,7 @@ TEST_F(AccessibilityTest, ScrollToNearestEdge) {
|
||||
EXPECT_EQ(gfx::Vector2d(-199, -199), client.GetScrollRequestDelta());
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, ScrollToGlobalPoint) {
|
||||
TEST_P(AccessibilityTest, ScrollToGlobalPoint) {
|
||||
ScrollEnabledTestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -390,7 +390,7 @@ class NavigationEnabledTestClient : public TestClient {
|
||||
float zoom_ = 0;
|
||||
};
|
||||
|
||||
TEST_F(AccessibilityTest, WebLinkClickActionHandling) {
|
||||
TEST_P(AccessibilityTest, WebLinkClickActionHandling) {
|
||||
NavigationEnabledTestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("weblinks.pdf"));
|
||||
@ -406,7 +406,7 @@ TEST_F(AccessibilityTest, WebLinkClickActionHandling) {
|
||||
EXPECT_EQ(WindowOpenDisposition::CURRENT_TAB, client.disposition());
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, InternalLinkClickActionHandling) {
|
||||
TEST_P(AccessibilityTest, InternalLinkClickActionHandling) {
|
||||
NavigationEnabledTestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("link_annots.pdf"));
|
||||
@ -425,7 +425,7 @@ TEST_F(AccessibilityTest, InternalLinkClickActionHandling) {
|
||||
EXPECT_TRUE(client.url().empty());
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, GetAccessibilityLinkInfo) {
|
||||
TEST_P(AccessibilityTest, GetAccessibilityLinkInfo) {
|
||||
AccessibilityLinkInfo expected_link_info[] = {
|
||||
{"http://yahoo.com", 0, {75, 191, 110, 16}, {1, 1}},
|
||||
{"http://bing.com", 1, {131, 121, 138, 20}, {4, 1}},
|
||||
@ -466,7 +466,7 @@ TEST_F(AccessibilityTest, GetAccessibilityLinkInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, GetAccessibilityHighlightInfo) {
|
||||
TEST_P(AccessibilityTest, GetAccessibilityHighlightInfo) {
|
||||
constexpr uint32_t kHighlightDefaultColor = MakeARGB(255, 255, 255, 0);
|
||||
constexpr uint32_t kHighlightRedColor = MakeARGB(102, 230, 0, 0);
|
||||
constexpr uint32_t kHighlightNoColor = MakeARGB(0, 0, 0, 0);
|
||||
@ -508,7 +508,7 @@ TEST_F(AccessibilityTest, GetAccessibilityHighlightInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, GetAccessibilityTextFieldInfo) {
|
||||
TEST_P(AccessibilityTest, GetAccessibilityTextFieldInfo) {
|
||||
static const AccessibilityTextFieldInfo kExpectedTextFieldInfo[] = {
|
||||
{"Text Box", "Text", false, false, false, 0, 5, {138, 230, 135, 41}},
|
||||
{"ReadOnly", "Elephant", true, false, false, 1, 5, {138, 163, 135, 41}},
|
||||
@ -560,7 +560,7 @@ TEST_F(AccessibilityTest, GetAccessibilityTextFieldInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, SelectionActionHandling) {
|
||||
TEST_P(AccessibilityTest, SelectionActionHandling) {
|
||||
struct Selection {
|
||||
uint32_t start_page_index;
|
||||
uint32_t start_char_index;
|
||||
@ -624,7 +624,7 @@ TEST_F(AccessibilityTest, SelectionActionHandling) {
|
||||
|
||||
// Tests if PP_PDF_SET_SELECTION updates scroll offsets if the selection is not
|
||||
// in the current visible rect.
|
||||
TEST_F(AccessibilityTest, SetSelectionAndScroll) {
|
||||
TEST_P(AccessibilityTest, SetSelectionAndScroll) {
|
||||
struct Selection {
|
||||
uint32_t start_page_index;
|
||||
uint32_t start_char_index;
|
||||
@ -682,4 +682,6 @@ TEST_F(AccessibilityTest, SetSelectionAndScroll) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, AccessibilityTest, testing::Bool());
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -85,7 +85,7 @@ void ExpectInitialSearchResults(FindTextTestClient& client, int count) {
|
||||
|
||||
using FindTextTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(FindTextTest, FindText) {
|
||||
TEST_P(FindTextTest, FindText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -95,7 +95,7 @@ TEST_F(FindTextTest, FindText) {
|
||||
engine->StartFind("o", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindHyphenatedText) {
|
||||
TEST_P(FindTextTest, FindHyphenatedText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("spanner.pdf"));
|
||||
@ -105,7 +105,7 @@ TEST_F(FindTextTest, FindHyphenatedText) {
|
||||
engine->StartFind("application", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindLineBreakText) {
|
||||
TEST_P(FindTextTest, FindLineBreakText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("spanner.pdf"));
|
||||
@ -115,7 +115,7 @@ TEST_F(FindTextTest, FindLineBreakText) {
|
||||
engine->StartFind("is the first system", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindSimpleQuotationMarkText) {
|
||||
TEST_P(FindTextTest, FindSimpleQuotationMarkText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("bug_142627.pdf"));
|
||||
@ -125,7 +125,7 @@ TEST_F(FindTextTest, FindSimpleQuotationMarkText) {
|
||||
engine->StartFind("don't", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindFancyQuotationMarkText) {
|
||||
TEST_P(FindTextTest, FindFancyQuotationMarkText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("bug_142627.pdf"));
|
||||
@ -138,7 +138,7 @@ TEST_F(FindTextTest, FindFancyQuotationMarkText) {
|
||||
engine->StartFind(base::UTF16ToUTF8(term), /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindHiddenCroppedText) {
|
||||
TEST_P(FindTextTest, FindHiddenCroppedText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world_cropped.pdf"));
|
||||
@ -149,7 +149,7 @@ TEST_F(FindTextTest, FindHiddenCroppedText) {
|
||||
engine->StartFind("Hello", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindVisibleCroppedText) {
|
||||
TEST_P(FindTextTest, FindVisibleCroppedText) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world_cropped.pdf"));
|
||||
@ -160,7 +160,7 @@ TEST_F(FindTextTest, FindVisibleCroppedText) {
|
||||
engine->StartFind("world", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, FindVisibleCroppedTextRepeatedly) {
|
||||
TEST_P(FindTextTest, FindVisibleCroppedTextRepeatedly) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world_cropped.pdf"));
|
||||
@ -174,7 +174,7 @@ TEST_F(FindTextTest, FindVisibleCroppedTextRepeatedly) {
|
||||
engine->StartFind("world", /*case_sensitive=*/true);
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, SelectFindResult) {
|
||||
TEST_P(FindTextTest, SelectFindResult) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/true);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -199,7 +199,7 @@ TEST_F(FindTextTest, SelectFindResult) {
|
||||
ASSERT_TRUE(engine->SelectFindResult(/*forward=*/false));
|
||||
}
|
||||
|
||||
TEST_F(FindTextTest, SelectFindResultAndSwitchToTwoUpView) {
|
||||
TEST_P(FindTextTest, SelectFindResultAndSwitchToTwoUpView) {
|
||||
FindTextTestClient client(/*expected_case_sensitive=*/false);
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -240,4 +240,6 @@ TEST_F(FindTextTest, SelectFindResultAndSwitchToTwoUpView) {
|
||||
ASSERT_TRUE(engine->SelectFindResult(/*forward=*/true));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, FindTextTest, testing::Bool());
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "third_party/pdfium/public/fpdf_fwlevent.h"
|
||||
#include "third_party/pdfium/public/fpdf_ppo.h"
|
||||
#include "third_party/pdfium/public/fpdf_searchex.h"
|
||||
#include "third_party/pdfium/public/fpdfview.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
|
||||
#include "ui/base/window_open_disposition_utils.h"
|
||||
@ -502,11 +503,15 @@ void ParamsTransformPageToScreen(unsigned long view_fit_type,
|
||||
|
||||
void InitializeSDK(bool enable_v8, FontMappingMode font_mapping_mode) {
|
||||
FPDF_LIBRARY_CONFIG config;
|
||||
config.version = 3;
|
||||
config.version = 4;
|
||||
config.m_pUserFontPaths = nullptr;
|
||||
config.m_pIsolate = nullptr;
|
||||
config.m_pPlatform = nullptr;
|
||||
config.m_v8EmbedderSlot = gin::kEmbedderPDFium;
|
||||
config.m_RendererType =
|
||||
base::FeatureList::IsEnabled(features::kPdfUseSkiaRenderer)
|
||||
? FPDF_RENDERERTYPE_SKIA
|
||||
: FPDF_RENDERERTYPE_AGG;
|
||||
|
||||
#if defined(PDF_ENABLE_V8)
|
||||
if (enable_v8) {
|
||||
|
@ -184,7 +184,7 @@ class PDFiumEngineTest : public PDFiumTestBase {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PDFiumEngineTest, InitializeWithRectanglesMultiPagesPdf) {
|
||||
TEST_P(PDFiumEngineTest, InitializeWithRectanglesMultiPagesPdf) {
|
||||
NiceMock<MockTestClient> client;
|
||||
|
||||
// ProposeDocumentLayout() gets called twice during loading because
|
||||
@ -208,7 +208,7 @@ TEST_F(PDFiumEngineTest, InitializeWithRectanglesMultiPagesPdf) {
|
||||
ExpectPageRect(*engine, 4, {38, 1324, 266, 333});
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, InitializeWithRectanglesMultiPagesPdfInTwoUpView) {
|
||||
TEST_P(PDFiumEngineTest, InitializeWithRectanglesMultiPagesPdfInTwoUpView) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -231,7 +231,7 @@ TEST_F(PDFiumEngineTest, InitializeWithRectanglesMultiPagesPdfInTwoUpView) {
|
||||
ExpectPageRect(*engine, 4, {68, 689, 266, 333});
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, AppendBlankPagesWithFewerPages) {
|
||||
TEST_P(PDFiumEngineTest, AppendBlankPagesWithFewerPages) {
|
||||
NiceMock<MockTestClient> client;
|
||||
{
|
||||
InSequence normal_then_append;
|
||||
@ -252,7 +252,7 @@ TEST_F(PDFiumEngineTest, AppendBlankPagesWithFewerPages) {
|
||||
ExpectPageRect(*engine, 2, {5, 697, 266, 333});
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, AppendBlankPagesWithMorePages) {
|
||||
TEST_P(PDFiumEngineTest, AppendBlankPagesWithMorePages) {
|
||||
NiceMock<MockTestClient> client;
|
||||
{
|
||||
InSequence normal_then_append;
|
||||
@ -277,7 +277,7 @@ TEST_F(PDFiumEngineTest, AppendBlankPagesWithMorePages) {
|
||||
ExpectPageRect(*engine, 6, {5, 2085, 266, 333});
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, ProposeDocumentLayoutWithOverlap) {
|
||||
TEST_P(PDFiumEngineTest, ProposeDocumentLayoutWithOverlap) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -292,7 +292,7 @@ TEST_F(PDFiumEngineTest, ProposeDocumentLayoutWithOverlap) {
|
||||
engine->RotateCounterclockwise();
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, ApplyDocumentLayoutBeforePluginSizeUpdated) {
|
||||
TEST_P(PDFiumEngineTest, ApplyDocumentLayoutBeforePluginSizeUpdated) {
|
||||
NiceMock<MockTestClient> client;
|
||||
InitializeEngineResult initialize_result = InitializeEngineWithoutLoading(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -309,7 +309,7 @@ TEST_F(PDFiumEngineTest, ApplyDocumentLayoutBeforePluginSizeUpdated) {
|
||||
FinishWithPluginSizeUpdated(engine);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, ApplyDocumentLayoutAvoidsInfiniteLoop) {
|
||||
TEST_P(PDFiumEngineTest, ApplyDocumentLayoutAvoidsInfiniteLoop) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -325,7 +325,7 @@ TEST_F(PDFiumEngineTest, ApplyDocumentLayoutAvoidsInfiniteLoop) {
|
||||
EXPECT_EQ(gfx::Size(343, 1463), engine->ApplyDocumentLayout(options));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetDocumentAttachments) {
|
||||
TEST_P(PDFiumEngineTest, GetDocumentAttachments) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("embedded_attachments.pdf"));
|
||||
@ -385,7 +385,7 @@ TEST_F(PDFiumEngineTest, GetDocumentAttachments) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetInvalidDocumentAttachment) {
|
||||
TEST_P(PDFiumEngineTest, GetInvalidDocumentAttachment) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("invalid_attachment.pdf"));
|
||||
@ -406,7 +406,7 @@ TEST_F(PDFiumEngineTest, GetInvalidDocumentAttachment) {
|
||||
EXPECT_THAT(attachment.modified_date, IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetDocumentAttachmentWithInvalidData) {
|
||||
TEST_P(PDFiumEngineTest, GetDocumentAttachmentWithInvalidData) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("embedded_attachments_invalid_data.pdf"));
|
||||
@ -426,7 +426,7 @@ TEST_F(PDFiumEngineTest, GetDocumentAttachmentWithInvalidData) {
|
||||
EXPECT_THAT(attachment.modified_date, IsEmpty());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, NoDocumentAttachmentInfo) {
|
||||
TEST_P(PDFiumEngineTest, NoDocumentAttachmentInfo) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -435,7 +435,7 @@ TEST_F(PDFiumEngineTest, NoDocumentAttachmentInfo) {
|
||||
EXPECT_EQ(0u, engine->GetDocumentAttachmentInfoList().size());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetDocumentMetadata) {
|
||||
TEST_P(PDFiumEngineTest, GetDocumentMetadata) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("document_info.pdf"));
|
||||
@ -464,7 +464,7 @@ TEST_F(PDFiumEngineTest, GetDocumentMetadata) {
|
||||
EXPECT_EQ(expected_mod_date, doc_metadata.mod_date);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetEmptyDocumentMetadata) {
|
||||
TEST_P(PDFiumEngineTest, GetEmptyDocumentMetadata) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -485,7 +485,7 @@ TEST_F(PDFiumEngineTest, GetEmptyDocumentMetadata) {
|
||||
EXPECT_TRUE(doc_metadata.mod_date.is_null());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetLinearizedDocumentMetadata) {
|
||||
TEST_P(PDFiumEngineTest, GetLinearizedDocumentMetadata) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("linearized.pdf"));
|
||||
@ -493,7 +493,7 @@ TEST_F(PDFiumEngineTest, GetLinearizedDocumentMetadata) {
|
||||
EXPECT_TRUE(engine->GetDocumentMetadata().linearized);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetBadPdfVersion) {
|
||||
TEST_P(PDFiumEngineTest, GetBadPdfVersion) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("bad_version.pdf"));
|
||||
@ -503,7 +503,7 @@ TEST_F(PDFiumEngineTest, GetBadPdfVersion) {
|
||||
EXPECT_EQ(PdfVersion::kUnknown, doc_metadata.version);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, GetNamedDestination) {
|
||||
TEST_P(PDFiumEngineTest, GetNamedDestination) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("named_destinations.pdf"));
|
||||
@ -536,7 +536,7 @@ TEST_F(PDFiumEngineTest, GetNamedDestination) {
|
||||
EXPECT_FALSE(invalid_page_number.has_value());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, PluginSizeUpdatedBeforeLoad) {
|
||||
TEST_P(PDFiumEngineTest, PluginSizeUpdatedBeforeLoad) {
|
||||
NiceMock<MockTestClient> client;
|
||||
InitializeEngineResult initialize_result = InitializeEngineWithoutLoading(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -549,7 +549,7 @@ TEST_F(PDFiumEngineTest, PluginSizeUpdatedBeforeLoad) {
|
||||
EXPECT_EQ(engine.GetNumberOfPages(), CountAvailablePages(engine));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, PluginSizeUpdatedDuringLoad) {
|
||||
TEST_P(PDFiumEngineTest, PluginSizeUpdatedDuringLoad) {
|
||||
NiceMock<MockTestClient> client;
|
||||
InitializeEngineResult initialize_result = InitializeEngineWithoutLoading(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -563,7 +563,7 @@ TEST_F(PDFiumEngineTest, PluginSizeUpdatedDuringLoad) {
|
||||
EXPECT_EQ(engine.GetNumberOfPages(), CountAvailablePages(engine));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, PluginSizeUpdatedAfterLoad) {
|
||||
TEST_P(PDFiumEngineTest, PluginSizeUpdatedAfterLoad) {
|
||||
NiceMock<MockTestClient> client;
|
||||
InitializeEngineResult initialize_result = InitializeEngineWithoutLoading(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -576,7 +576,7 @@ TEST_F(PDFiumEngineTest, PluginSizeUpdatedAfterLoad) {
|
||||
EXPECT_EQ(engine.GetNumberOfPages(), CountAvailablePages(engine));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, OnLeftMouseDownBeforePluginSizeUpdated) {
|
||||
TEST_P(PDFiumEngineTest, OnLeftMouseDownBeforePluginSizeUpdated) {
|
||||
NiceMock<MockTestClient> client;
|
||||
InitializeEngineResult initialize_result = InitializeEngineWithoutLoading(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -591,7 +591,7 @@ TEST_F(PDFiumEngineTest, OnLeftMouseDownBeforePluginSizeUpdated) {
|
||||
blink::WebInputEvent::GetStaticTimeStampForTests())));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, OnLeftMouseDownAfterPluginSizeUpdated) {
|
||||
TEST_P(PDFiumEngineTest, OnLeftMouseDownAfterPluginSizeUpdated) {
|
||||
NiceMock<MockTestClient> client;
|
||||
InitializeEngineResult initialize_result = InitializeEngineWithoutLoading(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -607,23 +607,23 @@ TEST_F(PDFiumEngineTest, OnLeftMouseDownAfterPluginSizeUpdated) {
|
||||
blink::WebInputEvent::GetStaticTimeStampForTests())));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, IncrementalLoadingFeatureDefault) {
|
||||
TEST_P(PDFiumEngineTest, IncrementalLoadingFeatureDefault) {
|
||||
EXPECT_FALSE(TryLoadIncrementally());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, IncrementalLoadingFeatureEnabled) {
|
||||
TEST_P(PDFiumEngineTest, IncrementalLoadingFeatureEnabled) {
|
||||
base::test::ScopedFeatureList scoped_feature_list;
|
||||
scoped_feature_list.InitAndEnableFeature(features::kPdfIncrementalLoading);
|
||||
EXPECT_TRUE(TryLoadIncrementally());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, IncrementalLoadingFeatureDisabled) {
|
||||
TEST_P(PDFiumEngineTest, IncrementalLoadingFeatureDisabled) {
|
||||
base::test::ScopedFeatureList scoped_feature_list;
|
||||
scoped_feature_list.InitAndDisableFeature(features::kPdfIncrementalLoading);
|
||||
EXPECT_FALSE(TryLoadIncrementally());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, RequestThumbnail) {
|
||||
TEST_P(PDFiumEngineTest, RequestThumbnail) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("rectangles_multi_pages.pdf"));
|
||||
@ -642,7 +642,7 @@ TEST_F(PDFiumEngineTest, RequestThumbnail) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, RequestThumbnailLinearized) {
|
||||
TEST_P(PDFiumEngineTest, RequestThumbnailLinearized) {
|
||||
base::test::ScopedFeatureList scoped_feature_list;
|
||||
scoped_feature_list.InitAndEnableFeature(features::kPdfIncrementalLoading);
|
||||
|
||||
@ -684,7 +684,7 @@ TEST_F(PDFiumEngineTest, RequestThumbnailLinearized) {
|
||||
initialize_result.FinishLoading();
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, HandleInputEventKeyDown) {
|
||||
TEST_P(PDFiumEngineTest, HandleInputEventKeyDown) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -698,7 +698,7 @@ TEST_F(PDFiumEngineTest, HandleInputEventKeyDown) {
|
||||
EXPECT_TRUE(engine->HandleInputEvent(key_down_event));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, HandleInputEventRawKeyDown) {
|
||||
TEST_P(PDFiumEngineTest, HandleInputEventRawKeyDown) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -723,7 +723,7 @@ constexpr char kSelectTextExpectedText[] =
|
||||
#endif
|
||||
} // namespace
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectText) {
|
||||
TEST_P(PDFiumEngineTest, SelectText) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -737,7 +737,7 @@ TEST_F(PDFiumEngineTest, SelectText) {
|
||||
EXPECT_EQ(kSelectTextExpectedText, engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectTextBackwards) {
|
||||
TEST_P(PDFiumEngineTest, SelectTextBackwards) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -763,7 +763,7 @@ TEST_F(PDFiumEngineTest, SelectTextBackwards) {
|
||||
EXPECT_EQ(kExpectedText, engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectTextWithCopyRestriction) {
|
||||
TEST_P(PDFiumEngineTest, SelectTextWithCopyRestriction) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("hello_world2_with_copy_restriction.pdf"));
|
||||
@ -778,7 +778,7 @@ TEST_F(PDFiumEngineTest, SelectTextWithCopyRestriction) {
|
||||
EXPECT_EQ(kSelectTextExpectedText, engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectCroppedText) {
|
||||
TEST_P(PDFiumEngineTest, SelectCroppedText) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world_cropped.pdf"));
|
||||
@ -795,7 +795,7 @@ TEST_F(PDFiumEngineTest, SelectCroppedText) {
|
||||
EXPECT_EQ(kExpectedText, engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectTextWithDoubleClick) {
|
||||
TEST_P(PDFiumEngineTest, SelectTextWithDoubleClick) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -812,7 +812,7 @@ TEST_F(PDFiumEngineTest, SelectTextWithDoubleClick) {
|
||||
EXPECT_EQ("Goodbye", engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectTextWithTripleClick) {
|
||||
TEST_P(PDFiumEngineTest, SelectTextWithTripleClick) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -829,7 +829,7 @@ TEST_F(PDFiumEngineTest, SelectTextWithTripleClick) {
|
||||
EXPECT_EQ("Goodbye, world!", engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectLinkAreaWithNoText) {
|
||||
TEST_P(PDFiumEngineTest, SelectLinkAreaWithNoText) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("link_annots.pdf"));
|
||||
@ -864,7 +864,7 @@ TEST_F(PDFiumEngineTest, SelectLinkAreaWithNoText) {
|
||||
EXPECT_EQ(kExpectedText, engine->GetSelectedText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTest, SelectTextWithNonPrintableCharacter) {
|
||||
TEST_P(PDFiumEngineTest, SelectTextWithNonPrintableCharacter) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("bug_1357385.pdf"));
|
||||
@ -876,9 +876,11 @@ TEST_F(PDFiumEngineTest, SelectTextWithNonPrintableCharacter) {
|
||||
EXPECT_EQ("Hello, world!", engine->GetSelectedText());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumEngineTest, testing::Bool());
|
||||
|
||||
using PDFiumEngineDeathTest = PDFiumEngineTest;
|
||||
|
||||
TEST_F(PDFiumEngineDeathTest, RequestThumbnailRedundant) {
|
||||
TEST_P(PDFiumEngineDeathTest, RequestThumbnailRedundant) {
|
||||
::testing::FLAGS_gtest_death_test_style = "threadsafe";
|
||||
base::test::ScopedFeatureList scoped_feature_list;
|
||||
scoped_feature_list.InitAndEnableFeature(features::kPdfIncrementalLoading);
|
||||
@ -901,6 +903,8 @@ TEST_F(PDFiumEngineDeathTest, RequestThumbnailRedundant) {
|
||||
/*page_index=*/1, /*device_pixel_ratio=*/1, mock_callback.Get()));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumEngineDeathTest, testing::Bool());
|
||||
|
||||
class PDFiumEngineTabbingTest : public PDFiumTestBase {
|
||||
public:
|
||||
PDFiumEngineTabbingTest() = default;
|
||||
@ -942,7 +946,7 @@ class PDFiumEngineTabbingTest : public PDFiumTestBase {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, LinkUnderCursor) {
|
||||
TEST_P(PDFiumEngineTabbingTest, LinkUnderCursor) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -988,7 +992,7 @@ TEST_F(PDFiumEngineTabbingTest, LinkUnderCursor) {
|
||||
}
|
||||
|
||||
// Test case for crbug.com/1088296
|
||||
TEST_F(PDFiumEngineTabbingTest, LinkUnderCursorAfterTabAndRightClick) {
|
||||
TEST_P(PDFiumEngineTabbingTest, LinkUnderCursorAfterTabAndRightClick) {
|
||||
NiceMock<MockTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("annots.pdf"));
|
||||
@ -1031,7 +1035,7 @@ TEST_F(PDFiumEngineTabbingTest, LinkUnderCursorAfterTabAndRightClick) {
|
||||
CreateRightClickWebMouseEventAtPosition(kLinkPosition)));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, TabbingSupportedAnnots) {
|
||||
TEST_P(PDFiumEngineTabbingTest, TabbingSupportedAnnots) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1087,7 +1091,7 @@ TEST_F(PDFiumEngineTabbingTest, TabbingSupportedAnnots) {
|
||||
GetFocusedElementType(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, TabbingForward) {
|
||||
TEST_P(PDFiumEngineTabbingTest, TabbingForward) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1139,7 +1143,7 @@ TEST_F(PDFiumEngineTabbingTest, TabbingForward) {
|
||||
GetFocusedElementType(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, TabbingBackward) {
|
||||
TEST_P(PDFiumEngineTabbingTest, TabbingBackward) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1196,7 +1200,7 @@ TEST_F(PDFiumEngineTabbingTest, TabbingBackward) {
|
||||
GetFocusedElementType(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, TabbingWithModifiers) {
|
||||
TEST_P(PDFiumEngineTabbingTest, TabbingWithModifiers) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1249,7 +1253,7 @@ TEST_F(PDFiumEngineTabbingTest, TabbingWithModifiers) {
|
||||
HandleTabEvent(engine.get(), blink::WebInputEvent::Modifiers::kAltKey));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, NoFocusableElementTabbing) {
|
||||
TEST_P(PDFiumEngineTabbingTest, NoFocusableElementTabbing) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1295,7 +1299,7 @@ TEST_F(PDFiumEngineTabbingTest, NoFocusableElementTabbing) {
|
||||
GetFocusedElementType(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, RestoringDocumentFocus) {
|
||||
TEST_P(PDFiumEngineTabbingTest, RestoringDocumentFocus) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1340,7 +1344,7 @@ TEST_F(PDFiumEngineTabbingTest, RestoringDocumentFocus) {
|
||||
GetFocusedElementType(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, RestoringAnnotFocus) {
|
||||
TEST_P(PDFiumEngineTabbingTest, RestoringAnnotFocus) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1393,7 +1397,7 @@ TEST_F(PDFiumEngineTabbingTest, RestoringAnnotFocus) {
|
||||
EXPECT_EQ(1, GetLastFocusedPage(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, VerifyFormFieldStatesOnTabbing) {
|
||||
TEST_P(PDFiumEngineTabbingTest, VerifyFormFieldStatesOnTabbing) {
|
||||
/*
|
||||
* Document structure
|
||||
* Document
|
||||
@ -1433,7 +1437,7 @@ TEST_F(PDFiumEngineTabbingTest, VerifyFormFieldStatesOnTabbing) {
|
||||
EXPECT_FALSE(engine->CanEditText());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, ClearSelectionOnFocusInFormTextArea) {
|
||||
TEST_P(PDFiumEngineTabbingTest, ClearSelectionOnFocusInFormTextArea) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("form_text_fields.pdf"));
|
||||
@ -1457,7 +1461,7 @@ TEST_F(PDFiumEngineTabbingTest, ClearSelectionOnFocusInFormTextArea) {
|
||||
EXPECT_EQ(0u, GetSelectionSize(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, RetainSelectionOnFocusNotInFormTextArea) {
|
||||
TEST_P(PDFiumEngineTabbingTest, RetainSelectionOnFocusNotInFormTextArea) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("annots.pdf"));
|
||||
@ -1493,7 +1497,7 @@ class ScrollingTestClient : public TestClient {
|
||||
MOCK_METHOD(void, ScrollToY, (int), (override));
|
||||
};
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, MaintainViewportWhenFocusIsUpdated) {
|
||||
TEST_P(PDFiumEngineTabbingTest, MaintainViewportWhenFocusIsUpdated) {
|
||||
StrictMock<ScrollingTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
|
||||
@ -1546,7 +1550,7 @@ TEST_F(PDFiumEngineTabbingTest, MaintainViewportWhenFocusIsUpdated) {
|
||||
EXPECT_EQ(0, GetLastFocusedPage(engine.get()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineTabbingTest, ScrollFocusedAnnotationIntoView) {
|
||||
TEST_P(PDFiumEngineTabbingTest, ScrollFocusedAnnotationIntoView) {
|
||||
StrictMock<ScrollingTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
|
||||
@ -1593,6 +1597,8 @@ TEST_F(PDFiumEngineTabbingTest, ScrollFocusedAnnotationIntoView) {
|
||||
ScrollFocusedAnnotationIntoView(engine.get());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumEngineTabbingTest, testing::Bool());
|
||||
|
||||
class ReadOnlyTestClient : public TestClient {
|
||||
public:
|
||||
ReadOnlyTestClient() = default;
|
||||
@ -1610,7 +1616,7 @@ class ReadOnlyTestClient : public TestClient {
|
||||
|
||||
using PDFiumEngineReadOnlyTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumEngineReadOnlyTest, KillFormFocus) {
|
||||
TEST_P(PDFiumEngineReadOnlyTest, KillFormFocus) {
|
||||
NiceMock<ReadOnlyTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
|
||||
@ -1630,7 +1636,7 @@ TEST_F(PDFiumEngineReadOnlyTest, KillFormFocus) {
|
||||
engine->UpdateFocus(true);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumEngineReadOnlyTest, UnselectText) {
|
||||
TEST_P(PDFiumEngineReadOnlyTest, UnselectText) {
|
||||
NiceMock<ReadOnlyTestClient> client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -1650,4 +1656,6 @@ TEST_F(PDFiumEngineReadOnlyTest, UnselectText) {
|
||||
engine->SetReadOnly(true);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumEngineReadOnlyTest, testing::Bool());
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -86,7 +86,7 @@ class FormFillerTest : public PDFiumTestBase {
|
||||
#endif // defined(PDF_ENABLE_V8)
|
||||
};
|
||||
|
||||
TEST_F(FormFillerTest, DoURIActionWithKeyboardModifier) {
|
||||
TEST_P(FormFillerTest, DoURIActionWithKeyboardModifier) {
|
||||
FormFillerTestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("annotation_form_fields.pdf"));
|
||||
@ -138,7 +138,7 @@ TEST_F(FormFillerTest, DoURIActionWithKeyboardModifier) {
|
||||
TriggerDoURIActionWithKeyboardModifier(engine.get(), kUri, modifiers);
|
||||
}
|
||||
|
||||
TEST_F(FormFillerTest, FormOnFocusChange) {
|
||||
TEST_P(FormFillerTest, FormOnFocusChange) {
|
||||
struct {
|
||||
// Initial scroll position of the document.
|
||||
gfx::Point initial_position;
|
||||
@ -187,6 +187,8 @@ TEST_F(FormFillerTest, FormOnFocusChange) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, FormFillerTest, testing::Bool());
|
||||
|
||||
#if defined(PDF_ENABLE_V8)
|
||||
class FormFillerJavaScriptTest : public FormFillerTest {
|
||||
public:
|
||||
@ -198,7 +200,7 @@ class FormFillerJavaScriptTest : public FormFillerTest {
|
||||
~FormFillerJavaScriptTest() override { ShutdownSDK(); }
|
||||
};
|
||||
|
||||
TEST_F(FormFillerJavaScriptTest, IsolateScoping) {
|
||||
TEST_P(FormFillerJavaScriptTest, IsolateScoping) {
|
||||
// Enter the embedder's isolate so it can be captured when the
|
||||
// `PDFiumFormFiller` is created.
|
||||
v8::Isolate* embedder_isolate = blink::MainThreadIsolate();
|
||||
@ -224,7 +226,7 @@ TEST_F(FormFillerJavaScriptTest, IsolateScoping) {
|
||||
EXPECT_EQ(v8::Isolate::TryGetCurrent(), pdfium_test_isolate);
|
||||
}
|
||||
|
||||
TEST_F(FormFillerJavaScriptTest, GetFilePath) {
|
||||
TEST_P(FormFillerJavaScriptTest, GetFilePath) {
|
||||
constexpr char kTestPath[] = "https://www.example.com/path/to/the.pdf";
|
||||
constexpr int kTestPathSize = static_cast<int>(std::size(kTestPath));
|
||||
|
||||
@ -241,7 +243,7 @@ TEST_F(FormFillerJavaScriptTest, GetFilePath) {
|
||||
EXPECT_STREQ(buffer.data(), kTestPath);
|
||||
}
|
||||
|
||||
TEST_F(FormFillerJavaScriptTest, GetFilePathEmpty) {
|
||||
TEST_P(FormFillerJavaScriptTest, GetFilePathEmpty) {
|
||||
FormFillerTestClient client;
|
||||
EXPECT_CALL(client, GetURL).Times(2).WillRepeatedly(Return(std::string()));
|
||||
PDFiumEngine engine(&client, PDFiumFormFiller::ScriptOption::kJavaScript);
|
||||
@ -255,7 +257,7 @@ TEST_F(FormFillerJavaScriptTest, GetFilePathEmpty) {
|
||||
EXPECT_STREQ(buffer, "");
|
||||
}
|
||||
|
||||
TEST_F(FormFillerJavaScriptTest, GetFilePathShortBuffer) {
|
||||
TEST_P(FormFillerJavaScriptTest, GetFilePathShortBuffer) {
|
||||
constexpr char kTestPath[] = "https://www.example.com/path/to/the.pdf";
|
||||
constexpr int kTestPathSize = static_cast<int>(std::size(kTestPath));
|
||||
|
||||
@ -271,6 +273,8 @@ TEST_F(FormFillerJavaScriptTest, GetFilePathShortBuffer) {
|
||||
// trailing null.
|
||||
EXPECT_THAT(buffer, Contains('X').Times(buffer.size()));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, FormFillerJavaScriptTest, testing::Bool());
|
||||
#endif // defined(PDF_ENABLE_V8)
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "build/build_config.h"
|
||||
#include "pdf/accessibility_structs.h"
|
||||
#include "pdf/pdfium/pdfium_engine.h"
|
||||
#include "pdf/pdfium/pdfium_test_base.h"
|
||||
@ -82,10 +83,12 @@ gfx::SizeF GetPageSizeHelper(PDFiumPage& pdfium_page) {
|
||||
|
||||
base::FilePath GetThumbnailTestData(const std::string& expectation_file_prefix,
|
||||
size_t page_index,
|
||||
float device_pixel_ratio) {
|
||||
float device_pixel_ratio,
|
||||
bool use_skia) {
|
||||
std::string file_dir = base::StringPrintf("%.1fx", device_pixel_ratio);
|
||||
std::string file_name = base::StringPrintf(
|
||||
"%s_expected.pdf.%zu.png", expectation_file_prefix.c_str(), page_index);
|
||||
"%s_expected%s.pdf.%zu.png", expectation_file_prefix.c_str(),
|
||||
use_skia ? "_skia" : "", page_index);
|
||||
return base::FilePath(FILE_PATH_LITERAL("thumbnail"))
|
||||
.AppendASCII(file_dir)
|
||||
.AppendASCII(file_name);
|
||||
@ -95,14 +98,14 @@ base::FilePath GetThumbnailTestData(const std::string& expectation_file_prefix,
|
||||
|
||||
using PDFiumPageTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageTest, Constructor) {
|
||||
TEST_P(PDFiumPageTest, Constructor) {
|
||||
PDFiumPage page(/*engine=*/nullptr, 2);
|
||||
EXPECT_EQ(page.index(), 2);
|
||||
EXPECT_TRUE(page.rect().IsEmpty());
|
||||
EXPECT_FALSE(page.available());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPageTest, IsCharInPageBounds) {
|
||||
TEST_P(PDFiumPageTest, IsCharInPageBounds) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world_cropped.pdf"));
|
||||
@ -133,6 +136,8 @@ TEST_F(PDFiumPageTest, IsCharInPageBounds) {
|
||||
EXPECT_FALSE(page.IsCharInPageBounds(29, page_bounds));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageTest, testing::Bool());
|
||||
|
||||
class PDFiumPageLinkTest : public PDFiumTestBase {
|
||||
public:
|
||||
PDFiumPageLinkTest() = default;
|
||||
@ -148,7 +153,7 @@ class PDFiumPageLinkTest : public PDFiumTestBase {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PDFiumPageLinkTest, LinkGeneration) {
|
||||
TEST_P(PDFiumPageLinkTest, LinkGeneration) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("weblinks.pdf"));
|
||||
@ -190,7 +195,7 @@ TEST_F(PDFiumPageLinkTest, LinkGeneration) {
|
||||
EXPECT_EQ(gfx::Rect(82, 67, 161, 21), third_link.bounding_rects[0]);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPageLinkTest, AnnotLinkGeneration) {
|
||||
TEST_P(PDFiumPageLinkTest, AnnotLinkGeneration) {
|
||||
struct ExpectedLink {
|
||||
int32_t start_char_index;
|
||||
int32_t char_count;
|
||||
@ -244,7 +249,7 @@ TEST_F(PDFiumPageLinkTest, AnnotLinkGeneration) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPageLinkTest, GetLinkTarget) {
|
||||
TEST_P(PDFiumPageLinkTest, GetLinkTarget) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("in_doc_link_with_various_page_sizes.pdf"));
|
||||
@ -279,9 +284,11 @@ TEST_F(PDFiumPageLinkTest, GetLinkTarget) {
|
||||
EXPECT_FALSE(target.zoom);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageLinkTest, testing::Bool());
|
||||
|
||||
using PDFiumPageImageTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageImageTest, CalculateImages) {
|
||||
TEST_P(PDFiumPageImageTest, CalculateImages) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("image_alt_text.pdf"));
|
||||
@ -299,7 +306,7 @@ TEST_F(PDFiumPageImageTest, CalculateImages) {
|
||||
EXPECT_EQ("Image 3", page.images_[2].alt_text);
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPageImageTest, ImageAltText) {
|
||||
TEST_P(PDFiumPageImageTest, ImageAltText) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("text_with_image.pdf"));
|
||||
@ -317,6 +324,8 @@ TEST_F(PDFiumPageImageTest, ImageAltText) {
|
||||
EXPECT_EQ("", page.images_[2].alt_text);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageImageTest, testing::Bool());
|
||||
|
||||
class PDFiumPageImageDataTest : public PDFiumPageImageTest {
|
||||
public:
|
||||
PDFiumPageImageDataTest() : enable_pdf_ocr_({features::kPdfOcr}) {}
|
||||
@ -329,7 +338,13 @@ class PDFiumPageImageDataTest : public PDFiumPageImageTest {
|
||||
base::test::ScopedFeatureList enable_pdf_ocr_;
|
||||
};
|
||||
|
||||
TEST_F(PDFiumPageImageDataTest, ImageData) {
|
||||
TEST_P(PDFiumPageImageDataTest, ImageData) {
|
||||
// TODO(crbug.com/1382257): This test currently crashes when using Skia
|
||||
// renderer. Fix this issue and re-enable the test.
|
||||
if (GetParam()) {
|
||||
GTEST_SKIP() << "Skipping this test for Skia";
|
||||
}
|
||||
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("text_with_image.pdf"));
|
||||
@ -350,9 +365,11 @@ TEST_F(PDFiumPageImageDataTest, ImageData) {
|
||||
EXPECT_EQ(page.images_[1].image_data.height(), 20);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageImageDataTest, testing::Bool());
|
||||
|
||||
using PDFiumPageTextTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageTextTest, TextRunBounds) {
|
||||
TEST_P(PDFiumPageTextTest, TextRunBounds) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine = InitializeEngine(
|
||||
&client, FILE_PATH_LITERAL("leading_trailing_spaces_per_text_run.pdf"));
|
||||
@ -426,7 +443,7 @@ TEST_F(PDFiumPageTextTest, TextRunBounds) {
|
||||
engine->GetCharBounds(kPageIndex, kSecondRunEndIndex)));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPageTextTest, GetTextRunInfo) {
|
||||
TEST_P(PDFiumPageTextTest, GetTextRunInfo) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("weblinks.pdf"));
|
||||
@ -499,7 +516,7 @@ TEST_F(PDFiumPageTextTest, GetTextRunInfo) {
|
||||
ASSERT_FALSE(text_run_info_result.has_value());
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPageTextTest, HighlightTextRunInfo) {
|
||||
TEST_P(PDFiumPageTextTest, HighlightTextRunInfo) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("highlights.pdf"));
|
||||
@ -541,9 +558,11 @@ TEST_F(PDFiumPageTextTest, HighlightTextRunInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageTextTest, testing::Bool());
|
||||
|
||||
using PDFiumPageHighlightTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageHighlightTest, PopulateHighlights) {
|
||||
TEST_P(PDFiumPageHighlightTest, PopulateHighlights) {
|
||||
struct ExpectedHighlight {
|
||||
int32_t start_char_index;
|
||||
int32_t char_count;
|
||||
@ -580,9 +599,11 @@ TEST_F(PDFiumPageHighlightTest, PopulateHighlights) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageHighlightTest, testing::Bool());
|
||||
|
||||
using PDFiumPageTextFieldTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageTextFieldTest, PopulateTextFields) {
|
||||
TEST_P(PDFiumPageTextFieldTest, PopulateTextFields) {
|
||||
struct ExpectedTextField {
|
||||
const char* name;
|
||||
const char* value;
|
||||
@ -616,9 +637,11 @@ TEST_F(PDFiumPageTextFieldTest, PopulateTextFields) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageTextFieldTest, testing::Bool());
|
||||
|
||||
using PDFiumPageChoiceFieldTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageChoiceFieldTest, PopulateChoiceFields) {
|
||||
TEST_P(PDFiumPageChoiceFieldTest, PopulateChoiceFields) {
|
||||
struct ExpectedChoiceFieldOption {
|
||||
const char* name;
|
||||
bool is_selected;
|
||||
@ -703,9 +726,11 @@ TEST_F(PDFiumPageChoiceFieldTest, PopulateChoiceFields) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageChoiceFieldTest, testing::Bool());
|
||||
|
||||
using PDFiumPageButtonTest = PDFiumTestBase;
|
||||
|
||||
TEST_F(PDFiumPageButtonTest, PopulateButtons) {
|
||||
TEST_P(PDFiumPageButtonTest, PopulateButtons) {
|
||||
struct ExpectedButton {
|
||||
const char* name;
|
||||
const char* value;
|
||||
@ -784,6 +809,8 @@ TEST_F(PDFiumPageButtonTest, PopulateButtons) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageButtonTest, testing::Bool());
|
||||
|
||||
class PDFiumPageThumbnailTest : public PDFiumTestBase {
|
||||
public:
|
||||
PDFiumPageThumbnailTest() = default;
|
||||
@ -812,14 +839,23 @@ class PDFiumPageThumbnailTest : public PDFiumTestBase {
|
||||
SkPixmap(image_info, data.data(), image_info.minRowBytes()));
|
||||
ASSERT_TRUE(image);
|
||||
|
||||
base::FilePath expectation_png_file_path = GetThumbnailTestData(
|
||||
expectation_file_prefix, page_index, device_pixel_ratio);
|
||||
base::FilePath expectation_png_file_path =
|
||||
GetThumbnailTestData(expectation_file_prefix, page_index,
|
||||
device_pixel_ratio, /*use_skia=*/GetParam());
|
||||
|
||||
EXPECT_TRUE(MatchesPngFile(image.get(), expectation_png_file_path));
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(PDFiumPageThumbnailTest, GenerateThumbnail) {
|
||||
// TODO(crbug.com/1379872): The thumbnails generated on macOS with ARM64 will
|
||||
// have small discrepancies due to floating point calculation. Need to add the
|
||||
// correct expectations for this test before re-enable it.
|
||||
#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
|
||||
#define MAYBE_GenerateThumbnail DISABLED_GenerateThumbnail
|
||||
#else
|
||||
#define MAYBE_GenerateThumbnail GenerateThumbnail
|
||||
#endif
|
||||
TEST_P(PDFiumPageThumbnailTest, MAYBE_GenerateThumbnail) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("variable_page_sizes.pdf"));
|
||||
@ -854,7 +890,7 @@ TEST_F(PDFiumPageThumbnailTest, GenerateThumbnail) {
|
||||
}
|
||||
|
||||
// For crbug.com/1248455
|
||||
TEST_F(PDFiumPageThumbnailTest, GenerateThumbnailForAnnotation) {
|
||||
TEST_P(PDFiumPageThumbnailTest, GenerateThumbnailForAnnotation) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("signature_widget.pdf"));
|
||||
@ -866,4 +902,6 @@ TEST_F(PDFiumPageThumbnailTest, GenerateThumbnailForAnnotation) {
|
||||
"signature_widget");
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPageThumbnailTest, testing::Bool());
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "pdf/pdfium/pdfium_engine.h"
|
||||
#include "pdf/pdfium/pdfium_engine_exports.h"
|
||||
#include "pdf/pdfium/pdfium_test_base.h"
|
||||
@ -39,6 +40,12 @@ constexpr gfx::Rect kPrintableAreaRect = {{18, 18}, {576, 733}};
|
||||
|
||||
using ExpectedDimensions = std::vector<gfx::SizeF>;
|
||||
|
||||
std::string GenerateRendererSpecificFileName(const std::string& file_name,
|
||||
bool use_skia_renderer) {
|
||||
return base::StringPrintf("%s%s.png", file_name.c_str(),
|
||||
use_skia_renderer ? "_skia" : "");
|
||||
}
|
||||
|
||||
base::FilePath GetReferenceFilePath(base::StringPiece test_filename) {
|
||||
return base::FilePath(FILE_PATH_LITERAL("pdfium_print"))
|
||||
.AppendASCII(test_filename);
|
||||
@ -104,7 +111,7 @@ void CheckPdfRendering(const std::vector<uint8_t>& pdf_data,
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(PDFiumPrintTest, Basic) {
|
||||
TEST_P(PDFiumPrintTest, Basic) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("hello_world2.pdf"));
|
||||
@ -149,7 +156,7 @@ TEST_F(PDFiumPrintTest, Basic) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPrintTest, AlterScalingDefault) {
|
||||
TEST_P(PDFiumPrintTest, AlterScalingDefault) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("rectangles.pdf"));
|
||||
@ -164,17 +171,20 @@ TEST_F(PDFiumPrintTest, AlterScalingDefault) {
|
||||
print_params.printable_area = kPrintableAreaRect;
|
||||
std::vector<uint8_t> pdf_data = print.PrintPagesAsPdf(pages, print_params);
|
||||
CheckPdfDimensions(pdf_data, kExpectedDimensions);
|
||||
CheckPdfRendering(pdf_data, 0, kExpectedDimensions[0],
|
||||
"alter_scaling_default.png");
|
||||
|
||||
CheckPdfRendering(
|
||||
pdf_data, 0, kExpectedDimensions[0],
|
||||
GenerateRendererSpecificFileName("alter_scaling_default",
|
||||
/*use_skia_renderer=*/GetParam()));
|
||||
print_params.rasterize_pdf = true;
|
||||
pdf_data = print.PrintPagesAsPdf(pages, print_params);
|
||||
CheckPdfDimensions(pdf_data, kExpectedDimensions);
|
||||
CheckPdfRendering(pdf_data, 0, kExpectedDimensions[0],
|
||||
"alter_scaling_default_raster.png");
|
||||
CheckPdfRendering(
|
||||
pdf_data, 0, kExpectedDimensions[0],
|
||||
GenerateRendererSpecificFileName("alter_scaling_default_raster",
|
||||
/*use_skia_renderer=*/GetParam()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPrintTest, AlterScalingFitPaper) {
|
||||
TEST_P(PDFiumPrintTest, AlterScalingFitPaper) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("rectangles.pdf"));
|
||||
@ -191,17 +201,20 @@ TEST_F(PDFiumPrintTest, AlterScalingFitPaper) {
|
||||
printing::mojom::PrintScalingOption::kFitToPaper;
|
||||
std::vector<uint8_t> pdf_data = print.PrintPagesAsPdf(pages, print_params);
|
||||
CheckPdfDimensions(pdf_data, kExpectedDimensions);
|
||||
CheckPdfRendering(pdf_data, 0, kExpectedDimensions[0],
|
||||
"alter_scaling_fit-paper.png");
|
||||
|
||||
CheckPdfRendering(
|
||||
pdf_data, 0, kExpectedDimensions[0],
|
||||
GenerateRendererSpecificFileName("alter_scaling_fit-paper",
|
||||
/*use_skia_renderer=*/GetParam()));
|
||||
print_params.rasterize_pdf = true;
|
||||
pdf_data = print.PrintPagesAsPdf(pages, print_params);
|
||||
CheckPdfDimensions(pdf_data, kExpectedDimensions);
|
||||
CheckPdfRendering(pdf_data, 0, kExpectedDimensions[0],
|
||||
"alter_scaling_fit-paper_raster.png");
|
||||
CheckPdfRendering(
|
||||
pdf_data, 0, kExpectedDimensions[0],
|
||||
GenerateRendererSpecificFileName("alter_scaling_fit-paper_raster",
|
||||
/*use_skia_renderer=*/GetParam()));
|
||||
}
|
||||
|
||||
TEST_F(PDFiumPrintTest, AlterScalingFitPrintable) {
|
||||
TEST_P(PDFiumPrintTest, AlterScalingFitPrintable) {
|
||||
TestClient client;
|
||||
std::unique_ptr<PDFiumEngine> engine =
|
||||
InitializeEngine(&client, FILE_PATH_LITERAL("rectangles.pdf"));
|
||||
@ -218,14 +231,19 @@ TEST_F(PDFiumPrintTest, AlterScalingFitPrintable) {
|
||||
printing::mojom::PrintScalingOption::kFitToPrintableArea;
|
||||
std::vector<uint8_t> pdf_data = print.PrintPagesAsPdf(pages, print_params);
|
||||
CheckPdfDimensions(pdf_data, kExpectedDimensions);
|
||||
CheckPdfRendering(pdf_data, 0, kExpectedDimensions[0],
|
||||
"alter_scaling_fit-printable.png");
|
||||
|
||||
CheckPdfRendering(
|
||||
pdf_data, 0, kExpectedDimensions[0],
|
||||
GenerateRendererSpecificFileName("alter_scaling_fit-printable",
|
||||
/*use_skia_renderer=*/GetParam()));
|
||||
print_params.rasterize_pdf = true;
|
||||
pdf_data = print.PrintPagesAsPdf(pages, print_params);
|
||||
CheckPdfDimensions(pdf_data, kExpectedDimensions);
|
||||
CheckPdfRendering(pdf_data, 0, kExpectedDimensions[0],
|
||||
"alter_scaling_fit-printable_raster.png");
|
||||
CheckPdfRendering(
|
||||
pdf_data, 0, kExpectedDimensions[0],
|
||||
GenerateRendererSpecificFileName("alter_scaling_fit-printable_raster",
|
||||
/*use_skia_renderer=*/GetParam()));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumPrintTest, testing::Bool());
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -36,7 +36,7 @@ class PDFiumRangeTest : public PDFiumTestBase {
|
||||
std::unique_ptr<PDFiumEngine> engine_;
|
||||
};
|
||||
|
||||
TEST_F(PDFiumRangeTest, Empty) {
|
||||
TEST_P(PDFiumRangeTest, Empty) {
|
||||
PDFiumPage page(engine(), 0);
|
||||
page.MarkAvailable();
|
||||
{
|
||||
@ -53,7 +53,7 @@ TEST_F(PDFiumRangeTest, Empty) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PDFiumRangeTest, Forward) {
|
||||
TEST_P(PDFiumRangeTest, Forward) {
|
||||
PDFiumPage page(engine(), 0);
|
||||
page.MarkAvailable();
|
||||
{
|
||||
@ -82,7 +82,7 @@ TEST_F(PDFiumRangeTest, Forward) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(PDFiumRangeTest, Backward) {
|
||||
TEST_P(PDFiumRangeTest, Backward) {
|
||||
PDFiumPage page(engine(), 0);
|
||||
page.MarkAvailable();
|
||||
{
|
||||
@ -111,4 +111,6 @@ TEST_F(PDFiumRangeTest, Backward) {
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(All, PDFiumRangeTest, testing::Bool());
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "pdf/test/test_client.h"
|
||||
#include "pdf/test/test_document_loader.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/pdfium/public/fpdfview.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
@ -113,11 +114,13 @@ void PDFiumTestBase::InitializePDFium() {
|
||||
#endif
|
||||
|
||||
FPDF_LIBRARY_CONFIG config;
|
||||
config.version = 3;
|
||||
config.version = 4;
|
||||
config.m_pUserFontPaths = font_paths_.data();
|
||||
config.m_pIsolate = nullptr;
|
||||
config.m_v8EmbedderSlot = 0;
|
||||
config.m_pPlatform = nullptr;
|
||||
config.m_RendererType =
|
||||
GetParam() ? FPDF_RENDERERTYPE_SKIA : FPDF_RENDERERTYPE_AGG;
|
||||
FPDF_InitLibraryWithConfig(&config);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ class PDFiumPage;
|
||||
class TestClient;
|
||||
class TestDocumentLoader;
|
||||
|
||||
class PDFiumTestBase : public testing::Test {
|
||||
class PDFiumTestBase : public testing::TestWithParam<bool> {
|
||||
public:
|
||||
PDFiumTestBase();
|
||||
PDFiumTestBase(const PDFiumTestBase&) = delete;
|
||||
|
BIN
pdf/test/data/pdfium_print/alter_scaling_default_raster_skia.png
Normal file
After ![]() (image error) Size: 48 KiB |
BIN
pdf/test/data/pdfium_print/alter_scaling_default_skia.png
Normal file
After ![]() (image error) Size: 13 KiB |
After ![]() (image error) Size: 54 KiB |
BIN
pdf/test/data/pdfium_print/alter_scaling_fit-paper_skia.png
Normal file
After ![]() (image error) Size: 13 KiB |
After ![]() (image error) Size: 52 KiB |
BIN
pdf/test/data/pdfium_print/alter_scaling_fit-printable_skia.png
Normal file
After ![]() (image error) Size: 13 KiB |
After ![]() (image error) Size: 117 B |
After ![]() (image error) Size: 348 B |
After ![]() (image error) Size: 355 B |
After ![]() (image error) Size: 285 B |
After ![]() (image error) Size: 396 B |
After ![]() (image error) Size: 407 B |
After ![]() (image error) Size: 385 B |
After ![]() (image error) Size: 454 B |
After ![]() (image error) Size: 138 B |
After ![]() (image error) Size: 524 B |
After ![]() (image error) Size: 513 B |
After ![]() (image error) Size: 523 B |
After ![]() (image error) Size: 460 B |
After ![]() (image error) Size: 493 B |
After ![]() (image error) Size: 385 B |
After ![]() (image error) Size: 454 B |