summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfppo_embeddertest.cpp8
-rw-r--r--fpdfsdk/fpdfsave_embeddertest.cpp35
2 files changed, 38 insertions, 5 deletions
diff --git a/fpdfsdk/fpdfppo_embeddertest.cpp b/fpdfsdk/fpdfppo_embeddertest.cpp
index 1df677f66b..c642b71ac0 100644
--- a/fpdfsdk/fpdfppo_embeddertest.cpp
+++ b/fpdfsdk/fpdfppo_embeddertest.cpp
@@ -158,7 +158,7 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
- std::string digest = HashBitmap(bitmap, 200, 200);
+ std::string digest = HashBitmap(bitmap);
FPDFBitmap_Destroy(bitmap);
UnloadPage(page);
EXPECT_EQ(kHashes[i], digest);
@@ -177,7 +177,7 @@ TEST_F(FPDFPPOEmbeddertest, BUG_750568) {
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
- std::string digest = HashBitmap(bitmap, 200, 200);
+ std::string digest = HashBitmap(bitmap);
FPDFBitmap_Destroy(bitmap);
FPDF_ClosePage(page);
EXPECT_EQ(kHashes[i], digest);
@@ -195,7 +195,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
ASSERT_EQ(200, FPDFBitmap_GetHeight(bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(bitmap));
- std::string digest = HashBitmap(bitmap, 200, 200);
+ std::string digest = HashBitmap(bitmap);
FPDFBitmap_Destroy(bitmap);
FPDF_ClosePage(page);
@@ -211,7 +211,7 @@ TEST_F(FPDFPPOEmbeddertest, ImportWithZeroLengthStream) {
ASSERT_EQ(200, FPDFBitmap_GetHeight(new_bitmap));
ASSERT_EQ(800, FPDFBitmap_GetStride(new_bitmap));
- std::string new_digest = HashBitmap(new_bitmap, 200, 200);
+ std::string new_digest = HashBitmap(new_bitmap);
FPDFBitmap_Destroy(new_bitmap);
FPDF_ClosePage(new_page);
FPDF_CloseDocument(new_doc);
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));