| 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_android.h" | 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_settings_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "base/test/test_simple_task_runner.h" |
| 16 #include "base/time/time.h" |
| 13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 17 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
| 14 #include "chrome/browser/prefs/proxy_prefs.h" | 18 #include "chrome/browser/prefs/proxy_prefs.h" |
| 15 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings_test_utils.h" | 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings_test_utils.h" |
| 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 21 | 26 |
| 22 using testing::_; | 27 using testing::_; |
| 23 using testing::AnyNumber; | 28 using testing::AnyNumber; |
| 24 using testing::Return; | 29 using testing::Return; |
| 25 | 30 |
| 26 const char kDataReductionProxyDev[] = "http://foo-dev.com:80"; | 31 const char kDataReductionProxyDev[] = "http://foo-dev.com:80"; |
| 27 | 32 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 new MockDataReductionProxySettings<C>(flags); | 74 new MockDataReductionProxySettings<C>(flags); |
| 70 EXPECT_CALL(*settings, GetOriginalProfilePrefs()) | 75 EXPECT_CALL(*settings, GetOriginalProfilePrefs()) |
| 71 .Times(AnyNumber()) | 76 .Times(AnyNumber()) |
| 72 .WillRepeatedly(Return(&pref_service_)); | 77 .WillRepeatedly(Return(&pref_service_)); |
| 73 EXPECT_CALL(*settings, GetLocalStatePrefs()) | 78 EXPECT_CALL(*settings, GetLocalStatePrefs()) |
| 74 .Times(AnyNumber()) | 79 .Times(AnyNumber()) |
| 75 .WillRepeatedly(Return(&pref_service_)); | 80 .WillRepeatedly(Return(&pref_service_)); |
| 76 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck()).Times(0); | 81 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck()).Times(0); |
| 77 EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0); | 82 EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0); |
| 78 settings_.reset(settings); | 83 settings_.reset(settings); |
| 79 settings_->SetDataReductionProxyStatisticsPrefs(statistics_prefs_.get()); | 84 settings_->SetDataReductionProxyStatisticsPrefs( |
| 85 scoped_ptr<DataReductionProxyStatisticsPrefs>( |
| 86 new DataReductionProxyStatisticsPrefs( |
| 87 &pref_service_, |
| 88 scoped_refptr<base::TestSimpleTaskRunner>( |
| 89 new base::TestSimpleTaskRunner()), |
| 90 base::TimeDelta()))); |
| 80 } | 91 } |
| 81 | 92 |
| 82 template <class C> | 93 template <class C> |
| 83 void data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult( | 94 void data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult( |
| 84 const std::string& test_url, | 95 const std::string& test_url, |
| 85 const std::string& response, | 96 const std::string& response, |
| 86 ProbeURLFetchResult result, | 97 ProbeURLFetchResult result, |
| 87 bool success, | 98 bool success, |
| 88 int expected_calls) { | 99 int expected_calls) { |
| 89 MockDataReductionProxySettings<C>* settings = | 100 MockDataReductionProxySettings<C>* settings = |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 198 |
| 188 jlong value; | 199 jlong value; |
| 189 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { | 200 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { |
| 190 env_->GetLongArrayRegion(result.obj(), i, 1, &value); | 201 env_->GetLongArrayRegion(result.obj(), i, 1, &value); |
| 191 ASSERT_EQ( | 202 ASSERT_EQ( |
| 192 static_cast<long>( | 203 static_cast<long>( |
| 193 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value); | 204 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value); |
| 194 } | 205 } |
| 195 } | 206 } |
| 196 | 207 |
| OLD | NEW |