| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 registry->RegisterDictionaryPref(prefs::kProxy); | 76 registry->RegisterDictionaryPref(prefs::kProxy); |
| 77 registry->RegisterBooleanPref(prefs::kSpdyProxyAuthEnabled, false); | 77 registry->RegisterBooleanPref(prefs::kSpdyProxyAuthEnabled, false); |
| 78 registry->RegisterBooleanPref(prefs::kSpdyProxyAuthWasEnabledBefore, false); | 78 registry->RegisterBooleanPref(prefs::kSpdyProxyAuthWasEnabledBefore, false); |
| 79 ResetSettings(); | 79 ResetSettings(); |
| 80 | 80 |
| 81 ListPrefUpdate original_update(&pref_service_, | 81 ListPrefUpdate original_update(&pref_service_, |
| 82 prefs::kDailyHttpOriginalContentLength); | 82 prefs::kDailyHttpOriginalContentLength); |
| 83 ListPrefUpdate received_update(&pref_service_, | 83 ListPrefUpdate received_update(&pref_service_, |
| 84 prefs::kDailyHttpReceivedContentLength); | 84 prefs::kDailyHttpReceivedContentLength); |
| 85 for (int64 i = 0; i < spdyproxy::kNumDaysInHistory; i++) { | 85 for (int64 i = 0; i < spdyproxy::kNumDaysInHistory; i++) { |
| 86 original_update->Insert(0, new StringValue(base::Int64ToString(2 * i))); | 86 original_update->Insert(0, |
| 87 received_update->Insert(0, new StringValue(base::Int64ToString(i))); | 87 new base::StringValue(base::Int64ToString(2 * i))); |
| 88 received_update->Insert(0, new base::StringValue(base::Int64ToString(i))); |
| 88 } | 89 } |
| 89 last_update_time_ = base::Time::Now().LocalMidnight(); | 90 last_update_time_ = base::Time::Now().LocalMidnight(); |
| 90 pref_service_.SetInt64( | 91 pref_service_.SetInt64( |
| 91 prefs::kDailyHttpContentLengthLastUpdateDate, | 92 prefs::kDailyHttpContentLengthLastUpdateDate, |
| 92 last_update_time_.ToInternalValue()); | 93 last_update_time_.ToInternalValue()); |
| 93 } | 94 } |
| 94 | 95 |
| 95 template <class C> | 96 template <class C> |
| 96 void DataReductionProxySettingsTestBase::ResetSettings() { | 97 void DataReductionProxySettingsTestBase::ResetSettings() { |
| 97 MockDataReductionProxySettings<C>* settings = | 98 MockDataReductionProxySettings<C>* settings = |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 template void | 148 template void |
| 148 DataReductionProxySettingsTestBase::SetProbeResult< | 149 DataReductionProxySettingsTestBase::SetProbeResult< |
| 149 DataReductionProxySettingsAndroid>(const std::string& test_url, | 150 DataReductionProxySettingsAndroid>(const std::string& test_url, |
| 150 const std::string& response, | 151 const std::string& response, |
| 151 bool success, | 152 bool success, |
| 152 int expected_calls); | 153 int expected_calls); |
| 153 | 154 |
| 154 void DataReductionProxySettingsTestBase::CheckProxyPref( | 155 void DataReductionProxySettingsTestBase::CheckProxyPref( |
| 155 const std::string& expected_servers, | 156 const std::string& expected_servers, |
| 156 const std::string& expected_mode) { | 157 const std::string& expected_mode) { |
| 157 const DictionaryValue* dict = pref_service_.GetDictionary(prefs::kProxy); | 158 const base::DictionaryValue* dict = |
| 159 pref_service_.GetDictionary(prefs::kProxy); |
| 158 std::string mode; | 160 std::string mode; |
| 159 std::string server; | 161 std::string server; |
| 160 dict->GetString("mode", &mode); | 162 dict->GetString("mode", &mode); |
| 161 ASSERT_EQ(expected_mode, mode); | 163 ASSERT_EQ(expected_mode, mode); |
| 162 dict->GetString("server", &server); | 164 dict->GetString("server", &server); |
| 163 ASSERT_EQ(expected_servers, server); | 165 ASSERT_EQ(expected_servers, server); |
| 164 } | 166 } |
| 165 | 167 |
| 166 void DataReductionProxySettingsTestBase::CheckProxyConfigs( | 168 void DataReductionProxySettingsTestBase::CheckProxyConfigs( |
| 167 bool expected_enabled, bool expected_restricted) { | 169 bool expected_enabled, bool expected_restricted) { |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { | 609 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| 608 std::string headers(tests[i].headers); | 610 std::string headers(tests[i].headers); |
| 609 HeadersToRaw(&headers); | 611 HeadersToRaw(&headers); |
| 610 scoped_refptr<net::HttpResponseHeaders> parsed( | 612 scoped_refptr<net::HttpResponseHeaders> parsed( |
| 611 new net::HttpResponseHeaders(headers)); | 613 new net::HttpResponseHeaders(headers)); |
| 612 | 614 |
| 613 EXPECT_EQ(tests[i].expected_result, | 615 EXPECT_EQ(tests[i].expected_result, |
| 614 DataReductionProxySettings::WasFetchedViaProxy(parsed)); | 616 DataReductionProxySettings::WasFetchedViaProxy(parsed)); |
| 615 } | 617 } |
| 616 } | 618 } |
| OLD | NEW |