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 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/run_loop.h" |
14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
20 #include "base/time/time.h" | 21 #include "base/time/time.h" |
21 #include "chrome/browser/password_manager/native_backend_gnome_x.h" | 22 #include "chrome/browser/password_manager/native_backend_gnome_x.h" |
22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
23 #include "components/autofill/core/common/password_form.h" | 24 #include "components/autofill/core/common/password_form.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 other_auth_.username_value = UTF8ToUTF16("username"); | 420 other_auth_.username_value = UTF8ToUTF16("username"); |
420 other_auth_.password_value = UTF8ToUTF16("pass"); | 421 other_auth_.password_value = UTF8ToUTF16("pass"); |
421 other_auth_.signon_realm = "http://www.example.com/Realm"; | 422 other_auth_.signon_realm = "http://www.example.com/Realm"; |
422 other_auth_.date_created = base::Time::Now(); | 423 other_auth_.date_created = base::Time::Now(); |
423 other_auth_.date_synced = base::Time::Now(); | 424 other_auth_.date_synced = base::Time::Now(); |
424 } | 425 } |
425 | 426 |
426 void TearDown() override { | 427 void TearDown() override { |
427 base::ThreadTaskRunnerHandle::Get()->PostTask( | 428 base::ThreadTaskRunnerHandle::Get()->PostTask( |
428 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 429 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
429 base::MessageLoop::current()->Run(); | 430 base::RunLoop().Run(); |
430 db_thread_.Stop(); | 431 db_thread_.Stop(); |
431 } | 432 } |
432 | 433 |
433 void RunBothThreads() { | 434 void RunBothThreads() { |
434 // First we post a message to the DB thread that will run after all other | 435 // First we post a message to the DB thread that will run after all other |
435 // messages that have been posted to the DB thread (we don't expect more | 436 // messages that have been posted to the DB thread (we don't expect more |
436 // to be posted), which posts a message to the UI thread to quit the loop. | 437 // to be posted), which posts a message to the UI thread to quit the loop. |
437 // That way we can run both loops and be sure that the UI thread loop will | 438 // That way we can run both loops and be sure that the UI thread loop will |
438 // quit so we can get on with the rest of the test. | 439 // quit so we can get on with the rest of the test. |
439 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 440 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
440 base::Bind(&PostQuitTask, &message_loop_)); | 441 base::Bind(&PostQuitTask, &message_loop_)); |
441 base::MessageLoop::current()->Run(); | 442 base::RunLoop().Run(); |
442 } | 443 } |
443 | 444 |
444 static void PostQuitTask(base::MessageLoop* loop) { | 445 static void PostQuitTask(base::MessageLoop* loop) { |
445 loop->task_runner()->PostTask(FROM_HERE, | 446 loop->task_runner()->PostTask(FROM_HERE, |
446 base::MessageLoop::QuitWhenIdleClosure()); | 447 base::MessageLoop::QuitWhenIdleClosure()); |
447 } | 448 } |
448 | 449 |
449 void CheckUint32Attribute(const MockKeyringItem* item, | 450 void CheckUint32Attribute(const MockKeyringItem* item, |
450 const std::string& attribute, | 451 const std::string& attribute, |
451 uint32_t value) { | 452 uint32_t value) { |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 base::Bind(&CheckTrue)); | 1299 base::Bind(&CheckTrue)); |
1299 | 1300 |
1300 RunBothThreads(); | 1301 RunBothThreads(); |
1301 | 1302 |
1302 EXPECT_EQ(2u, form_list.size()); | 1303 EXPECT_EQ(2u, form_list.size()); |
1303 EXPECT_THAT(form_list, UnorderedElementsAre(Pointee(form_google_), | 1304 EXPECT_THAT(form_list, UnorderedElementsAre(Pointee(form_google_), |
1304 Pointee(form_facebook_))); | 1305 Pointee(form_facebook_))); |
1305 } | 1306 } |
1306 | 1307 |
1307 // TODO(mdm): add more basic tests here at some point. | 1308 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |