blob: 0b62dbff2b41a426ba29662455125c02ccb6c23b [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 the V8 project 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 "include/libplatform/libplatform.h"
6#include "include/v8.h"
7#include "src/base/compiler-specific.h"
8#include "testing/gmock/include/gmock/gmock.h"
9
10namespace {
11
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000012class DefaultPlatformEnvironment final : public ::testing::Environment {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000013 public:
14 DefaultPlatformEnvironment() : platform_(NULL) {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000015
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000016 void SetUp() override {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000017 EXPECT_EQ(NULL, platform_);
18 platform_ = v8::platform::CreateDefaultPlatform();
19 ASSERT_TRUE(platform_ != NULL);
20 v8::V8::InitializePlatform(platform_);
21 ASSERT_TRUE(v8::V8::Initialize());
22 }
23
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000024 void TearDown() override {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000025 ASSERT_TRUE(platform_ != NULL);
26 v8::V8::Dispose();
27 v8::V8::ShutdownPlatform();
28 delete platform_;
29 platform_ = NULL;
30 }
31
32 private:
33 v8::Platform* platform_;
34};
35
36} // namespace
37
38
39int main(int argc, char** argv) {
40 testing::InitGoogleMock(&argc, argv);
41 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment);
42 v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000043 v8::V8::InitializeExternalStartupData(argv[0]);
Ben Murdochb8a8cc12014-11-26 15:28:44 +000044 return RUN_ALL_TESTS();
45}