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 |
| index 589e391c61ab4938cb349df7ce108bf1e4f7d2d5..4dc3bb9626cc927b32d88f8aecd7022675b490dd 100644 |
| --- 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 |
| @@ -8,6 +8,7 @@ |
| #include "base/macros.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_test_utils.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usage_stats.h" |
| @@ -40,6 +41,44 @@ class MockDataReductionProxyConfig; |
| class TestDataReductionProxyConfig; |
| class TestDataReductionProxyConfigurator; |
| +// Test version of |DataReductionProxyRequestOptions|. |
| +class TestDataReductionProxyRequestOptions |
| + : public DataReductionProxyRequestOptions { |
| + public: |
| + TestDataReductionProxyRequestOptions( |
| + Client client, |
| + const std::string& version, |
| + DataReductionProxyConfig* config, |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
|
bengr
2015/03/19 16:31:14
Includes needed for string, scoped_refptr and Sing
jeremyim
2015/03/20 16:21:11
Done.
|
| + |
| + // Overrides of DataReductionProxyRequestOptions. |
| + std::string GetDefaultKey() const override; |
| + base::Time Now() const override; |
|
bengr
2015/03/19 16:31:15
#include "base/time/time.h"
jeremyim
2015/03/20 16:21:11
Done.
|
| + void RandBytes(void* output, size_t length) const override; |
| + |
| + // Time after the unix epoch that Now() reports. |
| + void set_offset(const base::TimeDelta& now_offset); |
| + |
| + private: |
| + base::TimeDelta now_offset_; |
| +}; |
| + |
| +// Mock version of |DataReductionProxyRequestOptions|. |
| +class MockDataReductionProxyRequestOptions |
| + : public DataReductionProxyRequestOptions { |
| + public: |
| + MockDataReductionProxyRequestOptions( |
| + Client client, |
| + const std::string& version, |
| + DataReductionProxyConfig* config, |
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
| + |
| + ~MockDataReductionProxyRequestOptions(); |
| + |
| + MOCK_CONST_METHOD1(PopulateConfigResponse, |
| + void(base::DictionaryValue* response)); |
| +}; |
| + |
| // Test version of |DataReductionProxyService|, which permits mocking of various |
| // methods. |
| class MockDataReductionProxyService : public DataReductionProxyService { |
| @@ -118,6 +157,10 @@ class DataReductionProxyTestContext { |
| // |DataReductionProxyService|. |
| Builder& WithMockDataReductionProxyService(); |
| + // Specifies the use of |MockDataReductionProxyRequestOptions| instead of |
| + // |DataReductionProxyRequestOptions|. |
| + Builder& WithMockRequestOptions(); |
| + |
| // Construct, but do not initialize the |DataReductionProxySettings| object. |
| Builder& SkipSettingsInitialization(); |
| @@ -134,6 +177,7 @@ class DataReductionProxyTestContext { |
| bool use_mock_config_; |
| bool use_test_configurator_; |
| bool use_mock_service_; |
| + bool use_mock_request_options_; |
| bool skip_settings_initialization_; |
| }; |
| @@ -179,6 +223,10 @@ class DataReductionProxyTestContext { |
| // be called if built with WithMockDataReductionProxyService. |
| MockDataReductionProxyService* mock_data_reduction_proxy_service() const; |
| + // Returns the underlying |MockDataReductionProxyRequestOptions|. This can |
| + // only be called if built with WithMockRequestOptions. |
| + MockDataReductionProxyRequestOptions* mock_request_options() const; |
| + |
| // Obtains a callback for notifying that the Data Reduction Proxy is no |
| // longer reachable. |
| DataReductionProxyUsageStats::UnreachableCallback |
| @@ -233,6 +281,8 @@ class DataReductionProxyTestContext { |
| SKIP_SETTINGS_INITIALIZATION = 0x4, |
| // Permits mocking of the underlying |DataReductionProxyService|. |
| USE_MOCK_SERVICE = 0x8, |
| + // Permits mocking of the underlying |DataReductionProxyRequestOptions|. |
| + USE_MOCK_REQUEST_OPTIONS = 0x10, |
| }; |
| DataReductionProxyTestContext( |