summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-18 12:17:14 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-18 17:19:26 +0000
commit04e4dc88da34c323e7a16586bddf377a610d63c5 (patch)
tree3edad973a50e8a24aed47a4aa6ab6e267720876a /testing
parent854d71c1420eb80ec79755a6cdf829f3f39aead7 (diff)
downloadpdfium-04e4dc88da34c323e7a16586bddf377a610d63c5.tar.xz
Fix rounding of colour values
This CL fixes rounding issues with the colour values when written then read from path objects. Bug: pdfium:919 Change-Id: I8ab33706f1c7d81c3ec755706b1a613cf2a557b3 Reviewed-on: https://pdfium-review.googlesource.com/16270 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/embedder_test.cpp60
-rw-r--r--testing/embedder_test.h12
2 files changed, 50 insertions, 22 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index 2694977384..4c29c06da5 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -310,10 +310,7 @@ void EmbedderTest::UnloadPage(FPDF_PAGE page) {
page_reverse_map_.erase(it);
}
-void EmbedderTest::TestSaved(int width,
- int height,
- const char* md5,
- const char* password) {
+FPDF_DOCUMENT EmbedderTest::OpenSavedDocument(const char* password) {
memset(&saved_file_access_, 0, sizeof(saved_file_access_));
saved_file_access_.m_FileLen = m_String.size();
saved_file_access_.m_GetBlock = GetBlockFromString;
@@ -322,28 +319,59 @@ void EmbedderTest::TestSaved(int width,
saved_fake_file_access_ =
pdfium::MakeUnique<FakeFileAccess>(&saved_file_access_);
- ASSERT_TRUE(OpenDocumentHelper(password, false, saved_fake_file_access_.get(),
+ EXPECT_TRUE(OpenDocumentHelper(password, false, saved_fake_file_access_.get(),
&m_SavedDocument, &m_SavedAvail,
&m_SavedForm));
+ return m_SavedDocument;
+}
+
+void EmbedderTest::CloseSavedDocument() {
+ ASSERT(!m_SavedPage);
+ ASSERT(m_SavedDocument);
+
+ FPDFDOC_ExitFormFillEnvironment(m_SavedForm);
+ FPDF_CloseDocument(m_SavedDocument);
+ FPDFAvail_Destroy(m_SavedAvail);
+
+ m_SavedForm = nullptr;
+ m_SavedDocument = nullptr;
+ m_SavedAvail = nullptr;
+}
+
+FPDF_PAGE EmbedderTest::LoadSavedPage() {
+ ASSERT(m_SavedDocument);
+
EXPECT_EQ(1, FPDF_GetPageCount(m_SavedDocument));
m_SavedPage = FPDF_LoadPage(m_SavedDocument, 0);
- ASSERT_TRUE(m_SavedPage);
+
+ ASSERT(m_SavedPage);
+ return m_SavedPage;
+}
+
+void EmbedderTest::CloseSavedPage() {
+ ASSERT(m_SavedPage);
+ FPDF_ClosePage(m_SavedPage);
+ m_SavedPage = nullptr;
+}
+
+void EmbedderTest::VerifySavedRendering(int width,
+ int height,
+ const char* md5) {
+ ASSERT(m_SavedDocument);
+ ASSERT(m_SavedPage);
+
FPDF_BITMAP new_bitmap =
RenderPageWithFlags(m_SavedPage, m_SavedForm, FPDF_ANNOT);
CompareBitmap(new_bitmap, width, height, md5);
FPDFBitmap_Destroy(new_bitmap);
}
-void EmbedderTest::CloseSaved() {
- FPDF_ClosePage(m_SavedPage);
- FPDFDOC_ExitFormFillEnvironment(m_SavedForm);
- FPDF_CloseDocument(m_SavedDocument);
- FPDFAvail_Destroy(m_SavedAvail);
-}
-
-void EmbedderTest::TestAndCloseSaved(int width, int height, const char* md5) {
- TestSaved(width, height, md5);
- CloseSaved();
+void EmbedderTest::VerifySavedDocument(int width, int height, const char* md5) {
+ OpenSavedDocument();
+ LoadSavedPage();
+ VerifySavedRendering(width, height, md5);
+ CloseSavedPage();
+ CloseSavedDocument();
}
void EmbedderTest::SetWholeFileAvailable() {
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index be89c2a6cd..606472bc1d 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -143,12 +143,12 @@ class EmbedderTest : public ::testing::Test,
unsigned char* buf,
unsigned long size);
- void TestSaved(int width,
- int height,
- const char* md5,
- const char* password = nullptr);
- void CloseSaved();
- void TestAndCloseSaved(int width, int height, const char* md5);
+ FPDF_DOCUMENT OpenSavedDocument(const char* password = nullptr);
+ void CloseSavedDocument();
+ FPDF_PAGE LoadSavedPage();
+ void CloseSavedPage();
+ void VerifySavedRendering(int width, int height, const char* md5);
+ void VerifySavedDocument(int width, int height, const char* md5);
void SetWholeFileAvailable();