summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2017-11-10 20:27:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-10 20:27:23 +0000
commit8baea3c694900581fef42ee64795aa5307c6373d (patch)
tree12f1a4415b4bc4906b1faa06efeba5fe72753a45 /testing
parent267d2a862fd9ec7bc722533914e8e5af8a19df26 (diff)
downloadpdfium-8baea3c694900581fef42ee64795aa5307c6373d.tar.xz
Stop using m_SavedPage in embedder tests.chromium/3265
Change-Id: Id53f57085fecfe331c8cbfa6bb372b5ea5044442 Reviewed-on: https://pdfium-review.googlesource.com/18332 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/embedder_test.cpp32
-rw-r--r--testing/embedder_test.h10
2 files changed, 21 insertions, 21 deletions
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.