| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 EXPECT_EQ(ASCIIToUTF16("*8555"), suggestions[1].label); | 2743 EXPECT_EQ(ASCIIToUTF16("*8555"), suggestions[1].label); |
| 2744 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); | 2744 EXPECT_EQ(ASCIIToUTF16("John Dillinger"), suggestions[0].value); |
| 2745 EXPECT_EQ(base::string16(), suggestions[0].label); | 2745 EXPECT_EQ(base::string16(), suggestions[0].label); |
| 2746 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); | 2746 EXPECT_EQ(ASCIIToUTF16("Bonnie Parker"), suggestions[2].value); |
| 2747 EXPECT_EQ(ASCIIToUTF16("*2109"), suggestions[2].label); | 2747 EXPECT_EQ(ASCIIToUTF16("*2109"), suggestions[2].label); |
| 2748 | 2748 |
| 2749 // Sublabel is expiration date when filling card number. | 2749 // Sublabel is expiration date when filling card number. |
| 2750 suggestions = personal_data_->GetCreditCardSuggestions( | 2750 suggestions = personal_data_->GetCreditCardSuggestions( |
| 2751 AutofillType(CREDIT_CARD_NUMBER), base::string16()); | 2751 AutofillType(CREDIT_CARD_NUMBER), base::string16()); |
| 2752 ASSERT_EQ(2U, suggestions.size()); | 2752 ASSERT_EQ(2U, suggestions.size()); |
| 2753 EXPECT_EQ(ASCIIToUTF16("American Express - 8555"), suggestions[0].value); | 2753 EXPECT_EQ(ASCIIToUTF16("Amex - 8555"), suggestions[0].value); |
| 2754 EXPECT_EQ(ASCIIToUTF16("04/15"), suggestions[0].label); | 2754 EXPECT_EQ(ASCIIToUTF16("04/15"), suggestions[0].label); |
| 2755 EXPECT_EQ(ASCIIToUTF16("MasterCard - 2109"), suggestions[1].value); | 2755 EXPECT_EQ(ASCIIToUTF16("MasterCard - 2109"), suggestions[1].value); |
| 2756 EXPECT_EQ(base::string16(), suggestions[1].label); | 2756 EXPECT_EQ(base::string16(), suggestions[1].label); |
| 2757 | 2757 |
| 2758 // Add some server cards. If there are local dupes, the locals should be | 2758 // Add some server cards. If there are local dupes, the locals should be |
| 2759 // hidden. | 2759 // hidden. |
| 2760 std::vector<CreditCard> server_cards; | 2760 std::vector<CreditCard> server_cards; |
| 2761 // This server card matches a local card, except the local card is missing the | 2761 // This server card matches a local card, except the local card is missing the |
| 2762 // number. This should count as a dupe. | 2762 // number. This should count as a dupe. |
| 2763 server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); | 2763 server_cards.push_back(CreditCard(CreditCard::MASKED_SERVER_CARD, "a123")); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2794 EXPECT_NE(suggestions[2].backend_id.guid, credit_card2.guid()); | 2794 EXPECT_NE(suggestions[2].backend_id.guid, credit_card2.guid()); |
| 2795 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[3].value); | 2795 EXPECT_EQ(ASCIIToUTF16("Clyde Barrow"), suggestions[3].value); |
| 2796 EXPECT_NE(suggestions[0].backend_id.guid, credit_card0.guid()); | 2796 EXPECT_NE(suggestions[0].backend_id.guid, credit_card0.guid()); |
| 2797 | 2797 |
| 2798 suggestions = personal_data_->GetCreditCardSuggestions( | 2798 suggestions = personal_data_->GetCreditCardSuggestions( |
| 2799 AutofillType(CREDIT_CARD_NUMBER), base::string16()); | 2799 AutofillType(CREDIT_CARD_NUMBER), base::string16()); |
| 2800 ASSERT_EQ(4U, suggestions.size()); | 2800 ASSERT_EQ(4U, suggestions.size()); |
| 2801 EXPECT_EQ(ASCIIToUTF16("MasterCard - 2109"), suggestions[0].value); | 2801 EXPECT_EQ(ASCIIToUTF16("MasterCard - 2109"), suggestions[0].value); |
| 2802 EXPECT_EQ(ASCIIToUTF16("Visa - 9012"), suggestions[1].value); | 2802 EXPECT_EQ(ASCIIToUTF16("Visa - 9012"), suggestions[1].value); |
| 2803 EXPECT_EQ(ASCIIToUTF16("Visa - 2109"), suggestions[2].value); | 2803 EXPECT_EQ(ASCIIToUTF16("Visa - 2109"), suggestions[2].value); |
| 2804 EXPECT_EQ(ASCIIToUTF16("American Express - 8555"), suggestions[3].value); | 2804 EXPECT_EQ(ASCIIToUTF16("Amex - 8555"), suggestions[3].value); |
| 2805 | 2805 |
| 2806 // Make sure a server card can be a dupe of more than one local card. | 2806 // Make sure a server card can be a dupe of more than one local card. |
| 2807 CreditCard credit_card3("4141084B-72D7-4B73-90CF-3D6AC154673B", | 2807 CreditCard credit_card3("4141084B-72D7-4B73-90CF-3D6AC154673B", |
| 2808 "https://www.example.com"); | 2808 "https://www.example.com"); |
| 2809 test::SetCreditCardInfo(&credit_card3, "John Dillinger", "", "01", ""); | 2809 test::SetCreditCardInfo(&credit_card3, "John Dillinger", "", "01", ""); |
| 2810 personal_data_->AddCreditCard(credit_card3); | 2810 personal_data_->AddCreditCard(credit_card3); |
| 2811 | 2811 |
| 2812 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) | 2812 EXPECT_CALL(personal_data_observer_, OnPersonalDataChanged()) |
| 2813 .WillOnce(QuitMainMessageLoop()); | 2813 .WillOnce(QuitMainMessageLoop()); |
| 2814 base::MessageLoop::current()->Run(); | 2814 base::MessageLoop::current()->Run(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2918 EXPECT_NE(base::Time(), added_profile->modification_date()); | 2918 EXPECT_NE(base::Time(), added_profile->modification_date()); |
| 2919 | 2919 |
| 2920 added_card = personal_data_->GetCreditCardByGUID(credit_card.guid()); | 2920 added_card = personal_data_->GetCreditCardByGUID(credit_card.guid()); |
| 2921 ASSERT_TRUE(added_card); | 2921 ASSERT_TRUE(added_card); |
| 2922 EXPECT_EQ(1U, added_card->use_count()); | 2922 EXPECT_EQ(1U, added_card->use_count()); |
| 2923 EXPECT_NE(base::Time(), added_card->use_date()); | 2923 EXPECT_NE(base::Time(), added_card->use_date()); |
| 2924 EXPECT_NE(base::Time(), added_card->modification_date()); | 2924 EXPECT_NE(base::Time(), added_card->modification_date()); |
| 2925 } | 2925 } |
| 2926 | 2926 |
| 2927 } // namespace autofill | 2927 } // namespace autofill |
| OLD | NEW |