diff options
Diffstat (limited to 'testing')
-rw-r--r-- | testing/js_embedder_test.cpp | 4 | ||||
-rw-r--r-- | testing/js_embedder_test.h | 2 | ||||
-rw-r--r-- | testing/unit_test_main.cpp | 28 | ||||
-rw-r--r-- | testing/xfa_js_embedder_test.cpp | 4 | ||||
-rw-r--r-- | testing/xfa_js_embedder_test.h | 2 |
5 files changed, 33 insertions, 7 deletions
diff --git a/testing/js_embedder_test.cpp b/testing/js_embedder_test.cpp index 8e95aee142..1ca957b44f 100644 --- a/testing/js_embedder_test.cpp +++ b/testing/js_embedder_test.cpp @@ -7,8 +7,8 @@ #include "third_party/base/ptr_util.h" JSEmbedderTest::JSEmbedderTest() - : m_pArrayBufferAllocator(pdfium::MakeUnique<FXJS_ArrayBufferAllocator>()) { -} + : m_pArrayBufferAllocator( + pdfium::MakeUnique<CFX_V8ArrayBufferAllocator>()) {} JSEmbedderTest::~JSEmbedderTest() {} diff --git a/testing/js_embedder_test.h b/testing/js_embedder_test.h index 1f27dbeae6..4bd5433b19 100644 --- a/testing/js_embedder_test.h +++ b/testing/js_embedder_test.h @@ -23,7 +23,7 @@ class JSEmbedderTest : public EmbedderTest { CFXJS_Engine* engine() { return m_Engine.get(); } private: - std::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator; + std::unique_ptr<CFX_V8ArrayBufferAllocator> m_pArrayBufferAllocator; v8::Isolate* m_pIsolate = nullptr; std::unique_ptr<CFXJS_Engine> m_Engine; }; diff --git a/testing/unit_test_main.cpp b/testing/unit_test_main.cpp index 64b12993a9..d0c4dfda9f 100644 --- a/testing/unit_test_main.cpp +++ b/testing/unit_test_main.cpp @@ -3,10 +3,17 @@ // found in the LICENSE file. #include <memory> +#include <string> #include "core/fxcrt/fx_memory.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/test_support.h" + +#if PDF_ENABLE_V8 +#include "v8/include/v8-platform.h" +#include "v8/include/v8.h" +#endif #if PDF_ENABLE_XFA #include "core/fxge/cfx_fontmgr.h" @@ -55,6 +62,18 @@ CFGAS_FontMgr* GetGlobalFontManager() { int main(int argc, char** argv) { FXMEM_InitializePartitionAlloc(); +#ifdef PDF_ENABLE_V8 + std::unique_ptr<v8::Platform> platform; + static v8::StartupData* natives = new v8::StartupData; + static v8::StartupData* snapshot = new v8::StartupData; +#ifdef V8_USE_EXTERNAL_STARTUP_DATA + platform = InitializeV8ForPDFiumWithStartupData(argv[0], std::string(), + natives, snapshot); +#else // V8_USE_EXTERNAL_STARTUP_DATA + platform = InitializeV8ForPDFium(argv[0]); +#endif // V8_USE_EXTERNAL_STARTUP_DATA +#endif // PDF_ENABLE_V8 + #if PDF_ENABLE_XFA env_ = new Environment(); // The env will be deleted by gtest. @@ -63,5 +82,12 @@ int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); testing::InitGoogleMock(&argc, argv); - return RUN_ALL_TESTS(); + + int ret_val = RUN_ALL_TESTS(); + +#ifdef PDF_ENABLE_V8 + v8::V8::ShutdownPlatform(); +#endif // PDF_ENABLE_V8 + + return ret_val; } diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp index d007c87f65..8ac17f3083 100644 --- a/testing/xfa_js_embedder_test.cpp +++ b/testing/xfa_js_embedder_test.cpp @@ -13,8 +13,8 @@ #include "third_party/base/ptr_util.h" XFAJSEmbedderTest::XFAJSEmbedderTest() - : array_buffer_allocator_(pdfium::MakeUnique<FXJS_ArrayBufferAllocator>()) { -} + : array_buffer_allocator_( + pdfium::MakeUnique<CFX_V8ArrayBufferAllocator>()) {} XFAJSEmbedderTest::~XFAJSEmbedderTest() {} diff --git a/testing/xfa_js_embedder_test.h b/testing/xfa_js_embedder_test.h index 5f4549601c..44840b31eb 100644 --- a/testing/xfa_js_embedder_test.h +++ b/testing/xfa_js_embedder_test.h @@ -38,7 +38,7 @@ class XFAJSEmbedderTest : public EmbedderTest { CFXJSE_Value* GetValue() const { return value_.get(); } private: - std::unique_ptr<FXJS_ArrayBufferAllocator> array_buffer_allocator_; + std::unique_ptr<CFX_V8ArrayBufferAllocator> array_buffer_allocator_; std::unique_ptr<CFXJSE_Value> value_; v8::Isolate* isolate_ = nullptr; CFXJSE_Engine* script_context_ = nullptr; |