blob: 28476b032da840c60221de486eff7c383124d78b [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2017 The PDFium Authors
Tom Sepez64ee2c32017-04-24 15:04:25 -07002// 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 Sepez22818532020-07-22 20:40:56 +00008#include "testing/pdf_test_environment.h"
Tom Sepez3f8ee5e2018-02-09 18:26:09 +00009
Tom Sepezab959fa2023-07-27 22:49:28 +000010#if defined(PDF_USE_PARTITION_ALLOC)
Tom Sepezf07f0012023-07-29 01:26:26 +000011#include "testing/allocator_shim_config.h"
Tom Sepezab959fa2023-07-27 22:49:28 +000012#endif
13
Ryan Harrison4f21d772018-06-01 15:19:04 +000014#ifdef PDF_ENABLE_V8
Tom Sepezeaf9d212020-07-22 16:24:00 +000015#include "testing/v8_test_environment.h"
Tom Sepez22818532020-07-22 20:40:56 +000016#ifdef PDF_ENABLE_XFA
17#include "testing/xfa_test_environment.h"
18#endif // PDF_ENABLE_XFA
Ryan Harrison4f21d772018-06-01 15:19:04 +000019#endif // PDF_ENABLE_V8
Tom Sepez64ee2c32017-04-24 15:04:25 -070020
21// Can't use gtest-provided main since we need to initialize partition
Tom Sepez22818532020-07-22 20:40:56 +000022// alloc before invoking any test, and add test environments.
Tom Sepez64ee2c32017-04-24 15:04:25 -070023int main(int argc, char** argv) {
Tom Sepezab959fa2023-07-27 22:49:28 +000024#if defined(PDF_USE_PARTITION_ALLOC)
Tom Sepezf07f0012023-07-29 01:26:26 +000025 pdfium::ConfigurePartitionAllocShimPartitionForTest();
Tom Sepezab959fa2023-07-27 22:49:28 +000026#endif // defined(PDF_USE_PARTITION_ALLOC)
27
Tom Sepezfa7f5902022-08-15 23:10:45 +000028 FX_InitializeMemoryAllocators();
Dan Sinclair574d4402017-08-28 10:11:24 -040029
Tom Sepez22818532020-07-22 20:40:56 +000030 // PDF test environment will be deleted by gtest.
31 AddGlobalTestEnvironment(new PDFTestEnvironment());
32
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000033#ifdef PDF_ENABLE_V8
Tom Sepezeaf9d212020-07-22 16:24:00 +000034 // V8 test environment will be deleted by gtest.
35 AddGlobalTestEnvironment(new V8TestEnvironment(argv[0]));
Ryan Harrisond60d7cb2018-06-01 15:28:54 +000036#ifdef PDF_ENABLE_XFA
Tom Sepezeaf9d212020-07-22 16:24:00 +000037 // XFA test environment will be deleted by gtest.
Tom Sepez22818532020-07-22 20:40:56 +000038 AddGlobalTestEnvironment(new XFATestEnvironment());
Dan Sinclair574d4402017-08-28 10:11:24 -040039#endif // PDF_ENABLE_XFA
Tom Sepez22818532020-07-22 20:40:56 +000040#endif // PDF_ENABLE_V8
Dan Sinclair574d4402017-08-28 10:11:24 -040041
Tom Sepez64ee2c32017-04-24 15:04:25 -070042 testing::InitGoogleTest(&argc, argv);
43 testing::InitGoogleMock(&argc, argv);
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000044
Tom Sepez22818532020-07-22 20:40:56 +000045 return RUN_ALL_TESTS();
Tom Sepez64ee2c32017-04-24 15:04:25 -070046}