| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 scoped_ptr<TestingProfile> profile_; | 277 scoped_ptr<TestingProfile> profile_; |
| 278 base::ScopedTempDir temp_dir_; | 278 base::ScopedTempDir temp_dir_; |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 ACTION(STLDeleteElements0) { | 281 ACTION(STLDeleteElements0) { |
| 282 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 282 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
| 283 } | 283 } |
| 284 | 284 |
| 285 TEST_P(PasswordStoreXTest, Notifications) { | 285 TEST_P(PasswordStoreXTest, Notifications) { |
| 286 scoped_refptr<PasswordStoreX> store( | 286 scoped_refptr<PasswordStoreX> store( |
| 287 new PasswordStoreX(login_db_.release(), | 287 new PasswordStoreX( |
| 288 profile_.get(), | 288 base::MessageLoopProxy::current(), |
| 289 GetBackend())); | 289 base::MessageLoopProxy::current(), |
| 290 login_db_.release(), |
| 291 profile_.get(), |
| 292 GetBackend())); |
| 290 store->Init(); | 293 store->Init(); |
| 291 | 294 |
| 292 PasswordFormData form_data = | 295 PasswordFormData form_data = |
| 293 { PasswordForm::SCHEME_HTML, | 296 { PasswordForm::SCHEME_HTML, |
| 294 "http://bar.example.com", | 297 "http://bar.example.com", |
| 295 "http://bar.example.com/origin", | 298 "http://bar.example.com/origin", |
| 296 "http://bar.example.com/action", | 299 "http://bar.example.com/action", |
| 297 L"submit_element", | 300 L"submit_element", |
| 298 L"username_element", | 301 L"username_element", |
| 299 L"password_element", | 302 L"password_element", |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 login_db->AddLogin(**it); | 392 login_db->AddLogin(**it); |
| 390 } | 393 } |
| 391 | 394 |
| 392 // Get the new size of the login DB file. We expect it to be larger. | 395 // Get the new size of the login DB file. We expect it to be larger. |
| 393 base::File::Info db_file_full_info; | 396 base::File::Info db_file_full_info; |
| 394 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); | 397 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); |
| 395 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); | 398 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); |
| 396 | 399 |
| 397 // Initializing the PasswordStore shouldn't trigger a native migration (yet). | 400 // Initializing the PasswordStore shouldn't trigger a native migration (yet). |
| 398 scoped_refptr<PasswordStoreX> store( | 401 scoped_refptr<PasswordStoreX> store( |
| 399 new PasswordStoreX(login_db_.release(), | 402 new PasswordStoreX( |
| 400 profile_.get(), | 403 base::MessageLoopProxy::current(), |
| 401 GetBackend())); | 404 base::MessageLoopProxy::current(), |
| 405 login_db_.release(), |
| 406 profile_.get(), |
| 407 GetBackend())); |
| 402 store->Init(); | 408 store->Init(); |
| 403 | 409 |
| 404 MockPasswordStoreConsumer consumer; | 410 MockPasswordStoreConsumer consumer; |
| 405 | 411 |
| 406 // The autofillable forms should have been migrated to the native backend. | 412 // The autofillable forms should have been migrated to the native backend. |
| 407 EXPECT_CALL(consumer, | 413 EXPECT_CALL(consumer, |
| 408 OnGetPasswordStoreResults( | 414 OnGetPasswordStoreResults( |
| 409 ContainsAllPasswordForms(expected_autofillable))) | 415 ContainsAllPasswordForms(expected_autofillable))) |
| 410 .WillOnce(WithArg<0>(STLDeleteElements0())); | 416 .WillOnce(WithArg<0>(STLDeleteElements0())); |
| 411 | 417 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 483 |
| 478 INSTANTIATE_TEST_CASE_P(NoBackend, | 484 INSTANTIATE_TEST_CASE_P(NoBackend, |
| 479 PasswordStoreXTest, | 485 PasswordStoreXTest, |
| 480 testing::Values(NO_BACKEND)); | 486 testing::Values(NO_BACKEND)); |
| 481 INSTANTIATE_TEST_CASE_P(FailingBackend, | 487 INSTANTIATE_TEST_CASE_P(FailingBackend, |
| 482 PasswordStoreXTest, | 488 PasswordStoreXTest, |
| 483 testing::Values(FAILING_BACKEND)); | 489 testing::Values(FAILING_BACKEND)); |
| 484 INSTANTIATE_TEST_CASE_P(WorkingBackend, | 490 INSTANTIATE_TEST_CASE_P(WorkingBackend, |
| 485 PasswordStoreXTest, | 491 PasswordStoreXTest, |
| 486 testing::Values(WORKING_BACKEND)); | 492 testing::Values(WORKING_BACKEND)); |
| OLD | NEW |