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

Side by Side Diff: chrome/browser/extensions/native_bindings_apitest.cc

Issue 2847313002: Update some host_resolver()->AddRules in chrome/browser. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 9 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
10 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 10 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
(...skipping 28 matching lines...) Expand all
39 // which are the only APIs that are prefixed twice. 39 // which are the only APIs that are prefixed twice.
40 command_line->AppendSwitchASCII( 40 command_line->AppendSwitchASCII(
41 switches::kWhitelistedExtensionID, 41 switches::kWhitelistedExtensionID,
42 "ddchlicdkolnonkihahngkmmmjnjlkkf"); 42 "ddchlicdkolnonkihahngkmmmjnjlkkf");
43 // Note: We don't use a FeatureSwitch::ScopedOverride here because we need 43 // Note: We don't use a FeatureSwitch::ScopedOverride here because we need
44 // the switch to be propogated to the renderer, which doesn't happen with 44 // the switch to be propogated to the renderer, which doesn't happen with
45 // a ScopedOverride. 45 // a ScopedOverride.
46 command_line->AppendSwitchASCII(switches::kNativeCrxBindings, "1"); 46 command_line->AppendSwitchASCII(switches::kNativeCrxBindings, "1");
47 } 47 }
48 48
49 void SetUpOnMainThread() override {
50 ExtensionApiTest::SetUpOnMainThread();
51 host_resolver()->AddRule("*", "127.0.0.1");
52 }
53
49 private: 54 private:
50 DISALLOW_COPY_AND_ASSIGN(NativeBindingsApiTest); 55 DISALLOW_COPY_AND_ASSIGN(NativeBindingsApiTest);
51 }; 56 };
52 57
53 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, SimpleEndToEndTest) { 58 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, SimpleEndToEndTest) {
54 host_resolver()->AddRule("*", "127.0.0.1");
55 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_); 59 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_);
56 ASSERT_TRUE(StartEmbeddedTestServer()); 60 ASSERT_TRUE(StartEmbeddedTestServer());
57 ASSERT_TRUE(RunExtensionTest("native_bindings/extension")) << message_; 61 ASSERT_TRUE(RunExtensionTest("native_bindings/extension")) << message_;
58 } 62 }
59 63
60 // A simplistic app test for app-specific APIs. 64 // A simplistic app test for app-specific APIs.
61 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, SimpleAppTest) { 65 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, SimpleAppTest) {
62 ExtensionTestMessageListener ready_listener("ready", true); 66 ExtensionTestMessageListener ready_listener("ready", true);
63 ASSERT_TRUE(RunPlatformAppTest("native_bindings/platform_app")) << message_; 67 ASSERT_TRUE(RunPlatformAppTest("native_bindings/platform_app")) << message_;
64 ASSERT_TRUE(ready_listener.WaitUntilSatisfied()); 68 ASSERT_TRUE(ready_listener.WaitUntilSatisfied());
65 69
66 // On reply, the extension will try to close the app window and send a 70 // On reply, the extension will try to close the app window and send a
67 // message. 71 // message.
68 ExtensionTestMessageListener close_listener(false); 72 ExtensionTestMessageListener close_listener(false);
69 ready_listener.Reply(std::string()); 73 ready_listener.Reply(std::string());
70 ASSERT_TRUE(close_listener.WaitUntilSatisfied()); 74 ASSERT_TRUE(close_listener.WaitUntilSatisfied());
71 EXPECT_EQ("success", close_listener.message()); 75 EXPECT_EQ("success", close_listener.message());
72 } 76 }
73 77
74 // Tests the declarativeContent API and declarative events. 78 // Tests the declarativeContent API and declarative events.
75 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, DeclarativeEvents) { 79 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, DeclarativeEvents) {
76 host_resolver()->AddRule("*", "127.0.0.1");
77 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_); 80 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_);
78 ASSERT_TRUE(StartEmbeddedTestServer()); 81 ASSERT_TRUE(StartEmbeddedTestServer());
79 // Load an extension and wait for it to be ready. 82 // Load an extension and wait for it to be ready.
80 ExtensionTestMessageListener listener("ready", false); 83 ExtensionTestMessageListener listener("ready", false);
81 const Extension* extension = LoadExtension( 84 const Extension* extension = LoadExtension(
82 test_data_dir_.AppendASCII("native_bindings/declarative_content")); 85 test_data_dir_.AppendASCII("native_bindings/declarative_content"));
83 ASSERT_TRUE(extension); 86 ASSERT_TRUE(extension);
84 ASSERT_TRUE(listener.WaitUntilSatisfied()); 87 ASSERT_TRUE(listener.WaitUntilSatisfied());
85 88
86 // The extension's page action should currently be hidden. 89 // The extension's page action should currently be hidden.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 "test_root", test_dir); 132 "test_root", test_dir);
130 base::FilePath test_file = test_dir.AppendASCII("text.txt"); 133 base::FilePath test_file = test_dir.AppendASCII("text.txt");
131 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( 134 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
132 &test_file); 135 &test_file);
133 ASSERT_TRUE(RunPlatformAppTest("native_bindings/instance_of")) << message_; 136 ASSERT_TRUE(RunPlatformAppTest("native_bindings/instance_of")) << message_;
134 } 137 }
135 138
136 // Tests the webRequest API, which requires IO thread requests and custom 139 // Tests the webRequest API, which requires IO thread requests and custom
137 // events. 140 // events.
138 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, WebRequest) { 141 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, WebRequest) {
139 host_resolver()->AddRule("*", "127.0.0.1");
140 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_); 142 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_);
141 ASSERT_TRUE(StartEmbeddedTestServer()); 143 ASSERT_TRUE(StartEmbeddedTestServer());
142 // Load an extension and wait for it to be ready. 144 // Load an extension and wait for it to be ready.
143 ResultCatcher catcher; 145 ResultCatcher catcher;
144 const Extension* extension = 146 const Extension* extension =
145 LoadExtension(test_data_dir_.AppendASCII("native_bindings/web_request")); 147 LoadExtension(test_data_dir_.AppendASCII("native_bindings/web_request"));
146 ASSERT_TRUE(extension); 148 ASSERT_TRUE(extension);
147 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 149 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
148 150
149 ui_test_utils::NavigateToURL( 151 ui_test_utils::NavigateToURL(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 199
198 ExtensionTestMessageListener listener("clicked", false); 200 ExtensionTestMessageListener listener("clicked", false);
199 int command_id = ContextMenuMatcher::ConvertToExtensionsCustomCommandId(0); 201 int command_id = ContextMenuMatcher::ConvertToExtensionsCustomCommandId(0);
200 EXPECT_TRUE(menu->IsCommandIdEnabled(command_id)); 202 EXPECT_TRUE(menu->IsCommandIdEnabled(command_id));
201 menu->ExecuteCommand(command_id, 0); 203 menu->ExecuteCommand(command_id, 0);
202 EXPECT_TRUE(listener.WaitUntilSatisfied()); 204 EXPECT_TRUE(listener.WaitUntilSatisfied());
203 } 205 }
204 206
205 // Tests that unchecked errors don't impede future calls. 207 // Tests that unchecked errors don't impede future calls.
206 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, ErrorsInCallbackTest) { 208 IN_PROC_BROWSER_TEST_F(NativeBindingsApiTest, ErrorsInCallbackTest) {
207 host_resolver()->AddRule("*", "127.0.0.1");
208 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_); 209 embedded_test_server()->ServeFilesFromDirectory(test_data_dir_);
209 ASSERT_TRUE(StartEmbeddedTestServer()); 210 ASSERT_TRUE(StartEmbeddedTestServer());
210 211
211 TestExtensionDir test_dir; 212 TestExtensionDir test_dir;
212 test_dir.WriteManifest( 213 test_dir.WriteManifest(
213 R"({ 214 R"({
214 "name": "Errors In Callback", 215 "name": "Errors In Callback",
215 "manifest_version": 2, 216 "manifest_version": 2,
216 "version": "0.1", 217 "version": "0.1",
217 "permissions": ["contextMenus"], 218 "permissions": ["contextMenus"],
(...skipping 21 matching lines...) Expand all
239 ui_test_utils::NavigateToURL( 240 ui_test_utils::NavigateToURL(
240 browser(), embedded_test_server()->GetURL( 241 browser(), embedded_test_server()->GetURL(
241 "example.com", "/native_bindings/simple.html")); 242 "example.com", "/native_bindings/simple.html"));
242 243
243 ExtensionTestMessageListener listener("callback", false); 244 ExtensionTestMessageListener listener("callback", false);
244 ASSERT_TRUE(LoadExtension(test_dir.UnpackedPath())); 245 ASSERT_TRUE(LoadExtension(test_dir.UnpackedPath()));
245 EXPECT_TRUE(listener.WaitUntilSatisfied()); 246 EXPECT_TRUE(listener.WaitUntilSatisfied());
246 } 247 }
247 248
248 } // namespace extensions 249 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/lazy_background_page_apitest.cc ('k') | chrome/browser/extensions/process_management_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698