OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "extensions/renderer/module_system_test.h" | 6 #include "extensions/renderer/module_system_test.h" |
7 #include "gin/dictionary.h" | 7 #include "gin/dictionary.h" |
8 #include "grit/extensions_renderer_resources.h" | 8 #include "grit/extensions_renderer_resources.h" |
9 | 9 |
10 namespace extensions { | 10 namespace extensions { |
11 namespace { | 11 namespace { |
12 | 12 |
13 class UtilsUnittest : public ModuleSystemTest { | 13 class UtilsUnittest : public ModuleSystemTest { |
14 private: | 14 private: |
15 void SetUp() override { | 15 void SetUp() override { |
16 ModuleSystemTest::SetUp(); | 16 ModuleSystemTest::SetUp(); |
17 | 17 |
18 env()->RegisterModule("utils", IDR_UTILS_JS); | 18 env()->RegisterModule("utils", IDR_UTILS_JS); |
19 env()->RegisterTestFile("utils_unittest", "utils_unittest.js"); | 19 env()->RegisterTestFile("utils_unittest", "utils_unittest.js"); |
20 env()->OverrideNativeHandler("schema_registry", | 20 env()->OverrideNativeHandler("schema_registry", |
21 "exports.GetSchema = function() {};"); | 21 "exports.$set('GetSchema', function() {});"); |
22 env()->OverrideNativeHandler("logging", | 22 env()->OverrideNativeHandler("logging", |
23 "exports.CHECK = function() {};\n" | 23 "exports.$set('CHECK', function() {});\n" |
24 "exports.DCHECK = function() {};\n" | 24 "exports.$set('DCHECK', function() {});\n" |
25 "exports.WARNING = function() {};"); | 25 "exports.$set('WARNING', function() {});"); |
26 env()->OverrideNativeHandler("v8_context", ""); | 26 env()->OverrideNativeHandler("v8_context", ""); |
27 gin::Dictionary chrome(env()->isolate(), env()->CreateGlobal("chrome")); | 27 gin::Dictionary chrome(env()->isolate(), env()->CreateGlobal("chrome")); |
28 gin::Dictionary chrome_runtime( | 28 gin::Dictionary chrome_runtime( |
29 gin::Dictionary::CreateEmpty(env()->isolate())); | 29 gin::Dictionary::CreateEmpty(env()->isolate())); |
30 chrome.Set("runtime", chrome_runtime); | 30 chrome.Set("runtime", chrome_runtime); |
31 } | 31 } |
32 }; | 32 }; |
33 | 33 |
34 TEST_F(UtilsUnittest, TestNothing) { | 34 TEST_F(UtilsUnittest, TestNothing) { |
35 ExpectNoAssertionsMade(); | 35 ExpectNoAssertionsMade(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 TEST_F(UtilsUnittest, PromiseError) { | 68 TEST_F(UtilsUnittest, PromiseError) { |
69 ModuleSystem::NativesEnabledScope natives_enabled_scope( | 69 ModuleSystem::NativesEnabledScope natives_enabled_scope( |
70 env()->module_system()); | 70 env()->module_system()); |
71 env()->module_system()->CallModuleMethod("utils_unittest", | 71 env()->module_system()->CallModuleMethod("utils_unittest", |
72 "testPromiseError"); | 72 "testPromiseError"); |
73 RunResolvedPromises(); | 73 RunResolvedPromises(); |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 } // namespace extensions | 77 } // namespace extensions |
OLD | NEW |