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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.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 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 "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h"
6 6
7 #include "base/message_loop/message_loop.h"
8 #include "base/prefs/testing_pref_service.h" 7 #include "base/prefs/testing_pref_service.h"
9 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h" 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h"
10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_service_client.h" 9 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_service_client.h"
11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_test_utils.h" 10 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_test_utils.h"
12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator_test_utils.h" 11 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf igurator_test_utils.h"
13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h" 12 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte rceptor.h"
14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta ble_config_values.h" 13 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_muta ble_config_values.h"
15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h"
17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 DataReductionProxyTestContext::Builder& 285 DataReductionProxyTestContext::Builder&
287 DataReductionProxyTestContext::Builder::SkipSettingsInitialization() { 286 DataReductionProxyTestContext::Builder::SkipSettingsInitialization() {
288 skip_settings_initialization_ = true; 287 skip_settings_initialization_ = true;
289 return *this; 288 return *this;
290 } 289 }
291 290
292 scoped_ptr<DataReductionProxyTestContext> 291 scoped_ptr<DataReductionProxyTestContext>
293 DataReductionProxyTestContext::Builder::Build() { 292 DataReductionProxyTestContext::Builder::Build() {
294 // Check for invalid builder combinations. 293 // Check for invalid builder combinations.
295 DCHECK(!(use_mock_config_ && use_config_client_)); 294 DCHECK(!(use_mock_config_ && use_config_client_));
296 scoped_ptr<base::MessageLoopForIO> loop(new base::MessageLoopForIO());
297 295
298 unsigned int test_context_flags = 0; 296 unsigned int test_context_flags = 0;
299 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 297 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
300 base::MessageLoopProxy::current(); 298 base::MessageLoopProxy::current();
301 scoped_refptr<net::URLRequestContextGetter> request_context_getter; 299 scoped_refptr<net::URLRequestContextGetter> request_context_getter;
302 scoped_ptr<TestingPrefServiceSimple> pref_service( 300 scoped_ptr<TestingPrefServiceSimple> pref_service(
303 new TestingPrefServiceSimple()); 301 new TestingPrefServiceSimple());
304 scoped_ptr<net::TestNetLog> net_log(new net::TestNetLog()); 302 scoped_ptr<net::TestNetLog> net_log(new net::TestNetLog());
305 if (request_context_) { 303 if (request_context_) {
306 request_context_getter = new net::TrivialURLRequestContextGetter( 304 request_context_getter = new net::TrivialURLRequestContextGetter(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 385
388 scoped_ptr<TestDataReductionProxyIOData> io_data( 386 scoped_ptr<TestDataReductionProxyIOData> io_data(
389 new TestDataReductionProxyIOData( 387 new TestDataReductionProxyIOData(
390 task_runner, config.Pass(), event_creator.Pass(), 388 task_runner, config.Pass(), event_creator.Pass(),
391 request_options.Pass(), configurator.Pass(), config_client.Pass())); 389 request_options.Pass(), configurator.Pass(), config_client.Pass()));
392 io_data->InitOnUIThread(pref_service.get()); 390 io_data->InitOnUIThread(pref_service.get());
393 io_data->SetSimpleURLRequestContextGetter(request_context_getter); 391 io_data->SetSimpleURLRequestContextGetter(request_context_getter);
394 392
395 scoped_ptr<DataReductionProxyTestContext> test_context( 393 scoped_ptr<DataReductionProxyTestContext> test_context(
396 new DataReductionProxyTestContext( 394 new DataReductionProxyTestContext(
397 loop.Pass(), task_runner, pref_service.Pass(), net_log.Pass(), 395 task_runner, pref_service.Pass(), net_log.Pass(),
398 request_context_getter, mock_socket_factory_, io_data.Pass(), 396 request_context_getter, mock_socket_factory_, io_data.Pass(),
399 settings.Pass(), storage_delegate.Pass(), raw_params, 397 settings.Pass(), storage_delegate.Pass(), raw_params,
400 test_context_flags)); 398 test_context_flags));
401 399
402 if (!skip_settings_initialization_) 400 if (!skip_settings_initialization_)
403 test_context->InitSettingsWithoutCheck(); 401 test_context->InitSettingsWithoutCheck();
404 402
405 return test_context.Pass(); 403 return test_context.Pass();
406 } 404 }
407 405
408 DataReductionProxyTestContext::DataReductionProxyTestContext( 406 DataReductionProxyTestContext::DataReductionProxyTestContext(
409 scoped_ptr<base::MessageLoop> loop,
410 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 407 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
411 scoped_ptr<TestingPrefServiceSimple> simple_pref_service, 408 scoped_ptr<TestingPrefServiceSimple> simple_pref_service,
412 scoped_ptr<net::TestNetLog> net_log, 409 scoped_ptr<net::TestNetLog> net_log,
413 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 410 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
414 net::MockClientSocketFactory* mock_socket_factory, 411 net::MockClientSocketFactory* mock_socket_factory,
415 scoped_ptr<TestDataReductionProxyIOData> io_data, 412 scoped_ptr<TestDataReductionProxyIOData> io_data,
416 scoped_ptr<DataReductionProxySettings> settings, 413 scoped_ptr<DataReductionProxySettings> settings,
417 scoped_ptr<TestDataReductionProxyEventStorageDelegate> storage_delegate, 414 scoped_ptr<TestDataReductionProxyEventStorageDelegate> storage_delegate,
418 TestDataReductionProxyParams* params, 415 TestDataReductionProxyParams* params,
419 unsigned int test_context_flags) 416 unsigned int test_context_flags)
420 : test_context_flags_(test_context_flags), 417 : test_context_flags_(test_context_flags),
421 loop_(loop.Pass()),
422 task_runner_(task_runner), 418 task_runner_(task_runner),
423 simple_pref_service_(simple_pref_service.Pass()), 419 simple_pref_service_(simple_pref_service.Pass()),
424 net_log_(net_log.Pass()), 420 net_log_(net_log.Pass()),
425 request_context_getter_(request_context_getter), 421 request_context_getter_(request_context_getter),
426 mock_socket_factory_(mock_socket_factory), 422 mock_socket_factory_(mock_socket_factory),
427 io_data_(io_data.Pass()), 423 io_data_(io_data.Pass()),
428 settings_(settings.Pass()), 424 settings_(settings.Pass()),
429 storage_delegate_(storage_delegate.Pass()), 425 storage_delegate_(storage_delegate.Pass()),
430 params_(params) { 426 params_(params) {
431 } 427 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 io_data_->config_client()); 579 io_data_->config_client());
584 } 580 }
585 581
586 DataReductionProxyBypassStats::UnreachableCallback 582 DataReductionProxyBypassStats::UnreachableCallback
587 DataReductionProxyTestContext::unreachable_callback() const { 583 DataReductionProxyTestContext::unreachable_callback() const {
588 return base::Bind(&DataReductionProxySettings::SetUnreachable, 584 return base::Bind(&DataReductionProxySettings::SetUnreachable,
589 base::Unretained(settings_.get())); 585 base::Unretained(settings_.get()));
590 } 586 }
591 587
592 } // namespace data_reduction_proxy 588 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698