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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_settings_unittest_android.cc

Issue 888713002: DataReductionProxyStatisticsPrefs should support WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Webview fix Created 5 years, 10 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 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 "net/proxy/proxy_server.h" 23 #include "net/proxy/proxy_server.h"
19 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
21 #include "url/gurl.h" 26 #include "url/gurl.h"
22 27
23 using testing::_; 28 using testing::_;
24 using testing::AnyNumber; 29 using testing::AnyNumber;
25 using testing::Return; 30 using testing::Return;
26 31
27 const char kDataReductionProxyDev[] = "foo-dev.com:80"; 32 const char kDataReductionProxyDev[] = "foo-dev.com:80";
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 new MockDataReductionProxySettings<C>(flags); 73 new MockDataReductionProxySettings<C>(flags);
69 EXPECT_CALL(*settings, GetOriginalProfilePrefs()) 74 EXPECT_CALL(*settings, GetOriginalProfilePrefs())
70 .Times(AnyNumber()) 75 .Times(AnyNumber())
71 .WillRepeatedly(Return(&pref_service_)); 76 .WillRepeatedly(Return(&pref_service_));
72 EXPECT_CALL(*settings, GetLocalStatePrefs()) 77 EXPECT_CALL(*settings, GetLocalStatePrefs())
73 .Times(AnyNumber()) 78 .Times(AnyNumber())
74 .WillRepeatedly(Return(&pref_service_)); 79 .WillRepeatedly(Return(&pref_service_));
75 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck()).Times(0); 80 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck()).Times(0);
76 EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0); 81 EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0);
77 settings_.reset(settings); 82 settings_.reset(settings);
78 settings_->SetDataReductionProxyStatisticsPrefs(statistics_prefs_.get()); 83 settings_->SetDataReductionProxyStatisticsPrefs(
84 scoped_ptr<DataReductionProxyStatisticsPrefs>(
85 new DataReductionProxyStatisticsPrefs(
86 &pref_service_,
87 scoped_refptr<base::TestSimpleTaskRunner>(
88 new base::TestSimpleTaskRunner()),
89 base::TimeDelta())));
79 } 90 }
80 91
81 template <class C> 92 template <class C>
82 void data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult( 93 void data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult(
83 const std::string& test_url, 94 const std::string& test_url,
84 const std::string& response, 95 const std::string& response,
85 ProbeURLFetchResult result, 96 ProbeURLFetchResult result,
86 bool success, 97 bool success,
87 int expected_calls) { 98 int expected_calls) {
88 MockDataReductionProxySettings<C>* settings = 99 MockDataReductionProxySettings<C>* settings =
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 197
187 jlong value; 198 jlong value;
188 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { 199 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) {
189 env_->GetLongArrayRegion(result.obj(), i, 1, &value); 200 env_->GetLongArrayRegion(result.obj(), i, 1, &value);
190 ASSERT_EQ( 201 ASSERT_EQ(
191 static_cast<long>( 202 static_cast<long>(
192 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value); 203 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value);
193 } 204 }
194 } 205 }
195 206
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698