| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 using testing::_; | 57 using testing::_; |
| 58 using WebKit::WebFormElement; | 58 using WebKit::WebFormElement; |
| 59 | 59 |
| 60 namespace { | 60 namespace { |
| 61 | 61 |
| 62 // The page ID sent to the AutofillManager from the RenderView, used to send | 62 // The page ID sent to the AutofillManager from the RenderView, used to send |
| 63 // an IPC message back to the renderer. | 63 // an IPC message back to the renderer. |
| 64 const int kDefaultPageID = 137; | 64 const int kDefaultPageID = 137; |
| 65 | 65 |
| 66 typedef Tuple5<int, | 66 typedef Tuple5<int, |
| 67 std::vector<string16>, | 67 std::vector<base::string16>, |
| 68 std::vector<string16>, | 68 std::vector<base::string16>, |
| 69 std::vector<string16>, | 69 std::vector<base::string16>, |
| 70 std::vector<int> > AutofillParam; | 70 std::vector<int> > AutofillParam; |
| 71 | 71 |
| 72 class TestPersonalDataManager : public PersonalDataManager { | 72 class TestPersonalDataManager : public PersonalDataManager { |
| 73 public: | 73 public: |
| 74 TestPersonalDataManager() : PersonalDataManager("en-US") { | 74 TestPersonalDataManager() : PersonalDataManager("en-US") { |
| 75 CreateTestAutofillProfiles(&web_profiles_); | 75 CreateTestAutofillProfiles(&web_profiles_); |
| 76 CreateTestCreditCards(&credit_cards_); | 76 CreateTestCreditCards(&credit_cards_); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void SetBrowserContext(content::BrowserContext* context) { | 79 void SetBrowserContext(content::BrowserContext* context) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 autofill_test::CreateTestFormField( | 322 autofill_test::CreateTestFormField( |
| 323 "Expiration Date", "ccmonth", "", "text", &field); | 323 "Expiration Date", "ccmonth", "", "text", &field); |
| 324 form->fields.push_back(field); | 324 form->fields.push_back(field); |
| 325 autofill_test::CreateTestFormField( | 325 autofill_test::CreateTestFormField( |
| 326 "", "ccyear", "", "text", &field); | 326 "", "ccyear", "", "text", &field); |
| 327 form->fields.push_back(field); | 327 form->fields.push_back(field); |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 void ExpectSuggestions(int page_id, | 331 void ExpectSuggestions(int page_id, |
| 332 const std::vector<string16>& values, | 332 const std::vector<base::string16>& values, |
| 333 const std::vector<string16>& labels, | 333 const std::vector<base::string16>& labels, |
| 334 const std::vector<string16>& icons, | 334 const std::vector<base::string16>& icons, |
| 335 const std::vector<int>& unique_ids, | 335 const std::vector<int>& unique_ids, |
| 336 int expected_page_id, | 336 int expected_page_id, |
| 337 size_t expected_num_suggestions, | 337 size_t expected_num_suggestions, |
| 338 const string16 expected_values[], | 338 const base::string16 expected_values[], |
| 339 const string16 expected_labels[], | 339 const base::string16 expected_labels[], |
| 340 const string16 expected_icons[], | 340 const base::string16 expected_icons[], |
| 341 const int expected_unique_ids[]) { | 341 const int expected_unique_ids[]) { |
| 342 EXPECT_EQ(expected_page_id, page_id); | 342 EXPECT_EQ(expected_page_id, page_id); |
| 343 ASSERT_EQ(expected_num_suggestions, values.size()); | 343 ASSERT_EQ(expected_num_suggestions, values.size()); |
| 344 ASSERT_EQ(expected_num_suggestions, labels.size()); | 344 ASSERT_EQ(expected_num_suggestions, labels.size()); |
| 345 ASSERT_EQ(expected_num_suggestions, icons.size()); | 345 ASSERT_EQ(expected_num_suggestions, icons.size()); |
| 346 ASSERT_EQ(expected_num_suggestions, unique_ids.size()); | 346 ASSERT_EQ(expected_num_suggestions, unique_ids.size()); |
| 347 for (size_t i = 0; i < expected_num_suggestions; ++i) { | 347 for (size_t i = 0; i < expected_num_suggestions; ++i) { |
| 348 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); | 348 SCOPED_TRACE(base::StringPrintf("i: %" PRIuS, i)); |
| 349 EXPECT_EQ(expected_values[i], values[i]); | 349 EXPECT_EQ(expected_values[i], values[i]); |
| 350 EXPECT_EQ(expected_labels[i], labels[i]); | 350 EXPECT_EQ(expected_labels[i], labels[i]); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 field, | 728 field, |
| 729 gfx::Rect(), | 729 gfx::Rect(), |
| 730 false); | 730 false); |
| 731 } | 731 } |
| 732 | 732 |
| 733 void GetAutofillSuggestions(const FormData& form, | 733 void GetAutofillSuggestions(const FormData& form, |
| 734 const FormFieldData& field) { | 734 const FormFieldData& field) { |
| 735 GetAutofillSuggestions(kDefaultPageID, form, field); | 735 GetAutofillSuggestions(kDefaultPageID, form, field); |
| 736 } | 736 } |
| 737 | 737 |
| 738 void AutocompleteSuggestionsReturned(const std::vector<string16>& result) { | 738 void AutocompleteSuggestionsReturned( |
| 739 const std::vector<base::string16>& result) { |
| 739 autofill_manager_->autocomplete_history_manager_.SendSuggestions(&result); | 740 autofill_manager_->autocomplete_history_manager_.SendSuggestions(&result); |
| 740 } | 741 } |
| 741 | 742 |
| 742 void FormsSeen(const std::vector<FormData>& forms) { | 743 void FormsSeen(const std::vector<FormData>& forms) { |
| 743 autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), false); | 744 autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), false); |
| 744 } | 745 } |
| 745 | 746 |
| 746 void PartialFormsSeen(const std::vector<FormData>& forms) { | 747 void PartialFormsSeen(const std::vector<FormData>& forms) { |
| 747 autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), true); | 748 autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), true); |
| 748 } | 749 } |
| 749 | 750 |
| 750 void FormSubmitted(const FormData& form) { | 751 void FormSubmitted(const FormData& form) { |
| 751 if (autofill_manager_->OnFormSubmitted(form, base::TimeTicks::Now())) | 752 if (autofill_manager_->OnFormSubmitted(form, base::TimeTicks::Now())) |
| 752 autofill_manager_->WaitForAsyncFormSubmit(); | 753 autofill_manager_->WaitForAsyncFormSubmit(); |
| 753 } | 754 } |
| 754 | 755 |
| 755 void FillAutofillFormData(int query_id, | 756 void FillAutofillFormData(int query_id, |
| 756 const FormData& form, | 757 const FormData& form, |
| 757 const FormFieldData& field, | 758 const FormFieldData& field, |
| 758 int unique_id) { | 759 int unique_id) { |
| 759 autofill_manager_->OnFillAutofillFormData(query_id, form, field, unique_id); | 760 autofill_manager_->OnFillAutofillFormData(query_id, form, field, unique_id); |
| 760 } | 761 } |
| 761 | 762 |
| 762 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const { | 763 int PackGUIDs(const GUIDPair& cc_guid, const GUIDPair& profile_guid) const { |
| 763 return autofill_manager_->PackGUIDs(cc_guid, profile_guid); | 764 return autofill_manager_->PackGUIDs(cc_guid, profile_guid); |
| 764 } | 765 } |
| 765 | 766 |
| 766 bool GetAutofillSuggestionsMessage(int* page_id, | 767 bool GetAutofillSuggestionsMessage(int* page_id, |
| 767 std::vector<string16>* values, | 768 std::vector<base::string16>* values, |
| 768 std::vector<string16>* labels, | 769 std::vector<base::string16>* labels, |
| 769 std::vector<string16>* icons, | 770 std::vector<base::string16>* icons, |
| 770 std::vector<int>* unique_ids) { | 771 std::vector<int>* unique_ids) { |
| 771 const uint32 kMsgID = AutofillMsg_SuggestionsReturned::ID; | 772 const uint32 kMsgID = AutofillMsg_SuggestionsReturned::ID; |
| 772 const IPC::Message* message = | 773 const IPC::Message* message = |
| 773 process()->sink().GetFirstMessageMatching(kMsgID); | 774 process()->sink().GetFirstMessageMatching(kMsgID); |
| 774 if (!message) | 775 if (!message) |
| 775 return false; | 776 return false; |
| 776 | 777 |
| 777 AutofillParam autofill_param; | 778 AutofillParam autofill_param; |
| 778 AutofillMsg_SuggestionsReturned::Read(message, &autofill_param); | 779 AutofillMsg_SuggestionsReturned::Read(message, &autofill_param); |
| 779 if (page_id) | 780 if (page_id) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 FormData form; | 892 FormData form; |
| 892 CreateTestAddressFormData(&form); | 893 CreateTestAddressFormData(&form); |
| 893 std::vector<FormData> forms(1, form); | 894 std::vector<FormData> forms(1, form); |
| 894 FormsSeen(forms); | 895 FormsSeen(forms); |
| 895 | 896 |
| 896 const FormFieldData& field = form.fields[0]; | 897 const FormFieldData& field = form.fields[0]; |
| 897 GetAutofillSuggestions(form, field); | 898 GetAutofillSuggestions(form, field); |
| 898 | 899 |
| 899 // No suggestions provided, so send an empty vector as the results. | 900 // No suggestions provided, so send an empty vector as the results. |
| 900 // This triggers the combined message send. | 901 // This triggers the combined message send. |
| 901 AutocompleteSuggestionsReturned(std::vector<string16>()); | 902 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 902 | 903 |
| 903 // Test that we sent the right message to the renderer. | 904 // Test that we sent the right message to the renderer. |
| 904 int page_id = 0; | 905 int page_id = 0; |
| 905 std::vector<string16> values; | 906 std::vector<base::string16> values; |
| 906 std::vector<string16> labels; | 907 std::vector<base::string16> labels; |
| 907 std::vector<string16> icons; | 908 std::vector<base::string16> icons; |
| 908 std::vector<int> unique_ids; | 909 std::vector<int> unique_ids; |
| 909 GetAutofillSuggestionsMessage( | 910 GetAutofillSuggestionsMessage( |
| 910 &page_id, &values, &labels, &icons, &unique_ids); | 911 &page_id, &values, &labels, &icons, &unique_ids); |
| 911 | 912 |
| 912 string16 expected_values[] = { | 913 base::string16 expected_values[] = { |
| 913 ASCIIToUTF16("Elvis"), | 914 ASCIIToUTF16("Elvis"), |
| 914 ASCIIToUTF16("Charles") | 915 ASCIIToUTF16("Charles") |
| 915 }; | 916 }; |
| 916 // Inferred labels include full first relevant field, which in this case is | 917 // Inferred labels include full first relevant field, which in this case is |
| 917 // the address line 1. | 918 // the address line 1. |
| 918 string16 expected_labels[] = { | 919 base::string16 expected_labels[] = { |
| 919 ASCIIToUTF16("3734 Elvis Presley Blvd."), | 920 ASCIIToUTF16("3734 Elvis Presley Blvd."), |
| 920 ASCIIToUTF16("123 Apple St.") | 921 ASCIIToUTF16("123 Apple St.") |
| 921 }; | 922 }; |
| 922 string16 expected_icons[] = {string16(), string16()}; | 923 base::string16 expected_icons[] = {base::string16(), base::string16()}; |
| 923 int expected_unique_ids[] = {1, 2}; | 924 int expected_unique_ids[] = {1, 2}; |
| 924 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 925 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 925 kDefaultPageID, arraysize(expected_values), expected_values, | 926 kDefaultPageID, arraysize(expected_values), expected_values, |
| 926 expected_labels, expected_icons, expected_unique_ids); | 927 expected_labels, expected_icons, expected_unique_ids); |
| 927 } | 928 } |
| 928 | 929 |
| 929 // Test that in the case of Autocheckout, forms seen are in order supplied. | 930 // Test that in the case of Autocheckout, forms seen are in order supplied. |
| 930 TEST_F(AutofillManagerTest, AutocheckoutFormsSeen) { | 931 TEST_F(AutofillManagerTest, AutocheckoutFormsSeen) { |
| 931 FormData shipping_options; | 932 FormData shipping_options; |
| 932 CreateTestShippingOptionsFormData(&shipping_options); | 933 CreateTestShippingOptionsFormData(&shipping_options); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 std::vector<FormData> forms(1, form); | 973 std::vector<FormData> forms(1, form); |
| 973 FormsSeen(forms); | 974 FormsSeen(forms); |
| 974 | 975 |
| 975 FormFieldData field; | 976 FormFieldData field; |
| 976 autofill_test::CreateTestFormField("First Name", "firstname", "E", "text", | 977 autofill_test::CreateTestFormField("First Name", "firstname", "E", "text", |
| 977 &field); | 978 &field); |
| 978 GetAutofillSuggestions(form, field); | 979 GetAutofillSuggestions(form, field); |
| 979 | 980 |
| 980 // No suggestions provided, so send an empty vector as the results. | 981 // No suggestions provided, so send an empty vector as the results. |
| 981 // This triggers the combined message send. | 982 // This triggers the combined message send. |
| 982 AutocompleteSuggestionsReturned(std::vector<string16>()); | 983 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 983 | 984 |
| 984 // Test that we sent the right message to the renderer. | 985 // Test that we sent the right message to the renderer. |
| 985 int page_id = 0; | 986 int page_id = 0; |
| 986 std::vector<string16> values; | 987 std::vector<base::string16> values; |
| 987 std::vector<string16> labels; | 988 std::vector<base::string16> labels; |
| 988 std::vector<string16> icons; | 989 std::vector<base::string16> icons; |
| 989 std::vector<int> unique_ids; | 990 std::vector<int> unique_ids; |
| 990 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 991 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 991 &unique_ids)); | 992 &unique_ids)); |
| 992 | 993 |
| 993 string16 expected_values[] = {ASCIIToUTF16("Elvis")}; | 994 base::string16 expected_values[] = {ASCIIToUTF16("Elvis")}; |
| 994 string16 expected_labels[] = {ASCIIToUTF16("3734 Elvis Presley Blvd.")}; | 995 base::string16 expected_labels[] = {ASCIIToUTF16("3734 Elvis Presley Blvd.")}; |
| 995 string16 expected_icons[] = {string16()}; | 996 base::string16 expected_icons[] = {base::string16()}; |
| 996 int expected_unique_ids[] = {1}; | 997 int expected_unique_ids[] = {1}; |
| 997 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 998 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 998 kDefaultPageID, arraysize(expected_values), expected_values, | 999 kDefaultPageID, arraysize(expected_values), expected_values, |
| 999 expected_labels, expected_icons, expected_unique_ids); | 1000 expected_labels, expected_icons, expected_unique_ids); |
| 1000 } | 1001 } |
| 1001 | 1002 |
| 1002 // Test that we return no suggestions when the form has no relevant fields. | 1003 // Test that we return no suggestions when the form has no relevant fields. |
| 1003 TEST_F(AutofillManagerTest, GetProfileSuggestionsUnknownFields) { | 1004 TEST_F(AutofillManagerTest, GetProfileSuggestionsUnknownFields) { |
| 1004 // Set up our form data. | 1005 // Set up our form data. |
| 1005 FormData form; | 1006 FormData form; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 new AutofillProfile( | 1042 new AutofillProfile( |
| 1042 *(autofill_manager_->GetProfileWithGUID( | 1043 *(autofill_manager_->GetProfileWithGUID( |
| 1043 "00000000-0000-0000-0000-000000000001"))); | 1044 "00000000-0000-0000-0000-000000000001"))); |
| 1044 autofill_manager_->AddProfile(duplicate_profile); | 1045 autofill_manager_->AddProfile(duplicate_profile); |
| 1045 | 1046 |
| 1046 const FormFieldData& field = form.fields[0]; | 1047 const FormFieldData& field = form.fields[0]; |
| 1047 GetAutofillSuggestions(form, field); | 1048 GetAutofillSuggestions(form, field); |
| 1048 | 1049 |
| 1049 // No suggestions provided, so send an empty vector as the results. | 1050 // No suggestions provided, so send an empty vector as the results. |
| 1050 // This triggers the combined message send. | 1051 // This triggers the combined message send. |
| 1051 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1052 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1052 | 1053 |
| 1053 // Test that we sent the right message to the renderer. | 1054 // Test that we sent the right message to the renderer. |
| 1054 int page_id = 0; | 1055 int page_id = 0; |
| 1055 std::vector<string16> values; | 1056 std::vector<base::string16> values; |
| 1056 std::vector<string16> labels; | 1057 std::vector<base::string16> labels; |
| 1057 std::vector<string16> icons; | 1058 std::vector<base::string16> icons; |
| 1058 std::vector<int> unique_ids; | 1059 std::vector<int> unique_ids; |
| 1059 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1060 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1060 &unique_ids)); | 1061 &unique_ids)); |
| 1061 | 1062 |
| 1062 string16 expected_values[] = { | 1063 base::string16 expected_values[] = { |
| 1063 ASCIIToUTF16("Elvis"), | 1064 ASCIIToUTF16("Elvis"), |
| 1064 ASCIIToUTF16("Charles") | 1065 ASCIIToUTF16("Charles") |
| 1065 }; | 1066 }; |
| 1066 string16 expected_labels[] = { | 1067 base::string16 expected_labels[] = { |
| 1067 ASCIIToUTF16("3734 Elvis Presley Blvd."), | 1068 ASCIIToUTF16("3734 Elvis Presley Blvd."), |
| 1068 ASCIIToUTF16("123 Apple St.") | 1069 ASCIIToUTF16("123 Apple St.") |
| 1069 }; | 1070 }; |
| 1070 string16 expected_icons[] = {string16(), string16()}; | 1071 base::string16 expected_icons[] = {base::string16(), base::string16()}; |
| 1071 int expected_unique_ids[] = {1, 2}; | 1072 int expected_unique_ids[] = {1, 2}; |
| 1072 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1073 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1073 kDefaultPageID, arraysize(expected_values), expected_values, | 1074 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1074 expected_labels, expected_icons, expected_unique_ids); | 1075 expected_labels, expected_icons, expected_unique_ids); |
| 1075 } | 1076 } |
| 1076 | 1077 |
| 1077 // Test that we return no suggestions when autofill is disabled. | 1078 // Test that we return no suggestions when autofill is disabled. |
| 1078 TEST_F(AutofillManagerTest, GetProfileSuggestionsAutofillDisabledByUser) { | 1079 TEST_F(AutofillManagerTest, GetProfileSuggestionsAutofillDisabledByUser) { |
| 1079 // Set up our form data. | 1080 // Set up our form data. |
| 1080 FormData form; | 1081 FormData form; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1098 CreateTestAddressFormData(&form); | 1099 CreateTestAddressFormData(&form); |
| 1099 form.method = ASCIIToUTF16("GET"); | 1100 form.method = ASCIIToUTF16("GET"); |
| 1100 std::vector<FormData> forms(1, form); | 1101 std::vector<FormData> forms(1, form); |
| 1101 FormsSeen(forms); | 1102 FormsSeen(forms); |
| 1102 | 1103 |
| 1103 const FormFieldData& field = form.fields[0]; | 1104 const FormFieldData& field = form.fields[0]; |
| 1104 GetAutofillSuggestions(form, field); | 1105 GetAutofillSuggestions(form, field); |
| 1105 | 1106 |
| 1106 // No suggestions provided, so send an empty vector as the results. | 1107 // No suggestions provided, so send an empty vector as the results. |
| 1107 // This triggers the combined message send. | 1108 // This triggers the combined message send. |
| 1108 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1109 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1109 | 1110 |
| 1110 // Test that we sent the right message to the renderer. | 1111 // Test that we sent the right message to the renderer. |
| 1111 int page_id = 0; | 1112 int page_id = 0; |
| 1112 std::vector<string16> values; | 1113 std::vector<base::string16> values; |
| 1113 std::vector<string16> labels; | 1114 std::vector<base::string16> labels; |
| 1114 std::vector<string16> icons; | 1115 std::vector<base::string16> icons; |
| 1115 std::vector<int> unique_ids; | 1116 std::vector<int> unique_ids; |
| 1116 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1117 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1117 &unique_ids)); | 1118 &unique_ids)); |
| 1118 | 1119 |
| 1119 string16 expected_values[] = { | 1120 base::string16 expected_values[] = { |
| 1120 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED) | 1121 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED) |
| 1121 }; | 1122 }; |
| 1122 string16 expected_labels[] = {string16()}; | 1123 base::string16 expected_labels[] = {base::string16()}; |
| 1123 string16 expected_icons[] = {string16()}; | 1124 base::string16 expected_icons[] = {base::string16()}; |
| 1124 int expected_unique_ids[] = | 1125 int expected_unique_ids[] = |
| 1125 {WebKit::WebAutofillClient::MenuItemIDWarningMessage}; | 1126 {WebKit::WebAutofillClient::MenuItemIDWarningMessage}; |
| 1126 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1127 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1127 kDefaultPageID, arraysize(expected_values), expected_values, | 1128 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1128 expected_labels, expected_icons, expected_unique_ids); | 1129 expected_labels, expected_icons, expected_unique_ids); |
| 1129 | 1130 |
| 1130 // Now add some Autocomplete suggestions. We should return the autocomplete | 1131 // Now add some Autocomplete suggestions. We should return the autocomplete |
| 1131 // suggestions and the warning; these will be culled by the renderer. | 1132 // suggestions and the warning; these will be culled by the renderer. |
| 1132 const int kPageID2 = 2; | 1133 const int kPageID2 = 2; |
| 1133 GetAutofillSuggestions(kPageID2, form, field); | 1134 GetAutofillSuggestions(kPageID2, form, field); |
| 1134 | 1135 |
| 1135 std::vector<string16> suggestions; | 1136 std::vector<base::string16> suggestions; |
| 1136 suggestions.push_back(ASCIIToUTF16("Jay")); | 1137 suggestions.push_back(ASCIIToUTF16("Jay")); |
| 1137 suggestions.push_back(ASCIIToUTF16("Jason")); | 1138 suggestions.push_back(ASCIIToUTF16("Jason")); |
| 1138 AutocompleteSuggestionsReturned(suggestions); | 1139 AutocompleteSuggestionsReturned(suggestions); |
| 1139 | 1140 |
| 1140 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1141 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1141 &unique_ids)); | 1142 &unique_ids)); |
| 1142 | 1143 |
| 1143 string16 expected_values2[] = { | 1144 base::string16 expected_values2[] = { |
| 1144 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED), | 1145 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_FORM_DISABLED), |
| 1145 ASCIIToUTF16("Jay"), | 1146 ASCIIToUTF16("Jay"), |
| 1146 ASCIIToUTF16("Jason") | 1147 ASCIIToUTF16("Jason") |
| 1147 }; | 1148 }; |
| 1148 string16 expected_labels2[] = {string16(), string16(), string16()}; | 1149 base::string16 expected_labels2[] = { base::string16(), base::string16(), |
| 1149 string16 expected_icons2[] = {string16(), string16(), string16()}; | 1150 base::string16()}; |
| 1151 base::string16 expected_icons2[] = { base::string16(), base::string16(), |
| 1152 base::string16()}; |
| 1150 int expected_unique_ids2[] = {-1, 0, 0}; | 1153 int expected_unique_ids2[] = {-1, 0, 0}; |
| 1151 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1154 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1152 kPageID2, arraysize(expected_values2), expected_values2, | 1155 kPageID2, arraysize(expected_values2), expected_values2, |
| 1153 expected_labels2, expected_icons2, expected_unique_ids2); | 1156 expected_labels2, expected_icons2, expected_unique_ids2); |
| 1154 | 1157 |
| 1155 // Now clear the test profiles and try again -- we shouldn't return a warning. | 1158 // Now clear the test profiles and try again -- we shouldn't return a warning. |
| 1156 personal_data_.ClearAutofillProfiles(); | 1159 personal_data_.ClearAutofillProfiles(); |
| 1157 GetAutofillSuggestions(form, field); | 1160 GetAutofillSuggestions(form, field); |
| 1158 EXPECT_FALSE(GetAutofillSuggestionsMessage(NULL, NULL, NULL, NULL, NULL)); | 1161 EXPECT_FALSE(GetAutofillSuggestionsMessage(NULL, NULL, NULL, NULL, NULL)); |
| 1159 } | 1162 } |
| 1160 | 1163 |
| 1161 // Test that we return all credit card profile suggestions when all form fields | 1164 // Test that we return all credit card profile suggestions when all form fields |
| 1162 // are empty. | 1165 // are empty. |
| 1163 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsEmptyValue) { | 1166 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsEmptyValue) { |
| 1164 // Set up our form data. | 1167 // Set up our form data. |
| 1165 FormData form; | 1168 FormData form; |
| 1166 CreateTestCreditCardFormData(&form, true, false); | 1169 CreateTestCreditCardFormData(&form, true, false); |
| 1167 std::vector<FormData> forms(1, form); | 1170 std::vector<FormData> forms(1, form); |
| 1168 FormsSeen(forms); | 1171 FormsSeen(forms); |
| 1169 | 1172 |
| 1170 FormFieldData field = form.fields[1]; | 1173 FormFieldData field = form.fields[1]; |
| 1171 GetAutofillSuggestions(form, field); | 1174 GetAutofillSuggestions(form, field); |
| 1172 | 1175 |
| 1173 // No suggestions provided, so send an empty vector as the results. | 1176 // No suggestions provided, so send an empty vector as the results. |
| 1174 // This triggers the combined message send. | 1177 // This triggers the combined message send. |
| 1175 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1178 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1176 | 1179 |
| 1177 // Test that we sent the right message to the renderer. | 1180 // Test that we sent the right message to the renderer. |
| 1178 int page_id = 0; | 1181 int page_id = 0; |
| 1179 std::vector<string16> values; | 1182 std::vector<base::string16> values; |
| 1180 std::vector<string16> labels; | 1183 std::vector<base::string16> labels; |
| 1181 std::vector<string16> icons; | 1184 std::vector<base::string16> icons; |
| 1182 std::vector<int> unique_ids; | 1185 std::vector<int> unique_ids; |
| 1183 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1186 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1184 &unique_ids)); | 1187 &unique_ids)); |
| 1185 | 1188 |
| 1186 string16 expected_values[] = { | 1189 base::string16 expected_values[] = { |
| 1187 ASCIIToUTF16("************3456"), | 1190 ASCIIToUTF16("************3456"), |
| 1188 ASCIIToUTF16("************8765") | 1191 ASCIIToUTF16("************8765") |
| 1189 }; | 1192 }; |
| 1190 string16 expected_labels[] = {ASCIIToUTF16("*3456"), ASCIIToUTF16("*8765")}; | 1193 base::string16 expected_labels[] = { ASCIIToUTF16("*3456"), |
| 1191 string16 expected_icons[] = { | 1194 ASCIIToUTF16("*8765")}; |
| 1195 base::string16 expected_icons[] = { |
| 1192 ASCIIToUTF16("visaCC"), | 1196 ASCIIToUTF16("visaCC"), |
| 1193 ASCIIToUTF16("genericCC") | 1197 ASCIIToUTF16("genericCC") |
| 1194 }; | 1198 }; |
| 1195 int expected_unique_ids[] = { | 1199 int expected_unique_ids[] = { |
| 1196 autofill_manager_->GetPackedCreditCardID(4), | 1200 autofill_manager_->GetPackedCreditCardID(4), |
| 1197 autofill_manager_->GetPackedCreditCardID(5) | 1201 autofill_manager_->GetPackedCreditCardID(5) |
| 1198 }; | 1202 }; |
| 1199 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1203 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1200 kDefaultPageID, arraysize(expected_values), expected_values, | 1204 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1201 expected_labels, expected_icons, expected_unique_ids); | 1205 expected_labels, expected_icons, expected_unique_ids); |
| 1202 } | 1206 } |
| 1203 | 1207 |
| 1204 // Test that we return only matching credit card profile suggestions when the | 1208 // Test that we return only matching credit card profile suggestions when the |
| 1205 // selected form field has been partially filled out. | 1209 // selected form field has been partially filled out. |
| 1206 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsMatchCharacter) { | 1210 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsMatchCharacter) { |
| 1207 // Set up our form data. | 1211 // Set up our form data. |
| 1208 FormData form; | 1212 FormData form; |
| 1209 CreateTestCreditCardFormData(&form, true, false); | 1213 CreateTestCreditCardFormData(&form, true, false); |
| 1210 std::vector<FormData> forms(1, form); | 1214 std::vector<FormData> forms(1, form); |
| 1211 FormsSeen(forms); | 1215 FormsSeen(forms); |
| 1212 | 1216 |
| 1213 FormFieldData field; | 1217 FormFieldData field; |
| 1214 autofill_test::CreateTestFormField( | 1218 autofill_test::CreateTestFormField( |
| 1215 "Card Number", "cardnumber", "4", "text", &field); | 1219 "Card Number", "cardnumber", "4", "text", &field); |
| 1216 GetAutofillSuggestions(form, field); | 1220 GetAutofillSuggestions(form, field); |
| 1217 | 1221 |
| 1218 // No suggestions provided, so send an empty vector as the results. | 1222 // No suggestions provided, so send an empty vector as the results. |
| 1219 // This triggers the combined message send. | 1223 // This triggers the combined message send. |
| 1220 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1224 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1221 | 1225 |
| 1222 // Test that we sent the right message to the renderer. | 1226 // Test that we sent the right message to the renderer. |
| 1223 int page_id = 0; | 1227 int page_id = 0; |
| 1224 std::vector<string16> values; | 1228 std::vector<base::string16> values; |
| 1225 std::vector<string16> labels; | 1229 std::vector<base::string16> labels; |
| 1226 std::vector<string16> icons; | 1230 std::vector<base::string16> icons; |
| 1227 std::vector<int> unique_ids; | 1231 std::vector<int> unique_ids; |
| 1228 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1232 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1229 &unique_ids)); | 1233 &unique_ids)); |
| 1230 | 1234 |
| 1231 string16 expected_values[] = {ASCIIToUTF16("************3456")}; | 1235 base::string16 expected_values[] = {ASCIIToUTF16("************3456")}; |
| 1232 string16 expected_labels[] = {ASCIIToUTF16("*3456")}; | 1236 base::string16 expected_labels[] = {ASCIIToUTF16("*3456")}; |
| 1233 string16 expected_icons[] = {ASCIIToUTF16("visaCC")}; | 1237 base::string16 expected_icons[] = {ASCIIToUTF16("visaCC")}; |
| 1234 int expected_unique_ids[] = {autofill_manager_->GetPackedCreditCardID(4)}; | 1238 int expected_unique_ids[] = {autofill_manager_->GetPackedCreditCardID(4)}; |
| 1235 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1239 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1236 kDefaultPageID, arraysize(expected_values), expected_values, | 1240 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1237 expected_labels, expected_icons, expected_unique_ids); | 1241 expected_labels, expected_icons, expected_unique_ids); |
| 1238 } | 1242 } |
| 1239 | 1243 |
| 1240 // Test that we return credit card profile suggestions when the selected form | 1244 // Test that we return credit card profile suggestions when the selected form |
| 1241 // field is not the credit card number field. | 1245 // field is not the credit card number field. |
| 1242 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 1246 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { |
| 1243 // Set up our form data. | 1247 // Set up our form data. |
| 1244 FormData form; | 1248 FormData form; |
| 1245 CreateTestCreditCardFormData(&form, true, false); | 1249 CreateTestCreditCardFormData(&form, true, false); |
| 1246 std::vector<FormData> forms(1, form); | 1250 std::vector<FormData> forms(1, form); |
| 1247 FormsSeen(forms); | 1251 FormsSeen(forms); |
| 1248 | 1252 |
| 1249 const FormFieldData& field = form.fields[0]; | 1253 const FormFieldData& field = form.fields[0]; |
| 1250 GetAutofillSuggestions(form, field); | 1254 GetAutofillSuggestions(form, field); |
| 1251 | 1255 |
| 1252 // No suggestions provided, so send an empty vector as the results. | 1256 // No suggestions provided, so send an empty vector as the results. |
| 1253 // This triggers the combined message send. | 1257 // This triggers the combined message send. |
| 1254 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1258 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1255 | 1259 |
| 1256 // Test that we sent the right message to the renderer. | 1260 // Test that we sent the right message to the renderer. |
| 1257 int page_id = 0; | 1261 int page_id = 0; |
| 1258 std::vector<string16> values; | 1262 std::vector<base::string16> values; |
| 1259 std::vector<string16> labels; | 1263 std::vector<base::string16> labels; |
| 1260 std::vector<string16> icons; | 1264 std::vector<base::string16> icons; |
| 1261 std::vector<int> unique_ids; | 1265 std::vector<int> unique_ids; |
| 1262 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1266 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1263 &unique_ids)); | 1267 &unique_ids)); |
| 1264 | 1268 |
| 1265 string16 expected_values[] = { | 1269 base::string16 expected_values[] = { |
| 1266 ASCIIToUTF16("Elvis Presley"), | 1270 ASCIIToUTF16("Elvis Presley"), |
| 1267 ASCIIToUTF16("Buddy Holly") | 1271 ASCIIToUTF16("Buddy Holly") |
| 1268 }; | 1272 }; |
| 1269 string16 expected_labels[] = {ASCIIToUTF16("*3456"), ASCIIToUTF16("*8765")}; | 1273 base::string16 expected_labels[] = { ASCIIToUTF16("*3456"), |
| 1270 string16 expected_icons[] = { | 1274 ASCIIToUTF16("*8765") }; |
| 1275 base::string16 expected_icons[] = { |
| 1271 ASCIIToUTF16("visaCC"), | 1276 ASCIIToUTF16("visaCC"), |
| 1272 ASCIIToUTF16("genericCC") | 1277 ASCIIToUTF16("genericCC") |
| 1273 }; | 1278 }; |
| 1274 int expected_unique_ids[] = { | 1279 int expected_unique_ids[] = { |
| 1275 autofill_manager_->GetPackedCreditCardID(4), | 1280 autofill_manager_->GetPackedCreditCardID(4), |
| 1276 autofill_manager_->GetPackedCreditCardID(5) | 1281 autofill_manager_->GetPackedCreditCardID(5) |
| 1277 }; | 1282 }; |
| 1278 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1283 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1279 kDefaultPageID, arraysize(expected_values), expected_values, | 1284 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1280 expected_labels, expected_icons, expected_unique_ids); | 1285 expected_labels, expected_icons, expected_unique_ids); |
| 1281 } | 1286 } |
| 1282 | 1287 |
| 1283 // Test that we return a warning explaining that credit card profile suggestions | 1288 // Test that we return a warning explaining that credit card profile suggestions |
| 1284 // are unavailable when the form is not https. | 1289 // are unavailable when the form is not https. |
| 1285 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonHTTPS) { | 1290 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonHTTPS) { |
| 1286 // Set up our form data. | 1291 // Set up our form data. |
| 1287 FormData form; | 1292 FormData form; |
| 1288 CreateTestCreditCardFormData(&form, false, false); | 1293 CreateTestCreditCardFormData(&form, false, false); |
| 1289 std::vector<FormData> forms(1, form); | 1294 std::vector<FormData> forms(1, form); |
| 1290 FormsSeen(forms); | 1295 FormsSeen(forms); |
| 1291 | 1296 |
| 1292 const FormFieldData& field = form.fields[0]; | 1297 const FormFieldData& field = form.fields[0]; |
| 1293 GetAutofillSuggestions(form, field); | 1298 GetAutofillSuggestions(form, field); |
| 1294 | 1299 |
| 1295 // No suggestions provided, so send an empty vector as the results. | 1300 // No suggestions provided, so send an empty vector as the results. |
| 1296 // This triggers the combined message send. | 1301 // This triggers the combined message send. |
| 1297 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1302 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1298 | 1303 |
| 1299 // Test that we sent the right message to the renderer. | 1304 // Test that we sent the right message to the renderer. |
| 1300 int page_id = 0; | 1305 int page_id = 0; |
| 1301 std::vector<string16> values; | 1306 std::vector<base::string16> values; |
| 1302 std::vector<string16> labels; | 1307 std::vector<base::string16> labels; |
| 1303 std::vector<string16> icons; | 1308 std::vector<base::string16> icons; |
| 1304 std::vector<int> unique_ids; | 1309 std::vector<int> unique_ids; |
| 1305 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1310 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1306 &unique_ids)); | 1311 &unique_ids)); |
| 1307 | 1312 |
| 1308 string16 expected_values[] = { | 1313 base::string16 expected_values[] = { |
| 1309 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION) | 1314 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION) |
| 1310 }; | 1315 }; |
| 1311 string16 expected_labels[] = {string16()}; | 1316 base::string16 expected_labels[] = {base::string16()}; |
| 1312 string16 expected_icons[] = {string16()}; | 1317 base::string16 expected_icons[] = {base::string16()}; |
| 1313 int expected_unique_ids[] = {-1}; | 1318 int expected_unique_ids[] = {-1}; |
| 1314 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1319 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1315 kDefaultPageID, arraysize(expected_values), expected_values, | 1320 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1316 expected_labels, expected_icons, expected_unique_ids); | 1321 expected_labels, expected_icons, expected_unique_ids); |
| 1317 | 1322 |
| 1318 // Now add some Autocomplete suggestions. We should show the autocomplete | 1323 // Now add some Autocomplete suggestions. We should show the autocomplete |
| 1319 // suggestions and the warning. | 1324 // suggestions and the warning. |
| 1320 const int kPageID2 = 2; | 1325 const int kPageID2 = 2; |
| 1321 GetAutofillSuggestions(kPageID2, form, field); | 1326 GetAutofillSuggestions(kPageID2, form, field); |
| 1322 | 1327 |
| 1323 std::vector<string16> suggestions; | 1328 std::vector<base::string16> suggestions; |
| 1324 suggestions.push_back(ASCIIToUTF16("Jay")); | 1329 suggestions.push_back(ASCIIToUTF16("Jay")); |
| 1325 suggestions.push_back(ASCIIToUTF16("Jason")); | 1330 suggestions.push_back(ASCIIToUTF16("Jason")); |
| 1326 AutocompleteSuggestionsReturned(suggestions); | 1331 AutocompleteSuggestionsReturned(suggestions); |
| 1327 | 1332 |
| 1328 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1333 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1329 &unique_ids)); | 1334 &unique_ids)); |
| 1330 string16 expected_values2[] = { | 1335 base::string16 expected_values2[] = { |
| 1331 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), | 1336 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION), |
| 1332 ASCIIToUTF16("Jay"), | 1337 ASCIIToUTF16("Jay"), |
| 1333 ASCIIToUTF16("Jason") | 1338 ASCIIToUTF16("Jason") |
| 1334 }; | 1339 }; |
| 1335 string16 expected_labels2[] = {string16(), string16(), string16()}; | 1340 base::string16 expected_labels2[] = { base::string16(), base::string16(), |
| 1336 string16 expected_icons2[] = {string16(), string16(), string16()}; | 1341 base::string16() }; |
| 1342 base::string16 expected_icons2[] = { base::string16(), base::string16(), |
| 1343 base::string16() }; |
| 1337 int expected_unique_ids2[] = {-1, 0, 0}; | 1344 int expected_unique_ids2[] = {-1, 0, 0}; |
| 1338 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1345 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1339 kPageID2, arraysize(expected_values2), expected_values2, | 1346 kPageID2, arraysize(expected_values2), expected_values2, |
| 1340 expected_labels2, expected_icons2, expected_unique_ids2); | 1347 expected_labels2, expected_icons2, expected_unique_ids2); |
| 1341 | 1348 |
| 1342 // Clear the test credit cards and try again -- we shouldn't return a warning. | 1349 // Clear the test credit cards and try again -- we shouldn't return a warning. |
| 1343 personal_data_.ClearCreditCards(); | 1350 personal_data_.ClearCreditCards(); |
| 1344 GetAutofillSuggestions(form, field); | 1351 GetAutofillSuggestions(form, field); |
| 1345 EXPECT_FALSE(GetAutofillSuggestionsMessage(NULL, NULL, NULL, NULL, NULL)); | 1352 EXPECT_FALSE(GetAutofillSuggestionsMessage(NULL, NULL, NULL, NULL, NULL)); |
| 1346 } | 1353 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1361 FormData form; | 1368 FormData form; |
| 1362 CreateTestCreditCardFormData(&form, true, false); | 1369 CreateTestCreditCardFormData(&form, true, false); |
| 1363 std::vector<FormData> forms(1, form); | 1370 std::vector<FormData> forms(1, form); |
| 1364 FormsSeen(forms); | 1371 FormsSeen(forms); |
| 1365 | 1372 |
| 1366 FormFieldData field = form.fields[1]; | 1373 FormFieldData field = form.fields[1]; |
| 1367 GetAutofillSuggestions(form, field); | 1374 GetAutofillSuggestions(form, field); |
| 1368 | 1375 |
| 1369 // No suggestions provided, so send an empty vector as the results. | 1376 // No suggestions provided, so send an empty vector as the results. |
| 1370 // This triggers the combined message send. | 1377 // This triggers the combined message send. |
| 1371 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1378 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1372 | 1379 |
| 1373 // Test that we sent the right message to the renderer. | 1380 // Test that we sent the right message to the renderer. |
| 1374 int page_id = 0; | 1381 int page_id = 0; |
| 1375 std::vector<string16> values; | 1382 std::vector<base::string16> values; |
| 1376 std::vector<string16> labels; | 1383 std::vector<base::string16> labels; |
| 1377 std::vector<string16> icons; | 1384 std::vector<base::string16> icons; |
| 1378 std::vector<int> unique_ids; | 1385 std::vector<int> unique_ids; |
| 1379 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1386 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1380 &unique_ids)); | 1387 &unique_ids)); |
| 1381 | 1388 |
| 1382 string16 expected_values[] = { | 1389 base::string16 expected_values[] = { |
| 1383 ASCIIToUTF16("************3456"), | 1390 ASCIIToUTF16("************3456"), |
| 1384 ASCIIToUTF16("************8765"), | 1391 ASCIIToUTF16("************8765"), |
| 1385 ASCIIToUTF16("************3456") | 1392 ASCIIToUTF16("************3456") |
| 1386 }; | 1393 }; |
| 1387 string16 expected_labels[] = { | 1394 base::string16 expected_labels[] = { |
| 1388 ASCIIToUTF16("*3456"), | 1395 ASCIIToUTF16("*3456"), |
| 1389 ASCIIToUTF16("*8765"), | 1396 ASCIIToUTF16("*8765"), |
| 1390 ASCIIToUTF16("*3456"), | 1397 ASCIIToUTF16("*3456"), |
| 1391 }; | 1398 }; |
| 1392 string16 expected_icons[] = { | 1399 base::string16 expected_icons[] = { |
| 1393 ASCIIToUTF16("visaCC"), | 1400 ASCIIToUTF16("visaCC"), |
| 1394 ASCIIToUTF16("genericCC"), | 1401 ASCIIToUTF16("genericCC"), |
| 1395 ASCIIToUTF16("masterCardCC") | 1402 ASCIIToUTF16("masterCardCC") |
| 1396 }; | 1403 }; |
| 1397 int expected_unique_ids[] = { | 1404 int expected_unique_ids[] = { |
| 1398 autofill_manager_->GetPackedCreditCardID(4), | 1405 autofill_manager_->GetPackedCreditCardID(4), |
| 1399 autofill_manager_->GetPackedCreditCardID(5), | 1406 autofill_manager_->GetPackedCreditCardID(5), |
| 1400 autofill_manager_->GetPackedCreditCardID(7) | 1407 autofill_manager_->GetPackedCreditCardID(7) |
| 1401 }; | 1408 }; |
| 1402 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1409 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1403 kDefaultPageID, arraysize(expected_values), expected_values, | 1410 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1404 expected_labels, expected_icons, expected_unique_ids); | 1411 expected_labels, expected_icons, expected_unique_ids); |
| 1405 } | 1412 } |
| 1406 | 1413 |
| 1407 // Test that we return profile and credit card suggestions for combined forms. | 1414 // Test that we return profile and credit card suggestions for combined forms. |
| 1408 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { | 1415 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { |
| 1409 // Set up our form data. | 1416 // Set up our form data. |
| 1410 FormData form; | 1417 FormData form; |
| 1411 CreateTestAddressFormData(&form); | 1418 CreateTestAddressFormData(&form); |
| 1412 CreateTestCreditCardFormData(&form, true, false); | 1419 CreateTestCreditCardFormData(&form, true, false); |
| 1413 std::vector<FormData> forms(1, form); | 1420 std::vector<FormData> forms(1, form); |
| 1414 FormsSeen(forms); | 1421 FormsSeen(forms); |
| 1415 | 1422 |
| 1416 FormFieldData field = form.fields[0]; | 1423 FormFieldData field = form.fields[0]; |
| 1417 GetAutofillSuggestions(form, field); | 1424 GetAutofillSuggestions(form, field); |
| 1418 | 1425 |
| 1419 // No suggestions provided, so send an empty vector as the results. | 1426 // No suggestions provided, so send an empty vector as the results. |
| 1420 // This triggers the combined message send. | 1427 // This triggers the combined message send. |
| 1421 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1428 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1422 | 1429 |
| 1423 // Test that we sent the right address suggestions to the renderer. | 1430 // Test that we sent the right address suggestions to the renderer. |
| 1424 int page_id = 0; | 1431 int page_id = 0; |
| 1425 std::vector<string16> values; | 1432 std::vector<base::string16> values; |
| 1426 std::vector<string16> labels; | 1433 std::vector<base::string16> labels; |
| 1427 std::vector<string16> icons; | 1434 std::vector<base::string16> icons; |
| 1428 std::vector<int> unique_ids; | 1435 std::vector<int> unique_ids; |
| 1429 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1436 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1430 &unique_ids)); | 1437 &unique_ids)); |
| 1431 | 1438 |
| 1432 string16 expected_values[] = { | 1439 base::string16 expected_values[] = { |
| 1433 ASCIIToUTF16("Elvis"), | 1440 ASCIIToUTF16("Elvis"), |
| 1434 ASCIIToUTF16("Charles") | 1441 ASCIIToUTF16("Charles") |
| 1435 }; | 1442 }; |
| 1436 string16 expected_labels[] = { | 1443 base::string16 expected_labels[] = { |
| 1437 ASCIIToUTF16("3734 Elvis Presley Blvd."), | 1444 ASCIIToUTF16("3734 Elvis Presley Blvd."), |
| 1438 ASCIIToUTF16("123 Apple St.") | 1445 ASCIIToUTF16("123 Apple St.") |
| 1439 }; | 1446 }; |
| 1440 string16 expected_icons[] = {string16(), string16()}; | 1447 base::string16 expected_icons[] = {base::string16(), base::string16()}; |
| 1441 int expected_unique_ids[] = {1, 2}; | 1448 int expected_unique_ids[] = {1, 2}; |
| 1442 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1449 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1443 kDefaultPageID, arraysize(expected_values), expected_values, | 1450 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1444 expected_labels, expected_icons, expected_unique_ids); | 1451 expected_labels, expected_icons, expected_unique_ids); |
| 1445 | 1452 |
| 1446 const int kPageID2 = 2; | 1453 const int kPageID2 = 2; |
| 1447 autofill_test::CreateTestFormField( | 1454 autofill_test::CreateTestFormField( |
| 1448 "Card Number", "cardnumber", "", "text", &field); | 1455 "Card Number", "cardnumber", "", "text", &field); |
| 1449 GetAutofillSuggestions(kPageID2, form, field); | 1456 GetAutofillSuggestions(kPageID2, form, field); |
| 1450 | 1457 |
| 1451 // No suggestions provided, so send an empty vector as the results. | 1458 // No suggestions provided, so send an empty vector as the results. |
| 1452 // This triggers the combined message send. | 1459 // This triggers the combined message send. |
| 1453 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1460 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1454 | 1461 |
| 1455 // Test that we sent the credit card suggestions to the renderer. | 1462 // Test that we sent the credit card suggestions to the renderer. |
| 1456 page_id = 0; | 1463 page_id = 0; |
| 1457 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1464 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1458 &unique_ids)); | 1465 &unique_ids)); |
| 1459 | 1466 |
| 1460 string16 expected_values2[] = { | 1467 base::string16 expected_values2[] = { |
| 1461 ASCIIToUTF16("************3456"), | 1468 ASCIIToUTF16("************3456"), |
| 1462 ASCIIToUTF16("************8765") | 1469 ASCIIToUTF16("************8765") |
| 1463 }; | 1470 }; |
| 1464 string16 expected_labels2[] = {ASCIIToUTF16("*3456"), ASCIIToUTF16("*8765")}; | 1471 base::string16 expected_labels2[] = { ASCIIToUTF16("*3456"), |
| 1465 string16 expected_icons2[] = { | 1472 ASCIIToUTF16("*8765")}; |
| 1473 base::string16 expected_icons2[] = { |
| 1466 ASCIIToUTF16("visaCC"), | 1474 ASCIIToUTF16("visaCC"), |
| 1467 ASCIIToUTF16("genericCC") | 1475 ASCIIToUTF16("genericCC") |
| 1468 }; | 1476 }; |
| 1469 int expected_unique_ids2[] = { | 1477 int expected_unique_ids2[] = { |
| 1470 autofill_manager_->GetPackedCreditCardID(4), | 1478 autofill_manager_->GetPackedCreditCardID(4), |
| 1471 autofill_manager_->GetPackedCreditCardID(5) | 1479 autofill_manager_->GetPackedCreditCardID(5) |
| 1472 }; | 1480 }; |
| 1473 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1481 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1474 kPageID2, arraysize(expected_values2), expected_values2, | 1482 kPageID2, arraysize(expected_values2), expected_values2, |
| 1475 expected_labels2, expected_icons2, expected_unique_ids2); | 1483 expected_labels2, expected_icons2, expected_unique_ids2); |
| 1476 } | 1484 } |
| 1477 | 1485 |
| 1478 // Test that for non-https forms with both address and credit card fields, we | 1486 // Test that for non-https forms with both address and credit card fields, we |
| 1479 // only return address suggestions. Instead of credit card suggestions, we | 1487 // only return address suggestions. Instead of credit card suggestions, we |
| 1480 // should return a warning explaining that credit card profile suggestions are | 1488 // should return a warning explaining that credit card profile suggestions are |
| 1481 // unavailable when the form is not https. | 1489 // unavailable when the form is not https. |
| 1482 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 1490 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { |
| 1483 // Set up our form data. | 1491 // Set up our form data. |
| 1484 FormData form; | 1492 FormData form; |
| 1485 CreateTestAddressFormData(&form); | 1493 CreateTestAddressFormData(&form); |
| 1486 CreateTestCreditCardFormData(&form, false, false); | 1494 CreateTestCreditCardFormData(&form, false, false); |
| 1487 std::vector<FormData> forms(1, form); | 1495 std::vector<FormData> forms(1, form); |
| 1488 FormsSeen(forms); | 1496 FormsSeen(forms); |
| 1489 | 1497 |
| 1490 FormFieldData field = form.fields[0]; | 1498 FormFieldData field = form.fields[0]; |
| 1491 GetAutofillSuggestions(form, field); | 1499 GetAutofillSuggestions(form, field); |
| 1492 | 1500 |
| 1493 // No suggestions provided, so send an empty vector as the results. | 1501 // No suggestions provided, so send an empty vector as the results. |
| 1494 // This triggers the combined message send. | 1502 // This triggers the combined message send. |
| 1495 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1503 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1496 | 1504 |
| 1497 // Test that we sent the right address suggestions to the renderer. | 1505 // Test that we sent the right address suggestions to the renderer. |
| 1498 int page_id = 0; | 1506 int page_id = 0; |
| 1499 std::vector<string16> values; | 1507 std::vector<base::string16> values; |
| 1500 std::vector<string16> labels; | 1508 std::vector<base::string16> labels; |
| 1501 std::vector<string16> icons; | 1509 std::vector<base::string16> icons; |
| 1502 std::vector<int> unique_ids; | 1510 std::vector<int> unique_ids; |
| 1503 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1511 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1504 &unique_ids)); | 1512 &unique_ids)); |
| 1505 | 1513 |
| 1506 string16 expected_values[] = { | 1514 base::string16 expected_values[] = { |
| 1507 ASCIIToUTF16("Elvis"), | 1515 ASCIIToUTF16("Elvis"), |
| 1508 ASCIIToUTF16("Charles") | 1516 ASCIIToUTF16("Charles") |
| 1509 }; | 1517 }; |
| 1510 string16 expected_labels[] = { | 1518 base::string16 expected_labels[] = { |
| 1511 ASCIIToUTF16("3734 Elvis Presley Blvd."), | 1519 ASCIIToUTF16("3734 Elvis Presley Blvd."), |
| 1512 ASCIIToUTF16("123 Apple St.") | 1520 ASCIIToUTF16("123 Apple St.") |
| 1513 }; | 1521 }; |
| 1514 string16 expected_icons[] = {string16(), string16()}; | 1522 base::string16 expected_icons[] = {base::string16(), base::string16()}; |
| 1515 int expected_unique_ids[] = {1, 2}; | 1523 int expected_unique_ids[] = {1, 2}; |
| 1516 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1524 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1517 kDefaultPageID, arraysize(expected_values), expected_values, | 1525 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1518 expected_labels, expected_icons, expected_unique_ids); | 1526 expected_labels, expected_icons, expected_unique_ids); |
| 1519 | 1527 |
| 1520 autofill_test::CreateTestFormField( | 1528 autofill_test::CreateTestFormField( |
| 1521 "Card Number", "cardnumber", "", "text", &field); | 1529 "Card Number", "cardnumber", "", "text", &field); |
| 1522 const int kPageID2 = 2; | 1530 const int kPageID2 = 2; |
| 1523 GetAutofillSuggestions(kPageID2, form, field); | 1531 GetAutofillSuggestions(kPageID2, form, field); |
| 1524 | 1532 |
| 1525 // No suggestions provided, so send an empty vector as the results. | 1533 // No suggestions provided, so send an empty vector as the results. |
| 1526 // This triggers the combined message send. | 1534 // This triggers the combined message send. |
| 1527 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1535 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1528 | 1536 |
| 1529 // Test that we sent the right message to the renderer. | 1537 // Test that we sent the right message to the renderer. |
| 1530 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1538 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1531 &unique_ids)); | 1539 &unique_ids)); |
| 1532 | 1540 |
| 1533 string16 expected_values2[] = { | 1541 base::string16 expected_values2[] = { |
| 1534 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION) | 1542 l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION) |
| 1535 }; | 1543 }; |
| 1536 string16 expected_labels2[] = {string16()}; | 1544 base::string16 expected_labels2[] = {base::string16()}; |
| 1537 string16 expected_icons2[] = {string16()}; | 1545 base::string16 expected_icons2[] = {base::string16()}; |
| 1538 int expected_unique_ids2[] = {-1}; | 1546 int expected_unique_ids2[] = {-1}; |
| 1539 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1547 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1540 kPageID2, arraysize(expected_values2), expected_values2, | 1548 kPageID2, arraysize(expected_values2), expected_values2, |
| 1541 expected_labels2, expected_icons2, expected_unique_ids2); | 1549 expected_labels2, expected_icons2, expected_unique_ids2); |
| 1542 | 1550 |
| 1543 // Clear the test credit cards and try again -- we shouldn't return a warning. | 1551 // Clear the test credit cards and try again -- we shouldn't return a warning. |
| 1544 personal_data_.ClearCreditCards(); | 1552 personal_data_.ClearCreditCards(); |
| 1545 GetAutofillSuggestions(form, field); | 1553 GetAutofillSuggestions(form, field); |
| 1546 EXPECT_FALSE(GetAutofillSuggestionsMessage(NULL, NULL, NULL, NULL, NULL)); | 1554 EXPECT_FALSE(GetAutofillSuggestionsMessage(NULL, NULL, NULL, NULL, NULL)); |
| 1547 } | 1555 } |
| 1548 | 1556 |
| 1549 // Test that we correctly combine autofill and autocomplete suggestions. | 1557 // Test that we correctly combine autofill and autocomplete suggestions. |
| 1550 TEST_F(AutofillManagerTest, GetCombinedAutofillAndAutocompleteSuggestions) { | 1558 TEST_F(AutofillManagerTest, GetCombinedAutofillAndAutocompleteSuggestions) { |
| 1551 // Set up our form data. | 1559 // Set up our form data. |
| 1552 FormData form; | 1560 FormData form; |
| 1553 CreateTestAddressFormData(&form); | 1561 CreateTestAddressFormData(&form); |
| 1554 std::vector<FormData> forms(1, form); | 1562 std::vector<FormData> forms(1, form); |
| 1555 FormsSeen(forms); | 1563 FormsSeen(forms); |
| 1556 | 1564 |
| 1557 const FormFieldData& field = form.fields[0]; | 1565 const FormFieldData& field = form.fields[0]; |
| 1558 GetAutofillSuggestions(form, field); | 1566 GetAutofillSuggestions(form, field); |
| 1559 | 1567 |
| 1560 // Add some Autocomplete suggestions. | 1568 // Add some Autocomplete suggestions. |
| 1561 // This triggers the combined message send. | 1569 // This triggers the combined message send. |
| 1562 std::vector<string16> suggestions; | 1570 std::vector<base::string16> suggestions; |
| 1563 suggestions.push_back(ASCIIToUTF16("Jay")); | 1571 suggestions.push_back(ASCIIToUTF16("Jay")); |
| 1564 // This suggestion is a duplicate, and should be trimmed. | 1572 // This suggestion is a duplicate, and should be trimmed. |
| 1565 suggestions.push_back(ASCIIToUTF16("Elvis")); | 1573 suggestions.push_back(ASCIIToUTF16("Elvis")); |
| 1566 suggestions.push_back(ASCIIToUTF16("Jason")); | 1574 suggestions.push_back(ASCIIToUTF16("Jason")); |
| 1567 AutocompleteSuggestionsReturned(suggestions); | 1575 AutocompleteSuggestionsReturned(suggestions); |
| 1568 | 1576 |
| 1569 // Test that we sent the right message to the renderer. | 1577 // Test that we sent the right message to the renderer. |
| 1570 int page_id = 0; | 1578 int page_id = 0; |
| 1571 std::vector<string16> values; | 1579 std::vector<base::string16> values; |
| 1572 std::vector<string16> labels; | 1580 std::vector<base::string16> labels; |
| 1573 std::vector<string16> icons; | 1581 std::vector<base::string16> icons; |
| 1574 std::vector<int> unique_ids; | 1582 std::vector<int> unique_ids; |
| 1575 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1583 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1576 &unique_ids)); | 1584 &unique_ids)); |
| 1577 | 1585 |
| 1578 string16 expected_values[] = { | 1586 base::string16 expected_values[] = { |
| 1579 ASCIIToUTF16("Elvis"), | 1587 ASCIIToUTF16("Elvis"), |
| 1580 ASCIIToUTF16("Charles"), | 1588 ASCIIToUTF16("Charles"), |
| 1581 ASCIIToUTF16("Jay"), | 1589 ASCIIToUTF16("Jay"), |
| 1582 ASCIIToUTF16("Jason") | 1590 ASCIIToUTF16("Jason") |
| 1583 }; | 1591 }; |
| 1584 string16 expected_labels[] = { | 1592 base::string16 expected_labels[] = { |
| 1585 ASCIIToUTF16("3734 Elvis Presley Blvd."), | 1593 ASCIIToUTF16("3734 Elvis Presley Blvd."), |
| 1586 ASCIIToUTF16("123 Apple St."), | 1594 ASCIIToUTF16("123 Apple St."), |
| 1587 string16(), | 1595 base::string16(), |
| 1588 string16() | 1596 base::string16() |
| 1589 }; | 1597 }; |
| 1590 string16 expected_icons[] = {string16(), string16(), string16(), string16()}; | 1598 base::string16 expected_icons[] = { base::string16(), base::string16(), |
| 1599 base::string16(), base::string16()}; |
| 1591 int expected_unique_ids[] = {1, 2, 0, 0}; | 1600 int expected_unique_ids[] = {1, 2, 0, 0}; |
| 1592 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1601 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1593 kDefaultPageID, arraysize(expected_values), expected_values, | 1602 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1594 expected_labels, expected_icons, expected_unique_ids); | 1603 expected_labels, expected_icons, expected_unique_ids); |
| 1595 } | 1604 } |
| 1596 | 1605 |
| 1597 // Test that we return autocomplete-like suggestions when trying to autofill | 1606 // Test that we return autocomplete-like suggestions when trying to autofill |
| 1598 // already filled forms. | 1607 // already filled forms. |
| 1599 TEST_F(AutofillManagerTest, GetFieldSuggestionsWhenFormIsAutofilled) { | 1608 TEST_F(AutofillManagerTest, GetFieldSuggestionsWhenFormIsAutofilled) { |
| 1600 // Set up our form data. | 1609 // Set up our form data. |
| 1601 FormData form; | 1610 FormData form; |
| 1602 CreateTestAddressFormData(&form); | 1611 CreateTestAddressFormData(&form); |
| 1603 std::vector<FormData> forms(1, form); | 1612 std::vector<FormData> forms(1, form); |
| 1604 FormsSeen(forms); | 1613 FormsSeen(forms); |
| 1605 | 1614 |
| 1606 // Mark one of the fields as filled. | 1615 // Mark one of the fields as filled. |
| 1607 form.fields[2].is_autofilled = true; | 1616 form.fields[2].is_autofilled = true; |
| 1608 const FormFieldData& field = form.fields[0]; | 1617 const FormFieldData& field = form.fields[0]; |
| 1609 GetAutofillSuggestions(form, field); | 1618 GetAutofillSuggestions(form, field); |
| 1610 | 1619 |
| 1611 // No suggestions provided, so send an empty vector as the results. | 1620 // No suggestions provided, so send an empty vector as the results. |
| 1612 // This triggers the combined message send. | 1621 // This triggers the combined message send. |
| 1613 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1622 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1614 | 1623 |
| 1615 // Test that we sent the right message to the renderer. | 1624 // Test that we sent the right message to the renderer. |
| 1616 int page_id = 0; | 1625 int page_id = 0; |
| 1617 std::vector<string16> values; | 1626 std::vector<base::string16> values; |
| 1618 std::vector<string16> labels; | 1627 std::vector<base::string16> labels; |
| 1619 std::vector<string16> icons; | 1628 std::vector<base::string16> icons; |
| 1620 std::vector<int> unique_ids; | 1629 std::vector<int> unique_ids; |
| 1621 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1630 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1622 &unique_ids)); | 1631 &unique_ids)); |
| 1623 string16 expected_values[] = { | 1632 base::string16 expected_values[] = { |
| 1624 ASCIIToUTF16("Elvis"), | 1633 ASCIIToUTF16("Elvis"), |
| 1625 ASCIIToUTF16("Charles") | 1634 ASCIIToUTF16("Charles") |
| 1626 }; | 1635 }; |
| 1627 string16 expected_labels[] = {string16(), string16()}; | 1636 base::string16 expected_labels[] = {base::string16(), base::string16()}; |
| 1628 string16 expected_icons[] = {string16(), string16()}; | 1637 base::string16 expected_icons[] = {base::string16(), base::string16()}; |
| 1629 int expected_unique_ids[] = {1, 2}; | 1638 int expected_unique_ids[] = {1, 2}; |
| 1630 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1639 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1631 kDefaultPageID, arraysize(expected_values), expected_values, | 1640 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1632 expected_labels, expected_icons, expected_unique_ids); | 1641 expected_labels, expected_icons, expected_unique_ids); |
| 1633 } | 1642 } |
| 1634 | 1643 |
| 1635 // Test that nothing breaks when there are autocomplete suggestions but no | 1644 // Test that nothing breaks when there are autocomplete suggestions but no |
| 1636 // autofill suggestions. | 1645 // autofill suggestions. |
| 1637 TEST_F(AutofillManagerTest, GetFieldSuggestionsForAutocompleteOnly) { | 1646 TEST_F(AutofillManagerTest, GetFieldSuggestionsForAutocompleteOnly) { |
| 1638 // Set up our form data. | 1647 // Set up our form data. |
| 1639 FormData form; | 1648 FormData form; |
| 1640 CreateTestAddressFormData(&form); | 1649 CreateTestAddressFormData(&form); |
| 1641 FormFieldData field; | 1650 FormFieldData field; |
| 1642 autofill_test::CreateTestFormField( | 1651 autofill_test::CreateTestFormField( |
| 1643 "Some Field", "somefield", "", "text", &field); | 1652 "Some Field", "somefield", "", "text", &field); |
| 1644 form.fields.push_back(field); | 1653 form.fields.push_back(field); |
| 1645 std::vector<FormData> forms(1, form); | 1654 std::vector<FormData> forms(1, form); |
| 1646 FormsSeen(forms); | 1655 FormsSeen(forms); |
| 1647 | 1656 |
| 1648 GetAutofillSuggestions(form, field); | 1657 GetAutofillSuggestions(form, field); |
| 1649 | 1658 |
| 1650 // Add some Autocomplete suggestions. | 1659 // Add some Autocomplete suggestions. |
| 1651 // This triggers the combined message send. | 1660 // This triggers the combined message send. |
| 1652 std::vector<string16> suggestions; | 1661 std::vector<base::string16> suggestions; |
| 1653 suggestions.push_back(ASCIIToUTF16("one")); | 1662 suggestions.push_back(ASCIIToUTF16("one")); |
| 1654 suggestions.push_back(ASCIIToUTF16("two")); | 1663 suggestions.push_back(ASCIIToUTF16("two")); |
| 1655 AutocompleteSuggestionsReturned(suggestions); | 1664 AutocompleteSuggestionsReturned(suggestions); |
| 1656 | 1665 |
| 1657 // Test that we sent the right message to the renderer. | 1666 // Test that we sent the right message to the renderer. |
| 1658 int page_id = 0; | 1667 int page_id = 0; |
| 1659 std::vector<string16> values; | 1668 std::vector<base::string16> values; |
| 1660 std::vector<string16> labels; | 1669 std::vector<base::string16> labels; |
| 1661 std::vector<string16> icons; | 1670 std::vector<base::string16> icons; |
| 1662 std::vector<int> unique_ids; | 1671 std::vector<int> unique_ids; |
| 1663 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1672 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1664 &unique_ids)); | 1673 &unique_ids)); |
| 1665 | 1674 |
| 1666 string16 expected_values[] = { | 1675 base::string16 expected_values[] = { |
| 1667 ASCIIToUTF16("one"), | 1676 ASCIIToUTF16("one"), |
| 1668 ASCIIToUTF16("two") | 1677 ASCIIToUTF16("two") |
| 1669 }; | 1678 }; |
| 1670 string16 expected_labels[] = {string16(), string16()}; | 1679 base::string16 expected_labels[] = {base::string16(), base::string16()}; |
| 1671 string16 expected_icons[] = {string16(), string16()}; | 1680 base::string16 expected_icons[] = {base::string16(), base::string16()}; |
| 1672 int expected_unique_ids[] = {0, 0}; | 1681 int expected_unique_ids[] = {0, 0}; |
| 1673 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1682 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1674 kDefaultPageID, arraysize(expected_values), expected_values, | 1683 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1675 expected_labels, expected_icons, expected_unique_ids); | 1684 expected_labels, expected_icons, expected_unique_ids); |
| 1676 } | 1685 } |
| 1677 | 1686 |
| 1678 // Test that we do not return duplicate values drawn from multiple profiles when | 1687 // Test that we do not return duplicate values drawn from multiple profiles when |
| 1679 // filling an already filled field. | 1688 // filling an already filled field. |
| 1680 TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) { | 1689 TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) { |
| 1681 // Set up our form data. | 1690 // Set up our form data. |
| 1682 FormData form; | 1691 FormData form; |
| 1683 CreateTestAddressFormData(&form); | 1692 CreateTestAddressFormData(&form); |
| 1684 std::vector<FormData> forms(1, form); | 1693 std::vector<FormData> forms(1, form); |
| 1685 FormsSeen(forms); | 1694 FormsSeen(forms); |
| 1686 | 1695 |
| 1687 // |profile| will be owned by the mock PersonalDataManager. | 1696 // |profile| will be owned by the mock PersonalDataManager. |
| 1688 AutofillProfile* profile = new AutofillProfile; | 1697 AutofillProfile* profile = new AutofillProfile; |
| 1689 autofill_test::SetProfileInfo(profile, "Elvis", "", "", "", "", "", "", "", | 1698 autofill_test::SetProfileInfo(profile, "Elvis", "", "", "", "", "", "", "", |
| 1690 "", "", "", ""); | 1699 "", "", "", ""); |
| 1691 profile->set_guid("00000000-0000-0000-0000-000000000101"); | 1700 profile->set_guid("00000000-0000-0000-0000-000000000101"); |
| 1692 autofill_manager_->AddProfile(profile); | 1701 autofill_manager_->AddProfile(profile); |
| 1693 | 1702 |
| 1694 FormFieldData& field = form.fields[0]; | 1703 FormFieldData& field = form.fields[0]; |
| 1695 field.is_autofilled = true; | 1704 field.is_autofilled = true; |
| 1696 field.value = ASCIIToUTF16("Elvis"); | 1705 field.value = ASCIIToUTF16("Elvis"); |
| 1697 GetAutofillSuggestions(form, field); | 1706 GetAutofillSuggestions(form, field); |
| 1698 | 1707 |
| 1699 // No suggestions provided, so send an empty vector as the results. | 1708 // No suggestions provided, so send an empty vector as the results. |
| 1700 // This triggers the combined message send. | 1709 // This triggers the combined message send. |
| 1701 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1710 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1702 | 1711 |
| 1703 // Test that we sent the right message to the renderer. | 1712 // Test that we sent the right message to the renderer. |
| 1704 int page_id = 0; | 1713 int page_id = 0; |
| 1705 std::vector<string16> values; | 1714 std::vector<base::string16> values; |
| 1706 std::vector<string16> labels; | 1715 std::vector<base::string16> labels; |
| 1707 std::vector<string16> icons; | 1716 std::vector<base::string16> icons; |
| 1708 std::vector<int> unique_ids; | 1717 std::vector<int> unique_ids; |
| 1709 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1718 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1710 &unique_ids)); | 1719 &unique_ids)); |
| 1711 | 1720 |
| 1712 string16 expected_values[] = { ASCIIToUTF16("Elvis") }; | 1721 base::string16 expected_values[] = { ASCIIToUTF16("Elvis") }; |
| 1713 string16 expected_labels[] = { string16() }; | 1722 base::string16 expected_labels[] = { base::string16() }; |
| 1714 string16 expected_icons[] = { string16() }; | 1723 base::string16 expected_icons[] = { base::string16() }; |
| 1715 int expected_unique_ids[] = { 1 }; | 1724 int expected_unique_ids[] = { 1 }; |
| 1716 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1725 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1717 kDefaultPageID, arraysize(expected_values), expected_values, | 1726 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1718 expected_labels, expected_icons, expected_unique_ids); | 1727 expected_labels, expected_icons, expected_unique_ids); |
| 1719 } | 1728 } |
| 1720 | 1729 |
| 1721 // Test that a non-default value is suggested for multi-valued profile, on an | 1730 // Test that a non-default value is suggested for multi-valued profile, on an |
| 1722 // unfilled form. | 1731 // unfilled form. |
| 1723 TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileUnfilled) { | 1732 TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileUnfilled) { |
| 1724 // Set up our form data. | 1733 // Set up our form data. |
| 1725 FormData form; | 1734 FormData form; |
| 1726 CreateTestAddressFormData(&form); | 1735 CreateTestAddressFormData(&form); |
| 1727 std::vector<FormData> forms(1, form); | 1736 std::vector<FormData> forms(1, form); |
| 1728 FormsSeen(forms); | 1737 FormsSeen(forms); |
| 1729 | 1738 |
| 1730 // |profile| will be owned by the mock PersonalDataManager. | 1739 // |profile| will be owned by the mock PersonalDataManager. |
| 1731 AutofillProfile* profile = new AutofillProfile; | 1740 AutofillProfile* profile = new AutofillProfile; |
| 1732 autofill_test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "", | 1741 autofill_test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "", |
| 1733 "", "", "", "", "", "", ""); | 1742 "", "", "", "", "", "", ""); |
| 1734 profile->set_guid("00000000-0000-0000-0000-000000000101"); | 1743 profile->set_guid("00000000-0000-0000-0000-000000000101"); |
| 1735 std::vector<string16> multi_values(2); | 1744 std::vector<base::string16> multi_values(2); |
| 1736 multi_values[0] = ASCIIToUTF16("Elvis Presley"); | 1745 multi_values[0] = ASCIIToUTF16("Elvis Presley"); |
| 1737 multi_values[1] = ASCIIToUTF16("Elena Love"); | 1746 multi_values[1] = ASCIIToUTF16("Elena Love"); |
| 1738 profile->SetRawMultiInfo(NAME_FULL, multi_values); | 1747 profile->SetRawMultiInfo(NAME_FULL, multi_values); |
| 1739 personal_data_.ClearAutofillProfiles(); | 1748 personal_data_.ClearAutofillProfiles(); |
| 1740 autofill_manager_->AddProfile(profile); | 1749 autofill_manager_->AddProfile(profile); |
| 1741 | 1750 |
| 1742 { | 1751 { |
| 1743 // Get the first name field. | 1752 // Get the first name field. |
| 1744 // Start out with "E", hoping for either "Elvis" or "Elena. | 1753 // Start out with "E", hoping for either "Elvis" or "Elena. |
| 1745 FormFieldData& field = form.fields[0]; | 1754 FormFieldData& field = form.fields[0]; |
| 1746 field.value = ASCIIToUTF16("E"); | 1755 field.value = ASCIIToUTF16("E"); |
| 1747 field.is_autofilled = false; | 1756 field.is_autofilled = false; |
| 1748 GetAutofillSuggestions(form, field); | 1757 GetAutofillSuggestions(form, field); |
| 1749 | 1758 |
| 1750 // Trigger the |Send|. | 1759 // Trigger the |Send|. |
| 1751 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1760 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1752 | 1761 |
| 1753 // Test that we sent the right message to the renderer. | 1762 // Test that we sent the right message to the renderer. |
| 1754 int page_id = 0; | 1763 int page_id = 0; |
| 1755 std::vector<string16> values; | 1764 std::vector<base::string16> values; |
| 1756 std::vector<string16> labels; | 1765 std::vector<base::string16> labels; |
| 1757 std::vector<string16> icons; | 1766 std::vector<base::string16> icons; |
| 1758 std::vector<int> unique_ids; | 1767 std::vector<int> unique_ids; |
| 1759 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, | 1768 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, |
| 1760 &icons, &unique_ids)); | 1769 &icons, &unique_ids)); |
| 1761 string16 expected_values[] = { | 1770 base::string16 expected_values[] = { |
| 1762 ASCIIToUTF16("Elvis"), | 1771 ASCIIToUTF16("Elvis"), |
| 1763 ASCIIToUTF16("Elena") | 1772 ASCIIToUTF16("Elena") |
| 1764 }; | 1773 }; |
| 1765 string16 expected_labels[] = { | 1774 base::string16 expected_labels[] = { |
| 1766 ASCIIToUTF16("me@x.com"), | 1775 ASCIIToUTF16("me@x.com"), |
| 1767 ASCIIToUTF16("me@x.com") | 1776 ASCIIToUTF16("me@x.com") |
| 1768 }; | 1777 }; |
| 1769 string16 expected_icons[] = { string16(), string16() }; | 1778 base::string16 expected_icons[] = { base::string16(), base::string16() }; |
| 1770 int expected_unique_ids[] = { 1, 2 }; | 1779 int expected_unique_ids[] = { 1, 2 }; |
| 1771 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1780 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1772 kDefaultPageID, arraysize(expected_values), | 1781 kDefaultPageID, arraysize(expected_values), |
| 1773 expected_values, expected_labels, expected_icons, | 1782 expected_values, expected_labels, expected_icons, |
| 1774 expected_unique_ids); | 1783 expected_unique_ids); |
| 1775 } | 1784 } |
| 1776 | 1785 |
| 1777 { | 1786 { |
| 1778 // Get the first name field. | 1787 // Get the first name field. |
| 1779 // This time, start out with "Ele", hoping for "Elena". | 1788 // This time, start out with "Ele", hoping for "Elena". |
| 1780 FormFieldData& field = form.fields[0]; | 1789 FormFieldData& field = form.fields[0]; |
| 1781 field.value = ASCIIToUTF16("Ele"); | 1790 field.value = ASCIIToUTF16("Ele"); |
| 1782 field.is_autofilled = false; | 1791 field.is_autofilled = false; |
| 1783 GetAutofillSuggestions(form, field); | 1792 GetAutofillSuggestions(form, field); |
| 1784 | 1793 |
| 1785 // Trigger the |Send|. | 1794 // Trigger the |Send|. |
| 1786 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1795 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1787 | 1796 |
| 1788 // Test that we sent the right message to the renderer. | 1797 // Test that we sent the right message to the renderer. |
| 1789 int page_id = 0; | 1798 int page_id = 0; |
| 1790 std::vector<string16> values; | 1799 std::vector<base::string16> values; |
| 1791 std::vector<string16> labels; | 1800 std::vector<base::string16> labels; |
| 1792 std::vector<string16> icons; | 1801 std::vector<base::string16> icons; |
| 1793 std::vector<int> unique_ids; | 1802 std::vector<int> unique_ids; |
| 1794 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, | 1803 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, |
| 1795 &icons, &unique_ids)); | 1804 &icons, &unique_ids)); |
| 1796 | 1805 |
| 1797 string16 expected_values[] = { ASCIIToUTF16("Elena") }; | 1806 base::string16 expected_values[] = { ASCIIToUTF16("Elena") }; |
| 1798 string16 expected_labels[] = { ASCIIToUTF16("me@x.com") }; | 1807 base::string16 expected_labels[] = { ASCIIToUTF16("me@x.com") }; |
| 1799 string16 expected_icons[] = { string16() }; | 1808 base::string16 expected_icons[] = { base::string16() }; |
| 1800 int expected_unique_ids[] = { 2 }; | 1809 int expected_unique_ids[] = { 2 }; |
| 1801 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1810 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1802 kDefaultPageID, arraysize(expected_values), | 1811 kDefaultPageID, arraysize(expected_values), |
| 1803 expected_values, expected_labels, expected_icons, | 1812 expected_values, expected_labels, expected_icons, |
| 1804 expected_unique_ids); | 1813 expected_unique_ids); |
| 1805 } | 1814 } |
| 1806 } | 1815 } |
| 1807 | 1816 |
| 1808 // Test that all values are suggested for multi-valued profile, on a filled | 1817 // Test that all values are suggested for multi-valued profile, on a filled |
| 1809 // form. This is the per-field "override" case. | 1818 // form. This is the per-field "override" case. |
| 1810 TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileFilled) { | 1819 TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileFilled) { |
| 1811 // Set up our form data. | 1820 // Set up our form data. |
| 1812 FormData form; | 1821 FormData form; |
| 1813 CreateTestAddressFormData(&form); | 1822 CreateTestAddressFormData(&form); |
| 1814 std::vector<FormData> forms(1, form); | 1823 std::vector<FormData> forms(1, form); |
| 1815 FormsSeen(forms); | 1824 FormsSeen(forms); |
| 1816 | 1825 |
| 1817 // |profile| will be owned by the mock PersonalDataManager. | 1826 // |profile| will be owned by the mock PersonalDataManager. |
| 1818 AutofillProfile* profile = new AutofillProfile; | 1827 AutofillProfile* profile = new AutofillProfile; |
| 1819 profile->set_guid("00000000-0000-0000-0000-000000000102"); | 1828 profile->set_guid("00000000-0000-0000-0000-000000000102"); |
| 1820 std::vector<string16> multi_values(3); | 1829 std::vector<base::string16> multi_values(3); |
| 1821 multi_values[0] = ASCIIToUTF16("Travis Smith"); | 1830 multi_values[0] = ASCIIToUTF16("Travis Smith"); |
| 1822 multi_values[1] = ASCIIToUTF16("Cynthia Love"); | 1831 multi_values[1] = ASCIIToUTF16("Cynthia Love"); |
| 1823 multi_values[2] = ASCIIToUTF16("Zac Mango"); | 1832 multi_values[2] = ASCIIToUTF16("Zac Mango"); |
| 1824 profile->SetRawMultiInfo(NAME_FULL, multi_values); | 1833 profile->SetRawMultiInfo(NAME_FULL, multi_values); |
| 1825 autofill_manager_->AddProfile(profile); | 1834 autofill_manager_->AddProfile(profile); |
| 1826 | 1835 |
| 1827 // Get the first name field. And start out with "Travis", hoping for all the | 1836 // Get the first name field. And start out with "Travis", hoping for all the |
| 1828 // multi-valued variants as suggestions. | 1837 // multi-valued variants as suggestions. |
| 1829 FormFieldData& field = form.fields[0]; | 1838 FormFieldData& field = form.fields[0]; |
| 1830 field.value = ASCIIToUTF16("Travis"); | 1839 field.value = ASCIIToUTF16("Travis"); |
| 1831 field.is_autofilled = true; | 1840 field.is_autofilled = true; |
| 1832 GetAutofillSuggestions(form, field); | 1841 GetAutofillSuggestions(form, field); |
| 1833 | 1842 |
| 1834 // Trigger the |Send|. | 1843 // Trigger the |Send|. |
| 1835 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1844 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1836 | 1845 |
| 1837 // Test that we sent the right message to the renderer. | 1846 // Test that we sent the right message to the renderer. |
| 1838 int page_id = 0; | 1847 int page_id = 0; |
| 1839 std::vector<string16> values; | 1848 std::vector<base::string16> values; |
| 1840 std::vector<string16> labels; | 1849 std::vector<base::string16> labels; |
| 1841 std::vector<string16> icons; | 1850 std::vector<base::string16> icons; |
| 1842 std::vector<int> unique_ids; | 1851 std::vector<int> unique_ids; |
| 1843 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, | 1852 EXPECT_TRUE(GetAutofillSuggestionsMessage(&page_id, &values, &labels, &icons, |
| 1844 &unique_ids)); | 1853 &unique_ids)); |
| 1845 | 1854 |
| 1846 string16 expected_values[] = { | 1855 base::string16 expected_values[] = { |
| 1847 ASCIIToUTF16("Travis"), | 1856 ASCIIToUTF16("Travis"), |
| 1848 ASCIIToUTF16("Cynthia"), | 1857 ASCIIToUTF16("Cynthia"), |
| 1849 ASCIIToUTF16("Zac") | 1858 ASCIIToUTF16("Zac") |
| 1850 }; | 1859 }; |
| 1851 string16 expected_labels[] = { string16(), string16(), string16() }; | 1860 base::string16 expected_labels[] = { base::string16(), base::string16(), |
| 1852 string16 expected_icons[] = { string16(), string16(), string16() }; | 1861 base::string16() }; |
| 1862 base::string16 expected_icons[] = { base::string16(), base::string16(), |
| 1863 base::string16() }; |
| 1853 int expected_unique_ids[] = { 1, 2, 3 }; | 1864 int expected_unique_ids[] = { 1, 2, 3 }; |
| 1854 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1865 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1855 kDefaultPageID, arraysize(expected_values), expected_values, | 1866 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1856 expected_labels, expected_icons, expected_unique_ids); | 1867 expected_labels, expected_icons, expected_unique_ids); |
| 1857 } | 1868 } |
| 1858 | 1869 |
| 1859 TEST_F(AutofillManagerTest, GetProfileSuggestionsFancyPhone) { | 1870 TEST_F(AutofillManagerTest, GetProfileSuggestionsFancyPhone) { |
| 1860 // Set up our form data. | 1871 // Set up our form data. |
| 1861 FormData form; | 1872 FormData form; |
| 1862 CreateTestAddressFormData(&form); | 1873 CreateTestAddressFormData(&form); |
| 1863 std::vector<FormData> forms(1, form); | 1874 std::vector<FormData> forms(1, form); |
| 1864 FormsSeen(forms); | 1875 FormsSeen(forms); |
| 1865 | 1876 |
| 1866 AutofillProfile* profile = new AutofillProfile; | 1877 AutofillProfile* profile = new AutofillProfile; |
| 1867 profile->set_guid("00000000-0000-0000-0000-000000000103"); | 1878 profile->set_guid("00000000-0000-0000-0000-000000000103"); |
| 1868 std::vector<string16> multi_values(1); | 1879 std::vector<base::string16> multi_values(1); |
| 1869 multi_values[0] = ASCIIToUTF16("Natty Bumppo"); | 1880 multi_values[0] = ASCIIToUTF16("Natty Bumppo"); |
| 1870 profile->SetRawMultiInfo(NAME_FULL, multi_values); | 1881 profile->SetRawMultiInfo(NAME_FULL, multi_values); |
| 1871 multi_values[0] = ASCIIToUTF16("1800PRAIRIE"); | 1882 multi_values[0] = ASCIIToUTF16("1800PRAIRIE"); |
| 1872 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, multi_values); | 1883 profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, multi_values); |
| 1873 autofill_manager_->AddProfile(profile); | 1884 autofill_manager_->AddProfile(profile); |
| 1874 | 1885 |
| 1875 const FormFieldData& field = form.fields[9]; | 1886 const FormFieldData& field = form.fields[9]; |
| 1876 GetAutofillSuggestions(form, field); | 1887 GetAutofillSuggestions(form, field); |
| 1877 | 1888 |
| 1878 // No suggestions provided, so send an empty vector as the results. | 1889 // No suggestions provided, so send an empty vector as the results. |
| 1879 // This triggers the combined message send. | 1890 // This triggers the combined message send. |
| 1880 AutocompleteSuggestionsReturned(std::vector<string16>()); | 1891 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
| 1881 | 1892 |
| 1882 // Test that we sent the right message to the renderer. | 1893 // Test that we sent the right message to the renderer. |
| 1883 int page_id = 0; | 1894 int page_id = 0; |
| 1884 std::vector<string16> values; | 1895 std::vector<base::string16> values; |
| 1885 std::vector<string16> labels; | 1896 std::vector<base::string16> labels; |
| 1886 std::vector<string16> icons; | 1897 std::vector<base::string16> icons; |
| 1887 std::vector<int> unique_ids; | 1898 std::vector<int> unique_ids; |
| 1888 GetAutofillSuggestionsMessage( | 1899 GetAutofillSuggestionsMessage( |
| 1889 &page_id, &values, &labels, &icons, &unique_ids); | 1900 &page_id, &values, &labels, &icons, &unique_ids); |
| 1890 | 1901 |
| 1891 string16 expected_values[] = { | 1902 base::string16 expected_values[] = { |
| 1892 ASCIIToUTF16("12345678901"), | 1903 ASCIIToUTF16("12345678901"), |
| 1893 ASCIIToUTF16("23456789012"), | 1904 ASCIIToUTF16("23456789012"), |
| 1894 ASCIIToUTF16("18007724743"), // 1800PRAIRIE | 1905 ASCIIToUTF16("18007724743"), // 1800PRAIRIE |
| 1895 }; | 1906 }; |
| 1896 // Inferred labels include full first relevant field, which in this case is | 1907 // Inferred labels include full first relevant field, which in this case is |
| 1897 // the address line 1. | 1908 // the address line 1. |
| 1898 string16 expected_labels[] = { | 1909 base::string16 expected_labels[] = { |
| 1899 ASCIIToUTF16("Elvis Aaron Presley"), | 1910 ASCIIToUTF16("Elvis Aaron Presley"), |
| 1900 ASCIIToUTF16("Charles Hardin Holley"), | 1911 ASCIIToUTF16("Charles Hardin Holley"), |
| 1901 ASCIIToUTF16("Natty Bumppo"), | 1912 ASCIIToUTF16("Natty Bumppo"), |
| 1902 }; | 1913 }; |
| 1903 string16 expected_icons[] = {string16(), string16(), string16()}; | 1914 base::string16 expected_icons[] = { base::string16(), base::string16(), |
| 1915 base::string16()}; |
| 1904 int expected_unique_ids[] = {1, 2, 3}; | 1916 int expected_unique_ids[] = {1, 2, 3}; |
| 1905 ExpectSuggestions(page_id, values, labels, icons, unique_ids, | 1917 ExpectSuggestions(page_id, values, labels, icons, unique_ids, |
| 1906 kDefaultPageID, arraysize(expected_values), expected_values, | 1918 kDefaultPageID, arraysize(expected_values), expected_values, |
| 1907 expected_labels, expected_icons, expected_unique_ids); | 1919 expected_labels, expected_icons, expected_unique_ids); |
| 1908 } | 1920 } |
| 1909 | 1921 |
| 1910 // Test that we correctly fill an address form. | 1922 // Test that we correctly fill an address form. |
| 1911 TEST_F(AutofillManagerTest, FillAddressForm) { | 1923 TEST_F(AutofillManagerTest, FillAddressForm) { |
| 1912 // Set up our form data. | 1924 // Set up our form data. |
| 1913 FormData form; | 1925 FormData form; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 | 2139 |
| 2128 int page_id = 0; | 2140 int page_id = 0; |
| 2129 FormData results; | 2141 FormData results; |
| 2130 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); | 2142 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); |
| 2131 { | 2143 { |
| 2132 SCOPED_TRACE("Address 1"); | 2144 SCOPED_TRACE("Address 1"); |
| 2133 | 2145 |
| 2134 // The second address section should be empty. | 2146 // The second address section should be empty. |
| 2135 ASSERT_EQ(results.fields.size(), 2*kAddressFormSize); | 2147 ASSERT_EQ(results.fields.size(), 2*kAddressFormSize); |
| 2136 for (size_t i = kAddressFormSize; i < form.fields.size(); ++i) { | 2148 for (size_t i = kAddressFormSize; i < form.fields.size(); ++i) { |
| 2137 EXPECT_EQ(string16(), results.fields[i].value); | 2149 EXPECT_EQ(base::string16(), results.fields[i].value); |
| 2138 } | 2150 } |
| 2139 | 2151 |
| 2140 // The first address section should be filled with Elvis's data. | 2152 // The first address section should be filled with Elvis's data. |
| 2141 results.fields.resize(kAddressFormSize); | 2153 results.fields.resize(kAddressFormSize); |
| 2142 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); | 2154 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); |
| 2143 } | 2155 } |
| 2144 | 2156 |
| 2145 // Fill the second section, with the initiating field somewhere in the middle | 2157 // Fill the second section, with the initiating field somewhere in the middle |
| 2146 // of the section. | 2158 // of the section. |
| 2147 const int kPageID2 = 2; | 2159 const int kPageID2 = 2; |
| 2148 GUIDPair guid2("00000000-0000-0000-0000-000000000001", 0); | 2160 GUIDPair guid2("00000000-0000-0000-0000-000000000001", 0); |
| 2149 ASSERT_LT(9U, kAddressFormSize); | 2161 ASSERT_LT(9U, kAddressFormSize); |
| 2150 FillAutofillFormData(kPageID2, form, form.fields[kAddressFormSize + 9], | 2162 FillAutofillFormData(kPageID2, form, form.fields[kAddressFormSize + 9], |
| 2151 PackGUIDs(empty, guid2)); | 2163 PackGUIDs(empty, guid2)); |
| 2152 | 2164 |
| 2153 page_id = 0; | 2165 page_id = 0; |
| 2154 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); | 2166 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); |
| 2155 { | 2167 { |
| 2156 SCOPED_TRACE("Address 2"); | 2168 SCOPED_TRACE("Address 2"); |
| 2157 ASSERT_EQ(results.fields.size(), form.fields.size()); | 2169 ASSERT_EQ(results.fields.size(), form.fields.size()); |
| 2158 | 2170 |
| 2159 // The first address section should be empty. | 2171 // The first address section should be empty. |
| 2160 ASSERT_EQ(results.fields.size(), 2*kAddressFormSize); | 2172 ASSERT_EQ(results.fields.size(), 2*kAddressFormSize); |
| 2161 for (size_t i = 0; i < kAddressFormSize; ++i) { | 2173 for (size_t i = 0; i < kAddressFormSize; ++i) { |
| 2162 EXPECT_EQ(string16(), results.fields[i].value); | 2174 EXPECT_EQ(base::string16(), results.fields[i].value); |
| 2163 } | 2175 } |
| 2164 | 2176 |
| 2165 // The second address section should be filled with Elvis's data. | 2177 // The second address section should be filled with Elvis's data. |
| 2166 FormData secondSection = results; | 2178 FormData secondSection = results; |
| 2167 secondSection.fields.erase(secondSection.fields.begin(), | 2179 secondSection.fields.erase(secondSection.fields.begin(), |
| 2168 secondSection.fields.begin() + kAddressFormSize); | 2180 secondSection.fields.begin() + kAddressFormSize); |
| 2169 for (size_t i = 0; i < kAddressFormSize; ++i) { | 2181 for (size_t i = 0; i < kAddressFormSize; ++i) { |
| 2170 // Restore the expected field names. | 2182 // Restore the expected field names. |
| 2171 string16 name = secondSection.fields[i].name; | 2183 base::string16 name = secondSection.fields[i].name; |
| 2172 string16 original_name = name.substr(0, name.size() - 1); | 2184 base::string16 original_name = name.substr(0, name.size() - 1); |
| 2173 secondSection.fields[i].name = original_name; | 2185 secondSection.fields[i].name = original_name; |
| 2174 } | 2186 } |
| 2175 ExpectFilledAddressFormElvis(page_id, secondSection, kPageID2, false); | 2187 ExpectFilledAddressFormElvis(page_id, secondSection, kPageID2, false); |
| 2176 } | 2188 } |
| 2177 } | 2189 } |
| 2178 | 2190 |
| 2179 // Test that we correctly fill a form that has author-specified sections, which | 2191 // Test that we correctly fill a form that has author-specified sections, which |
| 2180 // might not match our expected section breakdown. | 2192 // might not match our expected section breakdown. |
| 2181 TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { | 2193 TEST_F(AutofillManagerTest, FillFormWithAuthorSpecifiedSections) { |
| 2182 // Create a form with a billing section and an unnamed section, interleaved. | 2194 // Create a form with a billing section and an unnamed section, interleaved. |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2435 TEST_F(AutofillManagerTest, FillAddressFormWithVariantType) { | 2447 TEST_F(AutofillManagerTest, FillAddressFormWithVariantType) { |
| 2436 // Set up our form data. | 2448 // Set up our form data. |
| 2437 FormData form; | 2449 FormData form; |
| 2438 CreateTestAddressFormData(&form); | 2450 CreateTestAddressFormData(&form); |
| 2439 std::vector<FormData> forms(1, form); | 2451 std::vector<FormData> forms(1, form); |
| 2440 FormsSeen(forms); | 2452 FormsSeen(forms); |
| 2441 | 2453 |
| 2442 // Add a name variant to the Elvis profile. | 2454 // Add a name variant to the Elvis profile. |
| 2443 AutofillProfile* profile = autofill_manager_->GetProfileWithGUID( | 2455 AutofillProfile* profile = autofill_manager_->GetProfileWithGUID( |
| 2444 "00000000-0000-0000-0000-000000000001"); | 2456 "00000000-0000-0000-0000-000000000001"); |
| 2445 const string16 elvis_name = profile->GetRawInfo(NAME_FULL); | 2457 const base::string16 elvis_name = profile->GetRawInfo(NAME_FULL); |
| 2446 | 2458 |
| 2447 std::vector<string16> name_variants; | 2459 std::vector<base::string16> name_variants; |
| 2448 name_variants.push_back(ASCIIToUTF16("Some Other Guy")); | 2460 name_variants.push_back(ASCIIToUTF16("Some Other Guy")); |
| 2449 name_variants.push_back(elvis_name); | 2461 name_variants.push_back(elvis_name); |
| 2450 profile->SetRawMultiInfo(NAME_FULL, name_variants); | 2462 profile->SetRawMultiInfo(NAME_FULL, name_variants); |
| 2451 | 2463 |
| 2452 GUIDPair guid(profile->guid(), 1); | 2464 GUIDPair guid(profile->guid(), 1); |
| 2453 GUIDPair empty(std::string(), 0); | 2465 GUIDPair empty(std::string(), 0); |
| 2454 FillAutofillFormData(kDefaultPageID, form, form.fields[0], | 2466 FillAutofillFormData(kDefaultPageID, form, form.fields[0], |
| 2455 PackGUIDs(empty, guid)); | 2467 PackGUIDs(empty, guid)); |
| 2456 | 2468 |
| 2457 int page_id = 0; | 2469 int page_id = 0; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 page_id = 0; | 2555 page_id = 0; |
| 2544 FormData results1; | 2556 FormData results1; |
| 2545 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results1)); | 2557 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results1)); |
| 2546 EXPECT_EQ(1, page_id); | 2558 EXPECT_EQ(1, page_id); |
| 2547 | 2559 |
| 2548 ASSERT_EQ(5U, results1.fields.size()); | 2560 ASSERT_EQ(5U, results1.fields.size()); |
| 2549 EXPECT_EQ(ASCIIToUTF16("1"), results1.fields[0].value); | 2561 EXPECT_EQ(ASCIIToUTF16("1"), results1.fields[0].value); |
| 2550 EXPECT_EQ(ASCIIToUTF16("650"), results1.fields[1].value); | 2562 EXPECT_EQ(ASCIIToUTF16("650"), results1.fields[1].value); |
| 2551 EXPECT_EQ(ASCIIToUTF16("555"), results1.fields[2].value); | 2563 EXPECT_EQ(ASCIIToUTF16("555"), results1.fields[2].value); |
| 2552 EXPECT_EQ(ASCIIToUTF16("4567"), results1.fields[3].value); | 2564 EXPECT_EQ(ASCIIToUTF16("4567"), results1.fields[3].value); |
| 2553 EXPECT_EQ(string16(), results1.fields[4].value); | 2565 EXPECT_EQ(base::string16(), results1.fields[4].value); |
| 2554 | 2566 |
| 2555 page_id = 2; | 2567 page_id = 2; |
| 2556 FillAutofillFormData(page_id, form_with_autocompletetype, | 2568 FillAutofillFormData(page_id, form_with_autocompletetype, |
| 2557 *form_with_autocompletetype.fields.begin(), | 2569 *form_with_autocompletetype.fields.begin(), |
| 2558 PackGUIDs(empty, guid)); | 2570 PackGUIDs(empty, guid)); |
| 2559 page_id = 0; | 2571 page_id = 0; |
| 2560 FormData results2; | 2572 FormData results2; |
| 2561 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results2)); | 2573 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results2)); |
| 2562 EXPECT_EQ(2, page_id); | 2574 EXPECT_EQ(2, page_id); |
| 2563 | 2575 |
| 2564 ASSERT_EQ(5U, results2.fields.size()); | 2576 ASSERT_EQ(5U, results2.fields.size()); |
| 2565 EXPECT_EQ(ASCIIToUTF16("1"), results2.fields[0].value); | 2577 EXPECT_EQ(ASCIIToUTF16("1"), results2.fields[0].value); |
| 2566 EXPECT_EQ(ASCIIToUTF16("650"), results2.fields[1].value); | 2578 EXPECT_EQ(ASCIIToUTF16("650"), results2.fields[1].value); |
| 2567 EXPECT_EQ(ASCIIToUTF16("555"), results2.fields[2].value); | 2579 EXPECT_EQ(ASCIIToUTF16("555"), results2.fields[2].value); |
| 2568 EXPECT_EQ(ASCIIToUTF16("4567"), results2.fields[3].value); | 2580 EXPECT_EQ(ASCIIToUTF16("4567"), results2.fields[3].value); |
| 2569 EXPECT_EQ(string16(), results2.fields[4].value); | 2581 EXPECT_EQ(base::string16(), results2.fields[4].value); |
| 2570 | 2582 |
| 2571 // We should not be able to fill prefix and suffix fields for international | 2583 // We should not be able to fill prefix and suffix fields for international |
| 2572 // numbers. | 2584 // numbers. |
| 2573 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB")); | 2585 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB")); |
| 2574 work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, | 2586 work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, |
| 2575 ASCIIToUTF16("447700954321")); | 2587 ASCIIToUTF16("447700954321")); |
| 2576 page_id = 3; | 2588 page_id = 3; |
| 2577 FillAutofillFormData(page_id, form_with_maxlength, | 2589 FillAutofillFormData(page_id, form_with_maxlength, |
| 2578 *form_with_maxlength.fields.begin(), | 2590 *form_with_maxlength.fields.begin(), |
| 2579 PackGUIDs(empty, guid)); | 2591 PackGUIDs(empty, guid)); |
| 2580 page_id = 0; | 2592 page_id = 0; |
| 2581 FormData results3; | 2593 FormData results3; |
| 2582 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results3)); | 2594 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results3)); |
| 2583 EXPECT_EQ(3, page_id); | 2595 EXPECT_EQ(3, page_id); |
| 2584 | 2596 |
| 2585 ASSERT_EQ(5U, results3.fields.size()); | 2597 ASSERT_EQ(5U, results3.fields.size()); |
| 2586 EXPECT_EQ(ASCIIToUTF16("44"), results3.fields[0].value); | 2598 EXPECT_EQ(ASCIIToUTF16("44"), results3.fields[0].value); |
| 2587 EXPECT_EQ(ASCIIToUTF16("7700"), results3.fields[1].value); | 2599 EXPECT_EQ(ASCIIToUTF16("7700"), results3.fields[1].value); |
| 2588 EXPECT_EQ(ASCIIToUTF16("954321"), results3.fields[2].value); | 2600 EXPECT_EQ(ASCIIToUTF16("954321"), results3.fields[2].value); |
| 2589 EXPECT_EQ(ASCIIToUTF16("954321"), results3.fields[3].value); | 2601 EXPECT_EQ(ASCIIToUTF16("954321"), results3.fields[3].value); |
| 2590 EXPECT_EQ(string16(), results3.fields[4].value); | 2602 EXPECT_EQ(base::string16(), results3.fields[4].value); |
| 2591 | 2603 |
| 2592 page_id = 4; | 2604 page_id = 4; |
| 2593 FillAutofillFormData(page_id, form_with_autocompletetype, | 2605 FillAutofillFormData(page_id, form_with_autocompletetype, |
| 2594 *form_with_autocompletetype.fields.begin(), | 2606 *form_with_autocompletetype.fields.begin(), |
| 2595 PackGUIDs(empty, guid)); | 2607 PackGUIDs(empty, guid)); |
| 2596 page_id = 0; | 2608 page_id = 0; |
| 2597 FormData results4; | 2609 FormData results4; |
| 2598 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results4)); | 2610 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results4)); |
| 2599 EXPECT_EQ(4, page_id); | 2611 EXPECT_EQ(4, page_id); |
| 2600 | 2612 |
| 2601 ASSERT_EQ(5U, results4.fields.size()); | 2613 ASSERT_EQ(5U, results4.fields.size()); |
| 2602 EXPECT_EQ(ASCIIToUTF16("44"), results4.fields[0].value); | 2614 EXPECT_EQ(ASCIIToUTF16("44"), results4.fields[0].value); |
| 2603 EXPECT_EQ(ASCIIToUTF16("7700"), results4.fields[1].value); | 2615 EXPECT_EQ(ASCIIToUTF16("7700"), results4.fields[1].value); |
| 2604 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[2].value); | 2616 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[2].value); |
| 2605 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[3].value); | 2617 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[3].value); |
| 2606 EXPECT_EQ(string16(), results4.fields[4].value); | 2618 EXPECT_EQ(base::string16(), results4.fields[4].value); |
| 2607 | 2619 |
| 2608 // We should fill all phone fields with the same phone number variant. | 2620 // We should fill all phone fields with the same phone number variant. |
| 2609 std::vector<string16> phone_variants; | 2621 std::vector<base::string16> phone_variants; |
| 2610 phone_variants.push_back(ASCIIToUTF16("16505554567")); | 2622 phone_variants.push_back(ASCIIToUTF16("16505554567")); |
| 2611 phone_variants.push_back(ASCIIToUTF16("18887771234")); | 2623 phone_variants.push_back(ASCIIToUTF16("18887771234")); |
| 2612 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); | 2624 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
| 2613 work_profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_variants); | 2625 work_profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_variants); |
| 2614 | 2626 |
| 2615 page_id = 5; | 2627 page_id = 5; |
| 2616 GUIDPair variant_guid(work_profile->guid(), 1); | 2628 GUIDPair variant_guid(work_profile->guid(), 1); |
| 2617 FillAutofillFormData(page_id, form_with_maxlength, | 2629 FillAutofillFormData(page_id, form_with_maxlength, |
| 2618 *form_with_maxlength.fields.begin(), | 2630 *form_with_maxlength.fields.begin(), |
| 2619 PackGUIDs(empty, variant_guid)); | 2631 PackGUIDs(empty, variant_guid)); |
| 2620 page_id = 0; | 2632 page_id = 0; |
| 2621 FormData results5; | 2633 FormData results5; |
| 2622 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results5)); | 2634 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results5)); |
| 2623 EXPECT_EQ(5, page_id); | 2635 EXPECT_EQ(5, page_id); |
| 2624 | 2636 |
| 2625 ASSERT_EQ(5U, results5.fields.size()); | 2637 ASSERT_EQ(5U, results5.fields.size()); |
| 2626 EXPECT_EQ(ASCIIToUTF16("1"), results5.fields[0].value); | 2638 EXPECT_EQ(ASCIIToUTF16("1"), results5.fields[0].value); |
| 2627 EXPECT_EQ(ASCIIToUTF16("888"), results5.fields[1].value); | 2639 EXPECT_EQ(ASCIIToUTF16("888"), results5.fields[1].value); |
| 2628 EXPECT_EQ(ASCIIToUTF16("777"), results5.fields[2].value); | 2640 EXPECT_EQ(ASCIIToUTF16("777"), results5.fields[2].value); |
| 2629 EXPECT_EQ(ASCIIToUTF16("1234"), results5.fields[3].value); | 2641 EXPECT_EQ(ASCIIToUTF16("1234"), results5.fields[3].value); |
| 2630 EXPECT_EQ(string16(), results5.fields[4].value); | 2642 EXPECT_EQ(base::string16(), results5.fields[4].value); |
| 2631 } | 2643 } |
| 2632 | 2644 |
| 2633 // Test that we can still fill a form when a field has been removed from it. | 2645 // Test that we can still fill a form when a field has been removed from it. |
| 2634 TEST_F(AutofillManagerTest, FormChangesRemoveField) { | 2646 TEST_F(AutofillManagerTest, FormChangesRemoveField) { |
| 2635 // Set up our form data. | 2647 // Set up our form data. |
| 2636 FormData form; | 2648 FormData form; |
| 2637 CreateTestAddressFormData(&form); | 2649 CreateTestAddressFormData(&form); |
| 2638 | 2650 |
| 2639 // Add a field -- we'll remove it again later. | 2651 // Add a field -- we'll remove it again later. |
| 2640 FormFieldData field; | 2652 FormFieldData field; |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3340 | 3352 |
| 3341 FormData form; | 3353 FormData form; |
| 3342 CreateTestAddressFormData(&form); | 3354 CreateTestAddressFormData(&form); |
| 3343 std::vector<FormData> forms(1, form); | 3355 std::vector<FormData> forms(1, form); |
| 3344 FormsSeen(forms); | 3356 FormsSeen(forms); |
| 3345 const FormFieldData& field = form.fields[0]; | 3357 const FormFieldData& field = form.fields[0]; |
| 3346 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3358 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
| 3347 | 3359 |
| 3348 autofill_manager_->SetExternalDelegate(NULL); | 3360 autofill_manager_->SetExternalDelegate(NULL); |
| 3349 } | 3361 } |
| OLD | NEW |