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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 11369179: Move url_request_test_util into net namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 #include <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 protected: 158 protected:
159 virtual void SetUp() OVERRIDE { 159 virtual void SetUp() OVERRIDE {
160 event_router_ = new extensions::EventRouterForwarder(); 160 event_router_ = new extensions::EventRouterForwarder();
161 enable_referrers_.Init( 161 enable_referrers_.Init(
162 prefs::kEnableReferrers, profile_.GetTestingPrefService(), NULL); 162 prefs::kEnableReferrers, profile_.GetTestingPrefService(), NULL);
163 network_delegate_.reset(new ChromeNetworkDelegate( 163 network_delegate_.reset(new ChromeNetworkDelegate(
164 event_router_.get(), NULL, NULL, NULL, &profile_, 164 event_router_.get(), NULL, NULL, NULL, &profile_,
165 CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_, 165 CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_,
166 NULL, NULL, NULL)); 166 NULL, NULL, NULL));
167 context_.reset(new TestURLRequestContext(true)); 167 context_.reset(new net::TestURLRequestContext(true));
168 context_->set_network_delegate(network_delegate_.get()); 168 context_->set_network_delegate(network_delegate_.get());
169 context_->Init(); 169 context_->Init();
170 } 170 }
171 171
172 // Fires a URLRequest with the specified |method|, |content_type| and three 172 // Fires a URLRequest with the specified |method|, |content_type| and three
173 // elements of upload data: bytes_1, a dummy empty file, bytes_2. 173 // elements of upload data: bytes_1, a dummy empty file, bytes_2.
174 void FireURLRequestWithData(const std::string& method, 174 void FireURLRequestWithData(const std::string& method,
175 const char* content_type, 175 const char* content_type,
176 const std::vector<char>& bytes_1, 176 const std::vector<char>& bytes_1,
177 const std::vector<char>& bytes_2); 177 const std::vector<char>& bytes_2);
178 178
179 MessageLoopForIO message_loop_; 179 MessageLoopForIO message_loop_;
180 content::TestBrowserThread ui_thread_; 180 content::TestBrowserThread ui_thread_;
181 content::TestBrowserThread io_thread_; 181 content::TestBrowserThread io_thread_;
182 TestingProfile profile_; 182 TestingProfile profile_;
183 TestDelegate delegate_; 183 net::TestDelegate delegate_;
184 BooleanPrefMember enable_referrers_; 184 BooleanPrefMember enable_referrers_;
185 TestIPCSender ipc_sender_; 185 TestIPCSender ipc_sender_;
186 scoped_refptr<extensions::EventRouterForwarder> event_router_; 186 scoped_refptr<extensions::EventRouterForwarder> event_router_;
187 scoped_refptr<ExtensionInfoMap> extension_info_map_; 187 scoped_refptr<ExtensionInfoMap> extension_info_map_;
188 scoped_ptr<ChromeNetworkDelegate> network_delegate_; 188 scoped_ptr<ChromeNetworkDelegate> network_delegate_;
189 scoped_ptr<TestURLRequestContext> context_; 189 scoped_ptr<net::TestURLRequestContext> context_;
190 }; 190 };
191 191
192 // Tests that we handle disagreements among extensions about responses to 192 // Tests that we handle disagreements among extensions about responses to
193 // blocking events (redirection) by choosing the response from the 193 // blocking events (redirection) by choosing the response from the
194 // most-recently-installed extension. 194 // most-recently-installed extension.
195 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) { 195 TEST_F(ExtensionWebRequestTest, BlockingEventPrecedenceRedirect) {
196 std::string extension1_id("1"); 196 std::string extension1_id("1");
197 std::string extension2_id("2"); 197 std::string extension2_id("2");
198 ExtensionWebRequestEventRouter::RequestFilter filter; 198 ExtensionWebRequestEventRouter::RequestFilter filter;
199 const std::string kEventName(keys::kOnBeforeRequest); 199 const std::string kEventName(keys::kOnBeforeRequest);
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 700
701 protected: 701 protected:
702 virtual void SetUp() { 702 virtual void SetUp() {
703 event_router_ = new extensions::EventRouterForwarder(); 703 event_router_ = new extensions::EventRouterForwarder();
704 enable_referrers_.Init( 704 enable_referrers_.Init(
705 prefs::kEnableReferrers, profile_.GetTestingPrefService(), NULL); 705 prefs::kEnableReferrers, profile_.GetTestingPrefService(), NULL);
706 network_delegate_.reset(new ChromeNetworkDelegate( 706 network_delegate_.reset(new ChromeNetworkDelegate(
707 event_router_.get(), NULL, NULL, NULL, &profile_, 707 event_router_.get(), NULL, NULL, NULL, &profile_,
708 CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_, 708 CookieSettings::Factory::GetForProfile(&profile_), &enable_referrers_,
709 NULL, NULL, NULL)); 709 NULL, NULL, NULL));
710 context_.reset(new TestURLRequestContext(true)); 710 context_.reset(new net::TestURLRequestContext(true));
711 host_resolver_.reset(new net::MockHostResolver()); 711 host_resolver_.reset(new net::MockHostResolver());
712 host_resolver_->rules()->AddSimulatedFailure("doesnotexist"); 712 host_resolver_->rules()->AddSimulatedFailure("doesnotexist");
713 context_->set_host_resolver(host_resolver_.get()); 713 context_->set_host_resolver(host_resolver_.get());
714 context_->set_network_delegate(network_delegate_.get()); 714 context_->set_network_delegate(network_delegate_.get());
715 context_->Init(); 715 context_->Init();
716 } 716 }
717 717
718 MessageLoopForIO message_loop_; 718 MessageLoopForIO message_loop_;
719 content::TestBrowserThread ui_thread_; 719 content::TestBrowserThread ui_thread_;
720 content::TestBrowserThread io_thread_; 720 content::TestBrowserThread io_thread_;
721 TestingProfile profile_; 721 TestingProfile profile_;
722 TestDelegate delegate_; 722 net::TestDelegate delegate_;
723 BooleanPrefMember enable_referrers_; 723 BooleanPrefMember enable_referrers_;
724 TestIPCSender ipc_sender_; 724 TestIPCSender ipc_sender_;
725 scoped_refptr<extensions::EventRouterForwarder> event_router_; 725 scoped_refptr<extensions::EventRouterForwarder> event_router_;
726 scoped_refptr<ExtensionInfoMap> extension_info_map_; 726 scoped_refptr<ExtensionInfoMap> extension_info_map_;
727 scoped_ptr<ChromeNetworkDelegate> network_delegate_; 727 scoped_ptr<ChromeNetworkDelegate> network_delegate_;
728 scoped_ptr<net::MockHostResolver> host_resolver_; 728 scoped_ptr<net::MockHostResolver> host_resolver_;
729 scoped_ptr<TestURLRequestContext> context_; 729 scoped_ptr<net::TestURLRequestContext> context_;
730 }; 730 };
731 731
732 TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) { 732 TEST_P(ExtensionWebRequestHeaderModificationTest, TestModifications) {
733 std::string extension1_id("1"); 733 std::string extension1_id("1");
734 std::string extension2_id("2"); 734 std::string extension2_id("2");
735 std::string extension3_id("3"); 735 std::string extension3_id("3");
736 ExtensionWebRequestEventRouter::RequestFilter filter; 736 ExtensionWebRequestEventRouter::RequestFilter filter;
737 const std::string kEventName(keys::kOnBeforeSendHeaders); 737 const std::string kEventName(keys::kOnBeforeSendHeaders);
738 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_); 738 base::WeakPtrFactory<TestIPCSender> ipc_sender_factory(&ipc_sender_);
739 739
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 credentials_set = MergeOnAuthRequiredResponses( 2066 credentials_set = MergeOnAuthRequiredResponses(
2067 deltas, &auth3, &conflicting_extensions, &net_log); 2067 deltas, &auth3, &conflicting_extensions, &net_log);
2068 EXPECT_TRUE(credentials_set); 2068 EXPECT_TRUE(credentials_set);
2069 EXPECT_FALSE(auth3.Empty()); 2069 EXPECT_FALSE(auth3.Empty());
2070 EXPECT_EQ(username, auth1.username()); 2070 EXPECT_EQ(username, auth1.username());
2071 EXPECT_EQ(password, auth1.password()); 2071 EXPECT_EQ(password, auth1.password());
2072 EXPECT_EQ(1u, conflicting_extensions.size()); 2072 EXPECT_EQ(1u, conflicting_extensions.size());
2073 EXPECT_TRUE(ContainsKey(conflicting_extensions, "extid2")); 2073 EXPECT_TRUE(ContainsKey(conflicting_extensions, "extid2"));
2074 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2074 EXPECT_EQ(3u, capturing_net_log.GetSize());
2075 } 2075 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698