OLD | NEW |
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/browser/data_reduction_proxy_settings_
test_utils.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings_
test_utils.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/test/test_simple_task_runner.h" | 13 #include "base/test/test_simple_task_runner.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" | 15 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic
s_prefs.h" | 16 #include "components/data_reduction_proxy/browser/data_reduction_proxy_statistic
s_prefs.h" |
17 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers_te
st_utils.h" | |
18 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" | 17 #include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names
.h" |
19 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" | 18 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" |
20 | 19 |
21 using testing::_; | 20 using testing::_; |
22 using testing::AnyNumber; | 21 using testing::AnyNumber; |
23 using testing::Return; | 22 using testing::Return; |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 const char kProbeURLWithOKResponse[] = "http://ok.org/"; | 26 const char kProbeURLWithOKResponse[] = "http://ok.org/"; |
28 | 27 |
29 const char kProxy[] = "proxy"; | 28 const char kProxy[] = "proxy"; |
30 | 29 |
31 } // namespace | 30 } // namespace |
32 | 31 |
33 namespace data_reduction_proxy { | 32 namespace data_reduction_proxy { |
34 | 33 |
| 34 // Transform "normal"-looking headers (\n-separated) to the appropriate |
| 35 // input format for ParseRawHeaders (\0-separated). |
| 36 void HeadersToRaw(std::string* headers) { |
| 37 std::replace(headers->begin(), headers->end(), '\n', '\0'); |
| 38 if (!headers->empty()) |
| 39 *headers += '\0'; |
| 40 } |
| 41 |
35 ProbeURLFetchResult FetchResult(bool enabled, bool success) { | 42 ProbeURLFetchResult FetchResult(bool enabled, bool success) { |
36 if (enabled) { | 43 if (enabled) { |
37 if (success) | 44 if (success) |
38 return SUCCEEDED_PROXY_ALREADY_ENABLED; | 45 return SUCCEEDED_PROXY_ALREADY_ENABLED; |
39 return FAILED_PROXY_DISABLED; | 46 return FAILED_PROXY_DISABLED; |
40 } | 47 } |
41 if (success) | 48 if (success) |
42 return SUCCEEDED_PROXY_ENABLED; | 49 return SUCCEEDED_PROXY_ENABLED; |
43 return FAILED_PROXY_ALREADY_DISABLED; | 50 return FAILED_PROXY_ALREADY_DISABLED; |
44 } | 51 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 base::Bind(&DataReductionProxySettingsTestBase:: | 300 base::Bind(&DataReductionProxySettingsTestBase:: |
294 RegisterSyntheticFieldTrialCallback, | 301 RegisterSyntheticFieldTrialCallback, |
295 base::Unretained(this))); | 302 base::Unretained(this))); |
296 | 303 |
297 base::MessageLoop::current()->RunUntilIdle(); | 304 base::MessageLoop::current()->RunUntilIdle(); |
298 CheckProxyConfigs(enabled_at_startup, false, false); | 305 CheckProxyConfigs(enabled_at_startup, false, false); |
299 EXPECT_EQ(enabled_at_startup, proxy_enabled_); | 306 EXPECT_EQ(enabled_at_startup, proxy_enabled_); |
300 } | 307 } |
301 | 308 |
302 } // namespace data_reduction_proxy | 309 } // namespace data_reduction_proxy |
OLD | NEW |