Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: chrome/browser/password_manager/password_store_default_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string_util.h" 10 #include "base/string_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ASSERT_TRUE(db_thread_.Start()); 105 ASSERT_TRUE(db_thread_.Start());
106 106
107 profile_.reset(new TestingProfile()); 107 profile_.reset(new TestingProfile());
108 108
109 login_db_.reset(new LoginDatabase()); 109 login_db_.reset(new LoginDatabase());
110 ASSERT_TRUE(login_db_->Init(profile_->GetPath().Append( 110 ASSERT_TRUE(login_db_->Init(profile_->GetPath().Append(
111 FILE_PATH_LITERAL("login_test")))); 111 FILE_PATH_LITERAL("login_test"))));
112 } 112 }
113 113
114 virtual void TearDown() { 114 virtual void TearDown() {
115 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 115 base::MessageLoop::current()->PostTask(FROM_HERE,
116 MessageLoop::current()->Run(); 116 base::MessageLoop::QuitClosure());
117 base::MessageLoop::current()->Run();
117 db_thread_.Stop(); 118 db_thread_.Stop();
118 } 119 }
119 120
120 MessageLoopForUI message_loop_; 121 base::MessageLoopForUI message_loop_;
121 content::TestBrowserThread ui_thread_; 122 content::TestBrowserThread ui_thread_;
122 // PasswordStore, WDS schedule work on this thread. 123 // PasswordStore, WDS schedule work on this thread.
123 content::TestBrowserThread db_thread_; 124 content::TestBrowserThread db_thread_;
124 125
125 scoped_ptr<LoginDatabase> login_db_; 126 scoped_ptr<LoginDatabase> login_db_;
126 scoped_ptr<TestingProfile> profile_; 127 scoped_ptr<TestingProfile> profile_;
127 }; 128 };
128 129
129 ACTION(STLDeleteElements0) { 130 ACTION(STLDeleteElements0) {
130 STLDeleteContainerPointers(arg0.begin(), arg0.end()); 131 STLDeleteContainerPointers(arg0.begin(), arg0.end());
131 } 132 }
132 133
133 ACTION(QuitUIMessageLoop) { 134 ACTION(QuitUIMessageLoop) {
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
135 MessageLoop::current()->Quit(); 136 base::MessageLoop::current()->Quit();
136 } 137 }
137 138
138 TEST_F(PasswordStoreDefaultTest, NonASCIIData) { 139 TEST_F(PasswordStoreDefaultTest, NonASCIIData) {
139 scoped_refptr<PasswordStoreDefault> store( 140 scoped_refptr<PasswordStoreDefault> store(
140 new PasswordStoreDefault(login_db_.release(), profile_.get())); 141 new PasswordStoreDefault(login_db_.release(), profile_.get()));
141 store->Init(); 142 store->Init();
142 143
143 // Some non-ASCII password form data. 144 // Some non-ASCII password form data.
144 static const PasswordFormData form_data[] = { 145 static const PasswordFormData form_data[] = {
145 { PasswordForm::SCHEME_HTML, 146 { PasswordForm::SCHEME_HTML,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) 178 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _))
178 .WillByDefault(QuitUIMessageLoop()); 179 .WillByDefault(QuitUIMessageLoop());
179 180
180 // We expect to get the same data back, even though it's not all ASCII. 181 // We expect to get the same data back, even though it's not all ASCII.
181 EXPECT_CALL(consumer, 182 EXPECT_CALL(consumer,
182 OnPasswordStoreRequestDone(_, 183 OnPasswordStoreRequestDone(_,
183 ContainsAllPasswordForms(expected_forms))) 184 ContainsAllPasswordForms(expected_forms)))
184 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); 185 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop()));
185 186
186 store->GetAutofillableLogins(&consumer); 187 store->GetAutofillableLogins(&consumer);
187 MessageLoop::current()->Run(); 188 base::MessageLoop::current()->Run();
188 189
189 STLDeleteElements(&expected_forms); 190 STLDeleteElements(&expected_forms);
190 } 191 }
191 192
192 TEST_F(PasswordStoreDefaultTest, Notifications) { 193 TEST_F(PasswordStoreDefaultTest, Notifications) {
193 scoped_refptr<PasswordStore> store( 194 scoped_refptr<PasswordStore> store(
194 new PasswordStoreDefault(login_db_.release(), profile_.get())); 195 new PasswordStoreDefault(login_db_.release(), profile_.get()));
195 store->Init(); 196 store->Init();
196 197
197 PasswordFormData form_data = 198 PasswordFormData form_data =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // Deleting the login should trigger a notification. 268 // Deleting the login should trigger a notification.
268 store->RemoveLogin(*form); 269 store->RemoveLogin(*form);
269 270
270 // Wait for PasswordStore to send the notification. 271 // Wait for PasswordStore to send the notification.
271 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 272 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
272 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); 273 base::Bind(&WaitableEvent::Signal, base::Unretained(&done)));
273 done.Wait(); 274 done.Wait();
274 275
275 store->ShutdownOnUIThread(); 276 store->ShutdownOnUIThread();
276 } 277 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_unittest.cc ('k') | chrome/browser/password_manager/password_store_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698