diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2018-06-07 15:18:55 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-07 15:18:55 +0000 |
commit | 5ebfd6405fce9bf71f9970431444419e572c2d9f (patch) | |
tree | 2f318afd2e7e2564d2d5905639c1fb454bebcb7a | |
parent | d5c4ab1ef458d158e268b5293c231928c59aacb9 (diff) | |
download | pdfium-5ebfd6405fce9bf71f9970431444419e572c2d9f.tar.xz |
Test to show editing a PageObject and saving the .pdf duplicates it.
It is disabled since pdfium:1051 currently causes it to fail.
Bug: pdfium:1051
Change-Id: I99a12db0ae4a58eab46e365f2f618fc98aee363f
Reviewed-on: https://pdfium-review.googlesource.com/34210
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r-- | fpdfsdk/fpdf_edit_embeddertest.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp index f339a82336..dc61c0d974 100644 --- a/fpdfsdk/fpdf_edit_embeddertest.cpp +++ b/fpdfsdk/fpdf_edit_embeddertest.cpp @@ -427,6 +427,55 @@ TEST_F(FPDFEditEmbeddertest, AddPaths) { VerifySavedDocument(612, 792, kLastMD5); } +// Fails due to pdfium:1051. +TEST_F(FPDFEditEmbeddertest, DISABLED_SetText) { + // Load document with some text. + EXPECT_TRUE(OpenDocument("hello_world.pdf")); + FPDF_PAGE page = LoadPage(0); + ASSERT_TRUE(page); + + // Get the "Hello, world!" text object and change it. + ASSERT_EQ(2, FPDFPage_CountObjects(page)); + FPDF_PAGEOBJECT page_object = FPDFPage_GetObject(page, 0); + ASSERT_TRUE(page_object); + std::unique_ptr<unsigned short, pdfium::FreeDeleter> text1 = + GetFPDFWideString(L"Changed for SetText test"); + EXPECT_TRUE(FPDFText_SetText(page_object, text1.get())); + + // Verify the "Hello, world!" text is gone and "Changed for SetText test" is + // now displayed. + ASSERT_EQ(2, FPDFPage_CountObjects(page)); +#if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ + const char kChangedMD5[] = "94c1e7a5af7dd9d77dc2223b1091acb7"; +#elif _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_ + const char kChangedMD5[] = "9d31703c1d1a3e1e9a778b1e297c9cd2"; +#else + const char kChangedMD5[] = "a0c4ea6620772991f66bf7130379b08a"; +#endif + { + ScopedFPDFBitmap page_bitmap = RenderPageWithFlags(page, nullptr, 0); + CompareBitmap(page_bitmap.get(), 200, 200, kChangedMD5); + } + + // Now save the result. + EXPECT_TRUE(FPDFPage_GenerateContent(page)); + EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); + + UnloadPage(page); + + // Re-open the file and check the changes were kept in the saved .pdf. + OpenSavedDocument(); + FPDF_PAGE saved_page = LoadSavedPage(0); + EXPECT_EQ(2, FPDFPage_CountObjects(saved_page)); + { + ScopedFPDFBitmap page_bitmap = RenderPageWithFlags(saved_page, nullptr, 0); + CompareBitmap(page_bitmap.get(), 200, 200, kChangedMD5); + } + + CloseSavedPage(saved_page); + CloseSavedDocument(); +} + TEST_F(FPDFEditEmbeddertest, RemovePageObject) { // Load document with some text. EXPECT_TRUE(OpenDocument("hello_world.pdf")); |