Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..15f3fc91e73ae557ffefb673115a24e0460f47c7 |
| --- /dev/null |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h |
| @@ -0,0 +1,146 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_TEST_UTILS_H_ |
|
bengr
2015/02/17 18:10:24
What do you think about landing this as a separate
jeremyim
2015/02/19 21:03:44
Done.
|
| +#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_TEST_UTILS_H_ |
| + |
| +#include "base/macros.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h" |
| +#include "components/data_reduction_proxy/core/browser/data_saver_service.h" |
| +#include "net/base/capturing_net_log.h" |
| +#include "testing/gmock/include/gmock/gmock.h" |
| + |
| +class TestingPrefServiceSimple; |
| + |
| +namespace base { |
| +class MessageLoopForUI; |
| +class SingleThreadTaskRunner; |
| +} |
| + |
| +namespace net { |
| +class NetLog; |
| +class URLRequestContextGetter; |
| +} |
| + |
| +namespace data_reduction_proxy { |
| + |
| +class DataReductionProxyConfigurator; |
| +class DataReductionProxyEventStore; |
| +class DataReductionProxyRequestOptions; |
| +class DataReductionProxySettings; |
| +class DataReductionProxyStatisticsPrefs; |
| +class MockDataReductionProxyConfig; |
| +class TestDataReductionProxyConfig; |
| +class TestDataReductionProxyConfigurator; |
| + |
| +class MockDataSaverService : public DataSaverService { |
| + public: |
| + MockDataSaverService( |
| + scoped_ptr<DataReductionProxyStatisticsPrefs> statistics_prefs, |
| + DataReductionProxySettings* settings, |
| + net::URLRequestContextGetter* request_context); |
| + ~MockDataSaverService() override; |
| + |
| + MOCK_METHOD2(CheckProbeURL, |
| + void(const GURL& probe_url, FetcherResponseCallback fetcher_callback)); |
| +}; |
| + |
| +class TestDataReductionProxyIOData : public DataReductionProxyIOData { |
| + public: |
| + TestDataReductionProxyIOData( |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| + scoped_ptr<TestDataReductionProxyConfig> config, |
| + scoped_ptr<DataReductionProxyEventStore> event_store, |
| + scoped_ptr<DataReductionProxyRequestOptions> request_options, |
| + scoped_ptr<DataReductionProxyConfigurator> configurator); |
| + ~TestDataReductionProxyIOData() override; |
| + |
| + DataReductionProxyConfigurator* configurator() const { |
| + return configurator_.get(); |
| + } |
| +}; |
| + |
| +class DataReductionProxyTestContext { |
|
bengr
2015/02/17 18:10:24
Add comments to every class, enum, non-trivial met
jeremyim
2015/02/19 21:03:44
Done.
|
| + public: |
| + enum TestContextOptions { |
|
bengr
2015/02/17 18:10:24
In particular, I have no idea how to use these opt
jeremyim
2015/02/19 21:03:44
Done.
|
| + USE_MOCK_CONFIG = 0x1, |
| + USE_TEST_CONFIGURATOR = 0x2, |
| + DONT_SET_DATASAVER_ON_SETTINGS = 0x4, |
| + }; |
| + |
| + explicit DataReductionProxyTestContext(int params_flags, |
| + unsigned int params_definitions, |
| + unsigned int test_context_flags); |
| + DataReductionProxyTestContext(); |
| + virtual ~DataReductionProxyTestContext(); |
| + |
| + void RunUntilIdle(); |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner() const { |
| + return task_runner_; |
| + } |
| + |
| + TestingPrefServiceSimple* pref_service() { |
| + return &simple_pref_service_; |
| + } |
| + |
| + net::NetLog* net_log() { |
| + return &net_log_; |
| + } |
| + |
| + net::URLRequestContextGetter* request_context() const { |
| + return request_context_.get(); |
| + } |
| + |
| + DataReductionProxyEventStore* event_store() const { |
| + return io_data_->event_store(); |
| + } |
| + |
| + DataReductionProxyConfigurator* configurator() const { |
| + return io_data_->configurator(); |
| + } |
| + |
| + TestDataReductionProxyConfig* config() const { |
| + return reinterpret_cast<TestDataReductionProxyConfig*>(io_data_->config()); |
| + } |
| + |
| + TestDataReductionProxyIOData* io_data() const { |
| + return io_data_.get(); |
| + } |
| + |
| + DataReductionProxySettings* settings() const { |
| + return settings_.get(); |
| + } |
| + |
| + TestDataReductionProxyConfigurator* test_configurator() const; |
| + |
| + MockDataReductionProxyConfig* mock_config() const; |
| + |
| + MockDataSaverService* data_saver_service() const; |
| + |
| + scoped_ptr<MockDataSaverService> CreateDataSaverService(); |
| + |
| + void InitSettings(); |
| + |
| + private: |
| + unsigned int test_context_flags_; |
| + |
| + base::MessageLoopForIO loop_; |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| + TestingPrefServiceSimple simple_pref_service_; |
| + net::CapturingNetLog net_log_; |
| + scoped_refptr<net::URLRequestContextGetter> request_context_; |
| + |
| + scoped_ptr<TestDataReductionProxyIOData> io_data_; |
| + scoped_ptr<DataReductionProxySettings> settings_; |
| + |
| + MockDataSaverService* data_saver_service_pointer_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DataReductionProxyTestContext); |
| +}; |
| + |
| +} // namespace data_reduction_proxy |
|
bengr
2015/02/17 18:10:24
Add a blank line below
jeremyim
2015/02/19 21:03:44
Done.
|
| +#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_TEST_UTILS_H_ |