summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp6
-rw-r--r--fpdfsdk/fpdfannot_embeddertest.cpp28
-rw-r--r--fpdfsdk/fpdfedit_embeddertest.cpp14
-rw-r--r--fpdfsdk/fpdfeditpath_embeddertest.cpp4
-rw-r--r--testing/embedder_test.cpp32
-rw-r--r--testing/embedder_test.h10
6 files changed, 47 insertions, 47 deletions
diff --git a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
index 91e625ab26..834ed8c48d 100644
--- a/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
+++ b/core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
@@ -81,11 +81,11 @@ TEST_F(CPDFSecurityHandlerEmbeddertest, PasswordAfterGenerateSave) {
for (const auto& test : tests) {
OpenSavedDocument(test.password);
- LoadSavedPage();
- VerifySavedRendering(612, 792, md5);
+ FPDF_PAGE page = LoadSavedPage(0);
+ VerifySavedRendering(page, 612, 792, md5);
EXPECT_EQ(test.permissions, FPDF_GetDocPermissions(m_SavedDocument));
- CloseSavedPage();
+ CloseSavedPage(page);
CloseSavedDocument();
}
}
diff --git a/fpdfsdk/fpdfannot_embeddertest.cpp b/fpdfsdk/fpdfannot_embeddertest.cpp
index c49e77bc2b..dce658201c 100644
--- a/fpdfsdk/fpdfannot_embeddertest.cpp
+++ b/fpdfsdk/fpdfannot_embeddertest.cpp
@@ -286,15 +286,15 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndSaveUnderlineAnnotation) {
const char md5[] = "dba153419f67b7c0c0e3d22d3e8910d5";
OpenSavedDocument();
- LoadSavedPage();
- VerifySavedRendering(612, 792, md5);
+ page = LoadSavedPage(0);
+ VerifySavedRendering(page, 612, 792, md5);
// Check that the saved document has 2 annotations on the first page
- EXPECT_EQ(2, FPDFPage_GetAnnotCount(m_SavedPage));
+ EXPECT_EQ(2, FPDFPage_GetAnnotCount(page));
// Check that the second annotation is an underline annotation and verify
// its quadpoints.
- FPDF_ANNOTATION new_annot = FPDFPage_GetAnnot(m_SavedPage, 1);
+ FPDF_ANNOTATION new_annot = FPDFPage_GetAnnot(page, 1);
ASSERT_TRUE(new_annot);
EXPECT_EQ(FPDF_ANNOT_UNDERLINE, FPDFAnnot_GetSubtype(new_annot));
FS_QUADPOINTSF new_quadpoints;
@@ -306,7 +306,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndSaveUnderlineAnnotation) {
FPDFPage_CloseAnnot(new_annot);
- CloseSavedPage();
+ CloseSavedPage(page);
CloseSavedDocument();
}
@@ -591,12 +591,12 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
// Open the saved document.
OpenSavedDocument();
- LoadSavedPage();
- VerifySavedRendering(595, 842, md5_new_annot);
+ page = LoadSavedPage(0);
+ VerifySavedRendering(page, 595, 842, md5_new_annot);
// Check that the document has a correct count of annotations and objects.
- EXPECT_EQ(3, FPDFPage_GetAnnotCount(m_SavedPage));
- annot = FPDFPage_GetAnnot(m_SavedPage, 2);
+ EXPECT_EQ(3, FPDFPage_GetAnnotCount(page));
+ annot = FPDFPage_GetAnnot(page, 2);
ASSERT_TRUE(annot);
EXPECT_EQ(1, FPDFAnnot_GetObjectCount(annot));
@@ -608,7 +608,7 @@ TEST_F(FPDFAnnotEmbeddertest, AddAndModifyPath) {
EXPECT_EQ(rect.top, new_rect.top);
FPDFPage_CloseAnnot(annot);
- CloseSavedPage();
+ CloseSavedPage(page);
CloseSavedDocument();
}
@@ -870,9 +870,9 @@ TEST_F(FPDFAnnotEmbeddertest, GetSetStringValue) {
const char md5[] = "c96ee1f316d7f5a1b154de9f9d467f01";
#endif
OpenSavedDocument();
- LoadSavedPage();
- VerifySavedRendering(595, 842, md5);
- FPDF_ANNOTATION new_annot = FPDFPage_GetAnnot(m_SavedPage, 0);
+ page = LoadSavedPage(0);
+ VerifySavedRendering(page, 595, 842, md5);
+ FPDF_ANNOTATION new_annot = FPDFPage_GetAnnot(page, 0);
// Check that the string value of the modified date is the newly-set value.
EXPECT_EQ(FPDF_OBJECT_STRING, FPDFAnnot_GetValueType(new_annot, kDateKey));
@@ -886,7 +886,7 @@ TEST_F(FPDFAnnotEmbeddertest, GetSetStringValue) {
.c_str());
FPDFPage_CloseAnnot(new_annot);
- CloseSavedPage();
+ CloseSavedPage(page);
CloseSavedDocument();
}
diff --git a/fpdfsdk/fpdfedit_embeddertest.cpp b/fpdfsdk/fpdfedit_embeddertest.cpp
index f1f02ffa6d..6cb2771154 100644
--- a/fpdfsdk/fpdfedit_embeddertest.cpp
+++ b/fpdfsdk/fpdfedit_embeddertest.cpp
@@ -457,31 +457,31 @@ TEST_F(FPDFEditEmbeddertest, EditOverExistingContent) {
UnloadPage(page);
OpenSavedDocument();
- LoadSavedPage();
- VerifySavedRendering(612, 792, "ad04e5bd0f471a9a564fb034bd0fb073");
+ page = LoadSavedPage(0);
+ VerifySavedRendering(page, 612, 792, "ad04e5bd0f471a9a564fb034bd0fb073");
ClearString();
// Add another opaque rectangle on top of the existing content
FPDF_PAGEOBJECT green_rect = FPDFPageObj_CreateNewRect(150, 700, 25, 50);
EXPECT_TRUE(FPDFPath_SetFillColor(green_rect, 0, 255, 0, 255));
EXPECT_TRUE(FPDFPath_SetDrawMode(green_rect, FPDF_FILLMODE_ALTERNATE, 0));
- FPDFPage_InsertObject(m_SavedPage, green_rect);
+ FPDFPage_InsertObject(page, green_rect);
// Add another transparent rectangle on top of existing content
FPDF_PAGEOBJECT green_rect2 = FPDFPageObj_CreateNewRect(175, 700, 25, 50);
EXPECT_TRUE(FPDFPath_SetFillColor(green_rect2, 0, 255, 0, 100));
EXPECT_TRUE(FPDFPath_SetDrawMode(green_rect2, FPDF_FILLMODE_ALTERNATE, 0));
- FPDFPage_InsertObject(m_SavedPage, green_rect2);
- FPDF_BITMAP new_bitmap = RenderPageWithFlags(m_SavedPage, m_SavedForm, 0);
+ FPDFPage_InsertObject(page, green_rect2);
+ FPDF_BITMAP new_bitmap = RenderPageWithFlags(page, m_SavedForm, 0);
const char last_md5[] = "4b5b00f824620f8c9b8801ebb98e1cdd";
CompareBitmap(new_bitmap, 612, 792, last_md5);
FPDFBitmap_Destroy(new_bitmap);
- EXPECT_TRUE(FPDFPage_GenerateContent(m_SavedPage));
+ EXPECT_TRUE(FPDFPage_GenerateContent(page));
// Now save the result, closing the page and document
EXPECT_TRUE(FPDF_SaveAsCopy(m_SavedDocument, this, 0));
- CloseSavedPage();
+ CloseSavedPage(page);
CloseSavedDocument();
// Render the saved result
diff --git a/fpdfsdk/fpdfeditpath_embeddertest.cpp b/fpdfsdk/fpdfeditpath_embeddertest.cpp
index 71af2fad55..59e5dbbabf 100644
--- a/fpdfsdk/fpdfeditpath_embeddertest.cpp
+++ b/fpdfsdk/fpdfeditpath_embeddertest.cpp
@@ -32,7 +32,7 @@ TEST_F(FPDFEditPathEmbedderTest, VerifyCorrectColoursReturned) {
page = nullptr;
OpenSavedDocument();
- page = LoadSavedPage();
+ page = LoadSavedPage(0);
ASSERT(page);
for (size_t i = 0; i < 256; ++i) {
@@ -58,6 +58,6 @@ TEST_F(FPDFEditPathEmbedderTest, VerifyCorrectColoursReturned) {
EXPECT_EQ(i, a);
}
- CloseSavedPage();
+ CloseSavedPage(page);
CloseSavedDocument();
}
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 4c29c06da5..36ee08f85d 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -326,7 +326,6 @@ FPDF_DOCUMENT EmbedderTest::OpenSavedDocument(const char* password) {
}
void EmbedderTest::CloseSavedDocument() {
- ASSERT(!m_SavedPage);
ASSERT(m_SavedDocument);
FPDFDOC_ExitFormFillEnvironment(m_SavedForm);
@@ -338,39 +337,38 @@ void EmbedderTest::CloseSavedDocument() {
m_SavedAvail = nullptr;
}
-FPDF_PAGE EmbedderTest::LoadSavedPage() {
+FPDF_PAGE EmbedderTest::LoadSavedPage(int page_number) {
ASSERT(m_SavedDocument);
- EXPECT_EQ(1, FPDF_GetPageCount(m_SavedDocument));
- m_SavedPage = FPDF_LoadPage(m_SavedDocument, 0);
+ EXPECT_LT(page_number, FPDF_GetPageCount(m_SavedDocument));
+ FPDF_PAGE page = FPDF_LoadPage(m_SavedDocument, page_number);
- ASSERT(m_SavedPage);
- return m_SavedPage;
+ ASSERT(page);
+ return page;
}
-void EmbedderTest::CloseSavedPage() {
- ASSERT(m_SavedPage);
- FPDF_ClosePage(m_SavedPage);
- m_SavedPage = nullptr;
+void EmbedderTest::CloseSavedPage(FPDF_PAGE page) {
+ ASSERT(page);
+ FPDF_ClosePage(page);
}
-void EmbedderTest::VerifySavedRendering(int width,
+void EmbedderTest::VerifySavedRendering(FPDF_PAGE page,
+ int width,
int height,
const char* md5) {
ASSERT(m_SavedDocument);
- ASSERT(m_SavedPage);
+ ASSERT(page);
- FPDF_BITMAP new_bitmap =
- RenderPageWithFlags(m_SavedPage, m_SavedForm, FPDF_ANNOT);
+ FPDF_BITMAP new_bitmap = RenderPageWithFlags(page, m_SavedForm, FPDF_ANNOT);
CompareBitmap(new_bitmap, width, height, md5);
FPDFBitmap_Destroy(new_bitmap);
}
void EmbedderTest::VerifySavedDocument(int width, int height, const char* md5) {
OpenSavedDocument();
- LoadSavedPage();
- VerifySavedRendering(width, height, md5);
- CloseSavedPage();
+ FPDF_PAGE page = LoadSavedPage(0);
+ VerifySavedRendering(page, width, height, md5);
+ CloseSavedPage(page);
CloseSavedDocument();
}
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index 606472bc1d..df9e837f0f 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -145,9 +145,12 @@ class EmbedderTest : public ::testing::Test,
FPDF_DOCUMENT OpenSavedDocument(const char* password = nullptr);
void CloseSavedDocument();
- FPDF_PAGE LoadSavedPage();
- void CloseSavedPage();
- void VerifySavedRendering(int width, int height, const char* md5);
+ FPDF_PAGE LoadSavedPage(int page_number);
+ void CloseSavedPage(FPDF_PAGE page);
+ void VerifySavedRendering(FPDF_PAGE page,
+ int width,
+ int height,
+ const char* md5);
void VerifySavedDocument(int width, int height, const char* md5);
void SetWholeFileAvailable();
@@ -168,7 +171,6 @@ class EmbedderTest : public ::testing::Test,
std::map<int, FPDF_PAGE> page_map_;
std::map<FPDF_PAGE, int> page_reverse_map_;
FPDF_DOCUMENT m_SavedDocument;
- FPDF_PAGE m_SavedPage;
FPDF_FORMHANDLE m_SavedForm;
FPDF_AVAIL m_SavedAvail;
FPDF_FILEACCESS saved_file_access_; // must outlive m_SavedAvail.