OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium 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 #ifndef EXTENSIONS_RENDERER_API_BINDING_TEST_H_ | 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_TEST_H_ |
6 #define EXTENSIONS_RENDERER_API_BINDING_TEST_H_ | 6 #define EXTENSIONS_RENDERER_API_BINDING_TEST_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "v8/include/v8.h" | 13 #include "v8/include/v8.h" |
14 | 14 |
15 namespace gin { | 15 namespace gin { |
16 class ContextHolder; | 16 class ContextHolder; |
17 class IsolateHolder; | 17 class IsolateHolder; |
18 } | 18 } |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 // A common unit test class for testing API bindings. Creates an isolate and an | 22 // A common unit test class for testing API bindings. Creates an isolate and an |
23 // initial v8 context, and checks for v8 leaks at the end of the test. | 23 // initial v8 context, and checks for v8 leaks at the end of the test. |
24 class APIBindingTest : public testing::Test { | 24 class APIBindingTest : public testing::Test { |
25 protected: | 25 protected: |
26 APIBindingTest(); | 26 APIBindingTest(); |
27 ~APIBindingTest() override; | 27 ~APIBindingTest() override; |
28 | 28 |
| 29 // Returns the V8 ExtensionConfiguration to use for contexts. The default |
| 30 // implementation returns null. |
| 31 virtual v8::ExtensionConfiguration* GetV8ExtensionConfiguration(); |
| 32 |
29 // testing::Test: | 33 // testing::Test: |
30 void SetUp() override; | 34 void SetUp() override; |
31 void TearDown() override; | 35 void TearDown() override; |
32 | 36 |
33 v8::Local<v8::Context> ContextLocal(); | 37 v8::Local<v8::Context> ContextLocal(); |
34 void DisposeContext(); | 38 void DisposeContext(); |
35 | 39 |
36 // Returns the associated isolate. Defined out-of-line to avoid the include | 40 // Returns the associated isolate. Defined out-of-line to avoid the include |
37 // for IsolateHolder in the header. | 41 // for IsolateHolder in the header. |
38 v8::Isolate* isolate(); | 42 v8::Isolate* isolate(); |
39 | 43 |
40 private: | 44 private: |
41 base::MessageLoop message_loop_; | 45 base::MessageLoop message_loop_; |
42 std::unique_ptr<gin::IsolateHolder> isolate_holder_; | 46 std::unique_ptr<gin::IsolateHolder> isolate_holder_; |
43 std::unique_ptr<gin::ContextHolder> context_holder_; | 47 std::unique_ptr<gin::ContextHolder> context_holder_; |
44 | 48 |
45 DISALLOW_COPY_AND_ASSIGN(APIBindingTest); | 49 DISALLOW_COPY_AND_ASSIGN(APIBindingTest); |
46 }; | 50 }; |
47 | 51 |
48 } // namespace extensions | 52 } // namespace extensions |
49 | 53 |
50 #endif // EXTENSIONS_RENDERER_API_BINDING_TEST_H_ | 54 #endif // EXTENSIONS_RENDERER_API_BINDING_TEST_H_ |
OLD | NEW |