| 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/sync/test/integration/passwords_helper.h" | 5 #include "chrome/browser/sync/test/integration/passwords_helper.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 form->date_synced = base::Time(); | 68 form->date_synced = base::Time(); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 } // namespace | 72 } // namespace |
| 73 | 73 |
| 74 namespace passwords_helper { | 74 namespace passwords_helper { |
| 75 | 75 |
| 76 void AddLogin(PasswordStore* store, const PasswordForm& form) { | 76 void AddLogin(PasswordStore* store, const PasswordForm& form) { |
| 77 ASSERT_TRUE(store); | 77 ASSERT_TRUE(store); |
| 78 base::WaitableEvent wait_event(true, false); | 78 base::WaitableEvent wait_event( |
| 79 base::WaitableEvent::ResetPolicy::MANUAL, |
| 80 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 79 store->AddLogin(form); | 81 store->AddLogin(form); |
| 80 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); | 82 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); |
| 81 wait_event.Wait(); | 83 wait_event.Wait(); |
| 82 } | 84 } |
| 83 | 85 |
| 84 void UpdateLogin(PasswordStore* store, const PasswordForm& form) { | 86 void UpdateLogin(PasswordStore* store, const PasswordForm& form) { |
| 85 ASSERT_TRUE(store); | 87 ASSERT_TRUE(store); |
| 86 base::WaitableEvent wait_event(true, false); | 88 base::WaitableEvent wait_event( |
| 89 base::WaitableEvent::ResetPolicy::MANUAL, |
| 90 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 87 store->UpdateLogin(form); | 91 store->UpdateLogin(form); |
| 88 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); | 92 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); |
| 89 wait_event.Wait(); | 93 wait_event.Wait(); |
| 90 } | 94 } |
| 91 | 95 |
| 92 ScopedVector<PasswordForm> GetLogins(PasswordStore* store) { | 96 ScopedVector<PasswordForm> GetLogins(PasswordStore* store) { |
| 93 EXPECT_TRUE(store); | 97 EXPECT_TRUE(store); |
| 94 PasswordForm matcher_form; | 98 PasswordForm matcher_form; |
| 95 matcher_form.signon_realm = kFakeSignonRealm; | 99 matcher_form.signon_realm = kFakeSignonRealm; |
| 96 PasswordStoreConsumerHelper consumer; | 100 PasswordStoreConsumerHelper consumer; |
| 97 store->GetLogins(matcher_form, &consumer); | 101 store->GetLogins(matcher_form, &consumer); |
| 98 content::RunMessageLoop(); | 102 content::RunMessageLoop(); |
| 99 return consumer.result(); | 103 return consumer.result(); |
| 100 } | 104 } |
| 101 | 105 |
| 102 void RemoveLogin(PasswordStore* store, const PasswordForm& form) { | 106 void RemoveLogin(PasswordStore* store, const PasswordForm& form) { |
| 103 ASSERT_TRUE(store); | 107 ASSERT_TRUE(store); |
| 104 base::WaitableEvent wait_event(true, false); | 108 base::WaitableEvent wait_event( |
| 109 base::WaitableEvent::ResetPolicy::MANUAL, |
| 110 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 105 store->RemoveLogin(form); | 111 store->RemoveLogin(form); |
| 106 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); | 112 store->ScheduleTask(base::Bind(&PasswordStoreCallback, &wait_event)); |
| 107 wait_event.Wait(); | 113 wait_event.Wait(); |
| 108 } | 114 } |
| 109 | 115 |
| 110 void RemoveLogins(PasswordStore* store) { | 116 void RemoveLogins(PasswordStore* store) { |
| 111 ScopedVector<PasswordForm> forms = GetLogins(store); | 117 ScopedVector<PasswordForm> forms = GetLogins(store); |
| 112 for (const PasswordForm* form : forms) { | 118 for (const PasswordForm* form : forms) { |
| 113 RemoveLogin(store, *form); | 119 RemoveLogin(store, *form); |
| 114 } | 120 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 form.origin = GURL(base::StringPrintf(kIndexedFakeOrigin, index)); | 350 form.origin = GURL(base::StringPrintf(kIndexedFakeOrigin, index)); |
| 345 form.username_value = | 351 form.username_value = |
| 346 base::ASCIIToUTF16(base::StringPrintf("username%d", index)); | 352 base::ASCIIToUTF16(base::StringPrintf("username%d", index)); |
| 347 form.password_value = | 353 form.password_value = |
| 348 base::ASCIIToUTF16(base::StringPrintf("password%d", index)); | 354 base::ASCIIToUTF16(base::StringPrintf("password%d", index)); |
| 349 form.date_created = base::Time::Now(); | 355 form.date_created = base::Time::Now(); |
| 350 return form; | 356 return form; |
| 351 } | 357 } |
| 352 | 358 |
| 353 } // namespace passwords_helper | 359 } // namespace passwords_helper |
| OLD | NEW |