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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 EXPECT_CALL(*password_store_, FillAutofillableLogins(_)) | 412 EXPECT_CALL(*password_store_, FillAutofillableLogins(_)) |
413 .WillOnce(DoAll(SetArgumentPointee<0>(forms), Return(true))); | 413 .WillOnce(DoAll(SetArgumentPointee<0>(forms), Return(true))); |
414 EXPECT_CALL(*password_store_, FillBlacklistLogins(_)) | 414 EXPECT_CALL(*password_store_, FillBlacklistLogins(_)) |
415 .WillOnce(Return(true)); | 415 .WillOnce(Return(true)); |
416 SetIdleChangeProcessorExpectations(); | 416 SetIdleChangeProcessorExpectations(); |
417 CreateRootHelper create_root(this, syncer::PASSWORDS); | 417 CreateRootHelper create_root(this, syncer::PASSWORDS); |
418 StartSyncService(create_root.callback(), base::Closure()); | 418 StartSyncService(create_root.callback(), base::Closure()); |
419 std::vector<PasswordForm> sync_forms; | 419 std::vector<PasswordForm> sync_forms; |
420 GetPasswordEntriesFromSyncDB(&sync_forms); | 420 GetPasswordEntriesFromSyncDB(&sync_forms); |
421 ASSERT_EQ(2U, sync_forms.size()); | 421 ASSERT_EQ(2U, sync_forms.size()); |
422 EXPECT_TRUE(ComparePasswords(expected_forms[0], sync_forms[1])); | 422 EXPECT_TRUE(ComparePasswords(expected_forms[0], sync_forms[0])); |
423 EXPECT_TRUE(ComparePasswords(expected_forms[1], sync_forms[0])); | 423 EXPECT_TRUE(ComparePasswords(expected_forms[1], sync_forms[1])); |
424 } | 424 } |
425 | 425 |
426 TEST_F(ProfileSyncServicePasswordTest, HasNativeHasSyncNoMerge) { | 426 TEST_F(ProfileSyncServicePasswordTest, HasNativeHasSyncNoMerge) { |
427 std::vector<PasswordForm*> native_forms; | 427 std::vector<PasswordForm*> native_forms; |
428 std::vector<PasswordForm> sync_forms; | 428 std::vector<PasswordForm> sync_forms; |
429 std::vector<PasswordForm> expected_forms; | 429 std::vector<PasswordForm> expected_forms; |
430 { | 430 { |
431 PasswordForm* new_form = new PasswordForm; | 431 PasswordForm* new_form = new PasswordForm; |
432 new_form->scheme = PasswordForm::SCHEME_HTML; | 432 new_form->scheme = PasswordForm::SCHEME_HTML; |
433 new_form->signon_realm = "pie"; | 433 new_form->signon_realm = "pie"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 EXPECT_CALL(*password_store_, AddLoginImpl(_)).Times(1); | 470 EXPECT_CALL(*password_store_, AddLoginImpl(_)).Times(1); |
471 | 471 |
472 CreateRootHelper create_root(this, syncer::PASSWORDS); | 472 CreateRootHelper create_root(this, syncer::PASSWORDS); |
473 StartSyncService(create_root.callback(), | 473 StartSyncService(create_root.callback(), |
474 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 474 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
475 | 475 |
476 std::vector<PasswordForm> new_sync_forms; | 476 std::vector<PasswordForm> new_sync_forms; |
477 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 477 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
478 | 478 |
479 EXPECT_EQ(2U, new_sync_forms.size()); | 479 EXPECT_EQ(2U, new_sync_forms.size()); |
480 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 480 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[1])); |
481 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[1])); | 481 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[0])); |
482 } | 482 } |
483 | 483 |
484 // Same as HasNativeHasEmptyNoMerge, but we attempt to aquire a sync transaction | 484 // Same as HasNativeHasEmptyNoMerge, but we attempt to aquire a sync transaction |
485 // every time the password store is accessed. | 485 // every time the password store is accessed. |
486 TEST_F(ProfileSyncServicePasswordTest, EnsureNoTransactions) { | 486 TEST_F(ProfileSyncServicePasswordTest, EnsureNoTransactions) { |
487 std::vector<PasswordForm*> native_forms; | 487 std::vector<PasswordForm*> native_forms; |
488 std::vector<PasswordForm> sync_forms; | 488 std::vector<PasswordForm> sync_forms; |
489 std::vector<PasswordForm> expected_forms; | 489 std::vector<PasswordForm> expected_forms; |
490 { | 490 { |
491 PasswordForm* new_form = new PasswordForm; | 491 PasswordForm* new_form = new PasswordForm; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 .WillOnce(AcquireSyncTransaction(this)); | 535 .WillOnce(AcquireSyncTransaction(this)); |
536 | 536 |
537 CreateRootHelper create_root(this, syncer::PASSWORDS); | 537 CreateRootHelper create_root(this, syncer::PASSWORDS); |
538 StartSyncService(create_root.callback(), | 538 StartSyncService(create_root.callback(), |
539 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 539 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
540 | 540 |
541 std::vector<PasswordForm> new_sync_forms; | 541 std::vector<PasswordForm> new_sync_forms; |
542 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 542 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
543 | 543 |
544 EXPECT_EQ(2U, new_sync_forms.size()); | 544 EXPECT_EQ(2U, new_sync_forms.size()); |
545 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 545 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[1])); |
546 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[1])); | 546 EXPECT_TRUE(ComparePasswords(expected_forms[1], new_sync_forms[0])); |
547 } | 547 } |
548 | 548 |
549 TEST_F(ProfileSyncServicePasswordTest, HasNativeHasSyncMergeEntry) { | 549 TEST_F(ProfileSyncServicePasswordTest, HasNativeHasSyncMergeEntry) { |
550 std::vector<PasswordForm*> native_forms; | 550 std::vector<PasswordForm*> native_forms; |
551 std::vector<PasswordForm> sync_forms; | 551 std::vector<PasswordForm> sync_forms; |
552 std::vector<PasswordForm> expected_forms; | 552 std::vector<PasswordForm> expected_forms; |
553 { | 553 { |
554 PasswordForm* new_form = new PasswordForm; | 554 PasswordForm* new_form = new PasswordForm; |
555 new_form->scheme = PasswordForm::SCHEME_HTML; | 555 new_form->scheme = PasswordForm::SCHEME_HTML; |
556 new_form->signon_realm = "pie"; | 556 new_form->signon_realm = "pie"; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 CreateRootHelper create_root(this, syncer::PASSWORDS); | 610 CreateRootHelper create_root(this, syncer::PASSWORDS); |
611 StartSyncService(create_root.callback(), | 611 StartSyncService(create_root.callback(), |
612 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); | 612 base::Bind(&AddPasswordEntriesCallback, this, sync_forms)); |
613 | 613 |
614 std::vector<PasswordForm> new_sync_forms; | 614 std::vector<PasswordForm> new_sync_forms; |
615 GetPasswordEntriesFromSyncDB(&new_sync_forms); | 615 GetPasswordEntriesFromSyncDB(&new_sync_forms); |
616 | 616 |
617 EXPECT_EQ(1U, new_sync_forms.size()); | 617 EXPECT_EQ(1U, new_sync_forms.size()); |
618 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); | 618 EXPECT_TRUE(ComparePasswords(expected_forms[0], new_sync_forms[0])); |
619 } | 619 } |
OLD | NEW |