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

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

Issue 2851103002: Update some host_resolver()->AddRules in chrome/browser. (Closed)
Patch Set: fix 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <string> 5 #include <string>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/scoped_observer.h" 10 #include "base/scoped_observer.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // case is from workers. 56 // case is from workers.
57 const char* kContentScriptJs = 57 const char* kContentScriptJs =
58 "chrome.test.getWakeEventPage()(function(success) {\n" 58 "chrome.test.getWakeEventPage()(function(success) {\n"
59 " chrome.test.sendMessage(success ? 'success' : 'failure');\n" 59 " chrome.test.sendMessage(success ? 'success' : 'failure');\n"
60 "});\n"; 60 "});\n";
61 61
62 class WakeEventPageTest : public ExtensionBrowserTest { 62 class WakeEventPageTest : public ExtensionBrowserTest {
63 public: 63 public:
64 WakeEventPageTest() {} 64 WakeEventPageTest() {}
65 65
66 void SetUpOnMainThread() override {
67 ExtensionBrowserTest::SetUpOnMainThread();
68 host_resolver()->AddRule("*", "127.0.0.1");
69 }
70
66 protected: 71 protected:
67 enum BackgroundPageConfiguration { EVENT, PERSISTENT, NONE }; 72 enum BackgroundPageConfiguration { EVENT, PERSISTENT, NONE };
68 73
69 void RunTest(bool expect_success, 74 void RunTest(bool expect_success,
70 BackgroundPageConfiguration bg_config, 75 BackgroundPageConfiguration bg_config,
71 bool should_close, 76 bool should_close,
72 bool will_be_open) { 77 bool will_be_open) {
73 ASSERT_TRUE(embedded_test_server()->Start()); 78 ASSERT_TRUE(embedded_test_server()->Start());
74 79
75 GURL web_url = embedded_test_server()->GetURL("example.com", "/empty.html"); 80 GURL web_url = embedded_test_server()->GetURL("example.com", "/empty.html");
76 host_resolver()->AddRule(web_url.host(), "127.0.0.1");
77 81
78 TestExtensionDir extension_dir; 82 TestExtensionDir extension_dir;
79 { 83 {
80 std::string manifest_json; 84 std::string manifest_json;
81 switch (bg_config) { 85 switch (bg_config) {
82 case EVENT: 86 case EVENT:
83 manifest_json = 87 manifest_json =
84 base::StringPrintf(kManifestJson, 88 base::StringPrintf(kManifestJson,
85 " 'background': {\n" 89 " 'background': {\n"
86 " 'persistent': false,\n" 90 " 'persistent': false,\n"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 true /* will_be_open */); 181 true /* will_be_open */);
178 } 182 }
179 183
180 IN_PROC_BROWSER_TEST_F(WakeEventPageTest, NoBackgroundPage) { 184 IN_PROC_BROWSER_TEST_F(WakeEventPageTest, NoBackgroundPage) {
181 RunTest(false /* expect_success */, NONE, false /* should_close */, 185 RunTest(false /* expect_success */, NONE, false /* should_close */,
182 false /* will_be_open */); 186 false /* will_be_open */);
183 } 187 }
184 188
185 } // namespace 189 } // namespace
186 } // namespace extensions 190 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698