Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/histogram_tester.h" | |
| 6 #include "base/test/scoped_feature_list.h" | 7 #include "base/test/scoped_feature_list.h" |
| 7 #include "components/variations/variations_params_manager.h" | 8 #include "components/variations/variations_params_manager.h" |
| 8 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 12 |
| 11 namespace safe_browsing { | 13 namespace safe_browsing { |
| 12 | 14 |
| 13 class MockChromePasswordProtectionService | 15 class MockChromePasswordProtectionService |
| 14 : public ChromePasswordProtectionService { | 16 : public ChromePasswordProtectionService { |
| 15 public: | 17 public: |
| 16 MockChromePasswordProtectionService() | 18 MockChromePasswordProtectionService() |
| 17 : ChromePasswordProtectionService(), | 19 : ChromePasswordProtectionService(), |
| 18 is_incognito_(false), | 20 is_incognito_(false), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 {"all_population", allowed_for_all ? "true" : "false"}, | 64 {"all_population", allowed_for_all ? "true" : "false"}, |
| 63 {"extended_reporting", | 65 {"extended_reporting", |
| 64 allowed_for_extended_reporting ? "true" : "false"}, | 66 allowed_for_extended_reporting ? "true" : "false"}, |
| 65 {"history_sync", allowed_for_history_sync ? "true" : "false"}}; | 67 {"history_sync", allowed_for_history_sync ? "true" : "false"}}; |
| 66 } | 68 } |
| 67 | 69 |
| 68 protected: | 70 protected: |
| 69 content::TestBrowserThreadBundle thread_bundle_; | 71 content::TestBrowserThreadBundle thread_bundle_; |
| 70 variations::testing::VariationParamsManager params_manager_; | 72 variations::testing::VariationParamsManager params_manager_; |
| 71 base::test::ScopedFeatureList scoped_feature_list_; | 73 base::test::ScopedFeatureList scoped_feature_list_; |
| 74 base::HistogramTester histograms_; | |
| 72 }; | 75 }; |
| 73 | 76 |
| 74 TEST_F(ChromePasswordProtectionServiceTest, | 77 TEST_F(ChromePasswordProtectionServiceTest, |
| 75 VerifyFinchControlForLowReputationPingSBEROnlyNoIncognito) { | 78 VerifyFinchControlForLowReputationPingSBEROnlyNoIncognito) { |
| 76 MockChromePasswordProtectionService service; | 79 MockChromePasswordProtectionService service; |
| 80 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); | |
| 77 // By default kPasswordFieldOnFocusPinging feature is disabled. | 81 // By default kPasswordFieldOnFocusPinging feature is disabled. |
| 78 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 82 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 83 EXPECT_THAT( | |
| 84 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 85 testing::ElementsAre(base::Bucket(12, 1))); | |
| 79 | 86 |
| 80 // Enables kPasswordFieldOnFocusPinging feature. | 87 // Enables kPasswordFieldOnFocusPinging feature. |
| 81 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); | 88 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); |
| 82 // Creates finch trial parameters correspond to the following experiment: | 89 // Creates finch trial parameters correspond to the following experiment: |
| 83 // "name": "SBEROnlyNoIncognito", | 90 // "name": "SBEROnlyNoIncognito", |
| 84 // "params": { | 91 // "params": { |
| 85 // "incognito": "false", | 92 // "incognito": "false", |
| 86 // "extended_reporting": "true", | 93 // "extended_reporting": "true", |
| 87 // "history_sync": "false" | 94 // "history_sync": "false" |
| 88 // }, | 95 // }, |
| 89 // "enable_features": [ | 96 // "enable_features": [ |
| 90 // "PasswordFieldOnFocusPinging" | 97 // "PasswordFieldOnFocusPinging" |
| 91 // ] | 98 // ] |
| 92 Parameters sber_and_no_incognito = | 99 Parameters sber_and_no_incognito = |
| 93 CreateParameters(false, false, true, false); | 100 CreateParameters(false, false, true, false); |
| 94 SetFeatureParams(kPasswordFieldOnFocusPinging, "SBEROnlyNoIncognito", | 101 SetFeatureParams(kPasswordFieldOnFocusPinging, "SBEROnlyNoIncognito", |
| 95 sber_and_no_incognito); | 102 sber_and_no_incognito); |
| 103 | |
| 96 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); | 104 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); |
| 97 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 105 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 106 EXPECT_THAT( | |
| 107 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
|
Nathan Parker
2017/05/11 23:36:31
How about a comment that says where the bucket val
Nathan Parker
2017/05/11 23:36:31
nit: Add up top
using testing:ElementsAre
using
Jialiu Lin
2017/05/12 02:12:32
Due to the code refactoring, no need to check hist
| |
| 108 testing::ElementsAre(base::Bucket(12, 1), base::Bucket(13, 1))); | |
| 109 | |
| 98 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); | 110 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); |
| 99 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 111 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 112 EXPECT_THAT( | |
| 113 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 114 testing::ElementsAre(base::Bucket(12, 1), base::Bucket(13, 2))); | |
| 115 | |
| 100 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); | 116 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); |
| 101 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 117 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 118 EXPECT_THAT( | |
| 119 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 120 testing::ElementsAre(base::Bucket(12, 1), base::Bucket(13, 2))); | |
| 121 | |
| 102 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); | 122 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); |
| 103 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 123 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 124 EXPECT_THAT( | |
| 125 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 126 testing::ElementsAre(base::Bucket(12, 1), base::Bucket(13, 2))); | |
| 127 | |
| 104 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); | 128 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); |
| 105 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 129 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 130 EXPECT_THAT( | |
| 131 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 132 testing::ElementsAre(base::Bucket(7, 1), base::Bucket(12, 1), | |
| 133 base::Bucket(13, 2))); | |
| 134 | |
| 106 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); | 135 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); |
| 107 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 136 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 137 EXPECT_THAT( | |
| 138 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 139 testing::ElementsAre(base::Bucket(7, 2), base::Bucket(12, 1), | |
| 140 base::Bucket(13, 2))); | |
| 141 | |
| 108 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); | 142 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); |
| 109 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 143 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 144 EXPECT_THAT( | |
| 145 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 146 testing::ElementsAre(base::Bucket(7, 3), base::Bucket(12, 1), | |
| 147 base::Bucket(13, 2))); | |
| 148 | |
| 110 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); | 149 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); |
| 111 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 150 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 151 EXPECT_THAT( | |
| 152 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 153 testing::ElementsAre(base::Bucket(7, 4), base::Bucket(12, 1), | |
| 154 base::Bucket(13, 2))); | |
| 112 } | 155 } |
| 113 | 156 |
| 114 TEST_F(ChromePasswordProtectionServiceTest, | 157 TEST_F(ChromePasswordProtectionServiceTest, |
| 115 VerifyFinchControlForLowReputationPingSBERAndHistorySyncNoIncognito) { | 158 VerifyFinchControlForLowReputationPingSBERAndHistorySyncNoIncognito) { |
| 116 MockChromePasswordProtectionService service; | 159 MockChromePasswordProtectionService service; |
| 117 // By default kPasswordFieldOnFocusPinging feature is disabled. | 160 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); |
| 118 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | |
| 119 | 161 |
| 120 // Enables kPasswordFieldOnFocusPinging feature. | 162 // Enables kPasswordFieldOnFocusPinging feature. |
| 121 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); | 163 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); |
| 122 // Creates finch trial parameters correspond to the following experiment: | 164 // Creates finch trial parameters correspond to the following experiment: |
| 123 // "name": "SBERAndHistorySyncNoIncognito", | 165 // "name": "SBERAndHistorySyncNoIncognito", |
| 124 // "params": { | 166 // "params": { |
| 125 // "incognito": "false", | 167 // "incognito": "false", |
| 126 // "extended_reporting": "true", | 168 // "extended_reporting": "true", |
| 127 // "history_sync": "true" | 169 // "history_sync": "true" |
| 128 // }, | 170 // }, |
| 129 // "enable_features": [ | 171 // "enable_features": [ |
| 130 // "PasswordFieldOnFocusPinging" | 172 // "PasswordFieldOnFocusPinging" |
| 131 // ] | 173 // ] |
| 132 Parameters sber_and_sync_no_incognito = | 174 Parameters sber_and_sync_no_incognito = |
| 133 CreateParameters(false, false, true, true); | 175 CreateParameters(false, false, true, true); |
| 134 SetFeatureParams(kPasswordFieldOnFocusPinging, | 176 SetFeatureParams(kPasswordFieldOnFocusPinging, |
| 135 "SBERAndHistorySyncNoIncognito", sber_and_sync_no_incognito); | 177 "SBERAndHistorySyncNoIncognito", sber_and_sync_no_incognito); |
| 136 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); | 178 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); |
| 137 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 179 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 180 EXPECT_THAT( | |
| 181 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 182 testing::ElementsAre(base::Bucket(13, 1))); | |
| 183 | |
| 138 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); | 184 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); |
| 139 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 185 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 186 EXPECT_THAT( | |
| 187 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 188 testing::ElementsAre(base::Bucket(13, 1))); | |
| 189 | |
| 140 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); | 190 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); |
| 141 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 191 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 192 EXPECT_THAT( | |
| 193 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 194 testing::ElementsAre(base::Bucket(13, 1))); | |
| 195 | |
| 142 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); | 196 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); |
| 143 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 197 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 198 EXPECT_THAT( | |
| 199 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 200 testing::ElementsAre(base::Bucket(13, 1))); | |
| 201 | |
| 144 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); | 202 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); |
| 145 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 203 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 204 EXPECT_THAT( | |
| 205 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 206 testing::ElementsAre(base::Bucket(7, 1), base::Bucket(13, 1))); | |
| 207 | |
| 146 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); | 208 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); |
| 147 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 209 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 210 EXPECT_THAT( | |
| 211 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 212 testing::ElementsAre(base::Bucket(7, 2), base::Bucket(13, 1))); | |
| 213 | |
| 148 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); | 214 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); |
| 149 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 215 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 216 EXPECT_THAT( | |
| 217 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 218 testing::ElementsAre(base::Bucket(7, 3), base::Bucket(13, 1))); | |
| 219 | |
| 150 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); | 220 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); |
| 151 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 221 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 222 EXPECT_THAT( | |
| 223 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 224 testing::ElementsAre(base::Bucket(7, 4), base::Bucket(13, 1))); | |
| 152 } | 225 } |
| 153 | 226 |
| 154 TEST_F(ChromePasswordProtectionServiceTest, | 227 TEST_F(ChromePasswordProtectionServiceTest, |
| 155 VerifyFinchControlForLowReputationPingAllButNoIncognito) { | 228 VerifyFinchControlForLowReputationPingAllButNoIncognito) { |
| 156 MockChromePasswordProtectionService service; | 229 MockChromePasswordProtectionService service; |
| 157 // By default kPasswordFieldOnFocusPinging feature is disabled. | 230 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); |
| 158 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | |
| 159 | 231 |
| 160 // Enables kPasswordFieldOnFocusPinging feature. | 232 // Enables kPasswordFieldOnFocusPinging feature. |
| 161 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); | 233 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); |
| 162 // Creates finch trial parameters correspond to the following experiment: | 234 // Creates finch trial parameters correspond to the following experiment: |
| 163 // "name": "AllButNoIncognito", | 235 // "name": "AllButNoIncognito", |
| 164 // "params": { | 236 // "params": { |
| 165 // "all_population": "true", | 237 // "all_population": "true", |
| 166 // "incongito": "false" | 238 // "incongito": "false" |
| 167 // }, | 239 // }, |
| 168 // "enable_features": [ | 240 // "enable_features": [ |
| 169 // "PasswordFieldOnFocusPinging" | 241 // "PasswordFieldOnFocusPinging" |
| 170 // ] | 242 // ] |
| 171 Parameters all_users = CreateParameters(false, true, true, true); | 243 Parameters all_users = CreateParameters(false, true, true, true); |
| 172 SetFeatureParams(kPasswordFieldOnFocusPinging, "AllButNoIncognito", | 244 SetFeatureParams(kPasswordFieldOnFocusPinging, "AllButNoIncognito", |
| 173 all_users); | 245 all_users); |
| 174 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); | 246 service.ConfigService(false /*incognito*/, false /*SBER*/, false /*sync*/); |
| 175 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 247 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 248 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); | |
| 249 | |
| 176 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); | 250 service.ConfigService(false /*incognito*/, false /*SBER*/, true /*sync*/); |
| 177 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 251 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 252 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); | |
| 253 | |
| 178 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); | 254 service.ConfigService(false /*incognito*/, true /*SBER*/, false /*sync*/); |
| 179 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 255 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 256 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); | |
| 257 | |
| 180 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); | 258 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); |
| 181 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 259 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 260 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); | |
| 261 | |
| 182 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); | 262 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); |
| 183 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 263 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 264 EXPECT_THAT( | |
| 265 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 266 testing::ElementsAre(base::Bucket(7, 1))); | |
| 267 | |
| 184 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); | 268 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); |
| 185 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 269 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 270 EXPECT_THAT( | |
| 271 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 272 testing::ElementsAre(base::Bucket(7, 2))); | |
| 273 | |
| 186 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); | 274 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); |
| 187 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 275 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 276 EXPECT_THAT( | |
| 277 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 278 testing::ElementsAre(base::Bucket(7, 3))); | |
| 279 | |
| 188 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); | 280 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); |
| 189 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 281 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 282 EXPECT_THAT( | |
| 283 histograms_.GetAllSamples(kPasswordOnFocusRequestOutcomeHistogramName), | |
| 284 testing::ElementsAre(base::Bucket(7, 4))); | |
| 190 } | 285 } |
| 191 | 286 |
| 192 TEST_F(ChromePasswordProtectionServiceTest, | 287 TEST_F(ChromePasswordProtectionServiceTest, |
| 193 VerifyFinchControlForLowReputationPingAll) { | 288 VerifyFinchControlForLowReputationPingAll) { |
| 194 MockChromePasswordProtectionService service; | 289 MockChromePasswordProtectionService service; |
| 195 // By default kPasswordFieldOnFocusPinging feature is disabled. | 290 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); |
| 196 EXPECT_FALSE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | |
| 197 | 291 |
| 198 // Enables kPasswordFieldOnFocusPinging feature. | 292 // Enables kPasswordFieldOnFocusPinging feature. |
| 199 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); | 293 scoped_feature_list_.InitAndEnableFeature(kPasswordFieldOnFocusPinging); |
| 200 // Creates finch trial parameters correspond to the following experiment: | 294 // Creates finch trial parameters correspond to the following experiment: |
| 201 // "name": "All", | 295 // "name": "All", |
| 202 // "params": { | 296 // "params": { |
| 203 // "all_population": "true", | 297 // "all_population": "true", |
| 204 // "incognito": "true" | 298 // "incognito": "true" |
| 205 // }, | 299 // }, |
| 206 // "enable_features": [ | 300 // "enable_features": [ |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 217 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); | 311 service.ConfigService(false /*incognito*/, true /*SBER*/, true /*sync*/); |
| 218 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 312 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 219 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); | 313 service.ConfigService(true /*incognito*/, false /*SBER*/, false /*sync*/); |
| 220 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 314 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 221 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); | 315 service.ConfigService(true /*incognito*/, false /*SBER*/, true /*sync*/); |
| 222 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 316 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 223 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); | 317 service.ConfigService(true /*incognito*/, true /*SBER*/, false /*sync*/); |
| 224 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 318 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 225 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); | 319 service.ConfigService(true /*incognito*/, true /*SBER*/, true /*sync*/); |
| 226 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); | 320 EXPECT_TRUE(service.IsPingingEnabled(kPasswordFieldOnFocusPinging)); |
| 321 histograms_.ExpectTotalCount(kPasswordOnFocusRequestOutcomeHistogramName, 0); | |
| 227 } | 322 } |
| 228 | 323 |
| 229 } // namespace safe_browsing | 324 } // namespace safe_browsing |
| OLD | NEW |