diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-11-10 22:40:44 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-10 22:40:44 +0000 |
commit | 9fa5036245c34ce8c420531c5b02e699a861bc18 (patch) | |
tree | 41030e8cd39e5c06e75b2c6fd17513e0a5ae92fe /fpdfsdk/fpdfsave_embeddertest.cpp | |
parent | 6e4656f88fba94f706e0e42d1b548e28f6645594 (diff) | |
download | pdfium-9fa5036245c34ce8c420531c5b02e699a861bc18.tar.xz |
Add FPDFSaveEmbedderTest.SaveLinearizedDocchromium/3267chromium/3266
Bug: pdfium:614
Change-Id: I3c6cd16dfe0ac5db66cc9e996d3f4e74a5d9d716
Reviewed-on: https://pdfium-review.googlesource.com/18251
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfsave_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdfsave_embeddertest.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/fpdfsdk/fpdfsave_embeddertest.cpp b/fpdfsdk/fpdfsave_embeddertest.cpp index 54eb347302..3122be1b53 100644 --- a/fpdfsdk/fpdfsave_embeddertest.cpp +++ b/fpdfsdk/fpdfsave_embeddertest.cpp @@ -4,7 +4,7 @@ #include "public/fpdf_save.h" -#include <string.h> +#include <string> #include "core/fxcrt/fx_string.h" #include "public/fpdf_edit.h" @@ -59,6 +59,39 @@ TEST_F(FPDFSaveEmbedderTest, SaveCopiedDoc) { UnloadPage(page); } +TEST_F(FPDFSaveEmbedderTest, SaveLinearizedDoc) { + const int kPageCount = 3; + std::string original_md5[kPageCount]; + + EXPECT_TRUE(OpenDocument("linearized.pdf")); + for (int i = 0; i < kPageCount; ++i) { + FPDF_PAGE page = LoadPage(i); + FPDF_BITMAP bitmap = RenderPage(page); + EXPECT_EQ(612, FPDFBitmap_GetWidth(bitmap)); + EXPECT_EQ(792, FPDFBitmap_GetHeight(bitmap)); + original_md5[i] = HashBitmap(bitmap); + FPDFBitmap_Destroy(bitmap); + UnloadPage(page); + } + + EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); + EXPECT_THAT(GetString(), testing::StartsWith("%PDF-1.6\r\n")); + EXPECT_THAT(GetString(), testing::HasSubstr("/Root ")); + EXPECT_THAT(GetString(), testing::HasSubstr("/Info ")); + EXPECT_EQ(8219u, GetString().length()); + + // Make sure new document renders the same as the old one. + EXPECT_TRUE(OpenSavedDocument()); + for (int i = 0; i < kPageCount; ++i) { + FPDF_PAGE page = LoadSavedPage(i); + FPDF_BITMAP bitmap = RenderSavedPage(page); + EXPECT_EQ(original_md5[i], HashBitmap(bitmap)); + FPDFBitmap_Destroy(bitmap); + CloseSavedPage(page); + } + CloseSavedDocument(); +} + TEST_F(FPDFSaveEmbedderTest, BUG_342) { EXPECT_TRUE(OpenDocument("hello_world.pdf")); EXPECT_TRUE(FPDF_SaveAsCopy(document(), this, 0)); |