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

Side by Side Diff: chrome/browser/password_manager/native_backend_gnome_x_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 <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 form_isc_.action = GURL("http://www.isc.org/auth"); 300 form_isc_.action = GURL("http://www.isc.org/auth");
301 form_isc_.username_element = UTF8ToUTF16("id"); 301 form_isc_.username_element = UTF8ToUTF16("id");
302 form_isc_.username_value = UTF8ToUTF16("janedoe"); 302 form_isc_.username_value = UTF8ToUTF16("janedoe");
303 form_isc_.password_element = UTF8ToUTF16("passwd"); 303 form_isc_.password_element = UTF8ToUTF16("passwd");
304 form_isc_.password_value = UTF8ToUTF16("ihazabukkit"); 304 form_isc_.password_value = UTF8ToUTF16("ihazabukkit");
305 form_isc_.submit_element = UTF8ToUTF16("login"); 305 form_isc_.submit_element = UTF8ToUTF16("login");
306 form_isc_.signon_realm = "ISC"; 306 form_isc_.signon_realm = "ISC";
307 } 307 }
308 308
309 virtual void TearDown() { 309 virtual void TearDown() {
310 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 310 base::MessageLoop::current()->PostTask(FROM_HERE,
311 MessageLoop::current()->Run(); 311 base::MessageLoop::QuitClosure());
312 base::MessageLoop::current()->Run();
312 db_thread_.Stop(); 313 db_thread_.Stop();
313 } 314 }
314 315
315 void RunBothThreads() { 316 void RunBothThreads() {
316 // First we post a message to the DB thread that will run after all other 317 // First we post a message to the DB thread that will run after all other
317 // messages that have been posted to the DB thread (we don't expect more 318 // messages that have been posted to the DB thread (we don't expect more
318 // to be posted), which posts a message to the UI thread to quit the loop. 319 // to be posted), which posts a message to the UI thread to quit the loop.
319 // That way we can run both loops and be sure that the UI thread loop will 320 // That way we can run both loops and be sure that the UI thread loop will
320 // quit so we can get on with the rest of the test. 321 // quit so we can get on with the rest of the test.
321 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 322 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
322 base::Bind(&PostQuitTask, &message_loop_)); 323 base::Bind(&PostQuitTask, &message_loop_));
323 MessageLoop::current()->Run(); 324 base::MessageLoop::current()->Run();
324 } 325 }
325 326
326 static void PostQuitTask(MessageLoop* loop) { 327 static void PostQuitTask(base::MessageLoop* loop) {
327 loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 328 loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure());
328 } 329 }
329 330
330 void CheckUint32Attribute(const MockKeyringItem* item, 331 void CheckUint32Attribute(const MockKeyringItem* item,
331 const std::string& attribute, 332 const std::string& attribute,
332 uint32_t value) { 333 uint32_t value) {
333 MockKeyringItem::attribute_map::const_iterator it = 334 MockKeyringItem::attribute_map::const_iterator it =
334 item->attributes.find(attribute); 335 item->attributes.find(attribute);
335 EXPECT_NE(item->attributes.end(), it); 336 EXPECT_NE(item->attributes.end(), it);
336 if (it != item->attributes.end()) { 337 if (it != item->attributes.end()) {
337 EXPECT_EQ(MockKeyringItem::ItemAttribute::UINT32, it->second.type); 338 EXPECT_EQ(MockKeyringItem::ItemAttribute::UINT32, it->second.type);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 UTF16ToUTF8(form.submit_element)); 372 UTF16ToUTF8(form.submit_element));
372 CheckStringAttribute(item, "signon_realm", form.signon_realm); 373 CheckStringAttribute(item, "signon_realm", form.signon_realm);
373 CheckUint32Attribute(item, "ssl_valid", form.ssl_valid); 374 CheckUint32Attribute(item, "ssl_valid", form.ssl_valid);
374 CheckUint32Attribute(item, "preferred", form.preferred); 375 CheckUint32Attribute(item, "preferred", form.preferred);
375 // We don't check the date created. It varies. 376 // We don't check the date created. It varies.
376 CheckUint32Attribute(item, "blacklisted_by_user", form.blacklisted_by_user); 377 CheckUint32Attribute(item, "blacklisted_by_user", form.blacklisted_by_user);
377 CheckUint32Attribute(item, "scheme", form.scheme); 378 CheckUint32Attribute(item, "scheme", form.scheme);
378 CheckStringAttribute(item, "application", app_string); 379 CheckStringAttribute(item, "application", app_string);
379 } 380 }
380 381
381 MessageLoopForUI message_loop_; 382 base::MessageLoopForUI message_loop_;
382 content::TestBrowserThread ui_thread_; 383 content::TestBrowserThread ui_thread_;
383 content::TestBrowserThread db_thread_; 384 content::TestBrowserThread db_thread_;
384 385
385 TestingProfile profile_; 386 TestingProfile profile_;
386 387
387 // Provide some test forms to avoid having to set them up in each test. 388 // Provide some test forms to avoid having to set them up in each test.
388 PasswordForm form_google_; 389 PasswordForm form_google_;
389 PasswordForm form_isc_; 390 PasswordForm form_isc_;
390 }; 391 };
391 392
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 RunBothThreads(); 897 RunBothThreads();
897 898
898 // The other two copies of the password in different profiles should remain. 899 // The other two copies of the password in different profiles should remain.
899 EXPECT_EQ(2u, mock_keyring_items.size()); 900 EXPECT_EQ(2u, mock_keyring_items.size());
900 if (mock_keyring_items.size() > 0) 901 if (mock_keyring_items.size() > 0)
901 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 902 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
902 if (mock_keyring_items.size() > 1) 903 if (mock_keyring_items.size() > 1)
903 CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42"); 904 CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42");
904 } 905 }
905 } 906 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698