OLD | NEW |
| (Empty) |
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 "src/isolate-inl.h" | |
7 #include "test/runtime-unittests/runtime-unittests.h" | |
8 #include "testing/gmock/include/gmock/gmock.h" | |
9 | |
10 using testing::IsNull; | |
11 using testing::NotNull; | |
12 | |
13 namespace v8 { | |
14 namespace internal { | |
15 | |
16 // static | |
17 v8::Isolate* RuntimeTest::isolate_ = NULL; | |
18 | |
19 | |
20 RuntimeTest::RuntimeTest() | |
21 : isolate_scope_(isolate_), handle_scope_(isolate_), zone_(isolate()) {} | |
22 | |
23 | |
24 RuntimeTest::~RuntimeTest() {} | |
25 | |
26 | |
27 Factory* RuntimeTest::factory() const { return isolate()->factory(); } | |
28 | |
29 | |
30 Heap* RuntimeTest::heap() const { return isolate()->heap(); } | |
31 | |
32 | |
33 // static | |
34 void RuntimeTest::SetUpTestCase() { | |
35 Test::SetUpTestCase(); | |
36 EXPECT_THAT(isolate_, IsNull()); | |
37 isolate_ = v8::Isolate::New(); | |
38 ASSERT_THAT(isolate_, NotNull()); | |
39 } | |
40 | |
41 | |
42 // static | |
43 void RuntimeTest::TearDownTestCase() { | |
44 ASSERT_THAT(isolate_, NotNull()); | |
45 isolate_->Dispose(); | |
46 isolate_ = NULL; | |
47 Test::TearDownTestCase(); | |
48 } | |
49 | |
50 } // namespace internal | |
51 } // namespace v8 | |
52 | |
53 | |
54 namespace { | |
55 | |
56 class RuntimeTestEnvironment V8_FINAL : public ::testing::Environment { | |
57 public: | |
58 RuntimeTestEnvironment() : platform_(NULL) {} | |
59 virtual ~RuntimeTestEnvironment() {} | |
60 | |
61 virtual void SetUp() V8_OVERRIDE { | |
62 EXPECT_THAT(platform_, IsNull()); | |
63 platform_ = v8::platform::CreateDefaultPlatform(); | |
64 v8::V8::InitializePlatform(platform_); | |
65 ASSERT_TRUE(v8::V8::Initialize()); | |
66 } | |
67 | |
68 virtual void TearDown() V8_OVERRIDE { | |
69 ASSERT_THAT(platform_, NotNull()); | |
70 v8::V8::Dispose(); | |
71 v8::V8::ShutdownPlatform(); | |
72 delete platform_; | |
73 platform_ = NULL; | |
74 } | |
75 | |
76 private: | |
77 v8::Platform* platform_; | |
78 }; | |
79 | |
80 } // namespace | |
81 | |
82 | |
83 int main(int argc, char** argv) { | |
84 testing::InitGoogleMock(&argc, argv); | |
85 testing::AddGlobalTestEnvironment(new RuntimeTestEnvironment); | |
86 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); | |
87 return RUN_ALL_TESTS(); | |
88 } | |
OLD | NEW |