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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 STLDeleteContainerPointers(arg0.begin(), arg0.end()); | 128 STLDeleteContainerPointers(arg0.begin(), arg0.end()); |
129 } | 129 } |
130 | 130 |
131 ACTION(QuitUIMessageLoop) { | 131 ACTION(QuitUIMessageLoop) { |
132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
133 base::MessageLoop::current()->Quit(); | 133 base::MessageLoop::current()->Quit(); |
134 } | 134 } |
135 | 135 |
136 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { | 136 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { |
137 scoped_refptr<PasswordStoreDefault> store( | 137 scoped_refptr<PasswordStoreDefault> store( |
138 new PasswordStoreDefault(login_db_.release(), profile_.get())); | 138 new PasswordStoreDefault( |
| 139 base::MessageLoopProxy::current(), |
| 140 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 141 login_db_.release(), |
| 142 profile_.get())); |
139 store->Init(); | 143 store->Init(); |
140 | 144 |
141 // Some non-ASCII password form data. | 145 // Some non-ASCII password form data. |
142 static const PasswordFormData form_data[] = { | 146 static const PasswordFormData form_data[] = { |
143 { PasswordForm::SCHEME_HTML, | 147 { PasswordForm::SCHEME_HTML, |
144 "http://foo.example.com", | 148 "http://foo.example.com", |
145 "http://foo.example.com/origin", | 149 "http://foo.example.com/origin", |
146 "http://foo.example.com/action", | 150 "http://foo.example.com/action", |
147 L"มีสีสัน", | 151 L"มีสีสัน", |
148 L"お元気ですか?", | 152 L"お元気ですか?", |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 OnGetPasswordStoreResults(ContainsAllPasswordForms(expected_forms))) | 184 OnGetPasswordStoreResults(ContainsAllPasswordForms(expected_forms))) |
181 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); | 185 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
182 | 186 |
183 store->GetAutofillableLogins(&consumer); | 187 store->GetAutofillableLogins(&consumer); |
184 base::MessageLoop::current()->Run(); | 188 base::MessageLoop::current()->Run(); |
185 | 189 |
186 STLDeleteElements(&expected_forms); | 190 STLDeleteElements(&expected_forms); |
187 } | 191 } |
188 | 192 |
189 TEST_F(PasswordStoreDefaultTest, Notifications) { | 193 TEST_F(PasswordStoreDefaultTest, Notifications) { |
190 scoped_refptr<PasswordStore> store( | 194 scoped_refptr<PasswordStoreDefault> store( |
191 new PasswordStoreDefault(login_db_.release(), profile_.get())); | 195 new PasswordStoreDefault( |
| 196 base::MessageLoopProxy::current(), |
| 197 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |
| 198 login_db_.release(), |
| 199 profile_.get())); |
192 store->Init(); | 200 store->Init(); |
193 | 201 |
194 PasswordFormData form_data = | 202 PasswordFormData form_data = |
195 { PasswordForm::SCHEME_HTML, | 203 { PasswordForm::SCHEME_HTML, |
196 "http://bar.example.com", | 204 "http://bar.example.com", |
197 "http://bar.example.com/origin", | 205 "http://bar.example.com/origin", |
198 "http://bar.example.com/action", | 206 "http://bar.example.com/action", |
199 L"submit_element", | 207 L"submit_element", |
200 L"username_element", | 208 L"username_element", |
201 L"password_element", | 209 L"password_element", |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // Deleting the login should trigger a notification. | 272 // Deleting the login should trigger a notification. |
265 store->RemoveLogin(*form); | 273 store->RemoveLogin(*form); |
266 | 274 |
267 // Wait for PasswordStore to send the notification. | 275 // Wait for PasswordStore to send the notification. |
268 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 276 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
269 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 277 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
270 done.Wait(); | 278 done.Wait(); |
271 | 279 |
272 store->ShutdownOnUIThread(); | 280 store->ShutdownOnUIThread(); |
273 } | 281 } |
OLD | NEW |