Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 1 | // Copyright 2017 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 5 | #include <memory> |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 6 | #include <string> |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 7 | |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 8 | #include "core/fxcrt/fx_memory.h" |
| 9 | #include "testing/gmock/include/gmock/gmock.h" |
| 10 | #include "testing/gtest/include/gtest/gtest.h" |
Tom Sepez | 78f6819 | 2019-05-31 17:28:15 +0000 | [diff] [blame] | 11 | #include "testing/test_support.h" |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 12 | |
Ryan Harrison | 4f21d77 | 2018-06-01 15:19:04 +0000 | [diff] [blame] | 13 | #ifdef PDF_ENABLE_V8 |
Lei Zhang | 72e8b69 | 2019-02-05 19:16:52 +0000 | [diff] [blame] | 14 | #include "testing/v8_initializer.h" |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 15 | #include "v8/include/v8-platform.h" |
| 16 | #include "v8/include/v8.h" |
Ryan Harrison | 4f21d77 | 2018-06-01 15:19:04 +0000 | [diff] [blame] | 17 | #endif // PDF_ENABLE_V8 |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 18 | |
Ryan Harrison | d60d7cb | 2018-06-01 15:28:54 +0000 | [diff] [blame] | 19 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 220ef3d | 2019-02-05 20:40:54 +0000 | [diff] [blame] | 20 | #include "testing/xfa_unit_test_support.h" |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 21 | #endif // PDF_ENABLE_XFA |
| 22 | |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 23 | // Can't use gtest-provided main since we need to initialize partition |
| 24 | // alloc before invoking any test. |
| 25 | int main(int argc, char** argv) { |
Dan Sinclair | dbc3d3e | 2017-05-11 13:41:38 -0400 | [diff] [blame] | 26 | FXMEM_InitializePartitionAlloc(); |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 27 | |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 28 | #ifdef PDF_ENABLE_V8 |
| 29 | std::unique_ptr<v8::Platform> platform; |
Nico Weber | 611431d | 2018-02-26 20:36:16 +0000 | [diff] [blame] | 30 | #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 31 | static v8::StartupData* snapshot = new v8::StartupData; |
Lei Zhang | a8e8baf | 2019-10-08 17:53:04 +0000 | [diff] [blame^] | 32 | platform = |
| 33 | InitializeV8ForPDFiumWithStartupData(argv[0], std::string(), snapshot); |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 34 | #else // V8_USE_EXTERNAL_STARTUP_DATA |
| 35 | platform = InitializeV8ForPDFium(argv[0]); |
| 36 | #endif // V8_USE_EXTERNAL_STARTUP_DATA |
| 37 | #endif // PDF_ENABLE_V8 |
| 38 | |
Tom Sepez | 78f6819 | 2019-05-31 17:28:15 +0000 | [diff] [blame] | 39 | InitializePDFTestEnvironment(); |
Ryan Harrison | d60d7cb | 2018-06-01 15:28:54 +0000 | [diff] [blame] | 40 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 220ef3d | 2019-02-05 20:40:54 +0000 | [diff] [blame] | 41 | InitializeXFATestEnvironment(); |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 42 | #endif // PDF_ENABLE_XFA |
| 43 | |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 44 | testing::InitGoogleTest(&argc, argv); |
| 45 | testing::InitGoogleMock(&argc, argv); |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 46 | |
| 47 | int ret_val = RUN_ALL_TESTS(); |
| 48 | |
Tom Sepez | 78f6819 | 2019-05-31 17:28:15 +0000 | [diff] [blame] | 49 | DestroyPDFTestEnvironment(); |
| 50 | // NOTE: XFA test environment, if present, destroyed by gtest. |
| 51 | |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 52 | #ifdef PDF_ENABLE_V8 |
| 53 | v8::V8::ShutdownPlatform(); |
| 54 | #endif // PDF_ENABLE_V8 |
| 55 | |
| 56 | return ret_val; |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 57 | } |