blob: 44918fceb6634b456c15670ab3f76368198fc5d3 [file] [log] [blame]
Tom Sepez64ee2c32017-04-24 15:04:25 -07001// 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 Sinclair574d4402017-08-28 10:11:24 -04005#include <memory>
Tom Sepez3f8ee5e2018-02-09 18:26:09 +00006#include <string>
Dan Sinclair574d4402017-08-28 10:11:24 -04007
Tom Sepez64ee2c32017-04-24 15:04:25 -07008#include "core/fxcrt/fx_memory.h"
9#include "testing/gmock/include/gmock/gmock.h"
10#include "testing/gtest/include/gtest/gtest.h"
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000011
Ryan Harrison4f21d772018-06-01 15:19:04 +000012#ifdef PDF_ENABLE_V8
Lei Zhang72e8b692019-02-05 19:16:52 +000013#include "testing/v8_initializer.h"
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000014#include "v8/include/v8-platform.h"
15#include "v8/include/v8.h"
Ryan Harrison4f21d772018-06-01 15:19:04 +000016#endif // PDF_ENABLE_V8
Tom Sepez64ee2c32017-04-24 15:04:25 -070017
Ryan Harrisond60d7cb2018-06-01 15:28:54 +000018#ifdef PDF_ENABLE_XFA
Lei Zhang220ef3d2019-02-05 20:40:54 +000019#include "testing/xfa_unit_test_support.h"
Dan Sinclair574d4402017-08-28 10:11:24 -040020#endif // PDF_ENABLE_XFA
21
Tom Sepez64ee2c32017-04-24 15:04:25 -070022// Can't use gtest-provided main since we need to initialize partition
23// alloc before invoking any test.
24int main(int argc, char** argv) {
Dan Sinclairdbc3d3e2017-05-11 13:41:38 -040025 FXMEM_InitializePartitionAlloc();
Dan Sinclair574d4402017-08-28 10:11:24 -040026
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000027#ifdef PDF_ENABLE_V8
28 std::unique_ptr<v8::Platform> platform;
Nico Weber611431d2018-02-26 20:36:16 +000029#ifdef V8_USE_EXTERNAL_STARTUP_DATA
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000030 static v8::StartupData* natives = new v8::StartupData;
31 static v8::StartupData* snapshot = new v8::StartupData;
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000032 platform = InitializeV8ForPDFiumWithStartupData(argv[0], std::string(),
33 natives, 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
Ryan Harrisond60d7cb2018-06-01 15:28:54 +000039#ifdef PDF_ENABLE_XFA
Lei Zhang220ef3d2019-02-05 20:40:54 +000040 InitializeXFATestEnvironment();
Dan Sinclair574d4402017-08-28 10:11:24 -040041#endif // PDF_ENABLE_XFA
42
Tom Sepez64ee2c32017-04-24 15:04:25 -070043 testing::InitGoogleTest(&argc, argv);
44 testing::InitGoogleMock(&argc, argv);
Tom Sepez3f8ee5e2018-02-09 18:26:09 +000045
46 int ret_val = RUN_ALL_TESTS();
47
48#ifdef PDF_ENABLE_V8
49 v8::V8::ShutdownPlatform();
50#endif // PDF_ENABLE_V8
51
52 return ret_val;
Tom Sepez64ee2c32017-04-24 15:04:25 -070053}