Avi Drissman | 468e51b6 | 2022-09-13 20:47:01 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef GIN_TEST_V8_TEST_H_ | ||||
6 | #define GIN_TEST_V8_TEST_H_ | ||||
7 | |||||
mostynb | c862da8 | 2016-04-03 15:54:33 | [diff] [blame] | 8 | #include <memory> |
9 | |||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 10 | #include "base/compiler_specific.h" |
Gabriel Charette | c710874 | 2019-08-23 03:31:40 | [diff] [blame] | 11 | #include "base/test/task_environment.h" |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 12 | #include "testing/gtest/include/gtest/gtest.h" |
Dan Elphick | 05acd60 | 2021-08-30 15:22:07 | [diff] [blame] | 13 | #include "v8/include/v8-forward.h" |
14 | #include "v8/include/v8-persistent-handle.h" | ||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 15 | |
16 | namespace gin { | ||||
17 | |||||
[email protected] | f04b0e9 | 2013-11-22 14:20:55 | [diff] [blame] | 18 | class IsolateHolder; |
[email protected] | 1b93c23 | 2013-11-19 19:25:12 | [diff] [blame] | 19 | |
[email protected] | 60531d5 | 2013-11-27 02:10:15 | [diff] [blame] | 20 | // V8Test is a simple harness for testing interactions with V8. V8Test doesn't |
21 | // have any dependencies on Gin's module system. | ||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 22 | class V8Test : public testing::Test { |
23 | public: | ||||
24 | V8Test(); | ||||
Daniel Hosseinian | 68c0798d | 2021-04-16 08:16:07 | [diff] [blame] | 25 | V8Test(const V8Test&) = delete; |
26 | V8Test& operator=(const V8Test&) = delete; | ||||
dcheng | d013972 | 2014-12-29 22:58:20 | [diff] [blame] | 27 | ~V8Test() override; |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 28 | |
dcheng | d013972 | 2014-12-29 22:58:20 | [diff] [blame] | 29 | void SetUp() override; |
30 | void TearDown() override; | ||||
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 31 | |
32 | protected: | ||||
Ulan Degenbaev | dc12d16a | 2018-09-06 15:12:16 | [diff] [blame] | 33 | // This is used during SetUp() to initialize instance_. |
34 | virtual std::unique_ptr<IsolateHolder> CreateIsolateHolder() const; | ||||
Ulan Degenbaev | 4f2f1a1 | 2019-09-24 14:42:57 | [diff] [blame] | 35 | base::test::TaskEnvironment task_environment_; |
mostynb | c862da8 | 2016-04-03 15:54:33 | [diff] [blame] | 36 | std::unique_ptr<IsolateHolder> instance_; |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 37 | v8::Persistent<v8::Context> context_; |
[email protected] | a22998a | 2013-11-10 05:00:50 | [diff] [blame] | 38 | }; |
39 | |||||
40 | } // namespace gin | ||||
41 | |||||
42 | #endif // GIN_TEST_V8_TEST_H_ |