OLD | NEW |
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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, model()->state()); | 252 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, model()->state()); |
253 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); | 253 std::unique_ptr<base::SimpleTestClock> clock(new base::SimpleTestClock); |
254 base::Time now = base::Time::Now(); | 254 base::Time now = base::Time::Now(); |
255 clock->SetNow(now); | 255 clock->SetNow(now); |
256 model()->SetClockForTesting(std::move(clock)); | 256 model()->SetClockForTesting(std::move(clock)); |
257 password_manager::InteractionsStats stats = GetTestStats(); | 257 password_manager::InteractionsStats stats = GetTestStats(); |
258 stats.dismissal_count++; | 258 stats.dismissal_count++; |
259 stats.update_time = now; | 259 stats.update_time = now; |
260 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(stats)); | 260 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(stats)); |
| 261 EXPECT_CALL(*controller(), OnNoInteraction()); |
261 EXPECT_CALL(*controller(), SavePassword()).Times(0); | 262 EXPECT_CALL(*controller(), SavePassword()).Times(0); |
262 EXPECT_CALL(*controller(), NeverSavePassword()).Times(0); | 263 EXPECT_CALL(*controller(), NeverSavePassword()).Times(0); |
263 DestroyModelExpectReason( | 264 DestroyModelExpectReason( |
264 password_manager::metrics_util::NO_DIRECT_INTERACTION); | 265 password_manager::metrics_util::NO_DIRECT_INTERACTION); |
265 } | 266 } |
266 | 267 |
267 TEST_F(ManagePasswordsBubbleModelTest, ClickSave) { | 268 TEST_F(ManagePasswordsBubbleModelTest, ClickSave) { |
268 PretendPasswordWaiting(); | 269 PretendPasswordWaiting(); |
269 | 270 |
270 EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin())); | 271 EXPECT_CALL(*GetStore(), RemoveSiteStatsImpl(GURL(kSiteOrigin).GetOrigin())); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 326 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
326 profile(), &TestingSyncFactoryFunction)); | 327 profile(), &TestingSyncFactoryFunction)); |
327 sync_service->set_smartlock_enabled(true); | 328 sync_service->set_smartlock_enabled(true); |
328 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName, | 329 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName, |
329 kSmartLockBrandingGroupName); | 330 kSmartLockBrandingGroupName); |
330 | 331 |
331 PretendPasswordWaiting(); | 332 PretendPasswordWaiting(); |
332 | 333 |
333 EXPECT_TRUE(model()->ShouldShowGoogleSmartLockWelcome()); | 334 EXPECT_TRUE(model()->ShouldShowGoogleSmartLockWelcome()); |
334 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_)); | 335 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_)); |
| 336 EXPECT_CALL(*controller(), OnNoInteraction()); |
335 DestroyModel(); | 337 DestroyModel(); |
336 PretendPasswordWaiting(); | 338 PretendPasswordWaiting(); |
337 | 339 |
338 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); | 340 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); |
339 EXPECT_TRUE(prefs()->GetBoolean( | 341 EXPECT_TRUE(prefs()->GetBoolean( |
340 password_manager::prefs::kWasSavePrompFirstRunExperienceShown)); | 342 password_manager::prefs::kWasSavePrompFirstRunExperienceShown)); |
341 } | 343 } |
342 | 344 |
343 TEST_F(ManagePasswordsBubbleModelTest, OmitSmartLockWarmWelcome) { | 345 TEST_F(ManagePasswordsBubbleModelTest, OmitSmartLockWarmWelcome) { |
344 TestSyncService* sync_service = static_cast<TestSyncService*>( | 346 TestSyncService* sync_service = static_cast<TestSyncService*>( |
345 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 347 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
346 profile(), &TestingSyncFactoryFunction)); | 348 profile(), &TestingSyncFactoryFunction)); |
347 sync_service->set_smartlock_enabled(false); | 349 sync_service->set_smartlock_enabled(false); |
348 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName, | 350 base::FieldTrialList::CreateFieldTrial(kBrandingExperimentName, |
349 kSmartLockBrandingGroupName); | 351 kSmartLockBrandingGroupName); |
350 | 352 |
351 PretendPasswordWaiting(); | 353 PretendPasswordWaiting(); |
352 | 354 |
353 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); | 355 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); |
354 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_)); | 356 EXPECT_CALL(*GetStore(), AddSiteStatsImpl(_)); |
| 357 EXPECT_CALL(*controller(), OnNoInteraction()); |
355 DestroyModel(); | 358 DestroyModel(); |
356 PretendPasswordWaiting(); | 359 PretendPasswordWaiting(); |
357 | 360 |
358 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); | 361 EXPECT_FALSE(model()->ShouldShowGoogleSmartLockWelcome()); |
359 EXPECT_FALSE(prefs()->GetBoolean( | 362 EXPECT_FALSE(prefs()->GetBoolean( |
360 password_manager::prefs::kWasSavePrompFirstRunExperienceShown)); | 363 password_manager::prefs::kWasSavePrompFirstRunExperienceShown)); |
361 } | 364 } |
362 | 365 |
363 TEST_F(ManagePasswordsBubbleModelTest, OnBrandLinkClicked) { | 366 TEST_F(ManagePasswordsBubbleModelTest, OnBrandLinkClicked) { |
364 PretendPasswordWaiting(); | 367 PretendPasswordWaiting(); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 ManageLinkTarget::SETTINGS_PAGE}, | 583 ManageLinkTarget::SETTINGS_PAGE}, |
581 {nullptr, SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE}, | 584 {nullptr, SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE}, |
582 {"Default", SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE}, | 585 {"Default", SmartLockStatus::DISABLE, ManageLinkTarget::SETTINGS_PAGE}, |
583 }; | 586 }; |
584 | 587 |
585 } // namespace | 588 } // namespace |
586 | 589 |
587 INSTANTIATE_TEST_CASE_P(Default, | 590 INSTANTIATE_TEST_CASE_P(Default, |
588 ManagePasswordsBubbleModelManageLinkTest, | 591 ManagePasswordsBubbleModelManageLinkTest, |
589 ::testing::ValuesIn(kManageLinkTestCases)); | 592 ::testing::ValuesIn(kManageLinkTestCases)); |
OLD | NEW |