OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MODULE_SYSTEM_TEST_H_ | 5 #ifndef CHROME_TEST_BASE_MODULE_SYSTEM_TEST_H_ |
6 #define CHROME_TEST_BASE_MODULE_SYSTEM_TEST_H_ | 6 #define CHROME_TEST_BASE_MODULE_SYSTEM_TEST_H_ |
7 | 7 |
8 #include "chrome/renderer/extensions/chrome_v8_context.h" | 8 #include "chrome/renderer/extensions/chrome_v8_context.h" |
9 #include "extensions/renderer/module_system.h" | 9 #include "extensions/renderer/module_system.h" |
10 #include "extensions/renderer/scoped_persistent.h" | 10 #include "extensions/renderer/scoped_persistent.h" |
| 11 #include "gin/public/context_holder.h" |
| 12 #include "gin/public/isolate_holder.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "v8/include/v8.h" | 14 #include "v8/include/v8.h" |
13 | 15 |
14 // Test fixture for testing JS that makes use of the module system. | 16 // Test fixture for testing JS that makes use of the module system. |
15 // | 17 // |
16 // Typically tests will look like: | 18 // Typically tests will look like: |
17 // | 19 // |
18 // TEST_F(MyModuleSystemTest, TestStuff) { | 20 // TEST_F(MyModuleSystemTest, TestStuff) { |
19 // ModuleSystem::NativesEnabledScope natives_enabled(module_system_.get()); | 21 // ModuleSystem::NativesEnabledScope natives_enabled(module_system_.get()); |
20 // RegisterModule("test", "requireNative('assert').AssertTrue(true);"); | 22 // RegisterModule("test", "requireNative('assert').AssertTrue(true);"); |
(...skipping 28 matching lines...) Expand all Loading... |
49 void RegisterTestFile(const std::string& module_name, | 51 void RegisterTestFile(const std::string& module_name, |
50 const std::string& file_name); | 52 const std::string& file_name); |
51 | 53 |
52 // Make the test fail if any asserts are called. By default a test will fail | 54 // Make the test fail if any asserts are called. By default a test will fail |
53 // if no asserts are called. | 55 // if no asserts are called. |
54 void ExpectNoAssertionsMade(); | 56 void ExpectNoAssertionsMade(); |
55 | 57 |
56 // Create an empty object in the global scope with name |name|. | 58 // Create an empty object in the global scope with name |name|. |
57 v8::Handle<v8::Object> CreateGlobal(const std::string& name); | 59 v8::Handle<v8::Object> CreateGlobal(const std::string& name); |
58 | 60 |
59 v8::Isolate* isolate_; | 61 gin::IsolateHolder isolate_holder_; |
| 62 gin::ContextHolder context_holder_; |
60 v8::HandleScope handle_scope_; | 63 v8::HandleScope handle_scope_; |
61 scoped_ptr<extensions::ChromeV8Context> context_; | 64 scoped_ptr<extensions::ChromeV8Context> context_; |
62 class AssertNatives; | 65 class AssertNatives; |
63 AssertNatives* assert_natives_; | 66 AssertNatives* assert_natives_; |
64 class StringSourceMap; | 67 class StringSourceMap; |
65 scoped_ptr<StringSourceMap> source_map_; | 68 scoped_ptr<StringSourceMap> source_map_; |
66 bool should_assertions_be_made_; | 69 bool should_assertions_be_made_; |
67 | 70 |
68 private: | 71 private: |
69 DISALLOW_COPY_AND_ASSIGN(ModuleSystemTest); | 72 DISALLOW_COPY_AND_ASSIGN(ModuleSystemTest); |
70 }; | 73 }; |
71 | 74 |
72 #endif // CHROME_TEST_BASE_MODULE_SYSTEM_TEST_H_ | 75 #endif // CHROME_TEST_BASE_MODULE_SYSTEM_TEST_H_ |
OLD | NEW |