xref: /aosp_15_r20/external/pdfium/testing/embedder_test_main.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2018 The PDFium Authors
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 "build/build_config.h"
6 #include "core/fxcrt/fx_memory.h"
7 #include "testing/embedder_test_environment.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 
11 #ifdef PDF_ENABLE_V8
12 #include "testing/v8_test_environment.h"
13 #endif  // PDF_ENABLE_V8
14 
15 #if defined(PDF_USE_PARTITION_ALLOC)
16 #include "testing/allocator_shim_config.h"
17 #endif
18 
19 // Can't use gtest-provided main since we need to create our own
20 // testing environment which needs the executable path in order to
21 // find the external V8 binary data files.
main(int argc,char ** argv)22 int main(int argc, char** argv) {
23 #if defined(PDF_USE_PARTITION_ALLOC)
24   pdfium::ConfigurePartitionAllocShimPartitionForTest();
25 #endif
26 
27   FX_InitializeMemoryAllocators();
28 
29 #ifdef PDF_ENABLE_V8
30   // The env will be deleted by gtest.
31   AddGlobalTestEnvironment(new V8TestEnvironment(argv[0]));
32 #endif  // PDF_ENABLE_V8
33 
34   // The env will be deleted by gtest.
35   AddGlobalTestEnvironment(new EmbedderTestEnvironment);
36 
37   testing::InitGoogleTest(&argc, argv);
38   testing::InitGoogleMock(&argc, argv);
39 
40   // Anything remaining in argc/argv is an embedder_tests flag.
41   EmbedderTestEnvironment::GetInstance()->AddFlags(argc, argv);
42 
43   return RUN_ALL_TESTS();
44 }
45