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 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2793 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com"); | 2793 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com"); |
2794 test::SetProfileInfo(&profile, | 2794 test::SetProfileInfo(&profile, |
2795 "Marion", "Mitchell", "Morrison", | 2795 "Marion", "Mitchell", "Morrison", |
2796 "johnwayne@me.xyz", "Fox", | 2796 "johnwayne@me.xyz", "Fox", |
2797 "123 Zoo St.\nSecond Line\nThird line", "unit 5", "Hollywood", "CA", | 2797 "123 Zoo St.\nSecond Line\nThird line", "unit 5", "Hollywood", "CA", |
2798 "91601", "US", "12345678910"); | 2798 "91601", "US", "12345678910"); |
2799 personal_data_->AddProfile(profile); | 2799 personal_data_->AddProfile(profile); |
2800 ResetPersonalDataManager(USER_MODE_NORMAL); | 2800 ResetPersonalDataManager(USER_MODE_NORMAL); |
2801 | 2801 |
2802 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( | 2802 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( |
2803 AutofillType(ADDRESS_HOME_STREET_ADDRESS), | 2803 AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), |
2804 base::UTF8ToUTF16("123"), | 2804 false, std::vector<ServerFieldType>()); |
2805 false, | |
2806 std::vector<ServerFieldType>()); | |
2807 ASSERT_FALSE(suggestions.empty()); | 2805 ASSERT_FALSE(suggestions.empty()); |
2808 EXPECT_EQ(suggestions[0].value, | 2806 EXPECT_EQ(suggestions[0].value, |
2809 base::UTF8ToUTF16("123 Zoo St., Second Line, Third line, unit 5")); | 2807 base::ASCIIToUTF16("123 Zoo St., Second Line, Third line, unit 5")); |
| 2808 } |
| 2809 |
| 2810 TEST_F(PersonalDataManagerTest, GetProfileSuggestionsHideSubsets) { |
| 2811 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com"); |
| 2812 test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison", |
| 2813 "johnwayne@me.xyz", "Fox", |
| 2814 "123 Zoo St.\nSecond Line\nThird line", "unit 5", |
| 2815 "Hollywood", "CA", "91601", "US", "12345678910"); |
| 2816 |
| 2817 // Dupe profile, except different in email address (irrelevant for this form). |
| 2818 AutofillProfile profile1 = profile; |
| 2819 profile1.set_guid(base::GenerateGUID()); |
| 2820 profile1.SetRawInfo(EMAIL_ADDRESS, base::ASCIIToUTF16("spam_me@example.com")); |
| 2821 |
| 2822 // Dupe profile, except different in address state. |
| 2823 AutofillProfile profile2 = profile; |
| 2824 profile2.set_guid(base::GenerateGUID()); |
| 2825 profile2.SetRawInfo(ADDRESS_HOME_STATE, base::ASCIIToUTF16("TX")); |
| 2826 |
| 2827 // Subset profile. |
| 2828 AutofillProfile profile3 = profile; |
| 2829 profile3.set_guid(base::GenerateGUID()); |
| 2830 profile3.SetRawInfo(ADDRESS_HOME_STATE, base::string16()); |
| 2831 |
| 2832 // For easier results verification, make sure |profile| is suggested first. |
| 2833 profile.set_use_count(5); |
| 2834 personal_data_->AddProfile(profile); |
| 2835 personal_data_->AddProfile(profile1); |
| 2836 personal_data_->AddProfile(profile2); |
| 2837 personal_data_->AddProfile(profile3); |
| 2838 ResetPersonalDataManager(USER_MODE_NORMAL); |
| 2839 |
| 2840 // Simulate a form with street address, city and state. |
| 2841 std::vector<ServerFieldType> types; |
| 2842 types.push_back(ADDRESS_HOME_CITY); |
| 2843 types.push_back(ADDRESS_HOME_STATE); |
| 2844 std::vector<Suggestion> suggestions = personal_data_->GetProfileSuggestions( |
| 2845 AutofillType(ADDRESS_HOME_STREET_ADDRESS), base::ASCIIToUTF16("123"), |
| 2846 false, types); |
| 2847 ASSERT_EQ(2U, suggestions.size()); |
| 2848 EXPECT_EQ(base::ASCIIToUTF16("Hollywood, CA"), suggestions[0].label); |
| 2849 EXPECT_EQ(base::ASCIIToUTF16("Hollywood, TX"), suggestions[1].label); |
2810 } | 2850 } |
2811 | 2851 |
2812 TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions) { | 2852 TEST_F(PersonalDataManagerTest, GetCreditCardSuggestions) { |
2813 EnableWalletCardImport(); | 2853 EnableWalletCardImport(); |
2814 | 2854 |
2815 CreditCard credit_card0("287151C8-6AB1-487C-9095-28E80BE5DA15", | 2855 CreditCard credit_card0("287151C8-6AB1-487C-9095-28E80BE5DA15", |
2816 "https://www.example.com"); | 2856 "https://www.example.com"); |
2817 test::SetCreditCardInfo(&credit_card0, | 2857 test::SetCreditCardInfo(&credit_card0, |
2818 "Clyde Barrow", "347666888555" /* American Express */, "04", "2015"); | 2858 "Clyde Barrow", "347666888555" /* American Express */, "04", "2015"); |
2819 credit_card0.set_use_count(2); | 2859 credit_card0.set_use_count(2); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3094 EXPECT_NE(base::Time(), personal_data_->GetCreditCards()[0]->use_date()); | 3134 EXPECT_NE(base::Time(), personal_data_->GetCreditCards()[0]->use_date()); |
3095 | 3135 |
3096 EXPECT_EQ(0U, personal_data_->GetCreditCards()[1]->use_count()); | 3136 EXPECT_EQ(0U, personal_data_->GetCreditCards()[1]->use_count()); |
3097 EXPECT_EQ(base::Time(), personal_data_->GetCreditCards()[1]->use_date()); | 3137 EXPECT_EQ(base::Time(), personal_data_->GetCreditCards()[1]->use_date()); |
3098 | 3138 |
3099 EXPECT_EQ(1U, personal_data_->GetCreditCards()[2]->use_count()); | 3139 EXPECT_EQ(1U, personal_data_->GetCreditCards()[2]->use_count()); |
3100 EXPECT_NE(base::Time(), personal_data_->GetCreditCards()[2]->use_date()); | 3140 EXPECT_NE(base::Time(), personal_data_->GetCreditCards()[2]->use_date()); |
3101 } | 3141 } |
3102 | 3142 |
3103 } // namespace autofill | 3143 } // namespace autofill |
OLD | NEW |