| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 base::FilePath PasswordStoreProxyMacTest::test_login_db_file_path() const { | 205 base::FilePath PasswordStoreProxyMacTest::test_login_db_file_path() const { |
| 206 return db_dir_.GetPath().Append(FILE_PATH_LITERAL("login.db")); | 206 return db_dir_.GetPath().Append(FILE_PATH_LITERAL("login.db")); |
| 207 } | 207 } |
| 208 | 208 |
| 209 MigrationStatus PasswordStoreProxyMacTest::GetTargetStatus( | 209 MigrationStatus PasswordStoreProxyMacTest::GetTargetStatus( |
| 210 bool keychain_locked) const { | 210 bool keychain_locked) const { |
| 211 if (GetParam() == MigrationStatus::NOT_STARTED || | 211 if (GetParam() == MigrationStatus::NOT_STARTED || |
| 212 GetParam() == MigrationStatus::FAILED_ONCE || | 212 GetParam() == MigrationStatus::FAILED_ONCE || |
| 213 GetParam() == MigrationStatus::FAILED_TWICE) { | 213 GetParam() == MigrationStatus::FAILED_TWICE) { |
| 214 return keychain_locked ? MigrationStatus::MIGRATED_PARTIALLY | 214 return MigrationStatus::MIGRATION_STOPPED; |
| 215 : MigrationStatus::MIGRATED; | |
| 216 } | 215 } |
| 217 if (GetParam() == MigrationStatus::MIGRATED) | 216 if (GetParam() == MigrationStatus::MIGRATED) |
| 218 return MigrationStatus::MIGRATED_DELETED; | 217 return MigrationStatus::MIGRATED_DELETED; |
| 219 return GetParam(); | 218 return GetParam(); |
| 220 } | 219 } |
| 221 | 220 |
| 222 void PasswordStoreProxyMacTest::AddForm(const PasswordForm& form) { | 221 void PasswordStoreProxyMacTest::AddForm(const PasswordForm& form) { |
| 223 MockPasswordStoreObserver mock_observer(store()); | 222 MockPasswordStoreObserver mock_observer(store()); |
| 224 | 223 |
| 225 password_manager::PasswordStoreChangeList list; | 224 password_manager::PasswordStoreChangeList list; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 ClosePasswordStore(); | 424 ClosePasswordStore(); |
| 426 } | 425 } |
| 427 | 426 |
| 428 INSTANTIATE_TEST_CASE_P(, | 427 INSTANTIATE_TEST_CASE_P(, |
| 429 PasswordStoreProxyMacTest, | 428 PasswordStoreProxyMacTest, |
| 430 testing::Values(MigrationStatus::NOT_STARTED, | 429 testing::Values(MigrationStatus::NOT_STARTED, |
| 431 MigrationStatus::MIGRATED, | 430 MigrationStatus::MIGRATED, |
| 432 MigrationStatus::FAILED_ONCE, | 431 MigrationStatus::FAILED_ONCE, |
| 433 MigrationStatus::FAILED_TWICE, | 432 MigrationStatus::FAILED_TWICE, |
| 434 MigrationStatus::MIGRATED_DELETED, | 433 MigrationStatus::MIGRATED_DELETED, |
| 435 MigrationStatus::MIGRATED_PARTIALLY)); | 434 MigrationStatus::MIGRATED_PARTIALLY, |
| 435 MigrationStatus::MIGRATION_STOPPED)); |
| 436 | 436 |
| 437 // Test the migration process. | 437 // Test the migration process. |
| 438 class PasswordStoreProxyMacMigrationTest : public PasswordStoreProxyMacTest { | 438 class PasswordStoreProxyMacMigrationTest : public PasswordStoreProxyMacTest { |
| 439 public: | 439 public: |
| 440 void SetUp() override; | 440 void SetUp() override; |
| 441 | 441 |
| 442 void TestMigration(bool lock_keychain); | 442 void TestMigration(bool lock_keychain); |
| 443 | 443 |
| 444 protected: | 444 protected: |
| 445 std::unique_ptr<password_manager::LoginDatabase> login_db_; | 445 std::unique_ptr<password_manager::LoginDatabase> login_db_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 keychain_->set_locked(true); | 479 keychain_->set_locked(true); |
| 480 store_ = new PasswordStoreProxyMac( | 480 store_ = new PasswordStoreProxyMac( |
| 481 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 481 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 482 std::move(keychain_), std::move(login_db_), &testing_prefs_); | 482 std::move(keychain_), std::move(login_db_), &testing_prefs_); |
| 483 ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 483 ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); |
| 484 FinishAsyncProcessing(); | 484 FinishAsyncProcessing(); |
| 485 | 485 |
| 486 MockPasswordStoreConsumer mock_consumer; | 486 MockPasswordStoreConsumer mock_consumer; |
| 487 store()->GetLogins(PasswordStore::FormDigest(form), &mock_consumer); | 487 store()->GetLogins(PasswordStore::FormDigest(form), &mock_consumer); |
| 488 mock_consumer.WaitForResult(); | 488 mock_consumer.WaitForResult(); |
| 489 if (before_migration && lock_keychain) | 489 if (before_migration) |
| 490 EXPECT_THAT(mock_consumer.forms(), IsEmpty()); | 490 EXPECT_THAT(mock_consumer.forms(), IsEmpty()); |
| 491 else | 491 else |
| 492 EXPECT_THAT(mock_consumer.forms(), ElementsAre(Pointee(form))); | 492 EXPECT_THAT(mock_consumer.forms(), ElementsAre(Pointee(form))); |
| 493 | 493 |
| 494 int status = testing_prefs_.GetInteger( | 494 int status = testing_prefs_.GetInteger( |
| 495 password_manager::prefs::kKeychainMigrationStatus); | 495 password_manager::prefs::kKeychainMigrationStatus); |
| 496 EXPECT_EQ(static_cast<int>(GetTargetStatus(lock_keychain)), status); | 496 EXPECT_EQ(static_cast<int>(GetTargetStatus(lock_keychain)), status); |
| 497 histogram_tester_.ExpectUniqueSample( | 497 histogram_tester_.ExpectUniqueSample( |
| 498 "PasswordManager.KeychainMigration.Status", status, 1); | 498 "PasswordManager.KeychainMigration.Status", status, 1); |
| 499 static_cast<crypto::MockAppleKeychain*>(store()->keychain()) | 499 static_cast<crypto::MockAppleKeychain*>(store()->keychain()) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 518 TestMigration(true); | 518 TestMigration(true); |
| 519 } | 519 } |
| 520 | 520 |
| 521 INSTANTIATE_TEST_CASE_P(, | 521 INSTANTIATE_TEST_CASE_P(, |
| 522 PasswordStoreProxyMacMigrationTest, | 522 PasswordStoreProxyMacMigrationTest, |
| 523 testing::Values(MigrationStatus::NOT_STARTED, | 523 testing::Values(MigrationStatus::NOT_STARTED, |
| 524 MigrationStatus::MIGRATED, | 524 MigrationStatus::MIGRATED, |
| 525 MigrationStatus::FAILED_ONCE, | 525 MigrationStatus::FAILED_ONCE, |
| 526 MigrationStatus::FAILED_TWICE, | 526 MigrationStatus::FAILED_TWICE, |
| 527 MigrationStatus::MIGRATED_DELETED, | 527 MigrationStatus::MIGRATED_DELETED, |
| 528 MigrationStatus::MIGRATED_PARTIALLY)); | 528 MigrationStatus::MIGRATED_PARTIALLY, |
| 529 MigrationStatus::MIGRATION_STOPPED)); |
| 529 | 530 |
| 530 } // namespace | 531 } // namespace |
| OLD | NEW |