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 <stdarg.h> | 5 #include <stdarg.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 other_auth_.origin = GURL("http://www.example.com/"); | 398 other_auth_.origin = GURL("http://www.example.com/"); |
399 other_auth_.username_value = UTF8ToUTF16("username"); | 399 other_auth_.username_value = UTF8ToUTF16("username"); |
400 other_auth_.password_value = UTF8ToUTF16("pass"); | 400 other_auth_.password_value = UTF8ToUTF16("pass"); |
401 other_auth_.signon_realm = "http://www.example.com/Realm"; | 401 other_auth_.signon_realm = "http://www.example.com/Realm"; |
402 other_auth_.date_created = base::Time::Now(); | 402 other_auth_.date_created = base::Time::Now(); |
403 other_auth_.date_synced = base::Time::Now(); | 403 other_auth_.date_synced = base::Time::Now(); |
404 } | 404 } |
405 | 405 |
406 void TearDown() override { | 406 void TearDown() override { |
407 base::ThreadTaskRunnerHandle::Get()->PostTask( | 407 base::ThreadTaskRunnerHandle::Get()->PostTask( |
408 FROM_HERE, base::MessageLoop::QuitClosure()); | 408 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
409 base::MessageLoop::current()->Run(); | 409 base::MessageLoop::current()->Run(); |
410 db_thread_.Stop(); | 410 db_thread_.Stop(); |
411 } | 411 } |
412 | 412 |
413 void RunBothThreads() { | 413 void RunBothThreads() { |
414 // First we post a message to the DB thread that will run after all other | 414 // First we post a message to the DB thread that will run after all other |
415 // messages that have been posted to the DB thread (we don't expect more | 415 // messages that have been posted to the DB thread (we don't expect more |
416 // to be posted), which posts a message to the UI thread to quit the loop. | 416 // to be posted), which posts a message to the UI thread to quit the loop. |
417 // That way we can run both loops and be sure that the UI thread loop will | 417 // That way we can run both loops and be sure that the UI thread loop will |
418 // quit so we can get on with the rest of the test. | 418 // quit so we can get on with the rest of the test. |
419 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 419 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
420 base::Bind(&PostQuitTask, &message_loop_)); | 420 base::Bind(&PostQuitTask, &message_loop_)); |
421 base::MessageLoop::current()->Run(); | 421 base::MessageLoop::current()->Run(); |
422 } | 422 } |
423 | 423 |
424 static void PostQuitTask(base::MessageLoop* loop) { | 424 static void PostQuitTask(base::MessageLoop* loop) { |
425 loop->task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 425 loop->task_runner()->PostTask(FROM_HERE, |
| 426 base::MessageLoop::QuitWhenIdleClosure()); |
426 } | 427 } |
427 | 428 |
428 void CheckUint32Attribute(const MockKeyringItem* item, | 429 void CheckUint32Attribute(const MockKeyringItem* item, |
429 const std::string& attribute, | 430 const std::string& attribute, |
430 uint32_t value) { | 431 uint32_t value) { |
431 MockKeyringItem::attribute_map::const_iterator it = | 432 MockKeyringItem::attribute_map::const_iterator it = |
432 item->attributes.find(attribute); | 433 item->attributes.find(attribute); |
433 EXPECT_NE(item->attributes.end(), it); | 434 EXPECT_NE(item->attributes.end(), it); |
434 if (it != item->attributes.end()) { | 435 if (it != item->attributes.end()) { |
435 EXPECT_EQ(MockKeyringItem::ItemAttribute::UINT32, it->second.type); | 436 EXPECT_EQ(MockKeyringItem::ItemAttribute::UINT32, it->second.type); |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 | 1198 |
1198 EXPECT_EQ(1u, form_list.size()); | 1199 EXPECT_EQ(1u, form_list.size()); |
1199 EXPECT_EQ(form_google_, *form_list[0]); | 1200 EXPECT_EQ(form_google_, *form_list[0]); |
1200 | 1201 |
1201 EXPECT_EQ(1u, mock_keyring_items.size()); | 1202 EXPECT_EQ(1u, mock_keyring_items.size()); |
1202 if (mock_keyring_items.size() > 0) | 1203 if (mock_keyring_items.size() > 0) |
1203 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); | 1204 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); |
1204 } | 1205 } |
1205 | 1206 |
1206 // TODO(mdm): add more basic tests here at some point. | 1207 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |