| 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 PrefService::UNSYNCABLE_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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 393 |
| 393 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 394 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 394 // task to notify us that it's safe to carry on with the test. | 395 // task to notify us that it's safe to carry on with the test. |
| 395 WaitableEvent done(false, false); | 396 WaitableEvent done(false, false); |
| 396 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 397 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 397 new SignalingTask(&done)); | 398 new SignalingTask(&done)); |
| 398 done.Wait(); | 399 done.Wait(); |
| 399 | 400 |
| 400 // Prentend that the migration has already taken place. | 401 // Prentend that the migration has already taken place. |
| 401 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 402 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 402 true); | 403 true, |
| 404 PrefService::UNSYNCABLE_PREF); |
| 403 | 405 |
| 404 // Initializing the PasswordStore shouldn't trigger a migration. | 406 // Initializing the PasswordStore shouldn't trigger a migration. |
| 405 scoped_refptr<PasswordStore> store( | 407 scoped_refptr<PasswordStore> store( |
| 406 new PasswordStoreDefault(login_db_.release(), profile_.get(), | 408 new PasswordStoreDefault(login_db_.release(), profile_.get(), |
| 407 wds_.get())); | 409 wds_.get())); |
| 408 store->Init(); | 410 store->Init(); |
| 409 | 411 |
| 410 MockPasswordStoreConsumer consumer; | 412 MockPasswordStoreConsumer consumer; |
| 411 // Make sure we quit the MessageLoop even if the test fails. | 413 // Make sure we quit the MessageLoop even if the test fails. |
| 412 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) | 414 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 423 MessageLoop::current()->Run(); | 425 MessageLoop::current()->Run(); |
| 424 | 426 |
| 425 STLDeleteElements(&unexpected_autofillable); | 427 STLDeleteElements(&unexpected_autofillable); |
| 426 | 428 |
| 427 store->Shutdown(); | 429 store->Shutdown(); |
| 428 } | 430 } |
| 429 | 431 |
| 430 TEST_F(PasswordStoreDefaultTest, Notifications) { | 432 TEST_F(PasswordStoreDefaultTest, Notifications) { |
| 431 // Prentend that the migration has already taken place. | 433 // Prentend that the migration has already taken place. |
| 432 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 434 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 433 true); | 435 true, |
| 436 PrefService::UNSYNCABLE_PREF); |
| 434 | 437 |
| 435 // Initializing the PasswordStore shouldn't trigger a migration. | 438 // Initializing the PasswordStore shouldn't trigger a migration. |
| 436 scoped_refptr<PasswordStore> store( | 439 scoped_refptr<PasswordStore> store( |
| 437 new PasswordStoreDefault(login_db_.release(), profile_.get(), | 440 new PasswordStoreDefault(login_db_.release(), profile_.get(), |
| 438 wds_.get())); | 441 wds_.get())); |
| 439 store->Init(); | 442 store->Init(); |
| 440 | 443 |
| 441 PasswordFormData form_data = | 444 PasswordFormData form_data = |
| 442 { PasswordForm::SCHEME_HTML, | 445 { PasswordForm::SCHEME_HTML, |
| 443 "http://bar.example.com", | 446 "http://bar.example.com", |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 // Deleting the login should trigger a notification. | 514 // Deleting the login should trigger a notification. |
| 512 store->RemoveLogin(*form); | 515 store->RemoveLogin(*form); |
| 513 | 516 |
| 514 // Wait for PasswordStore to send the notification. | 517 // Wait for PasswordStore to send the notification. |
| 515 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 518 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 516 new SignalingTask(&done)); | 519 new SignalingTask(&done)); |
| 517 done.Wait(); | 520 done.Wait(); |
| 518 | 521 |
| 519 store->Shutdown(); | 522 store->Shutdown(); |
| 520 } | 523 } |
| OLD | NEW |