OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 494 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
495 .WillOnce(QuitMainMessageLoop()); | 495 .WillOnce(QuitMainMessageLoop()); |
496 base::MessageLoop::current()->Run(); | 496 base::MessageLoop::current()->Run(); |
497 | 497 |
498 std::vector<CreditCard*> cards; | 498 std::vector<CreditCard*> cards; |
499 cards.push_back(&credit_card0); | 499 cards.push_back(&credit_card0); |
500 cards.push_back(&credit_card1); | 500 cards.push_back(&credit_card1); |
501 ExpectSameElements(cards, personal_data_->GetCreditCards()); | 501 ExpectSameElements(cards, personal_data_->GetCreditCards()); |
502 | 502 |
503 // Update, remove, and add. | 503 // Update, remove, and add. |
504 credit_card0.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Joe")); | 504 credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Joe")); |
505 personal_data_->UpdateCreditCard(credit_card0); | 505 personal_data_->UpdateCreditCard(credit_card0); |
506 personal_data_->RemoveByGUID(credit_card1.guid()); | 506 personal_data_->RemoveByGUID(credit_card1.guid()); |
507 personal_data_->AddCreditCard(credit_card2); | 507 personal_data_->AddCreditCard(credit_card2); |
508 | 508 |
509 // Verify that the web database has been updated and the notification sent. | 509 // Verify that the web database has been updated and the notification sent. |
510 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 510 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
511 .WillOnce(QuitMainMessageLoop()); | 511 .WillOnce(QuitMainMessageLoop()); |
512 base::MessageLoop::current()->Run(); | 512 base::MessageLoop::current()->Run(); |
513 | 513 |
514 cards.clear(); | 514 cards.clear(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 const std::vector<CreditCard*>& cards2 = personal_data_->GetCreditCards(); | 578 const std::vector<CreditCard*>& cards2 = personal_data_->GetCreditCards(); |
579 ASSERT_EQ(1U, profiles2.size()); | 579 ASSERT_EQ(1U, profiles2.size()); |
580 ASSERT_EQ(1U, cards2.size()); | 580 ASSERT_EQ(1U, cards2.size()); |
581 EXPECT_NE(profile.origin(), profiles2[0]->origin()); | 581 EXPECT_NE(profile.origin(), profiles2[0]->origin()); |
582 EXPECT_NE(credit_card.origin(), cards2[0]->origin()); | 582 EXPECT_NE(credit_card.origin(), cards2[0]->origin()); |
583 EXPECT_EQ(original_profile.origin(), profiles2[0]->origin()); | 583 EXPECT_EQ(original_profile.origin(), profiles2[0]->origin()); |
584 EXPECT_EQ(original_credit_card.origin(), cards2[0]->origin()); | 584 EXPECT_EQ(original_credit_card.origin(), cards2[0]->origin()); |
585 | 585 |
586 // Try to update with data changed as well. | 586 // Try to update with data changed as well. |
587 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); | 587 profile.SetRawInfo(NAME_FIRST, ASCIIToUTF16("John")); |
588 credit_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Joe")); | 588 credit_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Joe")); |
589 | 589 |
590 personal_data_->UpdateProfile(profile); | 590 personal_data_->UpdateProfile(profile); |
591 personal_data_->UpdateCreditCard(credit_card); | 591 personal_data_->UpdateCreditCard(credit_card); |
592 | 592 |
593 // Verify that the web database has been updated and the notification sent. | 593 // Verify that the web database has been updated and the notification sent. |
594 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 594 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
595 .WillOnce(QuitMainMessageLoop()); | 595 .WillOnce(QuitMainMessageLoop()); |
596 base::MessageLoop::current()->Run(); | 596 base::MessageLoop::current()->Run(); |
597 | 597 |
598 const std::vector<AutofillProfile*>& profiles3 = | 598 const std::vector<AutofillProfile*>& profiles3 = |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 // Make sure the two profiles have different GUIDs, both valid. | 832 // Make sure the two profiles have different GUIDs, both valid. |
833 const std::vector<AutofillProfile*>& results3 = personal_data_->GetProfiles(); | 833 const std::vector<AutofillProfile*>& results3 = personal_data_->GetProfiles(); |
834 ASSERT_EQ(2U, results3.size()); | 834 ASSERT_EQ(2U, results3.size()); |
835 EXPECT_NE(results3[0]->guid(), results3[1]->guid()); | 835 EXPECT_NE(results3[0]->guid(), results3[1]->guid()); |
836 EXPECT_TRUE(base::IsValidGUID(results3[0]->guid())); | 836 EXPECT_TRUE(base::IsValidGUID(results3[0]->guid())); |
837 EXPECT_TRUE(base::IsValidGUID(results3[1]->guid())); | 837 EXPECT_TRUE(base::IsValidGUID(results3[1]->guid())); |
838 } | 838 } |
839 | 839 |
840 TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { | 840 TEST_F(PersonalDataManagerTest, SetUniqueCreditCardLabels) { |
841 CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com"); | 841 CreditCard credit_card0(base::GenerateGUID(), "https://www.example.com"); |
842 credit_card0.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("John")); | 842 credit_card0.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("John")); |
843 CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); | 843 CreditCard credit_card1(base::GenerateGUID(), "https://www.example.com"); |
844 credit_card1.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Paul")); | 844 credit_card1.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Paul")); |
845 CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com"); | 845 CreditCard credit_card2(base::GenerateGUID(), "https://www.example.com"); |
846 credit_card2.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Ringo")); | 846 credit_card2.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Ringo")); |
847 CreditCard credit_card3(base::GenerateGUID(), "https://www.example.com"); | 847 CreditCard credit_card3(base::GenerateGUID(), "https://www.example.com"); |
848 credit_card3.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Other")); | 848 credit_card3.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Other")); |
849 CreditCard credit_card4(base::GenerateGUID(), "https://www.example.com"); | 849 CreditCard credit_card4(base::GenerateGUID(), "https://www.example.com"); |
850 credit_card4.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Ozzy")); | 850 credit_card4.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Ozzy")); |
851 CreditCard credit_card5(base::GenerateGUID(), "https://www.example.com"); | 851 CreditCard credit_card5(base::GenerateGUID(), "https://www.example.com"); |
852 credit_card5.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Dio")); | 852 credit_card5.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Dio")); |
853 | 853 |
854 // Add the test credit cards to the database. | 854 // Add the test credit cards to the database. |
855 personal_data_->AddCreditCard(credit_card0); | 855 personal_data_->AddCreditCard(credit_card0); |
856 personal_data_->AddCreditCard(credit_card1); | 856 personal_data_->AddCreditCard(credit_card1); |
857 personal_data_->AddCreditCard(credit_card2); | 857 personal_data_->AddCreditCard(credit_card2); |
858 personal_data_->AddCreditCard(credit_card3); | 858 personal_data_->AddCreditCard(credit_card3); |
859 personal_data_->AddCreditCard(credit_card4); | 859 personal_data_->AddCreditCard(credit_card4); |
860 personal_data_->AddCreditCard(credit_card5); | 860 personal_data_->AddCreditCard(credit_card5); |
861 | 861 |
862 // Reset the PersonalDataManager. This tests that the personal data was saved | 862 // Reset the PersonalDataManager. This tests that the personal data was saved |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 // Add the credit card to the database. | 2513 // Add the credit card to the database. |
2514 personal_data_->AddCreditCard(credit_card); | 2514 personal_data_->AddCreditCard(credit_card); |
2515 | 2515 |
2516 // Verify that the web database has been updated and the notification sent. | 2516 // Verify that the web database has been updated and the notification sent. |
2517 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 2517 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
2518 .WillOnce(QuitMainMessageLoop()); | 2518 .WillOnce(QuitMainMessageLoop()); |
2519 base::MessageLoop::current()->Run(); | 2519 base::MessageLoop::current()->Run(); |
2520 | 2520 |
2521 CreditCard new_verified_card = credit_card; | 2521 CreditCard new_verified_card = credit_card; |
2522 new_verified_card.set_guid(base::GenerateGUID()); | 2522 new_verified_card.set_guid(base::GenerateGUID()); |
2523 new_verified_card.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("B. Small")); | 2523 new_verified_card.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("B. Small")); |
2524 EXPECT_TRUE(new_verified_card.IsVerified()); | 2524 EXPECT_TRUE(new_verified_card.IsVerified()); |
2525 | 2525 |
2526 personal_data_->SaveImportedCreditCard(new_verified_card); | 2526 personal_data_->SaveImportedCreditCard(new_verified_card); |
2527 | 2527 |
2528 // Verify that the web database has been updated and the notification sent. | 2528 // Verify that the web database has been updated and the notification sent. |
2529 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 2529 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
2530 .WillOnce(QuitMainMessageLoop()); | 2530 .WillOnce(QuitMainMessageLoop()); |
2531 base::MessageLoop::current()->Run(); | 2531 base::MessageLoop::current()->Run(); |
2532 | 2532 |
2533 // Expect that the saved credit card is updated. | 2533 // Expect that the saved credit card is updated. |
2534 const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); | 2534 const std::vector<CreditCard*>& results = personal_data_->GetCreditCards(); |
2535 ASSERT_EQ(1U, results.size()); | 2535 ASSERT_EQ(1U, results.size()); |
2536 EXPECT_EQ(ASCIIToUTF16("B. Small"), results[0]->GetRawInfo(CREDIT_CARD_NAME)); | 2536 EXPECT_EQ(ASCIIToUTF16("B. Small"), |
| 2537 results[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); |
2537 } | 2538 } |
2538 | 2539 |
2539 TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { | 2540 TEST_F(PersonalDataManagerTest, GetNonEmptyTypes) { |
2540 // Check that there are no available types with no profiles stored. | 2541 // Check that there are no available types with no profiles stored. |
2541 ServerFieldTypeSet non_empty_types; | 2542 ServerFieldTypeSet non_empty_types; |
2542 personal_data_->GetNonEmptyTypes(&non_empty_types); | 2543 personal_data_->GetNonEmptyTypes(&non_empty_types); |
2543 EXPECT_EQ(0U, non_empty_types.size()); | 2544 EXPECT_EQ(0U, non_empty_types.size()); |
2544 | 2545 |
2545 // Test with one profile stored. | 2546 // Test with one profile stored. |
2546 AutofillProfile profile0(base::GenerateGUID(), "https://www.example.com"); | 2547 AutofillProfile profile0(base::GenerateGUID(), "https://www.example.com"); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STREET_ADDRESS)); | 2644 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STREET_ADDRESS)); |
2644 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); | 2645 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_CITY)); |
2645 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); | 2646 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_STATE)); |
2646 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); | 2647 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_ZIP)); |
2647 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); | 2648 EXPECT_TRUE(non_empty_types.count(ADDRESS_HOME_COUNTRY)); |
2648 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); | 2649 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_NUMBER)); |
2649 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); | 2650 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_CODE)); |
2650 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); | 2651 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_COUNTRY_CODE)); |
2651 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); | 2652 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_CITY_AND_NUMBER)); |
2652 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); | 2653 EXPECT_TRUE(non_empty_types.count(PHONE_HOME_WHOLE_NUMBER)); |
2653 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME)); | 2654 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NAME_FULL)); |
2654 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); | 2655 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_NUMBER)); |
2655 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_TYPE)); | 2656 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_TYPE)); |
2656 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); | 2657 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_MONTH)); |
2657 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); | 2658 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_2_DIGIT_YEAR)); |
2658 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 2659 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
2659 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); | 2660 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR)); |
2660 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); | 2661 EXPECT_TRUE(non_empty_types.count(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR)); |
2661 } | 2662 } |
2662 | 2663 |
2663 TEST_F(PersonalDataManagerTest, IncognitoReadOnly) { | 2664 TEST_F(PersonalDataManagerTest, IncognitoReadOnly) { |
(...skipping 29 matching lines...) Expand all Loading... |
2693 personal_data_->AddCreditCard(larry_page); | 2694 personal_data_->AddCreditCard(larry_page); |
2694 | 2695 |
2695 ResetPersonalDataManager(USER_MODE_INCOGNITO); | 2696 ResetPersonalDataManager(USER_MODE_INCOGNITO); |
2696 EXPECT_EQ(1U, personal_data_->GetProfiles().size()); | 2697 EXPECT_EQ(1U, personal_data_->GetProfiles().size()); |
2697 EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); | 2698 EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); |
2698 | 2699 |
2699 // Saving or creating profiles from imported profiles shouldn't work. | 2700 // Saving or creating profiles from imported profiles shouldn't work. |
2700 steve_jobs.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Steve")); | 2701 steve_jobs.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Steve")); |
2701 personal_data_->SaveImportedProfile(steve_jobs); | 2702 personal_data_->SaveImportedProfile(steve_jobs); |
2702 | 2703 |
2703 bill_gates.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill Gates")); | 2704 bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Bill Gates")); |
2704 personal_data_->SaveImportedCreditCard(bill_gates); | 2705 personal_data_->SaveImportedCreditCard(bill_gates); |
2705 | 2706 |
2706 ResetPersonalDataManager(USER_MODE_INCOGNITO); | 2707 ResetPersonalDataManager(USER_MODE_INCOGNITO); |
2707 EXPECT_EQ(ASCIIToUTF16("Steven"), | 2708 EXPECT_EQ(ASCIIToUTF16("Steven"), |
2708 personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); | 2709 personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); |
2709 EXPECT_EQ(ASCIIToUTF16("William H. Gates"), | 2710 EXPECT_EQ( |
2710 personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME)); | 2711 ASCIIToUTF16("William H. Gates"), |
| 2712 personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); |
2711 | 2713 |
2712 // Updating existing profiles shouldn't work. | 2714 // Updating existing profiles shouldn't work. |
2713 steve_jobs.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Steve")); | 2715 steve_jobs.SetRawInfo(NAME_FIRST, ASCIIToUTF16("Steve")); |
2714 personal_data_->UpdateProfile(steve_jobs); | 2716 personal_data_->UpdateProfile(steve_jobs); |
2715 | 2717 |
2716 bill_gates.SetRawInfo(CREDIT_CARD_NAME, ASCIIToUTF16("Bill Gates")); | 2718 bill_gates.SetRawInfo(CREDIT_CARD_NAME_FULL, ASCIIToUTF16("Bill Gates")); |
2717 personal_data_->UpdateCreditCard(bill_gates); | 2719 personal_data_->UpdateCreditCard(bill_gates); |
2718 | 2720 |
2719 ResetPersonalDataManager(USER_MODE_INCOGNITO); | 2721 ResetPersonalDataManager(USER_MODE_INCOGNITO); |
2720 EXPECT_EQ(ASCIIToUTF16("Steven"), | 2722 EXPECT_EQ(ASCIIToUTF16("Steven"), |
2721 personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); | 2723 personal_data_->GetProfiles()[0]->GetRawInfo(NAME_FIRST)); |
2722 EXPECT_EQ(ASCIIToUTF16("William H. Gates"), | 2724 EXPECT_EQ( |
2723 personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME)); | 2725 ASCIIToUTF16("William H. Gates"), |
| 2726 personal_data_->GetCreditCards()[0]->GetRawInfo(CREDIT_CARD_NAME_FULL)); |
2724 | 2727 |
2725 // Removing shouldn't work. | 2728 // Removing shouldn't work. |
2726 personal_data_->RemoveByGUID(steve_jobs.guid()); | 2729 personal_data_->RemoveByGUID(steve_jobs.guid()); |
2727 personal_data_->RemoveByGUID(bill_gates.guid()); | 2730 personal_data_->RemoveByGUID(bill_gates.guid()); |
2728 | 2731 |
2729 ResetPersonalDataManager(USER_MODE_INCOGNITO); | 2732 ResetPersonalDataManager(USER_MODE_INCOGNITO); |
2730 EXPECT_EQ(1U, personal_data_->GetProfiles().size()); | 2733 EXPECT_EQ(1U, personal_data_->GetProfiles().size()); |
2731 EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); | 2734 EXPECT_EQ(1U, personal_data_->GetCreditCards().size()); |
2732 } | 2735 } |
2733 | 2736 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3018 } | 3021 } |
3019 | 3022 |
3020 // Test that local credit cards are ordered as expected. | 3023 // Test that local credit cards are ordered as expected. |
3021 TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_LocalCardsRanking) { | 3024 TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions_LocalCardsRanking) { |
3022 SetupReferenceLocalCreditCards(); | 3025 SetupReferenceLocalCreditCards(); |
3023 | 3026 |
3024 // Sublabel is card number when filling name (exact format depends on | 3027 // Sublabel is card number when filling name (exact format depends on |
3025 // the platform, but the last 4 digits should appear). | 3028 // the platform, but the last 4 digits should appear). |
3026 std::vector<Suggestion> suggestions = | 3029 std::vector<Suggestion> suggestions = |
3027 personal_data_->GetCreditCardSuggestions( | 3030 personal_data_->GetCreditCardSuggestions( |
3028 AutofillType(CREDIT_CARD_NAME), | 3031 AutofillType(CREDIT_CARD_NAME_FULL), |
3029 /* field_contents= */ base::string16()); | 3032 /* field_contents= */ base::string16()); |
3030 ASSERT_EQ(3U, suggestions.size()); | 3033 ASSERT_EQ(3U, suggestions.size()); |
3031 | 3034 |
3032 // Ordered as expected. | 3035 // Ordered as expected. |
3033 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); | 3036 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); |
3034 EXPECT_TRUE(suggestions[0].label.find(ASCIIToUTF16("9012")) != | 3037 EXPECT_TRUE(suggestions[0].label.find(ASCIIToUTF16("9012")) != |
3035 base::string16::npos); | 3038 base::string16::npos); |
3036 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); | 3039 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); |
3037 EXPECT_TRUE(suggestions[1].label.find(ASCIIToUTF16("8555")) != | 3040 EXPECT_TRUE(suggestions[1].label.find(ASCIIToUTF16("8555")) != |
3038 base::string16::npos); | 3041 base::string16::npos); |
(...skipping 26 matching lines...) Expand all Loading... |
3065 base::TimeDelta::FromDays(1)); | 3068 base::TimeDelta::FromDays(1)); |
3066 | 3069 |
3067 test::SetServerCreditCards(autofill_table_, server_cards); | 3070 test::SetServerCreditCards(autofill_table_, server_cards); |
3068 personal_data_->Refresh(); | 3071 personal_data_->Refresh(); |
3069 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 3072 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
3070 .WillOnce(QuitMainMessageLoop()); | 3073 .WillOnce(QuitMainMessageLoop()); |
3071 base::MessageLoop::current()->Run(); | 3074 base::MessageLoop::current()->Run(); |
3072 | 3075 |
3073 std::vector<Suggestion> suggestions = | 3076 std::vector<Suggestion> suggestions = |
3074 personal_data_->GetCreditCardSuggestions( | 3077 personal_data_->GetCreditCardSuggestions( |
3075 AutofillType(CREDIT_CARD_NAME), | 3078 AutofillType(CREDIT_CARD_NAME_FULL), |
3076 /* field_contents= */ base::string16()); | 3079 /* field_contents= */ base::string16()); |
3077 ASSERT_EQ(5U, suggestions.size()); | 3080 ASSERT_EQ(5U, suggestions.size()); |
3078 | 3081 |
3079 // All cards should be ordered as expected. | 3082 // All cards should be ordered as expected. |
3080 EXPECT_EQ(ASCIIToUTF16("Jesse James"), suggestions[0].value); | 3083 EXPECT_EQ(ASCIIToUTF16("Jesse James"), suggestions[0].value); |
3081 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[1].value); | 3084 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[1].value); |
3082 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[2].value); | 3085 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[2].value); |
3083 EXPECT_EQ(ASCIIToUTF16("Emmet Dalton"), suggestions[3].value); | 3086 EXPECT_EQ(ASCIIToUTF16("Emmet Dalton"), suggestions[3].value); |
3084 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[4].value); | 3087 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[4].value); |
3085 } | 3088 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3164 base::TimeDelta::FromDays(15)); | 3167 base::TimeDelta::FromDays(15)); |
3165 | 3168 |
3166 test::SetServerCreditCards(autofill_table_, server_cards); | 3169 test::SetServerCreditCards(autofill_table_, server_cards); |
3167 personal_data_->Refresh(); | 3170 personal_data_->Refresh(); |
3168 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 3171 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
3169 .WillOnce(QuitMainMessageLoop()); | 3172 .WillOnce(QuitMainMessageLoop()); |
3170 base::MessageLoop::current()->Run(); | 3173 base::MessageLoop::current()->Run(); |
3171 | 3174 |
3172 std::vector<Suggestion> suggestions = | 3175 std::vector<Suggestion> suggestions = |
3173 personal_data_->GetCreditCardSuggestions( | 3176 personal_data_->GetCreditCardSuggestions( |
3174 AutofillType(CREDIT_CARD_NAME), | 3177 AutofillType(CREDIT_CARD_NAME_FULL), |
3175 /* field_contents= */ base::string16()); | 3178 /* field_contents= */ base::string16()); |
3176 ASSERT_EQ(4U, suggestions.size()); | 3179 ASSERT_EQ(4U, suggestions.size()); |
3177 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); | 3180 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); |
3178 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); | 3181 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[1].value); |
3179 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); | 3182 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); |
3180 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[3].value); | 3183 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[3].value); |
3181 | 3184 |
3182 suggestions = personal_data_->GetCreditCardSuggestions( | 3185 suggestions = personal_data_->GetCreditCardSuggestions( |
3183 AutofillType(CREDIT_CARD_NUMBER), /* field_contents= */ base::string16()); | 3186 AutofillType(CREDIT_CARD_NUMBER), /* field_contents= */ base::string16()); |
3184 ASSERT_EQ(4U, suggestions.size()); | 3187 ASSERT_EQ(4U, suggestions.size()); |
(...skipping 26 matching lines...) Expand all Loading... |
3211 "347666888555" /* American Express */, "04", "2015"); | 3214 "347666888555" /* American Express */, "04", "2015"); |
3212 | 3215 |
3213 test::SetServerCreditCards(autofill_table_, server_cards); | 3216 test::SetServerCreditCards(autofill_table_, server_cards); |
3214 personal_data_->Refresh(); | 3217 personal_data_->Refresh(); |
3215 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 3218 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
3216 .WillOnce(QuitMainMessageLoop()); | 3219 .WillOnce(QuitMainMessageLoop()); |
3217 base::MessageLoop::current()->Run(); | 3220 base::MessageLoop::current()->Run(); |
3218 | 3221 |
3219 std::vector<Suggestion> suggestions = | 3222 std::vector<Suggestion> suggestions = |
3220 personal_data_->GetCreditCardSuggestions( | 3223 personal_data_->GetCreditCardSuggestions( |
3221 AutofillType(CREDIT_CARD_NAME), | 3224 AutofillType(CREDIT_CARD_NAME_FULL), |
3222 /* field_contents= */ base::string16()); | 3225 /* field_contents= */ base::string16()); |
3223 ASSERT_EQ(3U, suggestions.size()); | 3226 ASSERT_EQ(3U, suggestions.size()); |
3224 | 3227 |
3225 // Add a second dupe local card to make sure a full server card can be a dupe | 3228 // Add a second dupe local card to make sure a full server card can be a dupe |
3226 // of more than one local card. | 3229 // of more than one local card. |
3227 CreditCard credit_card3("4141084B-72D7-4B73-90CF-3D6AC154673B", | 3230 CreditCard credit_card3("4141084B-72D7-4B73-90CF-3D6AC154673B", |
3228 "https://www.example.com"); | 3231 "https://www.example.com"); |
3229 test::SetCreditCardInfo(&credit_card3, "Clyde Barrow", "", "04", ""); | 3232 test::SetCreditCardInfo(&credit_card3, "Clyde Barrow", "", "04", ""); |
3230 personal_data_->AddCreditCard(credit_card3); | 3233 personal_data_->AddCreditCard(credit_card3); |
3231 | 3234 |
3232 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 3235 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
3233 .WillOnce(QuitMainMessageLoop()); | 3236 .WillOnce(QuitMainMessageLoop()); |
3234 base::MessageLoop::current()->Run(); | 3237 base::MessageLoop::current()->Run(); |
3235 | 3238 |
3236 suggestions = personal_data_->GetCreditCardSuggestions( | 3239 suggestions = personal_data_->GetCreditCardSuggestions( |
3237 AutofillType(CREDIT_CARD_NAME), /* field_contents= */ base::string16()); | 3240 AutofillType(CREDIT_CARD_NAME_FULL), |
| 3241 /* field_contents= */ base::string16()); |
3238 ASSERT_EQ(3U, suggestions.size()); | 3242 ASSERT_EQ(3U, suggestions.size()); |
3239 } | 3243 } |
3240 | 3244 |
3241 // Tests that only the full server card is kept when deduping with a local | 3245 // Tests that only the full server card is kept when deduping with a local |
3242 // duplicate of it. | 3246 // duplicate of it. |
3243 TEST_F(PersonalDataManagerTest, | 3247 TEST_F(PersonalDataManagerTest, |
3244 DedupeCreditCardSuggestions_FullServerShadowsLocal) { | 3248 DedupeCreditCardSuggestions_FullServerShadowsLocal) { |
3245 std::list<const CreditCard*> credit_cards; | 3249 std::list<const CreditCard*> credit_cards; |
3246 | 3250 |
3247 // Create 3 different local credit cards. | 3251 // Create 3 different local credit cards. |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3799 EXPECT_GT(base::TimeDelta::FromMilliseconds(500), | 3803 EXPECT_GT(base::TimeDelta::FromMilliseconds(500), |
3800 base::Time::Now() - saved_profiles.front()->use_date()); | 3804 base::Time::Now() - saved_profiles.front()->use_date()); |
3801 } | 3805 } |
3802 | 3806 |
3803 // Erase the profiles for the next test. | 3807 // Erase the profiles for the next test. |
3804 ResetProfiles(); | 3808 ResetProfiles(); |
3805 } | 3809 } |
3806 } | 3810 } |
3807 | 3811 |
3808 } // namespace autofill | 3812 } // namespace autofill |
OLD | NEW |