| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_TEST_BASE_V8_UNIT_TEST_H_ | 5 #ifndef CHROME_TEST_BASE_V8_UNIT_TEST_H_ |
| 6 #define CHROME_TEST_BASE_V8_UNIT_TEST_H_ | 6 #define CHROME_TEST_BASE_V8_UNIT_TEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/strings/string_piece.h" | 12 #include "base/strings/string_piece.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
| 15 | 15 |
| 16 namespace base { |
| 17 class MessageLoop; |
| 18 } // namespace base |
| 19 |
| 16 // A superclass for unit tests that involve running JavaScript. This class | 20 // A superclass for unit tests that involve running JavaScript. This class |
| 17 // sets up V8 context and has methods that make it easy to execute scripts in | 21 // sets up V8 context and has methods that make it easy to execute scripts in |
| 18 // this context as well as call functions in the context. | 22 // this context as well as call functions in the context. |
| 19 class V8UnitTest : public testing::Test { | 23 class V8UnitTest : public testing::Test { |
| 20 public: | 24 public: |
| 21 V8UnitTest(); | 25 V8UnitTest(); |
| 22 ~V8UnitTest() override; | 26 ~V8UnitTest() override; |
| 23 | 27 |
| 24 // Methods from testing::Test. | 28 // Methods from testing::Test. |
| 25 void SetUp() override; | 29 void SetUp() override; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 void InitPathsAndLibraries(); | 79 void InitPathsAndLibraries(); |
| 76 | 80 |
| 77 // Handle scope that is used throughout the life of this class. | 81 // Handle scope that is used throughout the life of this class. |
| 78 v8::HandleScope handle_scope_; | 82 v8::HandleScope handle_scope_; |
| 79 | 83 |
| 80 // Context for the JavaScript in the test. | 84 // Context for the JavaScript in the test. |
| 81 v8::Persistent<v8::Context> context_; | 85 v8::Persistent<v8::Context> context_; |
| 82 | 86 |
| 83 // User added libraries. | 87 // User added libraries. |
| 84 std::vector<base::FilePath> user_libraries_; | 88 std::vector<base::FilePath> user_libraries_; |
| 89 |
| 90 std::unique_ptr<base::MessageLoop> loop_; |
| 85 }; | 91 }; |
| 86 | 92 |
| 87 #endif // CHROME_TEST_BASE_V8_UNIT_TEST_H_ | 93 #endif // CHROME_TEST_BASE_V8_UNIT_TEST_H_ |
| OLD | NEW |