OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 FormFieldData field = form.fields[1]; | 852 FormFieldData field = form.fields[1]; |
853 GetAutofillSuggestions(form, field); | 853 GetAutofillSuggestions(form, field); |
854 | 854 |
855 // No suggestions provided, so send an empty vector as the results. | 855 // No suggestions provided, so send an empty vector as the results. |
856 // This triggers the combined message send. | 856 // This triggers the combined message send. |
857 AutocompleteSuggestionsReturned(std::vector<base::string16>()); | 857 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
858 | 858 |
859 // Test that we sent the right values to the external delegate. | 859 // Test that we sent the right values to the external delegate. |
860 external_delegate_->CheckSuggestions( | 860 external_delegate_->CheckSuggestions( |
861 kDefaultPageID, | 861 kDefaultPageID, |
862 Suggestion("************3456", "04/12", kVisaCard, | 862 Suggestion("Visa - 3456", "04/12", kVisaCard, |
863 autofill_manager_->GetPackedCreditCardID(4)), | 863 autofill_manager_->GetPackedCreditCardID(4)), |
864 Suggestion("************8765", "10/14", kMasterCard, | 864 Suggestion("MasterCard - 8765", "10/14", kMasterCard, |
865 autofill_manager_->GetPackedCreditCardID(5))); | 865 autofill_manager_->GetPackedCreditCardID(5))); |
866 } | 866 } |
867 | 867 |
868 // Test that we return only matching credit card profile suggestions when the | 868 // Test that we return only matching credit card profile suggestions when the |
869 // selected form field has been partially filled out. | 869 // selected form field has been partially filled out. |
870 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsMatchCharacter) { | 870 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsMatchCharacter) { |
871 // Set up our form data. | 871 // Set up our form data. |
872 FormData form; | 872 FormData form; |
873 CreateTestCreditCardFormData(&form, true, false); | 873 CreateTestCreditCardFormData(&form, true, false); |
874 std::vector<FormData> forms(1, form); | 874 std::vector<FormData> forms(1, form); |
875 FormsSeen(forms); | 875 FormsSeen(forms); |
876 | 876 |
877 FormFieldData field; | 877 FormFieldData field; |
878 test::CreateTestFormField("Card Number", "cardnumber", "78", "text", &field); | 878 test::CreateTestFormField("Card Number", "cardnumber", "78", "text", &field); |
879 GetAutofillSuggestions(form, field); | 879 GetAutofillSuggestions(form, field); |
880 | 880 |
881 // No suggestions provided, so send an empty vector as the results. | 881 // No suggestions provided, so send an empty vector as the results. |
882 // This triggers the combined message send. | 882 // This triggers the combined message send. |
883 AutocompleteSuggestionsReturned(std::vector<base::string16>()); | 883 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
884 | 884 |
885 // Test that we sent the right values to the external delegate. | 885 // Test that we sent the right values to the external delegate. |
886 external_delegate_->CheckSuggestions( | 886 external_delegate_->CheckSuggestions( |
887 kDefaultPageID, | 887 kDefaultPageID, |
888 Suggestion("************3456", "04/12", kVisaCard, | 888 Suggestion("Visa - 3456", "04/12", kVisaCard, |
889 autofill_manager_->GetPackedCreditCardID(4))); | 889 autofill_manager_->GetPackedCreditCardID(4))); |
890 } | 890 } |
891 | 891 |
892 // Test that we return credit card profile suggestions when the selected form | 892 // Test that we return credit card profile suggestions when the selected form |
893 // field is not the credit card number field. | 893 // field is not the credit card number field. |
894 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { | 894 TEST_F(AutofillManagerTest, GetCreditCardSuggestionsNonCCNumber) { |
895 // Set up our form data. | 895 // Set up our form data. |
896 FormData form; | 896 FormData form; |
897 CreateTestCreditCardFormData(&form, true, false); | 897 CreateTestCreditCardFormData(&form, true, false); |
898 std::vector<FormData> forms(1, form); | 898 std::vector<FormData> forms(1, form); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 FormFieldData field = form.fields[1]; | 982 FormFieldData field = form.fields[1]; |
983 GetAutofillSuggestions(form, field); | 983 GetAutofillSuggestions(form, field); |
984 | 984 |
985 // No suggestions provided, so send an empty vector as the results. | 985 // No suggestions provided, so send an empty vector as the results. |
986 // This triggers the combined message send. | 986 // This triggers the combined message send. |
987 AutocompleteSuggestionsReturned(std::vector<base::string16>()); | 987 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
988 | 988 |
989 // Test that we sent the right values to the external delegate. | 989 // Test that we sent the right values to the external delegate. |
990 external_delegate_->CheckSuggestions( | 990 external_delegate_->CheckSuggestions( |
991 kDefaultPageID, | 991 kDefaultPageID, |
992 Suggestion("************3456", "04/12", kVisaCard, | 992 Suggestion("Visa - 3456", "04/12", kVisaCard, |
993 autofill_manager_->GetPackedCreditCardID(4)), | 993 autofill_manager_->GetPackedCreditCardID(4)), |
994 Suggestion("************8765", "10/14", kMasterCard, | 994 Suggestion("MasterCard - 8765", "10/14", kMasterCard, |
995 autofill_manager_->GetPackedCreditCardID(5)), | 995 autofill_manager_->GetPackedCreditCardID(5)), |
996 Suggestion("************3456", "05/12", kMasterCard, | 996 Suggestion("MasterCard - 3456", "05/12", kMasterCard, |
997 autofill_manager_->GetPackedCreditCardID(7))); | 997 autofill_manager_->GetPackedCreditCardID(7))); |
998 } | 998 } |
999 | 999 |
1000 // Test that we return profile and credit card suggestions for combined forms. | 1000 // Test that we return profile and credit card suggestions for combined forms. |
1001 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { | 1001 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestions) { |
1002 // Set up our form data. | 1002 // Set up our form data. |
1003 FormData form; | 1003 FormData form; |
1004 test::CreateTestAddressFormData(&form); | 1004 test::CreateTestAddressFormData(&form); |
1005 CreateTestCreditCardFormData(&form, true, false); | 1005 CreateTestCreditCardFormData(&form, true, false); |
1006 std::vector<FormData> forms(1, form); | 1006 std::vector<FormData> forms(1, form); |
(...skipping 16 matching lines...) Expand all Loading... |
1023 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); | 1023 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); |
1024 GetAutofillSuggestions(kPageID2, form, field); | 1024 GetAutofillSuggestions(kPageID2, form, field); |
1025 | 1025 |
1026 // No suggestions provided, so send an empty vector as the results. | 1026 // No suggestions provided, so send an empty vector as the results. |
1027 // This triggers the combined message send. | 1027 // This triggers the combined message send. |
1028 AutocompleteSuggestionsReturned(std::vector<base::string16>()); | 1028 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
1029 | 1029 |
1030 // Test that we sent the credit card suggestions to the external delegate. | 1030 // Test that we sent the credit card suggestions to the external delegate. |
1031 external_delegate_->CheckSuggestions( | 1031 external_delegate_->CheckSuggestions( |
1032 kPageID2, | 1032 kPageID2, |
1033 Suggestion("************3456", "04/12", kVisaCard, | 1033 Suggestion("Visa - 3456", "04/12", kVisaCard, |
1034 autofill_manager_->GetPackedCreditCardID(4)), | 1034 autofill_manager_->GetPackedCreditCardID(4)), |
1035 Suggestion("************8765", "10/14", kMasterCard, | 1035 Suggestion("MasterCard - 8765", "10/14", kMasterCard, |
1036 autofill_manager_->GetPackedCreditCardID(5))); | 1036 autofill_manager_->GetPackedCreditCardID(5))); |
1037 } | 1037 } |
1038 | 1038 |
1039 // Test that for non-https forms with both address and credit card fields, we | 1039 // Test that for non-https forms with both address and credit card fields, we |
1040 // only return address suggestions. Instead of credit card suggestions, we | 1040 // only return address suggestions. Instead of credit card suggestions, we |
1041 // should return a warning explaining that credit card profile suggestions are | 1041 // should return a warning explaining that credit card profile suggestions are |
1042 // unavailable when the form is not https. | 1042 // unavailable when the form is not https. |
1043 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { | 1043 TEST_F(AutofillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) { |
1044 // Set up our form data. | 1044 // Set up our form data. |
1045 FormData form; | 1045 FormData form; |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2924 | 2924 |
2925 // Get the suggestions for already filled credit card |number_field|. | 2925 // Get the suggestions for already filled credit card |number_field|. |
2926 GetAutofillSuggestions(form, number_field); | 2926 GetAutofillSuggestions(form, number_field); |
2927 | 2927 |
2928 // No autocomplete suggestions provided, so send an empty vector as the | 2928 // No autocomplete suggestions provided, so send an empty vector as the |
2929 // results. This triggers the combined message send. | 2929 // results. This triggers the combined message send. |
2930 AutocompleteSuggestionsReturned(std::vector<base::string16>()); | 2930 AutocompleteSuggestionsReturned(std::vector<base::string16>()); |
2931 | 2931 |
2932 external_delegate_->CheckSuggestions( | 2932 external_delegate_->CheckSuggestions( |
2933 kDefaultPageID, | 2933 kDefaultPageID, |
2934 Suggestion("************3456", "04/12", kVisaCard, | 2934 Suggestion("Visa - 3456", "04/12", kVisaCard, |
2935 autofill_manager_->GetPackedCreditCardID(4))); | 2935 autofill_manager_->GetPackedCreditCardID(4))); |
2936 } | 2936 } |
2937 | 2937 |
2938 } // namespace autofill | 2938 } // namespace autofill |
OLD | NEW |