| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 14 #include "chrome/browser/password_manager/native_backend_gnome_x.h" | 17 #include "chrome/browser/password_manager/native_backend_gnome_x.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
| 16 #include "components/autofill/core/common/password_form.h" | 19 #include "components/autofill/core/common/password_form.h" |
| 17 #include "components/password_manager/core/browser/psl_matching_helper.h" | 20 #include "components/password_manager/core/browser/psl_matching_helper.h" |
| 18 #include "components/password_manager/core/common/password_manager_pref_names.h" | 21 #include "components/password_manager/core/common/password_manager_pref_names.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 22 #include "content/public/test/test_browser_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 24 |
| 22 using autofill::PasswordForm; | 25 using autofill::PasswordForm; |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 | 394 |
| 392 other_auth_.origin = GURL("http://www.example.com/"); | 395 other_auth_.origin = GURL("http://www.example.com/"); |
| 393 other_auth_.username_value = UTF8ToUTF16("username"); | 396 other_auth_.username_value = UTF8ToUTF16("username"); |
| 394 other_auth_.password_value = UTF8ToUTF16("pass"); | 397 other_auth_.password_value = UTF8ToUTF16("pass"); |
| 395 other_auth_.signon_realm = "http://www.example.com/Realm"; | 398 other_auth_.signon_realm = "http://www.example.com/Realm"; |
| 396 other_auth_.date_created = base::Time::Now(); | 399 other_auth_.date_created = base::Time::Now(); |
| 397 other_auth_.date_synced = base::Time::Now(); | 400 other_auth_.date_synced = base::Time::Now(); |
| 398 } | 401 } |
| 399 | 402 |
| 400 void TearDown() override { | 403 void TearDown() override { |
| 401 base::MessageLoop::current()->PostTask(FROM_HERE, | 404 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 402 base::MessageLoop::QuitClosure()); | 405 FROM_HERE, base::MessageLoop::QuitClosure()); |
| 403 base::MessageLoop::current()->Run(); | 406 base::MessageLoop::current()->Run(); |
| 404 db_thread_.Stop(); | 407 db_thread_.Stop(); |
| 405 } | 408 } |
| 406 | 409 |
| 407 void RunBothThreads() { | 410 void RunBothThreads() { |
| 408 // First we post a message to the DB thread that will run after all other | 411 // First we post a message to the DB thread that will run after all other |
| 409 // messages that have been posted to the DB thread (we don't expect more | 412 // messages that have been posted to the DB thread (we don't expect more |
| 410 // to be posted), which posts a message to the UI thread to quit the loop. | 413 // to be posted), which posts a message to the UI thread to quit the loop. |
| 411 // That way we can run both loops and be sure that the UI thread loop will | 414 // That way we can run both loops and be sure that the UI thread loop will |
| 412 // quit so we can get on with the rest of the test. | 415 // quit so we can get on with the rest of the test. |
| 413 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 416 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 414 base::Bind(&PostQuitTask, &message_loop_)); | 417 base::Bind(&PostQuitTask, &message_loop_)); |
| 415 base::MessageLoop::current()->Run(); | 418 base::MessageLoop::current()->Run(); |
| 416 } | 419 } |
| 417 | 420 |
| 418 static void PostQuitTask(base::MessageLoop* loop) { | 421 static void PostQuitTask(base::MessageLoop* loop) { |
| 419 loop->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 422 loop->task_runner()->PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
| 420 } | 423 } |
| 421 | 424 |
| 422 void CheckUint32Attribute(const MockKeyringItem* item, | 425 void CheckUint32Attribute(const MockKeyringItem* item, |
| 423 const std::string& attribute, | 426 const std::string& attribute, |
| 424 uint32_t value) { | 427 uint32_t value) { |
| 425 MockKeyringItem::attribute_map::const_iterator it = | 428 MockKeyringItem::attribute_map::const_iterator it = |
| 426 item->attributes.find(attribute); | 429 item->attributes.find(attribute); |
| 427 EXPECT_NE(item->attributes.end(), it); | 430 EXPECT_NE(item->attributes.end(), it); |
| 428 if (it != item->attributes.end()) { | 431 if (it != item->attributes.end()) { |
| 429 EXPECT_EQ(MockKeyringItem::ItemAttribute::UINT32, it->second.type); | 432 EXPECT_EQ(MockKeyringItem::ItemAttribute::UINT32, it->second.type); |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 | 1076 |
| 1074 TEST_F(NativeBackendGnomeTest, RemoveLoginsCreatedBetween) { | 1077 TEST_F(NativeBackendGnomeTest, RemoveLoginsCreatedBetween) { |
| 1075 CheckRemoveLoginsBetween(CREATED); | 1078 CheckRemoveLoginsBetween(CREATED); |
| 1076 } | 1079 } |
| 1077 | 1080 |
| 1078 TEST_F(NativeBackendGnomeTest, RemoveLoginsSyncedBetween) { | 1081 TEST_F(NativeBackendGnomeTest, RemoveLoginsSyncedBetween) { |
| 1079 CheckRemoveLoginsBetween(SYNCED); | 1082 CheckRemoveLoginsBetween(SYNCED); |
| 1080 } | 1083 } |
| 1081 | 1084 |
| 1082 // TODO(mdm): add more basic tests here at some point. | 1085 // TODO(mdm): add more basic tests here at some point. |
| OLD | NEW |