OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_x.h" | 5 #include "chrome/browser/password_manager/password_store_x.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 }; | 330 }; |
331 | 331 |
332 PasswordStoreXTestDelegate::PasswordStoreXTestDelegate(BackendType backend_type) | 332 PasswordStoreXTestDelegate::PasswordStoreXTestDelegate(BackendType backend_type) |
333 : backend_type_(backend_type) { | 333 : backend_type_(backend_type) { |
334 SetupTempDir(); | 334 SetupTempDir(); |
335 store_ = new PasswordStoreX(base::ThreadTaskRunnerHandle::Get(), | 335 store_ = new PasswordStoreX(base::ThreadTaskRunnerHandle::Get(), |
336 base::ThreadTaskRunnerHandle::Get(), | 336 base::ThreadTaskRunnerHandle::Get(), |
337 base::MakeUnique<password_manager::LoginDatabase>( | 337 base::MakeUnique<password_manager::LoginDatabase>( |
338 test_login_db_file_path()), | 338 test_login_db_file_path()), |
339 GetBackend(backend_type_)); | 339 GetBackend(backend_type_)); |
340 store_->Init(syncer::SyncableService::StartSyncFlare()); | 340 store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
341 } | 341 } |
342 | 342 |
343 PasswordStoreXTestDelegate::~PasswordStoreXTestDelegate() { | 343 PasswordStoreXTestDelegate::~PasswordStoreXTestDelegate() { |
344 store_->ShutdownOnUIThread(); | 344 store_->ShutdownOnUIThread(); |
345 FinishAsyncProcessing(); | 345 FinishAsyncProcessing(); |
346 } | 346 } |
347 | 347 |
348 void PasswordStoreXTestDelegate::FinishAsyncProcessing() { | 348 void PasswordStoreXTestDelegate::FinishAsyncProcessing() { |
349 base::RunLoop().RunUntilIdle(); | 349 base::RunLoop().RunUntilIdle(); |
350 } | 350 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 399 |
400 base::ScopedTempDir temp_dir_; | 400 base::ScopedTempDir temp_dir_; |
401 }; | 401 }; |
402 | 402 |
403 TEST_P(PasswordStoreXTest, Notifications) { | 403 TEST_P(PasswordStoreXTest, Notifications) { |
404 std::unique_ptr<password_manager::LoginDatabase> login_db( | 404 std::unique_ptr<password_manager::LoginDatabase> login_db( |
405 new password_manager::LoginDatabase(test_login_db_file_path())); | 405 new password_manager::LoginDatabase(test_login_db_file_path())); |
406 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( | 406 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( |
407 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), | 407 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), |
408 std::move(login_db), GetBackend(GetParam()))); | 408 std::move(login_db), GetBackend(GetParam()))); |
409 store->Init(syncer::SyncableService::StartSyncFlare()); | 409 store->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
410 | 410 |
411 password_manager::PasswordFormData form_data = { | 411 password_manager::PasswordFormData form_data = { |
412 PasswordForm::SCHEME_HTML, | 412 PasswordForm::SCHEME_HTML, |
413 "http://bar.example.com", | 413 "http://bar.example.com", |
414 "http://bar.example.com/origin", | 414 "http://bar.example.com/origin", |
415 "http://bar.example.com/action", | 415 "http://bar.example.com/action", |
416 L"submit_element", | 416 L"submit_element", |
417 L"username_element", | 417 L"username_element", |
418 L"password_element", | 418 L"password_element", |
419 L"username_value", | 419 L"username_value", |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // Get the new size of the login DB file. We expect it to be larger. | 505 // Get the new size of the login DB file. We expect it to be larger. |
506 base::File::Info db_file_full_info; | 506 base::File::Info db_file_full_info; |
507 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); | 507 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); |
508 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); | 508 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); |
509 | 509 |
510 // Initializing the PasswordStore shouldn't trigger a native migration (yet). | 510 // Initializing the PasswordStore shouldn't trigger a native migration (yet). |
511 login_db.reset(new password_manager::LoginDatabase(login_db_file)); | 511 login_db.reset(new password_manager::LoginDatabase(login_db_file)); |
512 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( | 512 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( |
513 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), | 513 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), |
514 std::move(login_db), GetBackend(GetParam()))); | 514 std::move(login_db), GetBackend(GetParam()))); |
515 store->Init(syncer::SyncableService::StartSyncFlare()); | 515 store->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
516 | 516 |
517 MockPasswordStoreConsumer consumer; | 517 MockPasswordStoreConsumer consumer; |
518 | 518 |
519 // The autofillable forms should have been migrated to the native backend. | 519 // The autofillable forms should have been migrated to the native backend. |
520 EXPECT_CALL(consumer, | 520 EXPECT_CALL(consumer, |
521 OnGetPasswordStoreResultsConstRef( | 521 OnGetPasswordStoreResultsConstRef( |
522 UnorderedPasswordFormElementsAre(&expected_autofillable))); | 522 UnorderedPasswordFormElementsAre(&expected_autofillable))); |
523 | 523 |
524 store->GetAutofillableLogins(&consumer); | 524 store->GetAutofillableLogins(&consumer); |
525 base::RunLoop().RunUntilIdle(); | 525 base::RunLoop().RunUntilIdle(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 580 |
581 INSTANTIATE_TEST_CASE_P(NoBackend, | 581 INSTANTIATE_TEST_CASE_P(NoBackend, |
582 PasswordStoreXTest, | 582 PasswordStoreXTest, |
583 testing::Values(NO_BACKEND)); | 583 testing::Values(NO_BACKEND)); |
584 INSTANTIATE_TEST_CASE_P(FailingBackend, | 584 INSTANTIATE_TEST_CASE_P(FailingBackend, |
585 PasswordStoreXTest, | 585 PasswordStoreXTest, |
586 testing::Values(FAILING_BACKEND)); | 586 testing::Values(FAILING_BACKEND)); |
587 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 587 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
588 PasswordStoreXTest, | 588 PasswordStoreXTest, |
589 testing::Values(WORKING_BACKEND)); | 589 testing::Values(WORKING_BACKEND)); |
OLD | NEW |