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

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

Issue 2439303002: Record UMA on number of days since data reduction proxy is enabled. (Closed)
Patch Set: fix compile error Created 4 years, 1 month 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
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 13 matching lines...) Expand all
24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h" 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h"
26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h" 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h"
27 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
28 #include "components/proxy_config/proxy_prefs.h" 28 #include "components/proxy_config/proxy_prefs.h"
29 #include "net/proxy/proxy_server.h" 29 #include "net/proxy/proxy_server.h"
30 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
31 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
32 #include "url/gurl.h" 32 #include "url/gurl.h"
33 33
34 namespace base {
35 class Clock;
36 }
37
34 using testing::_; 38 using testing::_;
35 using testing::AnyNumber; 39 using testing::AnyNumber;
36 using testing::Return; 40 using testing::Return;
37 41
38 using data_reduction_proxy::DataReductionProxySettings; 42 using data_reduction_proxy::DataReductionProxySettings;
39 43
40 // Used for testing the DataReductionProxySettingsAndroid class. 44 // Used for testing the DataReductionProxySettingsAndroid class.
41 class TestDataReductionProxySettingsAndroid 45 class TestDataReductionProxySettingsAndroid
42 : public DataReductionProxySettingsAndroid { 46 : public DataReductionProxySettingsAndroid {
43 public: 47 public:
44 // Constructs an Android settings object for test that wraps the provided 48 // Constructs an Android settings object for test that wraps the provided
45 // settings object. 49 // settings object.
46 explicit TestDataReductionProxySettingsAndroid( 50 explicit TestDataReductionProxySettingsAndroid(
47 DataReductionProxySettings* settings) 51 DataReductionProxySettings* settings)
48 : DataReductionProxySettingsAndroid(), 52 : DataReductionProxySettingsAndroid(),
49 settings_(settings) {} 53 settings_(settings) {}
50 54
51 // Returns the provided setting object. Used by wrapping methods. 55 // Returns the provided setting object. Used by wrapping methods.
52 DataReductionProxySettings* Settings() override { return settings_; } 56 DataReductionProxySettings* Settings() override { return settings_; }
53 57
54 // The wrapped settings object. 58 // The wrapped settings object.
55 DataReductionProxySettings* settings_; 59 DataReductionProxySettings* settings_;
56 }; 60 };
57 61
58 template <class C> 62 template <class C>
59 void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings( 63 void data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings(
64 std::unique_ptr<base::Clock> clock,
60 bool allowed, 65 bool allowed,
61 bool fallback_allowed, 66 bool fallback_allowed,
62 bool promo_allowed, 67 bool promo_allowed,
63 bool holdback) { 68 bool holdback) {
64 int flags = 0; 69 int flags = 0;
65 if (allowed) 70 if (allowed)
66 flags |= DataReductionProxyParams::kAllowed; 71 flags |= DataReductionProxyParams::kAllowed;
67 if (fallback_allowed) 72 if (fallback_allowed)
68 flags |= DataReductionProxyParams::kFallbackAllowed; 73 flags |= DataReductionProxyParams::kFallbackAllowed;
69 if (promo_allowed) 74 if (promo_allowed)
(...skipping 11 matching lines...) Expand all
81 EXPECT_CALL(*settings, GetLocalStatePrefs()) 86 EXPECT_CALL(*settings, GetLocalStatePrefs())
82 .Times(AnyNumber()) 87 .Times(AnyNumber())
83 .WillRepeatedly(Return(test_context_->pref_service())); 88 .WillRepeatedly(Return(test_context_->pref_service()));
84 settings_.reset(settings); 89 settings_.reset(settings);
85 settings_->data_reduction_proxy_service_ = 90 settings_->data_reduction_proxy_service_ =
86 test_context_->CreateDataReductionProxyService(settings_.get()); 91 test_context_->CreateDataReductionProxyService(settings_.get());
87 } 92 }
88 93
89 template void 94 template void
90 data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings< 95 data_reduction_proxy::DataReductionProxySettingsTestBase::ResetSettings<
91 DataReductionProxyChromeSettings>(bool allowed, 96 DataReductionProxyChromeSettings>(std::unique_ptr<base::Clock> clock,
92 bool fallback_allowed, 97 bool allowed,
93 bool promo_allowed, 98 bool fallback_allowed,
94 bool holdback); 99 bool promo_allowed,
100 bool holdback);
95 101
96 class DataReductionProxySettingsAndroidTest 102 class DataReductionProxySettingsAndroidTest
97 : public data_reduction_proxy::ConcreteDataReductionProxySettingsTest< 103 : public data_reduction_proxy::ConcreteDataReductionProxySettingsTest<
98 DataReductionProxyChromeSettings> { 104 DataReductionProxyChromeSettings> {
99 public: 105 public:
100 // DataReductionProxySettingsTest implementation: 106 // DataReductionProxySettingsTest implementation:
101 void SetUp() override { 107 void SetUp() override {
102 env_ = base::android::AttachCurrentThread(); 108 env_ = base::android::AttachCurrentThread();
103 DataReductionProxySettingsAndroid::Register(env_); 109 DataReductionProxySettingsAndroid::Register(env_);
104 DataReductionProxySettingsTestBase::SetUp(); 110 DataReductionProxySettingsTestBase::SetUp();
(...skipping 28 matching lines...) Expand all
133 java_array_len); 139 java_array_len);
134 140
135 jlong value; 141 jlong value;
136 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) { 142 for (size_t i = 0; i < data_reduction_proxy::kNumDaysInHistory; ++i) {
137 env_->GetLongArrayRegion(result.obj(), i, 1, &value); 143 env_->GetLongArrayRegion(result.obj(), i, 1, &value);
138 ASSERT_EQ( 144 ASSERT_EQ(
139 static_cast<long>( 145 static_cast<long>(
140 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value); 146 (data_reduction_proxy::kNumDaysInHistory - 1 - i) * 2), value);
141 } 147 }
142 } 148 }
OLDNEW
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698