summaryrefslogtreecommitdiff
path: root/testing/embedder_test.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-08 21:49:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-08 21:49:54 +0000
commit9f72c45cbcd159f7b811589be1e896c9781e8394 (patch)
tree8ecdf33f5877a090ec442c920ab59ea52857db90 /testing/embedder_test.h
parente0518bf0a0e703b1e010081079c988f011834cb6 (diff)
downloadpdfium-9f72c45cbcd159f7b811589be1e896c9781e8394.tar.xz
Do page load/unload checks in EmbedderTest for saved pages.chromium/3344
Change-Id: I9286b24957f9d96da10869098eb0e04991bd6571 Reviewed-on: https://pdfium-review.googlesource.com/25570 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'testing/embedder_test.h')
-rw-r--r--testing/embedder_test.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index c8fce4825f..25896dcafc 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -163,6 +163,8 @@ class EmbedderTest : public ::testing::Test,
RenderPageWithFlags(FPDF_PAGE page, FPDF_FORMHANDLE handle, int flags);
protected:
+ using PageNumberToHandleMap = std::map<int, FPDF_PAGE>;
+
bool OpenDocumentHelper(const char* password,
bool must_linearize,
FakeFileAccess* network_simulator,
@@ -195,10 +197,12 @@ class EmbedderTest : public ::testing::Test,
unsigned char* buf,
unsigned long size);
+ // See comments in the respective non-Saved versions of these methods.
FPDF_DOCUMENT OpenSavedDocument(const char* password = nullptr);
void CloseSavedDocument();
FPDF_PAGE LoadSavedPage(int page_number);
void CloseSavedPage(FPDF_PAGE page);
+
void VerifySavedRendering(FPDF_PAGE page,
int width,
int height,
@@ -220,7 +224,7 @@ class EmbedderTest : public ::testing::Test,
TestLoader* loader_ = nullptr;
size_t file_length_ = 0;
std::unique_ptr<char, pdfium::FreeDeleter> file_contents_;
- std::map<int, FPDF_PAGE> page_map_;
+ PageNumberToHandleMap page_map_;
FPDF_DOCUMENT saved_document_ = nullptr;
FPDF_FORMHANDLE saved_form_handle_ = nullptr;
@@ -228,6 +232,7 @@ class EmbedderTest : public ::testing::Test,
FPDF_FILEACCESS saved_file_access_; // must outlive |saved_avail_|.
// must outlive |saved_avail_|.
std::unique_ptr<FakeFileAccess> saved_fake_file_access_;
+ PageNumberToHandleMap saved_page_map_;
private:
static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type);
@@ -247,10 +252,16 @@ class EmbedderTest : public ::testing::Test,
const void* data,
unsigned long size);
+ // Helper method for the methods below.
+ static int GetPageNumberForPage(const PageNumberToHandleMap& page_map,
+ FPDF_PAGE page);
// Find |page| inside |page_map_| and return the associated page number, or -1
// if |page| cannot be found.
int GetPageNumberForLoadedPage(FPDF_PAGE page) const;
+ // Same as GetPageNumberForLoadedPage(), but with |saved_page_map_|.
+ int GetPageNumberForSavedPage(FPDF_PAGE page) const;
+
std::string data_string_;
};