| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_temp_dir.h" | 6 #include "base/memory/scoped_temp_dir.h" |
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 | 146 |
| 147 MATCHER(EmptyWDResult, "") { | 147 MATCHER(EmptyWDResult, "") { |
| 148 return static_cast<const WDResult<std::vector<PasswordForm*> >*>( | 148 return static_cast<const WDResult<std::vector<PasswordForm*> >*>( |
| 149 arg)->GetValue().empty(); | 149 arg)->GetValue().empty(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { | 152 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { |
| 153 // Prentend that the migration has already taken place. | 153 // Prentend that the migration has already taken place. |
| 154 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 154 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 155 true); | 155 true, |
| 156 false /* don't sync pref */); |
| 156 | 157 |
| 157 // Initializing the PasswordStore shouldn't trigger a migration. | 158 // Initializing the PasswordStore shouldn't trigger a migration. |
| 158 scoped_refptr<PasswordStoreDefault> store( | 159 scoped_refptr<PasswordStoreDefault> store( |
| 159 new PasswordStoreDefault(login_db_.release(), profile_.get(), | 160 new PasswordStoreDefault(login_db_.release(), profile_.get(), |
| 160 wds_.get())); | 161 wds_.get())); |
| 161 store->Init(); | 162 store->Init(); |
| 162 | 163 |
| 163 // Some non-ASCII password form data. | 164 // Some non-ASCII password form data. |
| 164 PasswordFormData form_data[] = { | 165 PasswordFormData form_data[] = { |
| 165 { PasswordForm::SCHEME_HTML, | 166 { PasswordForm::SCHEME_HTML, |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 391 |
| 391 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 392 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 392 // task to notify us that it's safe to carry on with the test. | 393 // task to notify us that it's safe to carry on with the test. |
| 393 WaitableEvent done(false, false); | 394 WaitableEvent done(false, false); |
| 394 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 395 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 395 new SignalingTask(&done)); | 396 new SignalingTask(&done)); |
| 396 done.Wait(); | 397 done.Wait(); |
| 397 | 398 |
| 398 // Prentend that the migration has already taken place. | 399 // Prentend that the migration has already taken place. |
| 399 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 400 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 400 true); | 401 true, |
| 402 false /* don't sync pref */); |
| 401 | 403 |
| 402 // Initializing the PasswordStore shouldn't trigger a migration. | 404 // Initializing the PasswordStore shouldn't trigger a migration. |
| 403 scoped_refptr<PasswordStoreDefault> store( | 405 scoped_refptr<PasswordStoreDefault> store( |
| 404 new PasswordStoreDefault(login_db_.release(), profile_.get(), | 406 new PasswordStoreDefault(login_db_.release(), profile_.get(), |
| 405 wds_.get())); | 407 wds_.get())); |
| 406 store->Init(); | 408 store->Init(); |
| 407 | 409 |
| 408 MockPasswordStoreConsumer consumer; | 410 MockPasswordStoreConsumer consumer; |
| 409 // Make sure we quit the MessageLoop even if the test fails. | 411 // Make sure we quit the MessageLoop even if the test fails. |
| 410 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) | 412 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) |
| 411 .WillByDefault(QuitUIMessageLoop()); | 413 .WillByDefault(QuitUIMessageLoop()); |
| 412 | 414 |
| 413 // No forms should be migrated. | 415 // No forms should be migrated. |
| 414 VectorOfForms empty; | 416 VectorOfForms empty; |
| 415 EXPECT_CALL(consumer, | 417 EXPECT_CALL(consumer, |
| 416 OnPasswordStoreRequestDone(_, | 418 OnPasswordStoreRequestDone(_, |
| 417 ContainsAllPasswordForms(empty))) | 419 ContainsAllPasswordForms(empty))) |
| 418 .WillOnce(QuitUIMessageLoop()); | 420 .WillOnce(QuitUIMessageLoop()); |
| 419 | 421 |
| 420 store->GetAutofillableLogins(&consumer); | 422 store->GetAutofillableLogins(&consumer); |
| 421 MessageLoop::current()->Run(); | 423 MessageLoop::current()->Run(); |
| 422 | 424 |
| 423 STLDeleteElements(&unexpected_autofillable); | 425 STLDeleteElements(&unexpected_autofillable); |
| 424 } | 426 } |
| 425 | 427 |
| 426 TEST_F(PasswordStoreDefaultTest, Notifications) { | 428 TEST_F(PasswordStoreDefaultTest, Notifications) { |
| 427 // Prentend that the migration has already taken place. | 429 // Prentend that the migration has already taken place. |
| 428 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 430 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 429 true); | 431 true, |
| 432 false /* don't sync pref */); |
| 430 | 433 |
| 431 // Initializing the PasswordStore shouldn't trigger a migration. | 434 // Initializing the PasswordStore shouldn't trigger a migration. |
| 432 scoped_refptr<PasswordStoreDefault> store( | 435 scoped_refptr<PasswordStoreDefault> store( |
| 433 new PasswordStoreDefault(login_db_.release(), profile_.get(), | 436 new PasswordStoreDefault(login_db_.release(), profile_.get(), |
| 434 wds_.get())); | 437 wds_.get())); |
| 435 store->Init(); | 438 store->Init(); |
| 436 | 439 |
| 437 PasswordFormData form_data = | 440 PasswordFormData form_data = |
| 438 { PasswordForm::SCHEME_HTML, | 441 { PasswordForm::SCHEME_HTML, |
| 439 "http://bar.example.com", | 442 "http://bar.example.com", |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 expected_delete_changes))))); | 508 expected_delete_changes))))); |
| 506 | 509 |
| 507 // Deleting the login should trigger a notification. | 510 // Deleting the login should trigger a notification. |
| 508 store->RemoveLogin(*form); | 511 store->RemoveLogin(*form); |
| 509 | 512 |
| 510 // Wait for PasswordStore to send the notification. | 513 // Wait for PasswordStore to send the notification. |
| 511 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 514 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 512 new SignalingTask(&done)); | 515 new SignalingTask(&done)); |
| 513 done.Wait(); | 516 done.Wait(); |
| 514 } | 517 } |
| OLD | NEW |