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 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 10 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
11 #include "src/startup-data-util.h" | 11 #include "src/startup-data-util.h" |
12 #endif // V8_USE_EXTERNAL_STARTUP_DATA | 12 #endif // V8_USE_EXTERNAL_STARTUP_DATA |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class DefaultPlatformEnvironment FINAL : public ::testing::Environment { | 16 class DefaultPlatformEnvironment final : public ::testing::Environment { |
17 public: | 17 public: |
18 DefaultPlatformEnvironment() : platform_(NULL) {} | 18 DefaultPlatformEnvironment() : platform_(NULL) {} |
19 ~DefaultPlatformEnvironment() {} | 19 ~DefaultPlatformEnvironment() {} |
20 | 20 |
21 virtual void SetUp() OVERRIDE { | 21 virtual void SetUp() override { |
22 EXPECT_EQ(NULL, platform_); | 22 EXPECT_EQ(NULL, platform_); |
23 platform_ = v8::platform::CreateDefaultPlatform(); | 23 platform_ = v8::platform::CreateDefaultPlatform(); |
24 ASSERT_TRUE(platform_ != NULL); | 24 ASSERT_TRUE(platform_ != NULL); |
25 v8::V8::InitializePlatform(platform_); | 25 v8::V8::InitializePlatform(platform_); |
26 ASSERT_TRUE(v8::V8::Initialize()); | 26 ASSERT_TRUE(v8::V8::Initialize()); |
27 } | 27 } |
28 | 28 |
29 virtual void TearDown() OVERRIDE { | 29 virtual void TearDown() override { |
30 ASSERT_TRUE(platform_ != NULL); | 30 ASSERT_TRUE(platform_ != NULL); |
31 v8::V8::Dispose(); | 31 v8::V8::Dispose(); |
32 v8::V8::ShutdownPlatform(); | 32 v8::V8::ShutdownPlatform(); |
33 delete platform_; | 33 delete platform_; |
34 platform_ = NULL; | 34 platform_ = NULL; |
35 } | 35 } |
36 | 36 |
37 private: | 37 private: |
38 v8::Platform* platform_; | 38 v8::Platform* platform_; |
39 }; | 39 }; |
40 | 40 |
41 } // namespace | 41 } // namespace |
42 | 42 |
43 | 43 |
44 int main(int argc, char** argv) { | 44 int main(int argc, char** argv) { |
45 testing::InitGoogleMock(&argc, argv); | 45 testing::InitGoogleMock(&argc, argv); |
46 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment); | 46 testing::AddGlobalTestEnvironment(new DefaultPlatformEnvironment); |
47 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | 47 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); |
48 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 48 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
49 v8::StartupDataHandler startup_data(argv[0], NULL, NULL); | 49 v8::StartupDataHandler startup_data(argv[0], NULL, NULL); |
50 #endif | 50 #endif |
51 return RUN_ALL_TESTS(); | 51 return RUN_ALL_TESTS(); |
52 } | 52 } |
OLD | NEW |