• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 #include <memory>
6 #include <string>
7 
8 #include "core/fxcrt/fx_memory.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/test_support.h"
12 
13 #ifdef PDF_ENABLE_V8
14 #include "testing/v8_initializer.h"
15 #include "v8/include/v8-platform.h"
16 #include "v8/include/v8.h"
17 #endif  // PDF_ENABLE_V8
18 
19 #ifdef PDF_ENABLE_XFA
20 #include "testing/xfa_unit_test_support.h"
21 #endif  // PDF_ENABLE_XFA
22 
23 // Can't use gtest-provided main since we need to initialize partition
24 // alloc before invoking any test.
main(int argc,char ** argv)25 int main(int argc, char** argv) {
26   FXMEM_InitializePartitionAlloc();
27 
28 #ifdef PDF_ENABLE_V8
29   std::unique_ptr<v8::Platform> platform;
30 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
31   static v8::StartupData* snapshot = new v8::StartupData;
32   platform =
33       InitializeV8ForPDFiumWithStartupData(argv[0], std::string(), snapshot);
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 
39   InitializePDFTestEnvironment();
40 #ifdef PDF_ENABLE_XFA
41   InitializeXFATestEnvironment();
42 #endif  // PDF_ENABLE_XFA
43 
44   testing::InitGoogleTest(&argc, argv);
45   testing::InitGoogleMock(&argc, argv);
46 
47   int ret_val = RUN_ALL_TESTS();
48 
49   DestroyPDFTestEnvironment();
50   // NOTE: XFA test environment, if present, destroyed by gtest.
51 
52 #ifdef PDF_ENABLE_V8
53   v8::V8::ShutdownPlatform();
54 #endif  // PDF_ENABLE_V8
55 
56   return ret_val;
57 }
58