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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_settings_test_utils.h

Issue 338723002: Add probe to warm data reduction proxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TE ST_UTILS_H_ 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TE ST_UTILS_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TE ST_UTILS_H_ 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS_TE ST_UTILS_H_
7 7
8 8
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura tor.h" 10 #include "components/data_reduction_proxy/browser/data_reduction_proxy_configura tor.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 template <class C> 54 template <class C>
55 class MockDataReductionProxySettings : public C { 55 class MockDataReductionProxySettings : public C {
56 public: 56 public:
57 MockDataReductionProxySettings<C>() : DataReductionProxySettings( 57 MockDataReductionProxySettings<C>() : DataReductionProxySettings(
58 new DataReductionProxyParams( 58 new DataReductionProxyParams(
59 DataReductionProxyParams::kAllowed | 59 DataReductionProxyParams::kAllowed |
60 DataReductionProxyParams::kFallbackAllowed | 60 DataReductionProxyParams::kFallbackAllowed |
61 DataReductionProxyParams::kPromoAllowed)) {} 61 DataReductionProxyParams::kPromoAllowed)) {}
62 MockDataReductionProxySettings<C>(int flags) 62 MockDataReductionProxySettings<C>(int flags)
63 : C(new DataReductionProxyParams(flags)) {} 63 : C(new DataReductionProxyParams(flags)) {}
64 MOCK_METHOD0(GetURLFetcher, net::URLFetcher*()); 64 MOCK_METHOD0(GetURLFetcherForAvailabilityCheck, net::URLFetcher*());
65 MOCK_METHOD0(GetURLFetcherForWarmup, net::URLFetcher*());
65 MOCK_METHOD0(GetOriginalProfilePrefs, PrefService*()); 66 MOCK_METHOD0(GetOriginalProfilePrefs, PrefService*());
66 MOCK_METHOD0(GetLocalStatePrefs, PrefService*()); 67 MOCK_METHOD0(GetLocalStatePrefs, PrefService*());
67 MOCK_METHOD3(LogProxyState, void( 68 MOCK_METHOD3(LogProxyState, void(
68 bool enabled, bool restricted, bool at_startup)); 69 bool enabled, bool restricted, bool at_startup));
69 MOCK_METHOD1(RecordProbeURLFetchResult, 70 MOCK_METHOD1(RecordProbeURLFetchResult,
70 void(ProbeURLFetchResult result)); 71 void(ProbeURLFetchResult result));
71 MOCK_METHOD1(RecordStartupState, 72 MOCK_METHOD1(RecordStartupState,
72 void(ProxyStartupState state)); 73 void(ProxyStartupState state));
73 74
74 // SetProxyConfigs should always call LogProxyState exactly once. 75 // SetProxyConfigs should always call LogProxyState exactly once.
(...skipping 25 matching lines...) Expand all
100 bool fallback_allowed, 101 bool fallback_allowed,
101 bool alt_allowed, 102 bool alt_allowed,
102 bool promo_allowed); 103 bool promo_allowed);
103 virtual void ResetSettings(bool allowed, 104 virtual void ResetSettings(bool allowed,
104 bool fallback_allowed, 105 bool fallback_allowed,
105 bool alt_allowed, 106 bool alt_allowed,
106 bool promo_allowed) = 0; 107 bool promo_allowed) = 0;
107 108
108 template <class C> void SetProbeResult( 109 template <class C> void SetProbeResult(
109 const std::string& test_url, 110 const std::string& test_url,
111 const std::string& warmup_test_url,
110 const std::string& response, 112 const std::string& response,
111 ProbeURLFetchResult state, 113 ProbeURLFetchResult state,
112 bool success, 114 bool success,
113 int expected_calls); 115 int expected_calls);
114 virtual void SetProbeResult(const std::string& test_url, 116 virtual void SetProbeResult(const std::string& test_url,
117 const std::string& warmup_test_url,
115 const std::string& response, 118 const std::string& response,
116 ProbeURLFetchResult result, 119 ProbeURLFetchResult result,
117 bool success, 120 bool success,
118 int expected_calls) = 0; 121 int expected_calls) = 0;
119 122
120 void CheckProxyConfigs(bool expected_enabled, 123 void CheckProxyConfigs(bool expected_enabled,
121 bool expected_restricted, 124 bool expected_restricted,
122 bool expected_fallback_restricted); 125 bool expected_fallback_restricted);
123 void CheckProbe(bool initially_enabled, 126 void CheckProbe(bool initially_enabled,
124 const std::string& probe_url, 127 const std::string& probe_url,
128 const std::string& warmup_url,
125 const std::string& response, 129 const std::string& response,
126 bool request_success, 130 bool request_success,
127 bool expected_enabled, 131 bool expected_enabled,
128 bool expected_restricted, 132 bool expected_restricted,
129 bool expected_fallback_restricted); 133 bool expected_fallback_restricted);
130 void CheckProbeOnIPChange(const std::string& probe_url, 134 void CheckProbeOnIPChange(const std::string& probe_url,
135 const std::string& warmup_url,
131 const std::string& response, 136 const std::string& response,
132 bool request_success, 137 bool request_success,
133 bool expected_enabled, 138 bool expected_enabled,
134 bool expected_fallback_restricted); 139 bool expected_fallback_restricted);
135 void CheckOnPrefChange(bool enabled, bool expected_enabled, bool managed); 140 void CheckOnPrefChange(bool enabled, bool expected_enabled, bool managed);
136 void CheckInitDataReductionProxy(bool enabled_at_startup); 141 void CheckInitDataReductionProxy(bool enabled_at_startup);
137 142
138 TestingPrefServiceSimple pref_service_; 143 TestingPrefServiceSimple pref_service_;
139 scoped_ptr<DataReductionProxySettings> settings_; 144 scoped_ptr<DataReductionProxySettings> settings_;
140 base::Time last_update_time_; 145 base::Time last_update_time_;
141 }; 146 };
142 147
143 // Test implementations should be subclasses of an instantiation of this 148 // Test implementations should be subclasses of an instantiation of this
144 // class parameterized for whatever DataReductionProxySettings class 149 // class parameterized for whatever DataReductionProxySettings class
145 // is being tested. 150 // is being tested.
146 template <class C> 151 template <class C>
147 class ConcreteDataReductionProxySettingsTest 152 class ConcreteDataReductionProxySettingsTest
148 : public DataReductionProxySettingsTestBase { 153 : public DataReductionProxySettingsTestBase {
149 public: 154 public:
150 typedef MockDataReductionProxySettings<C> MockSettings; 155 typedef MockDataReductionProxySettings<C> MockSettings;
151 virtual void ResetSettings(bool allowed, 156 virtual void ResetSettings(bool allowed,
152 bool fallback_allowed, 157 bool fallback_allowed,
153 bool alt_allowed, 158 bool alt_allowed,
154 bool promo_allowed) OVERRIDE { 159 bool promo_allowed) OVERRIDE {
155 return DataReductionProxySettingsTestBase::ResetSettings<C>( 160 return DataReductionProxySettingsTestBase::ResetSettings<C>(
156 allowed, fallback_allowed, alt_allowed, promo_allowed); 161 allowed, fallback_allowed, alt_allowed, promo_allowed);
157 } 162 }
158 163
159 virtual void SetProbeResult(const std::string& test_url, 164 virtual void SetProbeResult(const std::string& test_url,
165 const std::string& warmup_test_url,
160 const std::string& response, 166 const std::string& response,
161 ProbeURLFetchResult result, 167 ProbeURLFetchResult result,
162 bool success, 168 bool success,
163 int expected_calls) OVERRIDE { 169 int expected_calls) OVERRIDE {
164 return DataReductionProxySettingsTestBase::SetProbeResult<C>( 170 return DataReductionProxySettingsTestBase::SetProbeResult<C>(
165 test_url, response, result, success, expected_calls); 171 test_url,
172 warmup_test_url,
173 response,
174 result,
175 success,
176 expected_calls);
166 } 177 }
167 }; 178 };
168 179
169 } // namespace data_reduction_proxy 180 } // namespace data_reduction_proxy
170 181
171 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _TEST_UTILS_H_ 182 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_SETTINGS _TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698