diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-02-09 18:26:09 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-09 18:26:09 +0000 |
commit | 3f8ee5e6b4e42fc77b4716b23ccd00840e24e250 (patch) | |
tree | 16406801eae8da64bbe44a1b014a3b3945c22bd6 /testing/unit_test_main.cpp | |
parent | 026717cb667cf0c7215cf55daf794d69752fc900 (diff) | |
download | pdfium-3f8ee5e6b4e42fc77b4716b23ccd00840e24e250.tar.xz |
Move CFX_V8 testing from embeddertest to unittest.
Test the lowest layer without firing up the whole library. Requires
firing up v8 in the unit test main, though.
Move array buffer allocator to cfx_v8 to allow building isolates.
Change-Id: I9a56d503a48e0e555d3310f2997fa12137695860
Reviewed-on: https://pdfium-review.googlesource.com/26130
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'testing/unit_test_main.cpp')
-rw-r--r-- | testing/unit_test_main.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
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; } |