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

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

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 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"
(...skipping 27 matching lines...) Expand all
38 if (promo_allowed) 38 if (promo_allowed)
39 flags |= DataReductionProxyParams::kPromoAllowed; 39 flags |= DataReductionProxyParams::kPromoAllowed;
40 MockDataReductionProxySettings<C>* settings = 40 MockDataReductionProxySettings<C>* settings =
41 new MockDataReductionProxySettings<C>(flags); 41 new MockDataReductionProxySettings<C>(flags);
42 EXPECT_CALL(*settings, GetOriginalProfilePrefs()) 42 EXPECT_CALL(*settings, GetOriginalProfilePrefs())
43 .Times(AnyNumber()) 43 .Times(AnyNumber())
44 .WillRepeatedly(Return(&pref_service_)); 44 .WillRepeatedly(Return(&pref_service_));
45 EXPECT_CALL(*settings, GetLocalStatePrefs()) 45 EXPECT_CALL(*settings, GetLocalStatePrefs())
46 .Times(AnyNumber()) 46 .Times(AnyNumber())
47 .WillRepeatedly(Return(&pref_service_)); 47 .WillRepeatedly(Return(&pref_service_));
48 EXPECT_CALL(*settings, GetURLFetcher()).Times(0); 48 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck()).Times(0);
49 EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0); 49 EXPECT_CALL(*settings, LogProxyState(_, _, _)).Times(0);
50 settings_.reset(settings); 50 settings_.reset(settings);
51 } 51 }
52 52
53 template <class C> 53 template <class C>
54 void data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult( 54 void data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult(
55 const std::string& test_url, 55 const std::string& test_url,
56 const std::string& warmup_test_url,
56 const std::string& response, 57 const std::string& response,
57 ProbeURLFetchResult result, 58 ProbeURLFetchResult result,
58 bool success, 59 bool success,
59 int expected_calls) { 60 int expected_calls) {
60 MockDataReductionProxySettings<C>* settings = 61 MockDataReductionProxySettings<C>* settings =
61 static_cast<MockDataReductionProxySettings<C>*>(settings_.get()); 62 static_cast<MockDataReductionProxySettings<C>*>(settings_.get());
62 if (0 == expected_calls) { 63 if (0 == expected_calls) {
63 EXPECT_CALL(*settings, GetURLFetcher()).Times(0); 64 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck()).Times(0);
64 EXPECT_CALL(*settings, RecordProbeURLFetchResult(_)).Times(0); 65 EXPECT_CALL(*settings, RecordProbeURLFetchResult(_)).Times(0);
65 } else { 66 } else {
66 EXPECT_CALL(*settings, RecordProbeURLFetchResult(result)).Times(1); 67 EXPECT_CALL(*settings, RecordProbeURLFetchResult(result)).Times(1);
67 EXPECT_CALL(*settings, GetURLFetcher()) 68 EXPECT_CALL(*settings, GetURLFetcherForAvailabilityCheck())
68 .Times(expected_calls) 69 .Times(expected_calls)
69 .WillRepeatedly(Return(new net::FakeURLFetcher( 70 .WillRepeatedly(Return(new net::FakeURLFetcher(
70 GURL(test_url), 71 GURL(test_url),
71 settings, 72 settings,
72 response, 73 response,
73 success ? net::HTTP_OK : net::HTTP_INTERNAL_SERVER_ERROR, 74 success ? net::HTTP_OK : net::HTTP_INTERNAL_SERVER_ERROR,
74 success ? net::URLRequestStatus::SUCCESS : 75 success ? net::URLRequestStatus::SUCCESS :
75 net::URLRequestStatus::FAILED))); 76 net::URLRequestStatus::FAILED)));
76 } 77 }
77 } 78 }
78 79
79 template void 80 template void
80 data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings< 81 data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings<
81 DataReductionProxySettingsAndroid>(bool allowed, 82 DataReductionProxySettingsAndroid>(bool allowed,
82 bool fallback_allowed, 83 bool fallback_allowed,
83 bool alt_allowed, 84 bool alt_allowed,
84 bool promo_allowed); 85 bool promo_allowed);
85 86
86 template void 87 template void
87 data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult< 88 data_reduction_proxy::DataReductionProxySettingsTestBase::SetProbeResult<
88 DataReductionProxySettingsAndroid>(const std::string& test_url, 89 DataReductionProxySettingsAndroid>(const std::string& test_url,
90 const std::string& warmup_test_url,
89 const std::string& response, 91 const std::string& response,
90 ProbeURLFetchResult result, 92 ProbeURLFetchResult result,
91 bool success, 93 bool success,
92 int expected_calls); 94 int expected_calls);
93 95
94 class DataReductionProxySettingsAndroidTest 96 class DataReductionProxySettingsAndroidTest
95 : public data_reduction_proxy::ConcreteDataReductionProxySettingsTest< 97 : public data_reduction_proxy::ConcreteDataReductionProxySettingsTest<
96 DataReductionProxySettingsAndroid> { 98 DataReductionProxySettingsAndroid> {
97 public: 99 public:
98 // DataReductionProxySettingsTest implementation: 100 // DataReductionProxySettingsTest implementation:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 jlong value; 148 jlong value;
147 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { 149 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) {
148 env_->GetLongArrayRegion(result.obj(), i, 1, &value); 150 env_->GetLongArrayRegion(result.obj(), i, 1, &value);
149 ASSERT_EQ( 151 ASSERT_EQ(
150 static_cast<long>( 152 static_cast<long>(
151 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), 153 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2),
152 value); 154 value);
153 } 155 }
154 } 156 }
155 157
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.cc ('k') | components/data_reduction_proxy/browser/data_reduction_proxy_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698