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

Side by Side Diff: chrome/browser/net/chrome_network_delegate_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 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 | 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 "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/prefs/pref_member.h" 10 #include "base/prefs/pref_member.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // itself (which we did above) to help ensure that a changed 71 // itself (which we did above) to help ensure that a changed
72 // implementation would show the same behavior, i.e. all instances 72 // implementation would show the same behavior, i.e. all instances
73 // of ChromeNetworkDelegate after the flag is set obey the flag. 73 // of ChromeNetworkDelegate after the flag is set obey the flag.
74 scoped_ptr<ChromeNetworkDelegate> second_delegate(CreateNetworkDelegate()); 74 scoped_ptr<ChromeNetworkDelegate> second_delegate(CreateNetworkDelegate());
75 ASSERT_FALSE(delegate->OnCanThrottleRequest(extension_request)); 75 ASSERT_FALSE(delegate->OnCanThrottleRequest(extension_request));
76 ASSERT_FALSE(delegate->OnCanThrottleRequest(web_page_request)); 76 ASSERT_FALSE(delegate->OnCanThrottleRequest(web_page_request));
77 } 77 }
78 78
79 private: 79 private:
80 bool never_throttle_requests_original_value_; 80 bool never_throttle_requests_original_value_;
81 MessageLoopForIO message_loop_; 81 base::MessageLoopForIO message_loop_;
82 82
83 scoped_refptr<extensions::EventRouterForwarder> forwarder_; 83 scoped_refptr<extensions::EventRouterForwarder> forwarder_;
84 BooleanPrefMember pref_member_; 84 BooleanPrefMember pref_member_;
85 }; 85 };
86 86
87 TEST_F(ChromeNetworkDelegateTest, NeverThrottleLogic) { 87 TEST_F(ChromeNetworkDelegateTest, NeverThrottleLogic) {
88 NeverThrottleLogicImpl(); 88 NeverThrottleLogicImpl();
89 } 89 }
90 90
91 class ChromeNetworkDelegateSafeSearchTest : public testing::Test { 91 class ChromeNetworkDelegateSafeSearchTest : public testing::Test {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // that request. 124 // that request.
125 void CheckAddedParameters(const std::string& url_string, 125 void CheckAddedParameters(const std::string& url_string,
126 const std::string& expected_query_parameters) { 126 const std::string& expected_query_parameters) {
127 // Show the URL in the trace so we know where we failed. 127 // Show the URL in the trace so we know where we failed.
128 SCOPED_TRACE(url_string); 128 SCOPED_TRACE(url_string);
129 129
130 net::TestURLRequest request( 130 net::TestURLRequest request(
131 GURL(url_string), &delegate_, &context_, network_delegate_); 131 GURL(url_string), &delegate_, &context_, network_delegate_);
132 132
133 request.Start(); 133 request.Start();
134 MessageLoop::current()->RunUntilIdle(); 134 base::MessageLoop::current()->RunUntilIdle();
135 135
136 EXPECT_EQ(expected_query_parameters, request.url().query()); 136 EXPECT_EQ(expected_query_parameters, request.url().query());
137 } 137 }
138 138
139 private: 139 private:
140 MessageLoopForIO message_loop_; 140 base::MessageLoopForIO message_loop_;
141 content::TestBrowserThread ui_thread_; 141 content::TestBrowserThread ui_thread_;
142 content::TestBrowserThread io_thread_; 142 content::TestBrowserThread io_thread_;
143 scoped_refptr<extensions::EventRouterForwarder> forwarder_; 143 scoped_refptr<extensions::EventRouterForwarder> forwarder_;
144 TestingProfile profile_; 144 TestingProfile profile_;
145 BooleanPrefMember enable_referrers_; 145 BooleanPrefMember enable_referrers_;
146 BooleanPrefMember force_google_safe_search_; 146 BooleanPrefMember force_google_safe_search_;
147 scoped_ptr<net::URLRequest> request_; 147 scoped_ptr<net::URLRequest> request_;
148 net::TestURLRequestContext context_; 148 net::TestURLRequestContext context_;
149 net::NetworkDelegate* network_delegate_; 149 net::NetworkDelegate* network_delegate_;
150 net::TestDelegate delegate_; 150 net::TestDelegate delegate_;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 network_delegate->set_cookie_settings(cookie_settings_); 309 network_delegate->set_cookie_settings(cookie_settings_);
310 return network_delegate.Pass(); 310 return network_delegate.Pass();
311 } 311 }
312 312
313 void SetDelegate(net::NetworkDelegate* delegate) { 313 void SetDelegate(net::NetworkDelegate* delegate) {
314 network_delegate_ = delegate; 314 network_delegate_ = delegate;
315 context_.set_network_delegate(network_delegate_); 315 context_.set_network_delegate(network_delegate_);
316 } 316 }
317 317
318 protected: 318 protected:
319 MessageLoopForIO message_loop_; 319 base::MessageLoopForIO message_loop_;
320 content::TestBrowserThread ui_thread_; 320 content::TestBrowserThread ui_thread_;
321 content::TestBrowserThread io_thread_; 321 content::TestBrowserThread io_thread_;
322 scoped_refptr<extensions::EventRouterForwarder> forwarder_; 322 scoped_refptr<extensions::EventRouterForwarder> forwarder_;
323 TestingProfile profile_; 323 TestingProfile profile_;
324 CookieSettings* cookie_settings_; 324 CookieSettings* cookie_settings_;
325 BooleanPrefMember enable_referrers_; 325 BooleanPrefMember enable_referrers_;
326 scoped_ptr<net::URLRequest> request_; 326 scoped_ptr<net::URLRequest> request_;
327 net::TestURLRequestContext context_; 327 net::TestURLRequestContext context_;
328 net::NetworkDelegate* network_delegate_; 328 net::NetworkDelegate* network_delegate_;
329 329
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 cookie_settings_->SetCookieSetting( 384 cookie_settings_->SetCookieSetting(
385 ContentSettingsPattern::FromURL(kBlockedFirstPartySite), 385 ContentSettingsPattern::FromURL(kBlockedFirstPartySite),
386 ContentSettingsPattern::Wildcard(), 386 ContentSettingsPattern::Wildcard(),
387 CONTENT_SETTING_BLOCK); 387 CONTENT_SETTING_BLOCK);
388 // Privacy mode is disabled as kAllowedSite is still getting cookies 388 // Privacy mode is disabled as kAllowedSite is still getting cookies
389 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite, 389 EXPECT_FALSE(network_delegate_->CanEnablePrivacyMode(kAllowedSite,
390 kBlockedFirstPartySite)); 390 kBlockedFirstPartySite));
391 } 391 }
392 392
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_fraudulent_certificate_reporter_unittest.cc ('k') | chrome/browser/net/connection_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698