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

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

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/location.h" 17 #include "base/location.h"
18 #include "base/pickle.h" 18 #include "base/pickle.h"
19 #include "base/run_loop.h" 19 #include "base/run_loop.h"
20 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
21 #include "base/stl_util.h" 21 #include "base/stl_util.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/synchronization/waitable_event.h"
24 #include "base/threading/thread_task_runner_handle.h" 23 #include "base/threading/thread_task_runner_handle.h"
25 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" 24 #include "chrome/browser/password_manager/native_backend_kwallet_x.h"
26 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
27 #include "components/autofill/core/common/password_form.h" 26 #include "components/autofill/core/common/password_form.h"
28 #include "components/password_manager/core/common/password_manager_pref_names.h" 27 #include "components/password_manager/core/common/password_manager_pref_names.h"
29 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
30 #include "content/public/test/test_browser_thread.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "content/public/test/test_utils.h"
31 #include "dbus/message.h" 31 #include "dbus/message.h"
32 #include "dbus/mock_bus.h" 32 #include "dbus/mock_bus.h"
33 #include "dbus/mock_object_proxy.h" 33 #include "dbus/mock_object_proxy.h"
34 #include "dbus/object_path.h" 34 #include "dbus/object_path.h"
35 #include "dbus/object_proxy.h" 35 #include "dbus/object_proxy.h"
36 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
37 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
38 38
39 using autofill::PasswordForm; 39 using autofill::PasswordForm;
40 using base::UTF8ToUTF16; 40 using base::UTF8ToUTF16;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 const PasswordStoreChangeList* expected, 280 const PasswordStoreChangeList* expected,
281 const PasswordStoreChangeList* actual, 281 const PasswordStoreChangeList* actual,
282 bool result) { 282 bool result) {
283 EXPECT_TRUE(result); 283 EXPECT_TRUE(result);
284 CheckPasswordChanges(*expected, *actual); 284 CheckPasswordChanges(*expected, *actual);
285 } 285 }
286 286
287 class NativeBackendKWalletTest : public NativeBackendKWalletTestBase { 287 class NativeBackendKWalletTest : public NativeBackendKWalletTestBase {
288 protected: 288 protected:
289 NativeBackendKWalletTest() 289 NativeBackendKWalletTest()
290 : ui_thread_(BrowserThread::UI, &message_loop_), 290 : test_browser_thread_bundle_(
291 db_thread_(BrowserThread::DB), klauncher_ret_(0), 291 content::TestBrowserThreadBundle::REAL_DB_THREAD),
292 klauncher_contacted_(false), kwallet_runnable_(true), 292 klauncher_ret_(0),
293 kwallet_running_(true), kwallet_enabled_(true), 293 klauncher_contacted_(false),
294 desktop_env_(GetParam()) { 294 kwallet_runnable_(true),
295 } 295 kwallet_running_(true),
296 kwallet_enabled_(true),
297 desktop_env_(GetParam()) {}
296 298
297 void SetUp() override; 299 void SetUp() override;
298 void TearDown() override;
299
300 // Let the DB thread run to completion of all current tasks.
301 void RunDBThread() {
302 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
303 base::WaitableEvent::InitialState::NOT_SIGNALED);
304 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
305 base::BindOnce(ThreadDone, &event));
306 event.Wait();
307 // Some of the tests may post messages to the UI thread, but we don't need
308 // to run those until after the DB thread is finished. So run it here.
309 base::RunLoop().RunUntilIdle();
310 }
311 static void ThreadDone(base::WaitableEvent* event) {
312 event->Signal();
313 }
314 300
315 // Utilities to help verify sets of expectations. 301 // Utilities to help verify sets of expectations.
316 typedef std::vector< 302 typedef std::vector<
317 std::pair<std::string, 303 std::pair<std::string,
318 std::vector<const PasswordForm*> > > ExpectationArray; 304 std::vector<const PasswordForm*> > > ExpectationArray;
319 void CheckPasswordForms(const std::string& folder, 305 void CheckPasswordForms(const std::string& folder,
320 const ExpectationArray& sorted_expected); 306 const ExpectationArray& sorted_expected);
321 307
322 enum RemoveBetweenMethod { 308 enum RemoveBetweenMethod {
323 CREATED, 309 CREATED,
324 SYNCED, 310 SYNCED,
325 }; 311 };
326 312
327 // Tests RemoveLoginsCreatedBetween or RemoveLoginsSyncedBetween. 313 // Tests RemoveLoginsCreatedBetween or RemoveLoginsSyncedBetween.
328 void TestRemoveLoginsBetween(RemoveBetweenMethod date_to_test); 314 void TestRemoveLoginsBetween(RemoveBetweenMethod date_to_test);
329 315
330 base::MessageLoopForUI message_loop_; 316 content::TestBrowserThreadBundle test_browser_thread_bundle_;
331 content::TestBrowserThread ui_thread_;
332 content::TestBrowserThread db_thread_;
333 317
334 scoped_refptr<dbus::MockBus> mock_session_bus_; 318 scoped_refptr<dbus::MockBus> mock_session_bus_;
335 scoped_refptr<dbus::MockObjectProxy> mock_klauncher_proxy_; 319 scoped_refptr<dbus::MockObjectProxy> mock_klauncher_proxy_;
336 scoped_refptr<dbus::MockObjectProxy> mock_kwallet_proxy_; 320 scoped_refptr<dbus::MockObjectProxy> mock_kwallet_proxy_;
337 321
338 int klauncher_ret_; 322 int klauncher_ret_;
339 std::string klauncher_error_; 323 std::string klauncher_error_;
340 bool klauncher_contacted_; 324 bool klauncher_contacted_;
341 325
342 bool kwallet_runnable_; 326 bool kwallet_runnable_;
(...skipping 11 matching lines...) Expand all
354 338
355 private: 339 private:
356 dbus::Response* KLauncherMethodCall( 340 dbus::Response* KLauncherMethodCall(
357 dbus::MethodCall* method_call, testing::Unused); 341 dbus::MethodCall* method_call, testing::Unused);
358 342
359 dbus::Response* KWalletMethodCall( 343 dbus::Response* KWalletMethodCall(
360 dbus::MethodCall* method_call, testing::Unused); 344 dbus::MethodCall* method_call, testing::Unused);
361 }; 345 };
362 346
363 void NativeBackendKWalletTest::SetUp() { 347 void NativeBackendKWalletTest::SetUp() {
364 ASSERT_TRUE(db_thread_.Start());
365
366 dbus::Bus::Options options; 348 dbus::Bus::Options options;
367 options.bus_type = dbus::Bus::SESSION; 349 options.bus_type = dbus::Bus::SESSION;
368 mock_session_bus_ = new dbus::MockBus(options); 350 mock_session_bus_ = new dbus::MockBus(options);
369 351
370 mock_klauncher_proxy_ = 352 mock_klauncher_proxy_ =
371 new dbus::MockObjectProxy(mock_session_bus_.get(), 353 new dbus::MockObjectProxy(mock_session_bus_.get(),
372 "org.kde.klauncher", 354 "org.kde.klauncher",
373 dbus::ObjectPath("/KLauncher")); 355 dbus::ObjectPath("/KLauncher"));
374 EXPECT_CALL(*mock_klauncher_proxy_.get(), MockCallMethodAndBlock(_, _)) 356 EXPECT_CALL(*mock_klauncher_proxy_.get(), MockCallMethodAndBlock(_, _))
375 .WillRepeatedly( 357 .WillRepeatedly(
(...skipping 29 matching lines...) Expand all
405 *mock_session_bus_.get(), 387 *mock_session_bus_.get(),
406 GetObjectProxy("org.kde.kwalletd", 388 GetObjectProxy("org.kde.kwalletd",
407 dbus::ObjectPath("/modules/kwalletd"))) 389 dbus::ObjectPath("/modules/kwalletd")))
408 .WillRepeatedly(Return(mock_kwallet_proxy_.get())); 390 .WillRepeatedly(Return(mock_kwallet_proxy_.get()));
409 } 391 }
410 392
411 EXPECT_CALL(*mock_session_bus_.get(), ShutdownAndBlock()).WillOnce(Return()) 393 EXPECT_CALL(*mock_session_bus_.get(), ShutdownAndBlock()).WillOnce(Return())
412 .WillRepeatedly(Return()); 394 .WillRepeatedly(Return());
413 } 395 }
414 396
415 void NativeBackendKWalletTest::TearDown() {
416 base::ThreadTaskRunnerHandle::Get()->PostTask(
417 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
418 base::RunLoop().Run();
419 db_thread_.Stop();
420 }
421
422 void NativeBackendKWalletTest::TestRemoveLoginsBetween( 397 void NativeBackendKWalletTest::TestRemoveLoginsBetween(
423 RemoveBetweenMethod date_to_test) { 398 RemoveBetweenMethod date_to_test) {
424 NativeBackendKWalletStub backend(42, desktop_env_); 399 NativeBackendKWalletStub backend(42, desktop_env_);
425 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 400 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
426 401
427 form_google_.date_synced = base::Time(); 402 form_google_.date_synced = base::Time();
428 form_isc_.date_synced = base::Time(); 403 form_isc_.date_synced = base::Time();
429 form_google_.date_created = base::Time(); 404 form_google_.date_created = base::Time();
430 form_isc_.date_created = base::Time(); 405 form_isc_.date_created = base::Time();
431 base::Time now = base::Time::Now(); 406 base::Time now = base::Time::Now();
(...skipping 23 matching lines...) Expand all
455 base::Time, base::Time, password_manager::PasswordStoreChangeList*) = 430 base::Time, base::Time, password_manager::PasswordStoreChangeList*) =
456 date_to_test == CREATED 431 date_to_test == CREATED
457 ? &NativeBackendKWalletStub::RemoveLoginsCreatedBetween 432 ? &NativeBackendKWalletStub::RemoveLoginsCreatedBetween
458 : &NativeBackendKWalletStub::RemoveLoginsSyncedBetween; 433 : &NativeBackendKWalletStub::RemoveLoginsSyncedBetween;
459 BrowserThread::PostTaskAndReplyWithResult( 434 BrowserThread::PostTaskAndReplyWithResult(
460 BrowserThread::DB, 435 BrowserThread::DB,
461 FROM_HERE, 436 FROM_HERE,
462 base::Bind( 437 base::Bind(
463 method, base::Unretained(&backend), base::Time(), next_day, &changes), 438 method, base::Unretained(&backend), base::Time(), next_day, &changes),
464 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); 439 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes));
465 RunDBThread(); 440 content::RunAllPendingInMessageLoop(BrowserThread::DB);
466 441
467 std::vector<const PasswordForm*> forms; 442 std::vector<const PasswordForm*> forms;
468 forms.push_back(&form_isc_); 443 forms.push_back(&form_isc_);
469 ExpectationArray expected; 444 ExpectationArray expected;
470 expected.push_back(make_pair(std::string(form_isc_.signon_realm), forms)); 445 expected.push_back(make_pair(std::string(form_isc_.signon_realm), forms));
471 CheckPasswordForms("Chrome Form Data (42)", expected); 446 CheckPasswordForms("Chrome Form Data (42)", expected);
472 447
473 // Remove form_isc_. 448 // Remove form_isc_.
474 expected_changes.clear(); 449 expected_changes.clear();
475 expected_changes.push_back( 450 expected_changes.push_back(
476 PasswordStoreChange(PasswordStoreChange::REMOVE, form_isc_)); 451 PasswordStoreChange(PasswordStoreChange::REMOVE, form_isc_));
477 BrowserThread::PostTaskAndReplyWithResult( 452 BrowserThread::PostTaskAndReplyWithResult(
478 BrowserThread::DB, 453 BrowserThread::DB,
479 FROM_HERE, 454 FROM_HERE,
480 base::Bind( 455 base::Bind(
481 method, base::Unretained(&backend), next_day, base::Time(), &changes), 456 method, base::Unretained(&backend), next_day, base::Time(), &changes),
482 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); 457 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes));
483 RunDBThread(); 458 content::RunAllPendingInMessageLoop(BrowserThread::DB);
484 459
485 CheckPasswordForms("Chrome Form Data (42)", ExpectationArray()); 460 CheckPasswordForms("Chrome Form Data (42)", ExpectationArray());
486 } 461 }
487 462
488 dbus::Response* NativeBackendKWalletTest::KLauncherMethodCall( 463 dbus::Response* NativeBackendKWalletTest::KLauncherMethodCall(
489 dbus::MethodCall* method_call, testing::Unused) { 464 dbus::MethodCall* method_call, testing::Unused) {
490 EXPECT_EQ("org.kde.KLauncher", method_call->GetInterface()); 465 EXPECT_EQ("org.kde.KLauncher", method_call->GetInterface());
491 EXPECT_EQ("start_service_by_desktop_name", method_call->GetMember()); 466 EXPECT_EQ("start_service_by_desktop_name", method_call->GetMember());
492 467
493 klauncher_contacted_ = true; 468 klauncher_contacted_ = true;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 684 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
710 685
711 BrowserThread::PostTaskAndReplyWithResult( 686 BrowserThread::PostTaskAndReplyWithResult(
712 BrowserThread::DB, FROM_HERE, 687 BrowserThread::DB, FROM_HERE,
713 base::Bind(&NativeBackendKWalletStub::AddLogin, 688 base::Bind(&NativeBackendKWalletStub::AddLogin,
714 base::Unretained(&backend), form_google_), 689 base::Unretained(&backend), form_google_),
715 base::Bind(&CheckPasswordChanges, 690 base::Bind(&CheckPasswordChanges,
716 PasswordStoreChangeList(1, PasswordStoreChange( 691 PasswordStoreChangeList(1, PasswordStoreChange(
717 PasswordStoreChange::ADD, form_google_)))); 692 PasswordStoreChange::ADD, form_google_))));
718 693
719 RunDBThread(); 694 content::RunAllPendingInMessageLoop(BrowserThread::DB);
720 695
721 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data")); 696 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data"));
722 697
723 std::vector<const PasswordForm*> forms; 698 std::vector<const PasswordForm*> forms;
724 forms.push_back(&form_google_); 699 forms.push_back(&form_google_);
725 ExpectationArray expected; 700 ExpectationArray expected;
726 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 701 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
727 CheckPasswordForms("Chrome Form Data (42)", expected); 702 CheckPasswordForms("Chrome Form Data (42)", expected);
728 } 703 }
729 704
730 TEST_P(NativeBackendKWalletTest, BasicUpdateLogin) { 705 TEST_P(NativeBackendKWalletTest, BasicUpdateLogin) {
731 NativeBackendKWalletStub backend(42, desktop_env_); 706 NativeBackendKWalletStub backend(42, desktop_env_);
732 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 707 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
733 708
734 BrowserThread::PostTask( 709 BrowserThread::PostTask(
735 BrowserThread::DB, FROM_HERE, 710 BrowserThread::DB, FROM_HERE,
736 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 711 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
737 base::Unretained(&backend), form_google_)); 712 base::Unretained(&backend), form_google_));
738 713
739 RunDBThread(); 714 content::RunAllPendingInMessageLoop(BrowserThread::DB);
740 715
741 PasswordForm new_form_google(form_google_); 716 PasswordForm new_form_google(form_google_);
742 new_form_google.times_used = 10; 717 new_form_google.times_used = 10;
743 new_form_google.action = GURL("http://www.google.com/different/login"); 718 new_form_google.action = GURL("http://www.google.com/different/login");
744 719
745 // Update login 720 // Update login
746 PasswordStoreChangeList changes; 721 PasswordStoreChangeList changes;
747 PasswordStoreChangeList expected_changes( 722 PasswordStoreChangeList expected_changes(
748 1, PasswordStoreChange(PasswordStoreChange::UPDATE, new_form_google)); 723 1, PasswordStoreChange(PasswordStoreChange::UPDATE, new_form_google));
749 BrowserThread::PostTaskAndReplyWithResult( 724 BrowserThread::PostTaskAndReplyWithResult(
750 BrowserThread::DB, FROM_HERE, 725 BrowserThread::DB, FROM_HERE,
751 base::Bind(&NativeBackendKWalletStub::UpdateLogin, 726 base::Bind(&NativeBackendKWalletStub::UpdateLogin,
752 base::Unretained(&backend), 727 base::Unretained(&backend),
753 new_form_google, 728 new_form_google,
754 &changes), 729 &changes),
755 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); 730 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes));
756 RunDBThread(); 731 content::RunAllPendingInMessageLoop(BrowserThread::DB);
757 732
758 ASSERT_EQ(1u, changes.size()); 733 ASSERT_EQ(1u, changes.size());
759 EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type()); 734 EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type());
760 EXPECT_EQ(new_form_google, changes.front().form()); 735 EXPECT_EQ(new_form_google, changes.front().form());
761 736
762 std::vector<const PasswordForm*> forms; 737 std::vector<const PasswordForm*> forms;
763 forms.push_back(&new_form_google); 738 forms.push_back(&new_form_google);
764 ExpectationArray expected; 739 ExpectationArray expected;
765 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 740 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
766 CheckPasswordForms("Chrome Form Data (42)", expected); 741 CheckPasswordForms("Chrome Form Data (42)", expected);
767 } 742 }
768 743
769 TEST_P(NativeBackendKWalletTest, BasicListLogins) { 744 TEST_P(NativeBackendKWalletTest, BasicListLogins) {
770 NativeBackendKWalletStub backend(42, desktop_env_); 745 NativeBackendKWalletStub backend(42, desktop_env_);
771 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 746 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
772 747
773 BrowserThread::PostTask( 748 BrowserThread::PostTask(
774 BrowserThread::DB, FROM_HERE, 749 BrowserThread::DB, FROM_HERE,
775 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 750 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
776 base::Unretained(&backend), form_google_)); 751 base::Unretained(&backend), form_google_));
777 752
778 std::vector<std::unique_ptr<PasswordForm>> form_list; 753 std::vector<std::unique_ptr<PasswordForm>> form_list;
779 BrowserThread::PostTaskAndReplyWithResult( 754 BrowserThread::PostTaskAndReplyWithResult(
780 BrowserThread::DB, FROM_HERE, 755 BrowserThread::DB, FROM_HERE,
781 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins, 756 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins,
782 base::Unretained(&backend), &form_list), 757 base::Unretained(&backend), &form_list),
783 base::Bind(&CheckTrue)); 758 base::Bind(&CheckTrue));
784 759
785 RunDBThread(); 760 content::RunAllPendingInMessageLoop(BrowserThread::DB);
786 761
787 // Quick check that we got something back. 762 // Quick check that we got something back.
788 EXPECT_EQ(1u, form_list.size()); 763 EXPECT_EQ(1u, form_list.size());
789 764
790 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data")); 765 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data"));
791 766
792 std::vector<const PasswordForm*> forms; 767 std::vector<const PasswordForm*> forms;
793 forms.push_back(&form_google_); 768 forms.push_back(&form_google_);
794 ExpectationArray expected; 769 ExpectationArray expected;
795 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 770 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
796 CheckPasswordForms("Chrome Form Data (42)", expected); 771 CheckPasswordForms("Chrome Form Data (42)", expected);
797 } 772 }
798 773
799 TEST_P(NativeBackendKWalletTest, BasicRemoveLogin) { 774 TEST_P(NativeBackendKWalletTest, BasicRemoveLogin) {
800 NativeBackendKWalletStub backend(42, desktop_env_); 775 NativeBackendKWalletStub backend(42, desktop_env_);
801 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 776 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
802 777
803 BrowserThread::PostTask( 778 BrowserThread::PostTask(
804 BrowserThread::DB, FROM_HERE, 779 BrowserThread::DB, FROM_HERE,
805 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 780 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
806 base::Unretained(&backend), form_google_)); 781 base::Unretained(&backend), form_google_));
807 782
808 RunDBThread(); 783 content::RunAllPendingInMessageLoop(BrowserThread::DB);
809 784
810 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data")); 785 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data"));
811 786
812 std::vector<const PasswordForm*> forms; 787 std::vector<const PasswordForm*> forms;
813 forms.push_back(&form_google_); 788 forms.push_back(&form_google_);
814 ExpectationArray expected; 789 ExpectationArray expected;
815 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 790 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
816 CheckPasswordForms("Chrome Form Data (42)", expected); 791 CheckPasswordForms("Chrome Form Data (42)", expected);
817 792
818 PasswordStoreChangeList changes; 793 PasswordStoreChangeList changes;
819 PasswordStoreChangeList expected_changes( 794 PasswordStoreChangeList expected_changes(
820 1, PasswordStoreChange(PasswordStoreChange::REMOVE, form_google_)); 795 1, PasswordStoreChange(PasswordStoreChange::REMOVE, form_google_));
821 BrowserThread::PostTaskAndReplyWithResult( 796 BrowserThread::PostTaskAndReplyWithResult(
822 BrowserThread::DB, FROM_HERE, 797 BrowserThread::DB, FROM_HERE,
823 base::Bind(&NativeBackendKWalletStub::RemoveLogin, 798 base::Bind(&NativeBackendKWalletStub::RemoveLogin,
824 base::Unretained(&backend), form_google_, &changes), 799 base::Unretained(&backend), form_google_, &changes),
825 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); 800 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes));
826 801
827 RunDBThread(); 802 content::RunAllPendingInMessageLoop(BrowserThread::DB);
828 803
829 expected.clear(); 804 expected.clear();
830 CheckPasswordForms("Chrome Form Data (42)", expected); 805 CheckPasswordForms("Chrome Form Data (42)", expected);
831 } 806 }
832 807
833 TEST_P(NativeBackendKWalletTest, UpdateNonexistentLogin) { 808 TEST_P(NativeBackendKWalletTest, UpdateNonexistentLogin) {
834 NativeBackendKWalletStub backend(42, desktop_env_); 809 NativeBackendKWalletStub backend(42, desktop_env_);
835 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 810 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
836 811
837 // First add an unrelated login. 812 // First add an unrelated login.
838 BrowserThread::PostTask( 813 BrowserThread::PostTask(
839 BrowserThread::DB, FROM_HERE, 814 BrowserThread::DB, FROM_HERE,
840 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 815 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
841 base::Unretained(&backend), form_google_)); 816 base::Unretained(&backend), form_google_));
842 817
843 RunDBThread(); 818 content::RunAllPendingInMessageLoop(BrowserThread::DB);
844 819
845 std::vector<const PasswordForm*> forms; 820 std::vector<const PasswordForm*> forms;
846 forms.push_back(&form_google_); 821 forms.push_back(&form_google_);
847 ExpectationArray expected; 822 ExpectationArray expected;
848 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 823 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
849 CheckPasswordForms("Chrome Form Data (42)", expected); 824 CheckPasswordForms("Chrome Form Data (42)", expected);
850 825
851 // Attempt to update a login that doesn't exist. 826 // Attempt to update a login that doesn't exist.
852 PasswordStoreChangeList changes; 827 PasswordStoreChangeList changes;
853 BrowserThread::PostTaskAndReplyWithResult( 828 BrowserThread::PostTaskAndReplyWithResult(
854 BrowserThread::DB, FROM_HERE, 829 BrowserThread::DB, FROM_HERE,
855 base::Bind(&NativeBackendKWalletStub::UpdateLogin, 830 base::Bind(&NativeBackendKWalletStub::UpdateLogin,
856 base::Unretained(&backend), 831 base::Unretained(&backend),
857 form_isc_, 832 form_isc_,
858 &changes), 833 &changes),
859 base::Bind(&CheckPasswordChangesWithResult, 834 base::Bind(&CheckPasswordChangesWithResult,
860 base::Owned(new PasswordStoreChangeList), &changes)); 835 base::Owned(new PasswordStoreChangeList), &changes));
861 836
862 RunDBThread(); 837 content::RunAllPendingInMessageLoop(BrowserThread::DB);
863 838
864 EXPECT_EQ(PasswordStoreChangeList(), changes); 839 EXPECT_EQ(PasswordStoreChangeList(), changes);
865 CheckPasswordForms("Chrome Form Data (42)", expected); 840 CheckPasswordForms("Chrome Form Data (42)", expected);
866 } 841 }
867 842
868 TEST_P(NativeBackendKWalletTest, RemoveNonexistentLogin) { 843 TEST_P(NativeBackendKWalletTest, RemoveNonexistentLogin) {
869 NativeBackendKWalletStub backend(42, desktop_env_); 844 NativeBackendKWalletStub backend(42, desktop_env_);
870 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 845 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
871 846
872 // First add an unrelated login. 847 // First add an unrelated login.
873 BrowserThread::PostTask( 848 BrowserThread::PostTask(
874 BrowserThread::DB, FROM_HERE, 849 BrowserThread::DB, FROM_HERE,
875 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 850 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
876 base::Unretained(&backend), form_google_)); 851 base::Unretained(&backend), form_google_));
877 852
878 RunDBThread(); 853 content::RunAllPendingInMessageLoop(BrowserThread::DB);
879 854
880 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data")); 855 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data"));
881 856
882 std::vector<const PasswordForm*> forms; 857 std::vector<const PasswordForm*> forms;
883 forms.push_back(&form_google_); 858 forms.push_back(&form_google_);
884 ExpectationArray expected; 859 ExpectationArray expected;
885 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 860 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
886 CheckPasswordForms("Chrome Form Data (42)", expected); 861 CheckPasswordForms("Chrome Form Data (42)", expected);
887 862
888 // Attempt to remove a login that doesn't exist. 863 // Attempt to remove a login that doesn't exist.
889 PasswordStoreChangeList changes; 864 PasswordStoreChangeList changes;
890 BrowserThread::PostTaskAndReplyWithResult( 865 BrowserThread::PostTaskAndReplyWithResult(
891 BrowserThread::DB, FROM_HERE, 866 BrowserThread::DB, FROM_HERE,
892 base::Bind(&NativeBackendKWalletStub::RemoveLogin, 867 base::Bind(&NativeBackendKWalletStub::RemoveLogin,
893 base::Unretained(&backend), form_isc_, &changes), 868 base::Unretained(&backend), form_isc_, &changes),
894 base::Bind(&CheckPasswordChangesWithResult, 869 base::Bind(&CheckPasswordChangesWithResult,
895 base::Owned(new PasswordStoreChangeList), &changes)); 870 base::Owned(new PasswordStoreChangeList), &changes));
896 871
897 // Make sure we can still get the first form back. 872 // Make sure we can still get the first form back.
898 std::vector<std::unique_ptr<PasswordForm>> form_list; 873 std::vector<std::unique_ptr<PasswordForm>> form_list;
899 BrowserThread::PostTaskAndReplyWithResult( 874 BrowserThread::PostTaskAndReplyWithResult(
900 BrowserThread::DB, FROM_HERE, 875 BrowserThread::DB, FROM_HERE,
901 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins, 876 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins,
902 base::Unretained(&backend), &form_list), 877 base::Unretained(&backend), &form_list),
903 base::Bind(&CheckTrue)); 878 base::Bind(&CheckTrue));
904 879
905 RunDBThread(); 880 content::RunAllPendingInMessageLoop(BrowserThread::DB);
906 881
907 // Quick check that we got something back. 882 // Quick check that we got something back.
908 EXPECT_EQ(1u, form_list.size()); 883 EXPECT_EQ(1u, form_list.size());
909 884
910 CheckPasswordForms("Chrome Form Data (42)", expected); 885 CheckPasswordForms("Chrome Form Data (42)", expected);
911 } 886 }
912 887
913 TEST_P(NativeBackendKWalletTest, AddDuplicateLogin) { 888 TEST_P(NativeBackendKWalletTest, AddDuplicateLogin) {
914 NativeBackendKWalletStub backend(42, desktop_env_); 889 NativeBackendKWalletStub backend(42, desktop_env_);
915 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 890 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
(...skipping 16 matching lines...) Expand all
932 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD, 907 changes.push_back(PasswordStoreChange(PasswordStoreChange::ADD,
933 form_google_)); 908 form_google_));
934 909
935 BrowserThread::PostTaskAndReplyWithResult( 910 BrowserThread::PostTaskAndReplyWithResult(
936 BrowserThread::DB, FROM_HERE, 911 BrowserThread::DB, FROM_HERE,
937 base::Bind(&NativeBackendKWalletStub::AddLogin, 912 base::Bind(&NativeBackendKWalletStub::AddLogin,
938 base::Unretained(&backend), form_google_), 913 base::Unretained(&backend), form_google_),
939 base::Bind(&NativeBackendKWalletTest::CheckPasswordChanges, 914 base::Bind(&NativeBackendKWalletTest::CheckPasswordChanges,
940 changes)); 915 changes));
941 916
942 RunDBThread(); 917 content::RunAllPendingInMessageLoop(BrowserThread::DB);
943 918
944 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data")); 919 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data"));
945 920
946 std::vector<const PasswordForm*> forms; 921 std::vector<const PasswordForm*> forms;
947 forms.push_back(&form_google_); 922 forms.push_back(&form_google_);
948 ExpectationArray expected; 923 ExpectationArray expected;
949 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 924 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
950 CheckPasswordForms("Chrome Form Data (42)", expected); 925 CheckPasswordForms("Chrome Form Data (42)", expected);
951 } 926 }
952 927
(...skipping 18 matching lines...) Expand all
971 PasswordStoreChangeList(1, PasswordStoreChange( 946 PasswordStoreChangeList(1, PasswordStoreChange(
972 PasswordStoreChange::ADD, saved_android_form)))); 947 PasswordStoreChange::ADD, saved_android_form))));
973 948
974 std::vector<std::unique_ptr<PasswordForm>> form_list; 949 std::vector<std::unique_ptr<PasswordForm>> form_list;
975 BrowserThread::PostTaskAndReplyWithResult( 950 BrowserThread::PostTaskAndReplyWithResult(
976 BrowserThread::DB, FROM_HERE, 951 BrowserThread::DB, FROM_HERE,
977 base::Bind(&NativeBackendKWalletStub::GetLogins, 952 base::Bind(&NativeBackendKWalletStub::GetLogins,
978 base::Unretained(&backend), observed_android_form, &form_list), 953 base::Unretained(&backend), observed_android_form, &form_list),
979 base::Bind(&CheckTrue)); 954 base::Bind(&CheckTrue));
980 955
981 RunDBThread(); 956 content::RunAllPendingInMessageLoop(BrowserThread::DB);
982 957
983 EXPECT_EQ(1u, form_list.size()); 958 EXPECT_EQ(1u, form_list.size());
984 959
985 std::vector<const PasswordForm*> forms; 960 std::vector<const PasswordForm*> forms;
986 forms.push_back(&saved_android_form); 961 forms.push_back(&saved_android_form);
987 ExpectationArray expected; 962 ExpectationArray expected;
988 expected.push_back( 963 expected.push_back(
989 make_pair(std::string(saved_android_form.signon_realm), forms)); 964 make_pair(std::string(saved_android_form.signon_realm), forms));
990 CheckPasswordForms("Chrome Form Data (42)", expected); 965 CheckPasswordForms("Chrome Form Data (42)", expected);
991 } 966 }
(...skipping 15 matching lines...) Expand all
1007 982
1008 BrowserThread::PostTask( 983 BrowserThread::PostTask(
1009 BrowserThread::DB, FROM_HERE, 984 BrowserThread::DB, FROM_HERE,
1010 base::BindOnce(base::IgnoreResult(&NativeBackendKWallet::AddLogin), 985 base::BindOnce(base::IgnoreResult(&NativeBackendKWallet::AddLogin),
1011 base::Unretained(&backend), form_isc_)); 986 base::Unretained(&backend), form_isc_));
1012 BrowserThread::PostTask( 987 BrowserThread::PostTask(
1013 BrowserThread::DB, FROM_HERE, 988 BrowserThread::DB, FROM_HERE,
1014 base::BindOnce(base::IgnoreResult(&NativeBackendKWallet::AddLogin), 989 base::BindOnce(base::IgnoreResult(&NativeBackendKWallet::AddLogin),
1015 base::Unretained(&backend), form_google_)); 990 base::Unretained(&backend), form_google_));
1016 991
1017 RunDBThread(); 992 content::RunAllPendingInMessageLoop(BrowserThread::DB);
1018 993
1019 // Set the canonical forms to the updated value for the following comparison. 994 // Set the canonical forms to the updated value for the following comparison.
1020 form_google_.skip_zero_click = true; 995 form_google_.skip_zero_click = true;
1021 PasswordStoreChangeList expected_changes; 996 PasswordStoreChangeList expected_changes;
1022 expected_changes.push_back( 997 expected_changes.push_back(
1023 PasswordStoreChange(PasswordStoreChange::UPDATE, form_google_)); 998 PasswordStoreChange(PasswordStoreChange::UPDATE, form_google_));
1024 999
1025 PasswordStoreChangeList changes; 1000 PasswordStoreChangeList changes;
1026 BrowserThread::PostTaskAndReplyWithResult( 1001 BrowserThread::PostTaskAndReplyWithResult(
1027 BrowserThread::DB, FROM_HERE, 1002 BrowserThread::DB, FROM_HERE,
1028 base::Bind( 1003 base::Bind(
1029 &NativeBackendKWallet::DisableAutoSignInForOrigins, 1004 &NativeBackendKWallet::DisableAutoSignInForOrigins,
1030 base::Unretained(&backend), 1005 base::Unretained(&backend),
1031 base::Bind( 1006 base::Bind(
1032 static_cast<bool (*)(const GURL&, const GURL&)>(operator==), 1007 static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
1033 form_google_.origin), 1008 form_google_.origin),
1034 &changes), 1009 &changes),
1035 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); 1010 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes));
1036 RunDBThread(); 1011 content::RunAllPendingInMessageLoop(BrowserThread::DB);
1037 1012
1038 std::vector<const PasswordForm*> forms; 1013 std::vector<const PasswordForm*> forms;
1039 forms.push_back(&form_google_); 1014 forms.push_back(&form_google_);
1040 ExpectationArray expected; 1015 ExpectationArray expected;
1041 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 1016 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
1042 forms.clear(); 1017 forms.clear();
1043 forms.push_back(&form_isc_); 1018 forms.push_back(&form_isc_);
1044 expected.push_back(make_pair(std::string(form_isc_.signon_realm), forms)); 1019 expected.push_back(make_pair(std::string(form_isc_.signon_realm), forms));
1045 CheckPasswordForms("Chrome Form Data (42)", expected); 1020 CheckPasswordForms("Chrome Form Data (42)", expected);
1046 } 1021 }
(...skipping 10 matching lines...) Expand all
1057 BrowserThread::PostTask( 1032 BrowserThread::PostTask(
1058 BrowserThread::DB, FROM_HERE, 1033 BrowserThread::DB, FROM_HERE,
1059 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 1034 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
1060 base::Unretained(&backend), form_google_)); 1035 base::Unretained(&backend), form_google_));
1061 form_google_.origin = 1036 form_google_.origin =
1062 GURL(std::string("http://www.google.com/") + unique_string_replacement); 1037 GURL(std::string("http://www.google.com/") + unique_string_replacement);
1063 BrowserThread::PostTask( 1038 BrowserThread::PostTask(
1064 BrowserThread::DB, FROM_HERE, 1039 BrowserThread::DB, FROM_HERE,
1065 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 1040 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
1066 base::Unretained(&backend), form_google_)); 1041 base::Unretained(&backend), form_google_));
1067 RunDBThread(); 1042 content::RunAllPendingInMessageLoop(BrowserThread::DB);
1068 1043
1069 // Read the raw value back. Change the |unique_string| to 1044 // Read the raw value back. Change the |unique_string| to
1070 // |unique_string_replacement| so the forms become unique. 1045 // |unique_string_replacement| so the forms become unique.
1071 TestKWallet::Blob value; 1046 TestKWallet::Blob value;
1072 ASSERT_TRUE(wallet_.readEntry("Chrome Form Data (42)", 1047 ASSERT_TRUE(wallet_.readEntry("Chrome Form Data (42)",
1073 form_google_.signon_realm, &value)); 1048 form_google_.signon_realm, &value));
1074 TestKWallet::Blob sample(reinterpret_cast<const uint8_t*>(unique_string)); 1049 TestKWallet::Blob sample(reinterpret_cast<const uint8_t*>(unique_string));
1075 size_t position = value.find(sample); 1050 size_t position = value.find(sample);
1076 ASSERT_NE(TestKWallet::Blob::npos, position); 1051 ASSERT_NE(TestKWallet::Blob::npos, position);
1077 value.replace(position, sample.length(), 1052 value.replace(position, sample.length(),
1078 reinterpret_cast<const uint8_t*>(unique_string_replacement)); 1053 reinterpret_cast<const uint8_t*>(unique_string_replacement));
1079 wallet_.writeEntry("Chrome Form Data (42)", form_google_.signon_realm, value); 1054 wallet_.writeEntry("Chrome Form Data (42)", form_google_.signon_realm, value);
1080 1055
1081 // Now test that GetAutofillableLogins returns only one form. 1056 // Now test that GetAutofillableLogins returns only one form.
1082 std::vector<std::unique_ptr<PasswordForm>> form_list; 1057 std::vector<std::unique_ptr<PasswordForm>> form_list;
1083 BrowserThread::PostTaskAndReplyWithResult( 1058 BrowserThread::PostTaskAndReplyWithResult(
1084 BrowserThread::DB, FROM_HERE, 1059 BrowserThread::DB, FROM_HERE,
1085 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins, 1060 base::Bind(&NativeBackendKWalletStub::GetAutofillableLogins,
1086 base::Unretained(&backend), &form_list), 1061 base::Unretained(&backend), &form_list),
1087 base::Bind(&CheckTrue)); 1062 base::Bind(&CheckTrue));
1088 RunDBThread(); 1063 content::RunAllPendingInMessageLoop(BrowserThread::DB);
1089 1064
1090 EXPECT_EQ(1u, form_list.size()); 1065 EXPECT_EQ(1u, form_list.size());
1091 EXPECT_EQ(form_google_, *form_list[0]); 1066 EXPECT_EQ(form_google_, *form_list[0]);
1092 1067
1093 std::vector<const PasswordForm*> forms; 1068 std::vector<const PasswordForm*> forms;
1094 forms.push_back(&form_google_); 1069 forms.push_back(&form_google_);
1095 ExpectationArray expected; 1070 ExpectationArray expected;
1096 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 1071 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
1097 CheckPasswordForms("Chrome Form Data (42)", expected); 1072 CheckPasswordForms("Chrome Form Data (42)", expected);
1098 } 1073 }
(...skipping 13 matching lines...) Expand all
1112 base::Bind(&CheckPasswordChanges, 1087 base::Bind(&CheckPasswordChanges,
1113 PasswordStoreChangeList(1, PasswordStoreChange( 1088 PasswordStoreChangeList(1, PasswordStoreChange(
1114 PasswordStoreChange::ADD, form_google_)))); 1089 PasswordStoreChange::ADD, form_google_))));
1115 1090
1116 // Verify that nothing is in fact returned, because KWallet fails to respond. 1091 // Verify that nothing is in fact returned, because KWallet fails to respond.
1117 std::vector<std::unique_ptr<PasswordForm>> form_list; 1092 std::vector<std::unique_ptr<PasswordForm>> form_list;
1118 BrowserThread::PostTask( 1093 BrowserThread::PostTask(
1119 BrowserThread::DB, FROM_HERE, 1094 BrowserThread::DB, FROM_HERE,
1120 base::BindOnce(&CheckGetAutofillableLoginsFails, 1095 base::BindOnce(&CheckGetAutofillableLoginsFails,
1121 base::Unretained(&backend), &form_list)); 1096 base::Unretained(&backend), &form_list));
1122 RunDBThread(); 1097 content::RunAllPendingInMessageLoop(BrowserThread::DB);
1123 EXPECT_EQ(0u, form_list.size()); 1098 EXPECT_EQ(0u, form_list.size());
1124 } 1099 }
1125 1100
1126 TEST_P(NativeBackendKWalletTest, GetAllLogins) { 1101 TEST_P(NativeBackendKWalletTest, GetAllLogins) {
1127 NativeBackendKWalletStub backend(42, desktop_env_); 1102 NativeBackendKWalletStub backend(42, desktop_env_);
1128 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 1103 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
1129 1104
1130 BrowserThread::PostTask( 1105 BrowserThread::PostTask(
1131 BrowserThread::DB, FROM_HERE, 1106 BrowserThread::DB, FROM_HERE,
1132 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 1107 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
1133 base::Unretained(&backend), form_google_)); 1108 base::Unretained(&backend), form_google_));
1134 BrowserThread::PostTask( 1109 BrowserThread::PostTask(
1135 BrowserThread::DB, FROM_HERE, 1110 BrowserThread::DB, FROM_HERE,
1136 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 1111 base::BindOnce(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
1137 base::Unretained(&backend), form_isc_)); 1112 base::Unretained(&backend), form_isc_));
1138 1113
1139 std::vector<std::unique_ptr<PasswordForm>> form_list; 1114 std::vector<std::unique_ptr<PasswordForm>> form_list;
1140 BrowserThread::PostTaskAndReplyWithResult( 1115 BrowserThread::PostTaskAndReplyWithResult(
1141 BrowserThread::DB, FROM_HERE, 1116 BrowserThread::DB, FROM_HERE,
1142 base::Bind(&NativeBackendKWalletStub::GetAllLogins, 1117 base::Bind(&NativeBackendKWalletStub::GetAllLogins,
1143 base::Unretained(&backend), &form_list), 1118 base::Unretained(&backend), &form_list),
1144 base::Bind(&CheckTrue)); 1119 base::Bind(&CheckTrue));
1145 1120
1146 RunDBThread(); 1121 content::RunAllPendingInMessageLoop(BrowserThread::DB);
1147 1122
1148 EXPECT_EQ(2u, form_list.size()); 1123 EXPECT_EQ(2u, form_list.size());
1149 EXPECT_THAT(form_list, 1124 EXPECT_THAT(form_list,
1150 UnorderedElementsAre(Pointee(form_google_), Pointee(form_isc_))); 1125 UnorderedElementsAre(Pointee(form_google_), Pointee(form_isc_)));
1151 } 1126 }
1152 1127
1153 INSTANTIATE_TEST_CASE_P(, 1128 INSTANTIATE_TEST_CASE_P(,
1154 NativeBackendKWalletTest, 1129 NativeBackendKWalletTest,
1155 ::testing::Values(base::nix::DESKTOP_ENVIRONMENT_KDE4, 1130 ::testing::Values(base::nix::DESKTOP_ENVIRONMENT_KDE4,
1156 base::nix::DESKTOP_ENVIRONMENT_KDE5)); 1131 base::nix::DESKTOP_ENVIRONMENT_KDE5));
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 CheckVersion7Pickle(); 1405 CheckVersion7Pickle();
1431 } 1406 }
1432 1407
1433 TEST_F(NativeBackendKWalletPickleTest, CheckVersion8Pickle) { 1408 TEST_F(NativeBackendKWalletPickleTest, CheckVersion8Pickle) {
1434 CheckVersion8Pickle(); 1409 CheckVersion8Pickle();
1435 } 1410 }
1436 1411
1437 TEST_F(NativeBackendKWalletPickleTest, CheckVersion9Pickle) { 1412 TEST_F(NativeBackendKWalletPickleTest, CheckVersion9Pickle) {
1438 CheckVersion9Pickle(); 1413 CheckVersion9Pickle();
1439 } 1414 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698