summaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-02-05 21:13:51 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-05 21:13:51 +0000
commit0729be26d745e2ea713908eb9040e2be7c40c96b (patch)
tree87d3010e209b5b46d8632145c882a0d0d2ef7e40 /testing
parent3355f459ecd2207c0cd1719c2cdafa15eea87bf6 (diff)
downloadpdfium-0729be26d745e2ea713908eb9040e2be7c40c96b.tar.xz
Make EmbedderTest class member style consistent.
The class started with |foo_bar_| but now has a mixture of |foo_bar_| and |m_FooBar|. Change them all to |foo_bar_|. While making this change, also initialize the members in the header when possible. Change-Id: I202ff5dc5e945175ad4da2f3245724f3493aa8aa Reviewed-on: https://pdfium-review.googlesource.com/25390 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'testing')
-rw-r--r--testing/embedder_test.cpp57
-rw-r--r--testing/embedder_test.h39
2 files changed, 47 insertions, 49 deletions
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index b434353bd9..d7f4376b24 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -49,17 +49,8 @@ int GetBitmapBytesPerPixel(FPDF_BITMAP bitmap) {
} // namespace
EmbedderTest::EmbedderTest()
- : default_delegate_(new EmbedderTest::Delegate()),
- document_(nullptr),
- form_handle_(nullptr),
- avail_(nullptr),
- external_isolate_(nullptr),
- loader_(nullptr),
- file_length_(0),
- file_contents_(nullptr) {
- memset(&file_access_, 0, sizeof(file_access_));
- delegate_ = default_delegate_.get();
-
+ : default_delegate_(pdfium::MakeUnique<EmbedderTest::Delegate>()),
+ delegate_(default_delegate_.get()) {
FPDF_FILEWRITE::version = 1;
FPDF_FILEWRITE::WriteBlock = WriteBlockCallback;
}
@@ -80,7 +71,7 @@ void EmbedderTest::SetUp() {
info->FSDK_UnSupport_Handler = UnsupportedHandlerTrampoline;
FSDK_SetUnSpObjProcessHandler(info);
- m_SavedDocument = nullptr;
+ saved_document_ = nullptr;
}
void EmbedderTest::TearDown() {
@@ -129,9 +120,12 @@ bool EmbedderTest::OpenDocumentWithOptions(const std::string& filename,
EXPECT_TRUE(!loader_);
loader_ = new TestLoader(file_contents_.get(), file_length_);
+
+ memset(&file_access_, 0, sizeof(file_access_));
file_access_.m_FileLen = static_cast<unsigned long>(file_length_);
file_access_.m_GetBlock = TestLoader::GetBlock;
file_access_.m_Param = loader_;
+
fake_file_access_ = pdfium::MakeUnique<FakeFileAccess>(&file_access_);
return OpenDocumentHelper(password, must_linearize, fake_file_access_.get(),
&document_, &avail_, &form_handle_);
@@ -301,43 +295,43 @@ void EmbedderTest::UnloadPage(FPDF_PAGE page) {
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_FileLen = data_string_.size();
saved_file_access_.m_GetBlock = GetBlockFromString;
- saved_file_access_.m_Param = &m_String;
+ saved_file_access_.m_Param = &data_string_;
saved_fake_file_access_ =
pdfium::MakeUnique<FakeFileAccess>(&saved_file_access_);
EXPECT_TRUE(OpenDocumentHelper(password, false, saved_fake_file_access_.get(),
- &m_SavedDocument, &m_SavedAvail,
- &m_SavedForm));
- return m_SavedDocument;
+ &saved_document_, &saved_avail_,
+ &saved_form_handle_));
+ return saved_document_;
}
void EmbedderTest::CloseSavedDocument() {
- ASSERT(m_SavedDocument);
+ ASSERT(saved_document_);
- FPDFDOC_ExitFormFillEnvironment(m_SavedForm);
- FPDF_CloseDocument(m_SavedDocument);
- FPDFAvail_Destroy(m_SavedAvail);
+ FPDFDOC_ExitFormFillEnvironment(saved_form_handle_);
+ FPDF_CloseDocument(saved_document_);
+ FPDFAvail_Destroy(saved_avail_);
- m_SavedForm = nullptr;
- m_SavedDocument = nullptr;
- m_SavedAvail = nullptr;
+ saved_form_handle_ = nullptr;
+ saved_document_ = nullptr;
+ saved_avail_ = nullptr;
}
FPDF_PAGE EmbedderTest::LoadSavedPage(int page_number) {
- ASSERT(m_SavedDocument);
+ ASSERT(saved_document_);
- EXPECT_LT(page_number, FPDF_GetPageCount(m_SavedDocument));
- FPDF_PAGE page = FPDF_LoadPage(m_SavedDocument, page_number);
+ EXPECT_LT(page_number, FPDF_GetPageCount(saved_document_));
+ FPDF_PAGE page = FPDF_LoadPage(saved_document_, page_number);
ASSERT(page);
return page;
}
FPDF_BITMAP EmbedderTest::RenderSavedPage(FPDF_PAGE page) {
- return RenderPageWithFlags(page, m_SavedForm, 0);
+ return RenderPageWithFlags(page, saved_form_handle_, 0);
}
void EmbedderTest::CloseSavedPage(FPDF_PAGE page) {
@@ -349,10 +343,11 @@ void EmbedderTest::VerifySavedRendering(FPDF_PAGE page,
int width,
int height,
const char* md5) {
- ASSERT(m_SavedDocument);
+ ASSERT(saved_document_);
ASSERT(page);
- FPDF_BITMAP new_bitmap = RenderPageWithFlags(page, m_SavedForm, FPDF_ANNOT);
+ FPDF_BITMAP new_bitmap =
+ RenderPageWithFlags(page, saved_form_handle_, FPDF_ANNOT);
CompareBitmap(new_bitmap, width, height, md5);
FPDFBitmap_Destroy(new_bitmap);
}
@@ -479,7 +474,7 @@ int EmbedderTest::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite,
const void* data,
unsigned long size) {
EmbedderTest* pThis = static_cast<EmbedderTest*>(pFileWrite);
- pThis->m_String.append(static_cast<const char*>(data), size);
+ pThis->data_string_.append(static_cast<const char*>(data), size);
return 1;
}
diff --git a/testing/embedder_test.h b/testing/embedder_test.h
index 98432e3e54..b36ac06a89 100644
--- a/testing/embedder_test.h
+++ b/testing/embedder_test.h
@@ -146,8 +146,8 @@ class EmbedderTest : public ::testing::Test,
int expected_height,
const char* expected_md5sum);
- void ClearString() { m_String.clear(); }
- const std::string& GetString() const { return m_String; }
+ void ClearString() { data_string_.clear(); }
+ const std::string& GetString() const { return data_string_; }
static int GetBlockFromString(void* param,
unsigned long pos,
@@ -167,25 +167,28 @@ class EmbedderTest : public ::testing::Test,
void SetWholeFileAvailable();
- Delegate* delegate_;
std::unique_ptr<Delegate> default_delegate_;
- FPDF_DOCUMENT document_;
- FPDF_FORMHANDLE form_handle_;
- FPDF_AVAIL avail_;
- FPDF_FILEACCESS file_access_; // must outlive avail_.
- void* external_isolate_;
- TestLoader* loader_;
- size_t file_length_;
+ Delegate* delegate_;
+
+ FPDF_DOCUMENT document_ = nullptr;
+ FPDF_FORMHANDLE form_handle_ = nullptr;
+ FPDF_AVAIL avail_ = nullptr;
+ FPDF_FILEACCESS file_access_; // must outlive |avail_|.
+ std::unique_ptr<FakeFileAccess> fake_file_access_; // must outlive |avail_|.
+
+ void* external_isolate_ = nullptr;
+ TestLoader* loader_ = nullptr;
+ size_t file_length_ = 0;
std::unique_ptr<char, pdfium::FreeDeleter> file_contents_;
std::map<int, FPDF_PAGE> page_map_;
std::map<FPDF_PAGE, int> page_reverse_map_;
- FPDF_DOCUMENT m_SavedDocument;
- FPDF_FORMHANDLE m_SavedForm;
- FPDF_AVAIL m_SavedAvail;
- FPDF_FILEACCESS saved_file_access_; // must outlive m_SavedAvail.
- std::unique_ptr<FakeFileAccess> fake_file_access_; // must outlive avail_.
- std::unique_ptr<FakeFileAccess>
- saved_fake_file_access_; // must outlive m_SavedAvail.
+
+ FPDF_DOCUMENT saved_document_ = nullptr;
+ FPDF_FORMHANDLE saved_form_handle_ = nullptr;
+ FPDF_AVAIL saved_avail_ = nullptr;
+ FPDF_FILEACCESS saved_file_access_; // must outlive |saved_avail_|.
+ // must outlive |saved_avail_|.
+ std::unique_ptr<FakeFileAccess> saved_fake_file_access_;
private:
static void UnsupportedHandlerTrampoline(UNSUPPORT_INFO*, int type);
@@ -205,7 +208,7 @@ class EmbedderTest : public ::testing::Test,
const void* data,
unsigned long size);
- std::string m_String;
+ std::string data_string_;
};
#endif // TESTING_EMBEDDER_TEST_H_