| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/libplatform/libplatform.h" | 5 #include "include/libplatform/libplatform.h" |
| 6 #include "include/v8.h" | 6 #include "include/v8.h" |
| 7 #include "src/base/compiler-specific.h" | 7 #include "src/base/compiler-specific.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 class DefaultPlatformEnvironment final : public ::testing::Environment { | 12 class DefaultPlatformEnvironment final : public ::testing::Environment { |
| 13 public: | 13 public: |
| 14 DefaultPlatformEnvironment() : platform_(NULL) {} | 14 DefaultPlatformEnvironment() : platform_(NULL) {} |
| 15 ~DefaultPlatformEnvironment() {} | |
| 16 | 15 |
| 17 virtual void SetUp() override { | 16 void SetUp() override { |
| 18 EXPECT_EQ(NULL, platform_); | 17 EXPECT_EQ(NULL, platform_); |
| 19 platform_ = v8::platform::CreateDefaultPlatform(); | 18 platform_ = v8::platform::CreateDefaultPlatform(); |
| 20 ASSERT_TRUE(platform_ != NULL); | 19 ASSERT_TRUE(platform_ != NULL); |
| 21 v8::V8::InitializePlatform(platform_); | 20 v8::V8::InitializePlatform(platform_); |
| 22 ASSERT_TRUE(v8::V8::Initialize()); | 21 ASSERT_TRUE(v8::V8::Initialize()); |
| 23 } | 22 } |
| 24 | 23 |
| 25 virtual void TearDown() override { | 24 void TearDown() override { |
| 26 ASSERT_TRUE(platform_ != NULL); | 25 ASSERT_TRUE(platform_ != NULL); |
| 27 v8::V8::Dispose(); | 26 v8::V8::Dispose(); |
| 28 v8::V8::ShutdownPlatform(); | 27 v8::V8::ShutdownPlatform(); |
| 29 delete platform_; | 28 delete platform_; |
| 30 platform_ = NULL; | 29 platform_ = NULL; |
| 31 } | 30 } |
| 32 | 31 |
| 33 private: | 32 private: |
| 34 v8::Platform* platform_; | 33 v8::Platform* platform_; |
| 35 }; | 34 }; |
| 36 | 35 |
| 37 } // namespace | 36 } // namespace |
| 38 | 37 |
| 39 | 38 |
| 40 int main(int argc, char** argv) { | 39 int main(int argc, char** argv) { |
| 41 testing::InitGoogleMock(&argc, argv); | 40 testing::InitGoogleMock(&argc, argv); |
| 42 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment); | 41 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment); |
| 43 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 42 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
| 44 v8::V8::InitializeExternalStartupData(argv[0]); | 43 v8::V8::InitializeExternalStartupData(argv[0]); |
| 45 return RUN_ALL_TESTS(); | 44 return RUN_ALL_TESTS(); |
| 46 } | 45 } |
| OLD | NEW |