Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: extensions/renderer/json_schema_unittest.cc

Issue 2936213002: [Extensions] Don't require() a module for calling a method (Closed)
Patch Set: lazyboy's Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/api_test_base.cc ('k') | extensions/renderer/module_system.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "extensions/grit/extensions_renderer_resources.h" 5 #include "extensions/grit/extensions_renderer_resources.h"
6 #include "extensions/renderer/module_system_test.h" 6 #include "extensions/renderer/module_system_test.h"
7 #include "extensions/renderer/v8_schema_registry.h" 7 #include "extensions/renderer/v8_schema_registry.h"
8 #include "gin/dictionary.h" 8 #include "gin/dictionary.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 class JsonSchemaTest : public ModuleSystemTest { 12 class JsonSchemaTest : public ModuleSystemTest {
13 public: 13 public:
14 void SetUp() override { 14 void SetUp() override {
15 ModuleSystemTest::SetUp(); 15 ModuleSystemTest::SetUp();
16 16
17 env()->RegisterModule("json_schema", IDR_JSON_SCHEMA_JS); 17 env()->RegisterModule("json_schema", IDR_JSON_SCHEMA_JS);
18 env()->RegisterModule("utils", IDR_UTILS_JS); 18 env()->RegisterModule("utils", IDR_UTILS_JS);
19 19
20 env()->module_system()->RegisterNativeHandler( 20 env()->module_system()->RegisterNativeHandler(
21 "schema_registry", schema_registry_.AsNativeHandler()); 21 "schema_registry", schema_registry_.AsNativeHandler());
22 22
23 env()->RegisterTestFile("json_schema_test", "json_schema_test.js"); 23 env()->RegisterTestFile("json_schema_test", "json_schema_test.js");
24 } 24 }
25 25
26 protected: 26 protected:
27 void TestFunction(const std::string& test_name) { 27 void TestFunction(const std::string& test_name) {
28 {
29 ModuleSystem::NativesEnabledScope natives_enabled_scope(
30 env()->module_system());
31 ASSERT_FALSE(env()
32 ->module_system()
33 ->Require("json_schema_test")
34 .ToLocalChecked()
35 .IsEmpty());
36 }
28 env()->module_system()->CallModuleMethodSafe("json_schema_test", test_name); 37 env()->module_system()->CallModuleMethodSafe("json_schema_test", test_name);
29 } 38 }
30 39
31 private: 40 private:
32 V8SchemaRegistry schema_registry_; 41 V8SchemaRegistry schema_registry_;
33 }; 42 };
34 43
35 TEST_F(JsonSchemaTest, TestFormatError) { 44 TEST_F(JsonSchemaTest, TestFormatError) {
36 TestFunction("testFormatError"); 45 TestFunction("testFormatError");
37 } 46 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 111
103 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) { 112 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) {
104 TestFunction("testCheckSchemaOverlap"); 113 TestFunction("testCheckSchemaOverlap");
105 } 114 }
106 115
107 TEST_F(JsonSchemaTest, TestInstanceOf) { 116 TEST_F(JsonSchemaTest, TestInstanceOf) {
108 TestFunction("testInstanceOf"); 117 TestFunction("testInstanceOf");
109 } 118 }
110 119
111 } // namespace extensions 120 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api_test_base.cc ('k') | extensions/renderer/module_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698