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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_interceptor_unittest.cc

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // URLRequestJobs may post clean-up tasks on destruction. 124 // URLRequestJobs may post clean-up tasks on destruction.
125 base::RunLoop().RunUntilIdle(); 125 base::RunLoop().RunUntilIdle();
126 } 126 }
127 127
128 void Init(scoped_ptr<net::URLRequestJobFactory> factory) { 128 void Init(scoped_ptr<net::URLRequestJobFactory> factory) {
129 job_factory_ = factory.Pass(); 129 job_factory_ = factory.Pass();
130 default_context_->set_job_factory(job_factory_.get()); 130 default_context_->set_job_factory(job_factory_.get());
131 default_context_->Init(); 131 default_context_->Init();
132 } 132 }
133 133
134 base::MessageLoopForIO message_loop_;
134 scoped_ptr<DataReductionProxyTestContext> test_context_; 135 scoped_ptr<DataReductionProxyTestContext> test_context_;
135 net::TestNetworkDelegate default_network_delegate_; 136 net::TestNetworkDelegate default_network_delegate_;
136 scoped_ptr<net::URLRequestJobFactory> job_factory_; 137 scoped_ptr<net::URLRequestJobFactory> job_factory_;
137 scoped_ptr<net::TestURLRequestContext> default_context_; 138 scoped_ptr<net::TestURLRequestContext> default_context_;
138 }; 139 };
139 140
140 TEST_F(DataReductionProxyInterceptorTest, TestJobFactoryChaining) { 141 TEST_F(DataReductionProxyInterceptorTest, TestJobFactoryChaining) {
141 // Verifies that job factories can be chained. 142 // Verifies that job factories can be chained.
142 scoped_ptr<net::URLRequestJobFactory> impl( 143 scoped_ptr<net::URLRequestJobFactory> impl(
143 new net::URLRequestJobFactoryImpl()); 144 new net::URLRequestJobFactoryImpl());
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 229
229 const net::TestURLRequestContext& context() { 230 const net::TestURLRequestContext& context() {
230 return context_; 231 return context_;
231 } 232 }
232 233
233 const net::test_server::EmbeddedTestServer& direct() { 234 const net::test_server::EmbeddedTestServer& direct() {
234 return direct_; 235 return direct_;
235 } 236 }
236 237
237 private: 238 private:
239 base::MessageLoopForIO message_loop_;
238 net::TestNetLog net_log_; 240 net::TestNetLog net_log_;
239 net::TestNetworkDelegate network_delegate_; 241 net::TestNetworkDelegate network_delegate_;
240 net::TestURLRequestContext context_; 242 net::TestURLRequestContext context_;
241 net::test_server::EmbeddedTestServer proxy_; 243 net::test_server::EmbeddedTestServer proxy_;
242 net::test_server::EmbeddedTestServer direct_; 244 net::test_server::EmbeddedTestServer direct_;
243 scoped_ptr<net::ProxyService> proxy_service_; 245 scoped_ptr<net::ProxyService> proxy_service_;
244 scoped_ptr<net::URLRequestJobFactory> job_factory_; 246 scoped_ptr<net::URLRequestJobFactory> job_factory_;
245 scoped_ptr<DataReductionProxyTestContext> test_context_; 247 scoped_ptr<DataReductionProxyTestContext> test_context_;
246 }; 248 };
247 249
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 324
323 net::MockClientSocketFactory* mock_socket_factory() { 325 net::MockClientSocketFactory* mock_socket_factory() {
324 return &mock_socket_factory_; 326 return &mock_socket_factory_;
325 } 327 }
326 328
327 TestDataReductionProxyConfig* config() const { 329 TestDataReductionProxyConfig* config() const {
328 return drp_test_context_->config(); 330 return drp_test_context_->config();
329 } 331 }
330 332
331 private: 333 private:
334 base::MessageLoopForIO message_loop_;
332 net::TestDelegate delegate_; 335 net::TestDelegate delegate_;
333 net::MockClientSocketFactory mock_socket_factory_; 336 net::MockClientSocketFactory mock_socket_factory_;
334 net::TestURLRequestContext context_; 337 net::TestURLRequestContext context_;
335 net::URLRequestContextStorage context_storage_; 338 net::URLRequestContextStorage context_storage_;
336 scoped_ptr<DataReductionProxyTestContext> drp_test_context_; 339 scoped_ptr<DataReductionProxyTestContext> drp_test_context_;
337 }; 340 };
338 341
339 const std::string kBody = "response body"; 342 const std::string kBody = "response body";
340 343
341 TEST_F(DataReductionProxyInterceptorEndToEndTest, ResponseWithoutRetry) { 344 TEST_F(DataReductionProxyInterceptorEndToEndTest, ResponseWithoutRetry) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 EXPECT_FALSE(request->was_fetched_via_proxy()); 475 EXPECT_FALSE(request->was_fetched_via_proxy());
473 476
474 // Each of the redirects should have been intercepted before being followed. 477 // Each of the redirects should have been intercepted before being followed.
475 EXPECT_EQ(0, delegate().received_redirect_count()); 478 EXPECT_EQ(0, delegate().received_redirect_count());
476 EXPECT_EQ(std::vector<GURL>(1, GURL("http://foo.com")), request->url_chain()); 479 EXPECT_EQ(std::vector<GURL>(1, GURL("http://foo.com")), request->url_chain());
477 } 480 }
478 481
479 } // namespace 482 } // namespace
480 483
481 } // namespace data_reduction_proxy 484 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698