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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); | 152 credit_card->set_guid("00000000-0000-0000-0000-000000000007"); |
153 credit_cards_.push_back(credit_card); | 153 credit_cards_.push_back(credit_card); |
154 } | 154 } |
155 | 155 |
156 private: | 156 private: |
157 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { | 157 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { |
158 AutofillProfile* profile = new AutofillProfile; | 158 AutofillProfile* profile = new AutofillProfile; |
159 autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", | 159 autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", |
160 "Presley", "theking@gmail.com", "RCA", | 160 "Presley", "theking@gmail.com", "RCA", |
161 "3734 Elvis Presley Blvd.", "Apt. 10", | 161 "3734 Elvis Presley Blvd.", "Apt. 10", |
162 "Memphis", "Tennessee", "38116", "USA", | 162 "Memphis", "Tennessee", "38116", "US", |
163 "12345678901"); | 163 "12345678901"); |
164 profile->set_guid("00000000-0000-0000-0000-000000000001"); | 164 profile->set_guid("00000000-0000-0000-0000-000000000001"); |
165 profiles->push_back(profile); | 165 profiles->push_back(profile); |
166 profile = new AutofillProfile; | 166 profile = new AutofillProfile; |
167 autofill_test::SetProfileInfo(profile, "Charles", "Hardin", | 167 autofill_test::SetProfileInfo(profile, "Charles", "Hardin", |
168 "Holley", "buddy@gmail.com", "Decca", | 168 "Holley", "buddy@gmail.com", "Decca", |
169 "123 Apple St.", "unit 6", "Lubbock", | 169 "123 Apple St.", "unit 6", "Lubbock", |
170 "Texas", "79401", "USA", "23456789012"); | 170 "Texas", "79401", "US", "23456789012"); |
171 profile->set_guid("00000000-0000-0000-0000-000000000002"); | 171 profile->set_guid("00000000-0000-0000-0000-000000000002"); |
172 profiles->push_back(profile); | 172 profiles->push_back(profile); |
173 profile = new AutofillProfile; | 173 profile = new AutofillProfile; |
174 autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", "", "", | 174 autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", "", "", |
175 "", "", ""); | 175 "", "", ""); |
176 profile->set_guid("00000000-0000-0000-0000-000000000003"); | 176 profile->set_guid("00000000-0000-0000-0000-000000000003"); |
177 profiles->push_back(profile); | 177 profiles->push_back(profile); |
178 } | 178 } |
179 | 179 |
180 void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { | 180 void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { |
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 | 2469 |
2470 ASSERT_EQ(5U, results2.fields.size()); | 2470 ASSERT_EQ(5U, results2.fields.size()); |
2471 EXPECT_EQ(ASCIIToUTF16("1"), results2.fields[0].value); | 2471 EXPECT_EQ(ASCIIToUTF16("1"), results2.fields[0].value); |
2472 EXPECT_EQ(ASCIIToUTF16("650"), results2.fields[1].value); | 2472 EXPECT_EQ(ASCIIToUTF16("650"), results2.fields[1].value); |
2473 EXPECT_EQ(ASCIIToUTF16("555"), results2.fields[2].value); | 2473 EXPECT_EQ(ASCIIToUTF16("555"), results2.fields[2].value); |
2474 EXPECT_EQ(ASCIIToUTF16("4567"), results2.fields[3].value); | 2474 EXPECT_EQ(ASCIIToUTF16("4567"), results2.fields[3].value); |
2475 EXPECT_EQ(string16(), results2.fields[4].value); | 2475 EXPECT_EQ(string16(), results2.fields[4].value); |
2476 | 2476 |
2477 // We should not be able to fill prefix and suffix fields for international | 2477 // We should not be able to fill prefix and suffix fields for international |
2478 // numbers. | 2478 // numbers. |
2479 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, | 2479 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("GB")); |
2480 ASCIIToUTF16("United Kingdom")); | |
2481 work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, | 2480 work_profile->SetRawInfo(PHONE_HOME_WHOLE_NUMBER, |
2482 ASCIIToUTF16("447700954321")); | 2481 ASCIIToUTF16("447700954321")); |
2483 page_id = 3; | 2482 page_id = 3; |
2484 FillAutofillFormData(page_id, form_with_maxlength, | 2483 FillAutofillFormData(page_id, form_with_maxlength, |
2485 *form_with_maxlength.fields.begin(), | 2484 *form_with_maxlength.fields.begin(), |
2486 PackGUIDs(empty, guid)); | 2485 PackGUIDs(empty, guid)); |
2487 page_id = 0; | 2486 page_id = 0; |
2488 FormData results3; | 2487 FormData results3; |
2489 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results3)); | 2488 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results3)); |
2490 EXPECT_EQ(3, page_id); | 2489 EXPECT_EQ(3, page_id); |
(...skipping 18 matching lines...) Expand all Loading... |
2509 EXPECT_EQ(ASCIIToUTF16("44"), results4.fields[0].value); | 2508 EXPECT_EQ(ASCIIToUTF16("44"), results4.fields[0].value); |
2510 EXPECT_EQ(ASCIIToUTF16("7700"), results4.fields[1].value); | 2509 EXPECT_EQ(ASCIIToUTF16("7700"), results4.fields[1].value); |
2511 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[2].value); | 2510 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[2].value); |
2512 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[3].value); | 2511 EXPECT_EQ(ASCIIToUTF16("954321"), results4.fields[3].value); |
2513 EXPECT_EQ(string16(), results4.fields[4].value); | 2512 EXPECT_EQ(string16(), results4.fields[4].value); |
2514 | 2513 |
2515 // We should fill all phone fields with the same phone number variant. | 2514 // We should fill all phone fields with the same phone number variant. |
2516 std::vector<string16> phone_variants; | 2515 std::vector<string16> phone_variants; |
2517 phone_variants.push_back(ASCIIToUTF16("16505554567")); | 2516 phone_variants.push_back(ASCIIToUTF16("16505554567")); |
2518 phone_variants.push_back(ASCIIToUTF16("18887771234")); | 2517 phone_variants.push_back(ASCIIToUTF16("18887771234")); |
2519 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States")); | 2518 work_profile->SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
2520 work_profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_variants); | 2519 work_profile->SetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, phone_variants); |
2521 | 2520 |
2522 page_id = 5; | 2521 page_id = 5; |
2523 GUIDPair variant_guid(work_profile->guid(), 1); | 2522 GUIDPair variant_guid(work_profile->guid(), 1); |
2524 FillAutofillFormData(page_id, form_with_maxlength, | 2523 FillAutofillFormData(page_id, form_with_maxlength, |
2525 *form_with_maxlength.fields.begin(), | 2524 *form_with_maxlength.fields.begin(), |
2526 PackGUIDs(empty, variant_guid)); | 2525 PackGUIDs(empty, variant_guid)); |
2527 page_id = 0; | 2526 page_id = 0; |
2528 FormData results5; | 2527 FormData results5; |
2529 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results5)); | 2528 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results5)); |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3231 | 3230 |
3232 FormData form; | 3231 FormData form; |
3233 CreateTestAddressFormData(&form); | 3232 CreateTestAddressFormData(&form); |
3234 std::vector<FormData> forms(1, form); | 3233 std::vector<FormData> forms(1, form); |
3235 FormsSeen(forms); | 3234 FormsSeen(forms); |
3236 const FormFieldData& field = form.fields[0]; | 3235 const FormFieldData& field = form.fields[0]; |
3237 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3236 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
3238 | 3237 |
3239 autofill_manager_->SetExternalDelegate(NULL); | 3238 autofill_manager_->SetExternalDelegate(NULL); |
3240 } | 3239 } |
OLD | NEW |