| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/thread_task_runner_handle.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "chrome/browser/password_manager/password_store_x.h" | 18 #include "chrome/browser/password_manager/password_store_x.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 20 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 20 #include "components/password_manager/core/browser/password_store_change.h" | 21 #include "components/password_manager/core/browser/password_store_change.h" |
| 21 #include "components/password_manager/core/browser/password_store_consumer.h" | 22 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 22 #include "components/password_manager/core/common/password_manager_pref_names.h" | 23 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 26 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 }; | 303 }; |
| 303 | 304 |
| 304 ACTION(STLDeleteElements0) { | 305 ACTION(STLDeleteElements0) { |
| 305 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 306 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
| 306 } | 307 } |
| 307 | 308 |
| 308 TEST_P(PasswordStoreXTest, Notifications) { | 309 TEST_P(PasswordStoreXTest, Notifications) { |
| 309 scoped_ptr<password_manager::LoginDatabase> login_db( | 310 scoped_ptr<password_manager::LoginDatabase> login_db( |
| 310 new password_manager::LoginDatabase(test_login_db_file_path())); | 311 new password_manager::LoginDatabase(test_login_db_file_path())); |
| 311 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( | 312 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( |
| 312 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), | 313 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), |
| 313 login_db.Pass(), GetBackend())); | 314 login_db.Pass(), GetBackend())); |
| 314 store->Init(syncer::SyncableService::StartSyncFlare()); | 315 store->Init(syncer::SyncableService::StartSyncFlare()); |
| 315 | 316 |
| 316 password_manager::PasswordFormData form_data = { | 317 password_manager::PasswordFormData form_data = { |
| 317 PasswordForm::SCHEME_HTML, "http://bar.example.com", | 318 PasswordForm::SCHEME_HTML, "http://bar.example.com", |
| 318 "http://bar.example.com/origin", "http://bar.example.com/action", | 319 "http://bar.example.com/origin", "http://bar.example.com/action", |
| 319 L"submit_element", L"username_element", | 320 L"submit_element", L"username_element", |
| 320 L"password_element", L"username_value", | 321 L"password_element", L"username_value", |
| 321 L"password_value", true, | 322 L"password_value", true, |
| 322 false, 1}; | 323 false, 1}; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 404 } |
| 404 | 405 |
| 405 // Get the new size of the login DB file. We expect it to be larger. | 406 // Get the new size of the login DB file. We expect it to be larger. |
| 406 base::File::Info db_file_full_info; | 407 base::File::Info db_file_full_info; |
| 407 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); | 408 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); |
| 408 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); | 409 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); |
| 409 | 410 |
| 410 // Initializing the PasswordStore shouldn't trigger a native migration (yet). | 411 // Initializing the PasswordStore shouldn't trigger a native migration (yet). |
| 411 login_db.reset(new password_manager::LoginDatabase(login_db_file)); | 412 login_db.reset(new password_manager::LoginDatabase(login_db_file)); |
| 412 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( | 413 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( |
| 413 base::MessageLoopProxy::current(), base::MessageLoopProxy::current(), | 414 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), |
| 414 login_db.Pass(), GetBackend())); | 415 login_db.Pass(), GetBackend())); |
| 415 store->Init(syncer::SyncableService::StartSyncFlare()); | 416 store->Init(syncer::SyncableService::StartSyncFlare()); |
| 416 | 417 |
| 417 MockPasswordStoreConsumer consumer; | 418 MockPasswordStoreConsumer consumer; |
| 418 | 419 |
| 419 // The autofillable forms should have been migrated to the native backend. | 420 // The autofillable forms should have been migrated to the native backend. |
| 420 EXPECT_CALL( | 421 EXPECT_CALL( |
| 421 consumer, | 422 consumer, |
| 422 OnGetPasswordStoreResultsConstRef( | 423 OnGetPasswordStoreResultsConstRef( |
| 423 UnorderedPasswordFormElementsAre(expected_autofillable.get()))); | 424 UnorderedPasswordFormElementsAre(expected_autofillable.get()))); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 483 |
| 483 INSTANTIATE_TEST_CASE_P(NoBackend, | 484 INSTANTIATE_TEST_CASE_P(NoBackend, |
| 484 PasswordStoreXTest, | 485 PasswordStoreXTest, |
| 485 testing::Values(NO_BACKEND)); | 486 testing::Values(NO_BACKEND)); |
| 486 INSTANTIATE_TEST_CASE_P(FailingBackend, | 487 INSTANTIATE_TEST_CASE_P(FailingBackend, |
| 487 PasswordStoreXTest, | 488 PasswordStoreXTest, |
| 488 testing::Values(FAILING_BACKEND)); | 489 testing::Values(FAILING_BACKEND)); |
| 489 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 490 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
| 490 PasswordStoreXTest, | 491 PasswordStoreXTest, |
| 491 testing::Values(WORKING_BACKEND)); | 492 testing::Values(WORKING_BACKEND)); |
| OLD | NEW |