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

Side by Side Diff: chrome/browser/safe_browsing/chrome_password_protection_service_unittest.cc

Issue 2872993003: Rename LowReputationPinging Feature to PasswordFieldOnFocusPinging (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | components/safe_browsing/password_protection/password_protection_service.h » ('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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "chrome/browser/safe_browsing/chrome_password_protection_service.h" 4 #include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
5 5
6 #include "base/test/scoped_feature_list.h" 6 #include "base/test/scoped_feature_list.h"
7 #include "components/variations/variations_params_manager.h" 7 #include "components/variations/variations_params_manager.h"
8 #include "content/public/test/test_browser_thread_bundle.h" 8 #include "content/public/test/test_browser_thread_bundle.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 protected: 68 protected:
69 content::TestBrowserThreadBundle thread_bundle_; 69 content::TestBrowserThreadBundle thread_bundle_;
70 variations::testing::VariationParamsManager params_manager_; 70 variations::testing::VariationParamsManager params_manager_;
71 base::test::ScopedFeatureList scoped_feature_list_; 71 base::test::ScopedFeatureList scoped_feature_list_;
72 }; 72 };
73 73
74 TEST_F(ChromePasswordProtectionServiceTest, 74 TEST_F(ChromePasswordProtectionServiceTest,
75 VerifyFinchControlForLowReputationPingSBEROnlyNoIncognito) { 75 VerifyFinchControlForLowReputationPingSBEROnlyNoIncognito) {
76 MockChromePasswordProtectionService service; 76 MockChromePasswordProtectionService service;
77 // By default kLowReputationPinging feature is disabled. 77 // By default kPasswordFieldOnFocusPinging feature is disabled.
78 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 78 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
79 79
80 // Enables kLowReputationPinging feature. 80 // Enables kPasswordFieldOnFocusPinging feature.
81 scoped_feature_list_.InitAndEnableFeature(kLowReputationPinging); 81 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
82 // Creates finch trial parameters correspond to the following experiment: 82 // Creates finch trial parameters correspond to the following experiment:
83 // "name": "SBEROnlyNoIncognito", 83 // "name": "SBEROnlyNoIncognito",
84 // "params": { 84 // "params": {
85 // "incognito": "false", 85 // "incognito": "false",
86 // "extended_reporting": "true", 86 // "extended_reporting": "true",
87 // "history_sync": "false" 87 // "history_sync": "false"
88 // }, 88 // },
89 // "enable_features": [ 89 // "enable_features": [
90 // "LowReputationPinging" 90 // "PasswordFieldOnFocusPinging"
91 // ] 91 // ]
92 Parameters sber_and_no_incognito = 92 Parameters sber_and_no_incognito =
93 CreateParameters(false, false, true, false); 93 CreateParameters(false, false, true, false);
94 SetFeatureParams(kLowReputationPinging, "SBEROnlyNoIncognito", 94 SetFeatureParams(kPasswordFieldOnFocusPinging, "SBEROnlyNoIncognito",
95 sber_and_no_incognito); 95 sber_and_no_incognito);
96 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); 96 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
97 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 97 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
98 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); 98 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
99 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 99 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
100 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); 100 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
101 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 101 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
102 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); 102 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
103 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 103 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
104 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); 104 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
105 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 105 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
106 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); 106 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
107 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 107 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
108 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); 108 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
109 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 109 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
110 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); 110 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
111 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 111 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
112 } 112 }
113 113
114 TEST_F(ChromePasswordProtectionServiceTest, 114 TEST_F(ChromePasswordProtectionServiceTest,
115 VerifyFinchControlForLowReputationPingSBERAndHistorySyncNoIncognito) { 115 VerifyFinchControlForLowReputationPingSBERAndHistorySyncNoIncognito) {
116 MockChromePasswordProtectionService service; 116 MockChromePasswordProtectionService service;
117 // By default kLowReputationPinging feature is disabled. 117 // By default kPasswordFieldOnFocusPinging feature is disabled.
118 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 118 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
119 119
120 // Enables kLowReputationPinging feature. 120 // Enables kPasswordFieldOnFocusPinging feature.
121 scoped_feature_list_.InitAndEnableFeature(kLowReputationPinging); 121 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
122 // Creates finch trial parameters correspond to the following experiment: 122 // Creates finch trial parameters correspond to the following experiment:
123 // "name": "SBERAndHistorySyncNoIncognito", 123 // "name": "SBERAndHistorySyncNoIncognito",
124 // "params": { 124 // "params": {
125 // "incognito": "false", 125 // "incognito": "false",
126 // "extended_reporting": "true", 126 // "extended_reporting": "true",
127 // "history_sync": "true" 127 // "history_sync": "true"
128 // }, 128 // },
129 // "enable_features": [ 129 // "enable_features": [
130 // "LowReputationPinging" 130 // "PasswordFieldOnFocusPinging"
131 // ] 131 // ]
132 Parameters sber_and_sync_no_incognito = 132 Parameters sber_and_sync_no_incognito =
133 CreateParameters(false, false, true, true); 133 CreateParameters(false, false, true, true);
134 SetFeatureParams(kLowReputationPinging, "SBERAndHistorySyncNoIncognito", 134 SetFeatureParams(kPasswordFieldOnFocusPinging,
135 sber_and_sync_no_incognito); 135 "SBERAndHistorySyncNoIncognito", sber_and_sync_no_incognito);
136 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); 136 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
137 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 137 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
138 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); 138 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
139 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 139 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
140 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); 140 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
141 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 141 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
142 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); 142 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
143 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 143 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
144 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); 144 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
145 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 145 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
146 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); 146 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
147 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 147 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
148 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); 148 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
149 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 149 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
150 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); 150 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
151 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 151 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
152 } 152 }
153 153
154 TEST_F(ChromePasswordProtectionServiceTest, 154 TEST_F(ChromePasswordProtectionServiceTest,
155 VerifyFinchControlForLowReputationPingAllButNoIncognito) { 155 VerifyFinchControlForLowReputationPingAllButNoIncognito) {
156 MockChromePasswordProtectionService service; 156 MockChromePasswordProtectionService service;
157 // By default kLowReputationPinging feature is disabled. 157 // By default kPasswordFieldOnFocusPinging feature is disabled.
158 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 158 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
159 159
160 // Enables kLowReputationPinging feature. 160 // Enables kPasswordFieldOnFocusPinging feature.
161 scoped_feature_list_.InitAndEnableFeature(kLowReputationPinging); 161 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
162 // Creates finch trial parameters correspond to the following experiment: 162 // Creates finch trial parameters correspond to the following experiment:
163 // "name": "AllButNoIncognito", 163 // "name": "AllButNoIncognito",
164 // "params": { 164 // "params": {
165 // "all_population": "true", 165 // "all_population": "true",
166 // "incongito": "false" 166 // "incongito": "false"
167 // }, 167 // },
168 // "enable_features": [ 168 // "enable_features": [
169 // "LowReputationPinging" 169 // "PasswordFieldOnFocusPinging"
170 // ] 170 // ]
171 Parameters all_users = CreateParameters(false, true, true, true); 171 Parameters all_users = CreateParameters(false, true, true, true);
172 SetFeatureParams(kLowReputationPinging, "AllButNoIncognito", all_users); 172 SetFeatureParams(kPasswordFieldOnFocusPinging, "AllButNoIncognito",
173 all_users);
173 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); 174 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
174 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 175 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
175 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); 176 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
176 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 177 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
177 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); 178 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
178 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 179 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
179 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); 180 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
180 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 181 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
181 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); 182 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
182 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 183 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
183 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); 184 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
184 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 185 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
185 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); 186 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
186 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 187 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
187 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); 188 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
188 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 189 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
189 } 190 }
190 191
191 TEST_F(ChromePasswordProtectionServiceTest, 192 TEST_F(ChromePasswordProtectionServiceTest,
192 VerifyFinchControlForLowReputationPingAll) { 193 VerifyFinchControlForLowReputationPingAll) {
193 MockChromePasswordProtectionService service; 194 MockChromePasswordProtectionService service;
194 // By default kLowReputationPinging feature is disabled. 195 // By default kPasswordFieldOnFocusPinging feature is disabled.
195 EXPECT_FALSE(service.IsPingingEnabled(kLowReputationPinging)); 196 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
196 197
197 // Enables kLowReputationPinging feature. 198 // Enables kPasswordFieldOnFocusPinging feature.
198 scoped_feature_list_.InitAndEnableFeature(kLowReputationPinging); 199 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging);
199 // Creates finch trial parameters correspond to the following experiment: 200 // Creates finch trial parameters correspond to the following experiment:
200 // "name": "All", 201 // "name": "All",
201 // "params": { 202 // "params": {
202 // "all_population": "true", 203 // "all_population": "true",
203 // "incognito": "true" 204 // "incognito": "true"
204 // }, 205 // },
205 // "enable_features": [ 206 // "enable_features": [
206 // "LowReputationPinging" 207 // "PasswordFieldOnFocusPinging"
207 // ] 208 // ]
208 Parameters all_users = CreateParameters(true, true, true, true); 209 Parameters all_users = CreateParameters(true, true, true, true);
209 SetFeatureParams(kLowReputationPinging, "All", all_users); 210 SetFeatureParams(kPasswordFieldOnFocusPinging, "All", all_users);
210 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); 211 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/);
211 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 212 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
212 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); 213 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/);
213 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 214 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
214 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); 215 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/);
215 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 216 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
216 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); 217 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/);
217 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 218 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
218 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); 219 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/);
219 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 220 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
220 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); 221 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/);
221 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 222 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
222 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); 223 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/);
223 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 224 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
224 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); 225 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/);
225 EXPECT_TRUE(service.IsPingingEnabled(kLowReputationPinging)); 226 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging));
226 } 227 }
227 228
228 } // namespace safe_browsing 229 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | components/safe_browsing/password_protection/password_protection_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698