K. Moon | 832a694 | 2022-10-31 20:11:31 +0000 | [diff] [blame] | 1 | // Copyright 2017 The PDFium Authors |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "core/fxcrt/fx_memory.h" |
| 6 | #include "testing/gmock/include/gmock/gmock.h" |
| 7 | #include "testing/gtest/include/gtest/gtest.h" |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 8 | #include "testing/pdf_test_environment.h" |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 9 | |
Tom Sepez | ab959fa | 2023-07-27 22:49:28 +0000 | [diff] [blame] | 10 | #if defined(PDF_USE_PARTITION_ALLOC) |
Tom Sepez | f07f001 | 2023-07-29 01:26:26 +0000 | [diff] [blame] | 11 | #include "testing/allocator_shim_config.h" |
Tom Sepez | ab959fa | 2023-07-27 22:49:28 +0000 | [diff] [blame] | 12 | #endif |
| 13 | |
Ryan Harrison | 4f21d77 | 2018-06-01 15:19:04 +0000 | [diff] [blame] | 14 | #ifdef PDF_ENABLE_V8 |
Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 15 | #include "testing/v8_test_environment.h" |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 16 | #ifdef PDF_ENABLE_XFA |
| 17 | #include "testing/xfa_test_environment.h" |
| 18 | #endif // PDF_ENABLE_XFA |
Ryan Harrison | 4f21d77 | 2018-06-01 15:19:04 +0000 | [diff] [blame] | 19 | #endif // PDF_ENABLE_V8 |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 20 | |
| 21 | // Can't use gtest-provided main since we need to initialize partition |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 22 | // alloc before invoking any test, and add test environments. |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 23 | int main(int argc, char** argv) { |
Tom Sepez | ab959fa | 2023-07-27 22:49:28 +0000 | [diff] [blame] | 24 | #if defined(PDF_USE_PARTITION_ALLOC) |
Tom Sepez | f07f001 | 2023-07-29 01:26:26 +0000 | [diff] [blame] | 25 | pdfium::ConfigurePartitionAllocShimPartitionForTest(); |
Tom Sepez | ab959fa | 2023-07-27 22:49:28 +0000 | [diff] [blame] | 26 | #endif // defined(PDF_USE_PARTITION_ALLOC) |
| 27 | |
Tom Sepez | fa7f590 | 2022-08-15 23:10:45 +0000 | [diff] [blame] | 28 | FX_InitializeMemoryAllocators(); |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 29 | |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 30 | // PDF test environment will be deleted by gtest. |
| 31 | AddGlobalTestEnvironment(new PDFTestEnvironment()); |
| 32 | |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 33 | #ifdef PDF_ENABLE_V8 |
Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 34 | // V8 test environment will be deleted by gtest. |
| 35 | AddGlobalTestEnvironment(new V8TestEnvironment(argv[0])); |
Ryan Harrison | d60d7cb | 2018-06-01 15:28:54 +0000 | [diff] [blame] | 36 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 37 | // XFA test environment will be deleted by gtest. |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 38 | AddGlobalTestEnvironment(new XFATestEnvironment()); |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 39 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 40 | #endif // PDF_ENABLE_V8 |
Dan Sinclair | 574d440 | 2017-08-28 10:11:24 -0400 | [diff] [blame] | 41 | |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 42 | testing::InitGoogleTest(&argc, argv); |
| 43 | testing::InitGoogleMock(&argc, argv); |
Tom Sepez | 3f8ee5e | 2018-02-09 18:26:09 +0000 | [diff] [blame] | 44 | |
Tom Sepez | 2281853 | 2020-07-22 20:40:56 +0000 | [diff] [blame] | 45 | return RUN_ALL_TESTS(); |
Tom Sepez | 64ee2c3 | 2017-04-24 15:04:25 -0700 | [diff] [blame] | 46 | } |