From 208eecfa7850ced5c0d776b9e5df5b104428608f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 20 Dec 2017 19:40:50 +0000 Subject: Avoid default arguments in EmbedderTest::OpenDocument(). Default arguments are banned on virtual functions. Remove default arguments and rename OpenDocument() to OpenDocumentWithOptions(). Add wrappers for OpenDocumentWithOptions() to call it with sensible options. Change-Id: I4955d88cf77a7eab1771692ea3d6a18260b52900 Reviewed-on: https://pdfium-review.googlesource.com/21891 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- testing/embedder_test.cpp | 19 ++++++++++++++++--- testing/embedder_test.h | 13 ++++++++++--- testing/xfa_js_embedder_test.cpp | 13 +++++++------ testing/xfa_js_embedder_test.h | 12 ++++++------ 4 files changed, 39 insertions(+), 18 deletions(-) (limited to 'testing') diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp index bb202bff1c..ccc98b4dcd 100644 --- a/testing/embedder_test.cpp +++ b/testing/embedder_test.cpp @@ -131,9 +131,22 @@ bool EmbedderTest::CreateEmptyDocument() { return true; } -bool EmbedderTest::OpenDocument(const std::string& filename, - const char* password, - bool must_linearize) { +bool EmbedderTest::OpenDocument(const std::string& filename) { + return OpenDocumentWithOptions(filename, nullptr, false); +} + +bool EmbedderTest::OpenDocumentLinearized(const std::string& filename) { + return OpenDocumentWithOptions(filename, nullptr, true); +} + +bool EmbedderTest::OpenDocumentWithPassword(const std::string& filename, + const char* password) { + return OpenDocumentWithOptions(filename, password, false); +} + +bool EmbedderTest::OpenDocumentWithOptions(const std::string& filename, + const char* password, + bool must_linearize) { std::string file_path; if (!PathService::GetTestFilePath(filename, &file_path)) return false; diff --git a/testing/embedder_test.h b/testing/embedder_test.h index 87c1fad6f1..03155793c5 100644 --- a/testing/embedder_test.h +++ b/testing/embedder_test.h @@ -87,9 +87,16 @@ class EmbedderTest : public ::testing::Test, // environment, or return false on failure. // The filename is relative to the test data directory where we store all the // test files. - virtual bool OpenDocument(const std::string& filename, - const char* password = nullptr, - bool must_linearize = false); + // |password| can be nullptr if there is none. + virtual bool OpenDocumentWithOptions(const std::string& filename, + const char* password, + bool must_linearize); + + // Variants provided for convenience. + bool OpenDocument(const std::string& filename); + bool OpenDocumentLinearized(const std::string& filename); + bool OpenDocumentWithPassword(const std::string& filename, + const char* password); // Perform JavaScript actions that are to run at document open time. void DoOpenActions(); diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp index db297292c6..d007c87f65 100644 --- a/testing/xfa_js_embedder_test.cpp +++ b/testing/xfa_js_embedder_test.cpp @@ -22,14 +22,14 @@ void XFAJSEmbedderTest::SetUp() { v8::Isolate::CreateParams params; params.array_buffer_allocator = array_buffer_allocator_.get(); isolate_ = v8::Isolate::New(params); - ASSERT_TRUE(isolate_ != nullptr); + ASSERT_TRUE(isolate_); EmbedderTest::SetExternalIsolate(isolate_); EmbedderTest::SetUp(); } void XFAJSEmbedderTest::TearDown() { - value_ = nullptr; + value_.reset(); script_context_ = nullptr; EmbedderTest::TearDown(); @@ -42,10 +42,11 @@ CXFA_Document* XFAJSEmbedderTest::GetXFADocument() { return UnderlyingFromFPDFDocument(document())->GetXFADoc()->GetXFADoc(); } -bool XFAJSEmbedderTest::OpenDocument(const std::string& filename, - const char* password, - bool must_linearize) { - if (!EmbedderTest::OpenDocument(filename, password, must_linearize)) +bool XFAJSEmbedderTest::OpenDocumentWithOptions(const std::string& filename, + const char* password, + bool must_linearize) { + if (!EmbedderTest::OpenDocumentWithOptions(filename, password, + must_linearize)) return false; script_context_ = GetXFADocument()->GetScriptContext(); diff --git a/testing/xfa_js_embedder_test.h b/testing/xfa_js_embedder_test.h index 73d7d576a7..5f4549601c 100644 --- a/testing/xfa_js_embedder_test.h +++ b/testing/xfa_js_embedder_test.h @@ -22,12 +22,12 @@ class XFAJSEmbedderTest : public EmbedderTest { XFAJSEmbedderTest(); ~XFAJSEmbedderTest() override; + // EmbedderTest: void SetUp() override; void TearDown() override; - - bool OpenDocument(const std::string& filename, - const char* password = nullptr, - bool must_linearize = false) override; + bool OpenDocumentWithOptions(const std::string& filename, + const char* password, + bool must_linearize) override; v8::Isolate* GetIsolate() const { return isolate_; } CXFA_Document* GetXFADocument(); @@ -40,8 +40,8 @@ class XFAJSEmbedderTest : public EmbedderTest { private: std::unique_ptr array_buffer_allocator_; std::unique_ptr value_; - v8::Isolate* isolate_; - CFXJSE_Engine* script_context_; + v8::Isolate* isolate_ = nullptr; + CFXJSE_Engine* script_context_ = nullptr; bool ExecuteHelper(const ByteStringView& input); }; -- cgit v1.2.3