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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model_unittest.cc

Issue 2542093002: [Password Generation] Fixes sending votes about the usage of the password generation popup (Closed)
Patch Set: Changes addressed to reviewer comments Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/passwords/manage_passwords_bubble_model.h" 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 249
250 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, model()->state()); 250 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, model()->state());
251 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); 251 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock);
252 base::Time now = base::Time::Now(); 252 base::Time now = base::Time::Now();
253 clock->SetNow(now); 253 clock->SetNow(now);
254 model()->SetClockForTesting(std::move(clock)); 254 model()->SetClockForTesting(std::move(clock));
255 password_manager::InteractionsStats stats = GetTestStats(); 255 password_manager::InteractionsStats stats = GetTestStats();
256 stats.dismissal_count++; 256 stats.dismissal_count++;
257 stats.update_time = now; 257 stats.update_time = now;
258 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(stats)); 258 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(stats));
259 EXPECT_CALL(*controller(), OnNoInteraction());
259 EXPECT_CALL(*controller(), SavePassword()).Times(0); 260 EXPECT_CALL(*controller(), SavePassword()).Times(0);
260 EXPECT_CALL(*controller(), NeverSavePassword()).Times(0); 261 EXPECT_CALL(*controller(), NeverSavePassword()).Times(0);
261 DestroyModelExpectReason( 262 DestroyModelExpectReason(
262 password_manager::metrics_util::NO_DIRECT_INTERACTION); 263 password_manager::metrics_util::NO_DIRECT_INTERACTION);
263 } 264 }
264 265
265 TEST_F(ManagePasswordsBubbleModelTest, ClickSave) { 266 TEST_F(ManagePasswordsBubbleModelTest, ClickSave) {
266 PretendPasswordWaiting(); 267 PretendPasswordWaiting();
267 268
268 EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin())); 269 EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin()));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 324 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
324 profile(), &TestingSyncFactoryFunction)); 325 profile(), &TestingSyncFactoryFunction));
325 sync_service->set_smartlock_enabled(true); 326 sync_service->set_smartlock_enabled(true);
326 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName, 327 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName,
327 kSmartLockBrandingGroupName); 328 kSmartLockBrandingGroupName);
328 329
329 PretendPasswordWaiting(); 330 PretendPasswordWaiting();
330 331
331 EXPECT_TRUE(model()->ShouldShowGoogleSmartLockWelcome()); 332 EXPECT_TRUE(model()->ShouldShowGoogleSmartLockWelcome());
332 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_)); 333 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_));
334 EXPECT_CALL(*controller(), OnNoInteraction());
333 DestroyModel(); 335 DestroyModel();
334 PretendPasswordWaiting(); 336 PretendPasswordWaiting();
335 337
336 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); 338 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome());
337 EXPECT_TRUE(prefs()->GetBoolean( 339 EXPECT_TRUE(prefs()->GetBoolean(
338 password_manager::prefs::kWasSavePrompFirstRunExperienceShown)); 340 password_manager::prefs::kWasSavePrompFirstRunExperienceShown));
339 } 341 }
340 342
341 TEST_F(ManagePasswordsBubbleModelTest, OmitSmartLockWarmWelcome) { 343 TEST_F(ManagePasswordsBubbleModelTest, OmitSmartLockWarmWelcome) {
342 TestSyncService* sync_service = static_cast<TestSyncService*>( 344 TestSyncService* sync_service = static_cast<TestSyncService*>(
343 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 345 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
344 profile(), &TestingSyncFactoryFunction)); 346 profile(), &TestingSyncFactoryFunction));
345 sync_service->set_smartlock_enabled(false); 347 sync_service->set_smartlock_enabled(false);
346 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName, 348 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName,
347 kSmartLockBrandingGroupName); 349 kSmartLockBrandingGroupName);
348 350
349 PretendPasswordWaiting(); 351 PretendPasswordWaiting();
350 352
351 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); 353 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome());
352 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_)); 354 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_));
355 EXPECT_CALL(*controller(), OnNoInteraction());
353 DestroyModel(); 356 DestroyModel();
354 PretendPasswordWaiting(); 357 PretendPasswordWaiting();
355 358
356 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); 359 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome());
357 EXPECT_FALSE(prefs()->GetBoolean( 360 EXPECT_FALSE(prefs()->GetBoolean(
358 password_manager::prefs::kWasSavePrompFirstRunExperienceShown)); 361 password_manager::prefs::kWasSavePrompFirstRunExperienceShown));
359 } 362 }
360 363
361 TEST_F(ManagePasswordsBubbleModelTest, OnBrandLinkClicked) { 364 TEST_F(ManagePasswordsBubbleModelTest, OnBrandLinkClicked) {
362 PretendPasswordWaiting(); 365 PretendPasswordWaiting();
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 ManageLinkTarget::SETTINGS_PAGE}, 577 ManageLinkTarget::SETTINGS_PAGE},
575 {nullptr, SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE}, 578 {nullptr, SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE},
576 {"Default", SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE}, 579 {"Default", SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE},
577 }; 580 };
578 581
579 } // namespace 582 } // namespace
580 583
581 INSTANTIATE_TEST_CASE_P(Default, 584 INSTANTIATE_TEST_CASE_P(Default,
582 ManagePasswordsBubbleModelManageLinkTest, 585 ManagePasswordsBubbleModelManageLinkTest,
583 ::testing::ValuesIn(kManageLinkTestCases)); 586 ::testing::ValuesIn(kManageLinkTestCases));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698