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/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 class MockPasswordStoreConsumer : public PasswordStoreConsumer { | 42 class MockPasswordStoreConsumer : public PasswordStoreConsumer { |
43 public: | 43 public: |
44 MOCK_METHOD2(OnPasswordStoreRequestDone, | 44 MOCK_METHOD2(OnPasswordStoreRequestDone, |
45 void(CancelableRequestProvider::Handle, | 45 void(CancelableRequestProvider::Handle, |
46 const std::vector<webkit::forms::PasswordForm*>&)); | 46 const std::vector<webkit::forms::PasswordForm*>&)); |
47 }; | 47 }; |
48 | 48 |
49 // This class will add and remove a mock notification observer from | 49 // This class will add and remove a mock notification observer from |
50 // the DB thread. | 50 // the DB thread. |
51 class DBThreadObserverHelper : | 51 class DBThreadObserverHelper |
52 public base::RefCountedThreadSafe<DBThreadObserverHelper, | 52 : public base::RefCountedThreadSafe<DBThreadObserverHelper, |
53 BrowserThread::DeleteOnDBThread> { | 53 BrowserThread::DeleteOnDBThread> { |
54 public: | 54 public: |
55 DBThreadObserverHelper() : done_event_(true, false) {} | 55 DBThreadObserverHelper() : done_event_(true, false) {} |
56 | 56 |
57 void Init(PasswordStore* password_store) { | 57 void Init(PasswordStore* password_store) { |
58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
59 BrowserThread::PostTask( | 59 BrowserThread::PostTask( |
60 BrowserThread::DB, | 60 BrowserThread::DB, |
61 FROM_HERE, | 61 FROM_HERE, |
62 base::Bind(&DBThreadObserverHelper::AddObserverTask, | 62 base::Bind(&DBThreadObserverHelper::AddObserverTask, |
63 this, | 63 this, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
137 MessageLoop::current()->Quit(); | 137 MessageLoop::current()->Quit(); |
138 } | 138 } |
139 | 139 |
140 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { | 140 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { |
141 scoped_refptr<PasswordStoreDefault> store( | 141 scoped_refptr<PasswordStoreDefault> store( |
142 new PasswordStoreDefault(login_db_.release(), profile_.get())); | 142 new PasswordStoreDefault(login_db_.release(), profile_.get())); |
143 store->Init(); | 143 store->Init(); |
144 | 144 |
145 // Some non-ASCII password form data. | 145 // Some non-ASCII password form data. |
146 PasswordFormData form_data[] = { | 146 static const PasswordFormData form_data[] = { |
147 { PasswordForm::SCHEME_HTML, | 147 { PasswordForm::SCHEME_HTML, |
148 "http://foo.example.com", | 148 "http://foo.example.com", |
149 "http://foo.example.com/origin", | 149 "http://foo.example.com/origin", |
150 "http://foo.example.com/action", | 150 "http://foo.example.com/action", |
151 L"มีสีสัน", | 151 L"มีสีสัน", |
152 L"お元気ですか?", | 152 L"お元気ですか?", |
153 L"盆栽", | 153 L"盆栽", |
154 L"أحب كرة", | 154 L"أحب كرة", |
155 L"£éä국수çà", | 155 L"£éä국수çà", |
156 true, false, 1 }, | 156 true, false, 1 }, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Deleting the login should trigger a notification. | 267 // Deleting the login should trigger a notification. |
268 store->RemoveLogin(*form); | 268 store->RemoveLogin(*form); |
269 | 269 |
270 // Wait for PasswordStore to send the notification. | 270 // Wait for PasswordStore to send the notification. |
271 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 271 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
272 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 272 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
273 done.Wait(); | 273 done.Wait(); |
274 | 274 |
275 store->ShutdownOnUIThread(); | 275 store->ShutdownOnUIThread(); |
276 } | 276 } |
OLD | NEW |