OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/password_manager/password_store_proxy_mac.h" | 5 #include "chrome/browser/password_manager/password_store_proxy_mac.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return; | 168 return; |
169 store_->ShutdownOnUIThread(); | 169 store_->ShutdownOnUIThread(); |
170 EXPECT_FALSE(store_->GetBackgroundTaskRunner()); | 170 EXPECT_FALSE(store_->GetBackgroundTaskRunner()); |
171 store_ = nullptr; | 171 store_ = nullptr; |
172 } | 172 } |
173 | 173 |
174 void PasswordStoreProxyMacTest::FinishAsyncProcessing() { | 174 void PasswordStoreProxyMacTest::FinishAsyncProcessing() { |
175 // Do a store-level query to wait for all the previously enqueued operations | 175 // Do a store-level query to wait for all the previously enqueued operations |
176 // to finish. | 176 // to finish. |
177 MockPasswordStoreConsumer consumer; | 177 MockPasswordStoreConsumer consumer; |
178 store_->GetLogins(PasswordForm(), | 178 store_->GetLogins(PasswordForm(), &consumer); |
179 password_manager::PasswordStore::ALLOW_PROMPT, &consumer); | |
180 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 179 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
181 .WillOnce(QuitUIMessageLoop()); | 180 .WillOnce(QuitUIMessageLoop()); |
182 base::MessageLoop::current()->Run(); | 181 base::MessageLoop::current()->Run(); |
183 } | 182 } |
184 | 183 |
185 base::FilePath PasswordStoreProxyMacTest::test_login_db_file_path() const { | 184 base::FilePath PasswordStoreProxyMacTest::test_login_db_file_path() const { |
186 return db_dir_.path().Append(FILE_PATH_LITERAL("login.db")); | 185 return db_dir_.path().Append(FILE_PATH_LITERAL("login.db")); |
187 } | 186 } |
188 | 187 |
189 void PasswordStoreProxyMacTest::AddForm(const PasswordForm& form) { | 188 void PasswordStoreProxyMacTest::AddForm(const PasswordForm& form) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 password_form.password_value = base::ASCIIToUTF16("12345"); | 303 password_form.password_value = base::ASCIIToUTF16("12345"); |
305 AddForm(password_form); | 304 AddForm(password_form); |
306 | 305 |
307 PasswordForm blacklisted_form; | 306 PasswordForm blacklisted_form; |
308 blacklisted_form.origin = GURL("http://example2.com"); | 307 blacklisted_form.origin = GURL("http://example2.com"); |
309 blacklisted_form.signon_realm = "http://example2.com/"; | 308 blacklisted_form.signon_realm = "http://example2.com/"; |
310 blacklisted_form.blacklisted_by_user = true; | 309 blacklisted_form.blacklisted_by_user = true; |
311 AddForm(blacklisted_form); | 310 AddForm(blacklisted_form); |
312 | 311 |
313 MockPasswordStoreConsumer mock_consumer; | 312 MockPasswordStoreConsumer mock_consumer; |
314 store()->GetLogins(password_form, PasswordStoreProxyMac::ALLOW_PROMPT, | 313 store()->GetLogins(password_form, &mock_consumer); |
315 &mock_consumer); | |
316 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef( | 314 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef( |
317 ElementsAre(Pointee(password_form)))) | 315 ElementsAre(Pointee(password_form)))) |
318 .WillOnce(QuitUIMessageLoop()); | 316 .WillOnce(QuitUIMessageLoop()); |
319 base::MessageLoop::current()->Run(); | 317 base::MessageLoop::current()->Run(); |
320 | 318 |
321 store()->GetBlacklistLogins(&mock_consumer); | 319 store()->GetBlacklistLogins(&mock_consumer); |
322 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef( | 320 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef( |
323 ElementsAre(Pointee(blacklisted_form)))) | 321 ElementsAre(Pointee(blacklisted_form)))) |
324 .WillOnce(QuitUIMessageLoop()); | 322 .WillOnce(QuitUIMessageLoop()); |
325 base::MessageLoop::current()->Run(); | 323 base::MessageLoop::current()->Run(); |
(...skipping 30 matching lines...) Expand all Loading... |
356 blacklisted_form->signon_realm = "http://foo.example.com"; | 354 blacklisted_form->signon_realm = "http://foo.example.com"; |
357 blacklisted_form->origin = GURL("http://foo.example.com/origin"); | 355 blacklisted_form->origin = GURL("http://foo.example.com/origin"); |
358 blacklisted_form->action = GURL("http://foo.example.com/action"); | 356 blacklisted_form->action = GURL("http://foo.example.com/action"); |
359 blacklisted_form->blacklisted_by_user = true; | 357 blacklisted_form->blacklisted_by_user = true; |
360 store()->AddLogin(*form); | 358 store()->AddLogin(*form); |
361 store()->AddLogin(*blacklisted_form); | 359 store()->AddLogin(*blacklisted_form); |
362 FinishAsyncProcessing(); | 360 FinishAsyncProcessing(); |
363 | 361 |
364 // Get all logins; autofillable logins; blacklisted logins. | 362 // Get all logins; autofillable logins; blacklisted logins. |
365 MockPasswordStoreConsumer mock_consumer; | 363 MockPasswordStoreConsumer mock_consumer; |
366 store()->GetLogins(*form, password_manager::PasswordStore::DISALLOW_PROMPT, | 364 store()->GetLogins(*form, &mock_consumer); |
367 &mock_consumer); | |
368 ON_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(_)) | 365 ON_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(_)) |
369 .WillByDefault(QuitUIMessageLoop()); | 366 .WillByDefault(QuitUIMessageLoop()); |
370 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 367 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
371 base::MessageLoop::current()->Run(); | 368 base::MessageLoop::current()->Run(); |
372 | 369 |
373 store()->GetAutofillableLogins(&mock_consumer); | 370 store()->GetAutofillableLogins(&mock_consumer); |
374 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 371 EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
375 base::MessageLoop::current()->Run(); | 372 base::MessageLoop::current()->Run(); |
376 | 373 |
377 store()->GetBlacklistLogins(&mock_consumer); | 374 store()->GetBlacklistLogins(&mock_consumer); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 std::move(keychain_), std::move(login_db_), &testing_prefs_); | 447 std::move(keychain_), std::move(login_db_), &testing_prefs_); |
451 ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 448 ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); |
452 FinishAsyncProcessing(); | 449 FinishAsyncProcessing(); |
453 | 450 |
454 // Check the password is still there. | 451 // Check the password is still there. |
455 if (lock_keychain && store_->password_store_mac()) { | 452 if (lock_keychain && store_->password_store_mac()) { |
456 static_cast<crypto::MockAppleKeychain*>( | 453 static_cast<crypto::MockAppleKeychain*>( |
457 store_->password_store_mac()->keychain())->set_locked(false); | 454 store_->password_store_mac()->keychain())->set_locked(false); |
458 } | 455 } |
459 MockPasswordStoreConsumer mock_consumer; | 456 MockPasswordStoreConsumer mock_consumer; |
460 store()->GetLogins(form, PasswordStoreProxyMac::ALLOW_PROMPT, &mock_consumer); | 457 store()->GetLogins(form, &mock_consumer); |
461 EXPECT_CALL(mock_consumer, | 458 EXPECT_CALL(mock_consumer, |
462 OnGetPasswordStoreResultsConstRef(ElementsAre(Pointee(form)))) | 459 OnGetPasswordStoreResultsConstRef(ElementsAre(Pointee(form)))) |
463 .WillOnce(QuitUIMessageLoop()); | 460 .WillOnce(QuitUIMessageLoop()); |
464 base::MessageLoop::current()->Run(); | 461 base::MessageLoop::current()->Run(); |
465 | 462 |
466 int status = testing_prefs_.GetInteger( | 463 int status = testing_prefs_.GetInteger( |
467 password_manager::prefs::kKeychainMigrationStatus); | 464 password_manager::prefs::kKeychainMigrationStatus); |
468 if (GetParam() == MigrationStatus::MIGRATED || | 465 if (GetParam() == MigrationStatus::MIGRATED || |
469 GetParam() == MigrationStatus::FAILED_TWICE) { | 466 GetParam() == MigrationStatus::FAILED_TWICE) { |
470 EXPECT_EQ(static_cast<int>(GetParam()), status); | 467 EXPECT_EQ(static_cast<int>(GetParam()), status); |
(...skipping 19 matching lines...) Expand all Loading... |
490 } | 487 } |
491 | 488 |
492 INSTANTIATE_TEST_CASE_P(, | 489 INSTANTIATE_TEST_CASE_P(, |
493 PasswordStoreProxyMacMigrationTest, | 490 PasswordStoreProxyMacMigrationTest, |
494 testing::Values(MigrationStatus::NOT_STARTED, | 491 testing::Values(MigrationStatus::NOT_STARTED, |
495 MigrationStatus::MIGRATED, | 492 MigrationStatus::MIGRATED, |
496 MigrationStatus::FAILED_ONCE, | 493 MigrationStatus::FAILED_ONCE, |
497 MigrationStatus::FAILED_TWICE)); | 494 MigrationStatus::FAILED_TWICE)); |
498 | 495 |
499 } // namespace | 496 } // namespace |
OLD | NEW |