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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Returns the provided setting object. Used by wrapping methods. | 55 // Returns the provided setting object. Used by wrapping methods. |
56 DataReductionProxySettings* Settings() override { return settings_; } | 56 DataReductionProxySettings* Settings() override { return settings_; } |
57 | 57 |
58 // The wrapped settings object. | 58 // The wrapped settings object. |
59 DataReductionProxySettings* settings_; | 59 DataReductionProxySettings* settings_; |
60 }; | 60 }; |
61 | 61 |
62 template <class C> | 62 template <class C> |
63 void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings( | 63 void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings( |
64 std::unique_ptr<base::Clock> clock, | 64 std::unique_ptr<base::Clock> clock) { |
65 bool promo_allowed, | |
66 bool holdback) { | |
67 int flags = 0; | |
68 if (promo_allowed) | |
69 flags |= DataReductionProxyParams::kPromoAllowed; | |
70 if (holdback) | |
71 flags |= DataReductionProxyParams::kHoldback; | |
72 MockDataReductionProxySettings<C>* settings = | 65 MockDataReductionProxySettings<C>* settings = |
73 new MockDataReductionProxySettings<C>(); | 66 new MockDataReductionProxySettings<C>(); |
74 settings->config_ = test_context_->config(); | 67 settings->config_ = test_context_->config(); |
75 test_context_->config()->ResetParamFlagsForTest(flags); | 68 test_context_->config()->ResetParamFlagsForTest(); |
76 settings->UpdateConfigValues(); | |
77 EXPECT_CALL(*settings, GetOriginalProfilePrefs()) | 69 EXPECT_CALL(*settings, GetOriginalProfilePrefs()) |
78 .Times(AnyNumber()) | 70 .Times(AnyNumber()) |
79 .WillRepeatedly(Return(test_context_->pref_service())); | 71 .WillRepeatedly(Return(test_context_->pref_service())); |
80 EXPECT_CALL(*settings, GetLocalStatePrefs()) | 72 EXPECT_CALL(*settings, GetLocalStatePrefs()) |
81 .Times(AnyNumber()) | 73 .Times(AnyNumber()) |
82 .WillRepeatedly(Return(test_context_->pref_service())); | 74 .WillRepeatedly(Return(test_context_->pref_service())); |
83 settings_.reset(settings); | 75 settings_.reset(settings); |
84 settings_->data_reduction_proxy_service_ = | 76 settings_->data_reduction_proxy_service_ = |
85 test_context_->CreateDataReductionProxyService(settings_.get()); | 77 test_context_->CreateDataReductionProxyService(settings_.get()); |
86 } | 78 } |
87 | 79 |
88 template void | 80 template void |
89 data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings< | 81 data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings< |
90 DataReductionProxyChromeSettings>(std::unique_ptr<base::Clock> clock, | 82 DataReductionProxyChromeSettings>(std::unique_ptr<base::Clock> clock); |
91 bool promo_allowed, | |
92 bool holdback); | |
93 | 83 |
94 class DataReductionProxySettingsAndroidTest | 84 class DataReductionProxySettingsAndroidTest |
95 : public data_reduction_proxy::ConcreteDataReductionProxySettingsTest< | 85 : public data_reduction_proxy::ConcreteDataReductionProxySettingsTest< |
96 DataReductionProxyChromeSettings> { | 86 DataReductionProxyChromeSettings> { |
97 public: | 87 public: |
98 // DataReductionProxySettingsTest implementation: | 88 // DataReductionProxySettingsTest implementation: |
99 void SetUp() override { | 89 void SetUp() override { |
100 env_ = base::android::AttachCurrentThread(); | 90 env_ = base::android::AttachCurrentThread(); |
101 DataReductionProxySettingsAndroid::Register(env_); | 91 DataReductionProxySettingsAndroid::Register(env_); |
102 DataReductionProxySettingsTestBase::SetUp(); | 92 DataReductionProxySettingsTestBase::SetUp(); |
(...skipping 28 matching lines...) Expand all Loading... |
131 java_array_len); | 121 java_array_len); |
132 | 122 |
133 jlong value; | 123 jlong value; |
134 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { | 124 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { |
135 env_->GetLongArrayRegion(result.obj(), i, 1, &value); | 125 env_->GetLongArrayRegion(result.obj(), i, 1, &value); |
136 ASSERT_EQ( | 126 ASSERT_EQ( |
137 static_cast<long>( | 127 static_cast<long>( |
138 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value); | 128 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value); |
139 } | 129 } |
140 } | 130 } |
OLD | NEW |