1 // 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 10 namespace { 11 12 class DefaultPlatformEnvironment final : public ::testing::Environment { 13 public: DefaultPlatformEnvironment()14 DefaultPlatformEnvironment() : platform_(NULL) {} 15 SetUp()16 void SetUp() override { 17 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 TearDown()24 void TearDown() override { 25 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 main(int argc,char ** argv)39int main(int argc, char** argv) { 40 testing::InitGoogleMock(&argc, argv); 41 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment); 42 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); 43 v8::V8::InitializeExternalStartupData(argv[0]); 44 return RUN_ALL_TESTS(); 45 } 46