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

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: Created 7 years, 8 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // itself (which we did above) to help ensure that a changed 70 // itself (which we did above) to help ensure that a changed
71 // implementation would show the same behavior, i.e. all instances 71 // implementation would show the same behavior, i.e. all instances
72 // of ChromeNetworkDelegate after the flag is set obey the flag. 72 // of ChromeNetworkDelegate after the flag is set obey the flag.
73 scoped_ptr<ChromeNetworkDelegate> second_delegate(CreateNetworkDelegate()); 73 scoped_ptr<ChromeNetworkDelegate> second_delegate(CreateNetworkDelegate());
74 ASSERT_FALSE(delegate->OnCanThrottleRequest(extension_request)); 74 ASSERT_FALSE(delegate->OnCanThrottleRequest(extension_request));
75 ASSERT_FALSE(delegate->OnCanThrottleRequest(web_page_request)); 75 ASSERT_FALSE(delegate->OnCanThrottleRequest(web_page_request));
76 } 76 }
77 77
78 private: 78 private:
79 bool never_throttle_requests_original_value_; 79 bool never_throttle_requests_original_value_;
80 MessageLoopForIO message_loop_; 80 base::MessageLoopForIO message_loop_;
81 81
82 scoped_refptr<extensions::EventRouterForwarder> forwarder_; 82 scoped_refptr<extensions::EventRouterForwarder> forwarder_;
83 BooleanPrefMember pref_member_; 83 BooleanPrefMember pref_member_;
84 }; 84 };
85 85
86 TEST_F(ChromeNetworkDelegateTest, NeverThrottleLogic) { 86 TEST_F(ChromeNetworkDelegateTest, NeverThrottleLogic) {
87 NeverThrottleLogicImpl(); 87 NeverThrottleLogicImpl();
88 } 88 }
89 89
90 class ChromeNetworkDelegateSafeSearchTest : public testing::Test { 90 class ChromeNetworkDelegateSafeSearchTest : public testing::Test {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // that request. 123 // that request.
124 void CheckAddedParameters(const std::string& url_string, 124 void CheckAddedParameters(const std::string& url_string,
125 const std::string& expected_query_parameters) { 125 const std::string& expected_query_parameters) {
126 // Show the URL in the trace so we know where we failed. 126 // Show the URL in the trace so we know where we failed.
127 SCOPED_TRACE(url_string); 127 SCOPED_TRACE(url_string);
128 128
129 net::TestURLRequest request( 129 net::TestURLRequest request(
130 GURL(url_string), &delegate_, &context_, network_delegate_); 130 GURL(url_string), &delegate_, &context_, network_delegate_);
131 131
132 request.Start(); 132 request.Start();
133 MessageLoop::current()->RunUntilIdle(); 133 base::MessageLoop::current()->RunUntilIdle();
134 134
135 EXPECT_EQ(expected_query_parameters, request.url().query()); 135 EXPECT_EQ(expected_query_parameters, request.url().query());
136 } 136 }
137 137
138 private: 138 private:
139 MessageLoopForIO message_loop_; 139 base::MessageLoopForIO message_loop_;
140 content::TestBrowserThread ui_thread_; 140 content::TestBrowserThread ui_thread_;
141 content::TestBrowserThread io_thread_; 141 content::TestBrowserThread io_thread_;
142 scoped_refptr<extensions::EventRouterForwarder> forwarder_; 142 scoped_refptr<extensions::EventRouterForwarder> forwarder_;
143 TestingProfile profile_; 143 TestingProfile profile_;
144 BooleanPrefMember enable_referrers_; 144 BooleanPrefMember enable_referrers_;
145 BooleanPrefMember force_google_safe_search_; 145 BooleanPrefMember force_google_safe_search_;
146 scoped_ptr<net::URLRequest> request_; 146 scoped_ptr<net::URLRequest> request_;
147 net::TestURLRequestContext context_; 147 net::TestURLRequestContext context_;
148 net::NetworkDelegate* network_delegate_; 148 net::NetworkDelegate* network_delegate_;
149 net::TestDelegate delegate_; 149 net::TestDelegate delegate_;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 "q=google"); 273 "q=google");
274 274
275 // Test the home page with parameters and safe set to off. 275 // Test the home page with parameters and safe set to off.
276 CheckAddedParameters("http://google.com/search?q=google&safe=off", 276 CheckAddedParameters("http://google.com/search?q=google&safe=off",
277 "q=google&safe=off"); 277 "q=google&safe=off");
278 278
279 // Test the home page with parameters and safe set to active. 279 // Test the home page with parameters and safe set to active.
280 CheckAddedParameters("http://google.com/search?q=google&safe=active", 280 CheckAddedParameters("http://google.com/search?q=google&safe=active",
281 "q=google&safe=active"); 281 "q=google&safe=active");
282 } 282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698