Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/autofill/autofill_manager_unittest.cc

Issue 7892048: Autofill: Remove fax number completely. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 credit_cards_->push_back(credit_card); 97 credit_cards_->push_back(credit_card);
98 } 98 }
99 99
100 private: 100 private:
101 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { 101 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) {
102 AutofillProfile* profile = new AutofillProfile; 102 AutofillProfile* profile = new AutofillProfile;
103 autofill_test::SetProfileInfo(profile, "Elvis", "Aaron", 103 autofill_test::SetProfileInfo(profile, "Elvis", "Aaron",
104 "Presley", "theking@gmail.com", "RCA", 104 "Presley", "theking@gmail.com", "RCA",
105 "3734 Elvis Presley Blvd.", "Apt. 10", 105 "3734 Elvis Presley Blvd.", "Apt. 10",
106 "Memphis", "Tennessee", "38116", "USA", 106 "Memphis", "Tennessee", "38116", "USA",
107 "12345678901", ""); 107 "12345678901");
108 profile->set_guid("00000000-0000-0000-0000-000000000001"); 108 profile->set_guid("00000000-0000-0000-0000-000000000001");
109 profiles->push_back(profile); 109 profiles->push_back(profile);
110 profile = new AutofillProfile; 110 profile = new AutofillProfile;
111 autofill_test::SetProfileInfo(profile, "Charles", "Hardin", 111 autofill_test::SetProfileInfo(profile, "Charles", "Hardin",
112 "Holley", "buddy@gmail.com", "Decca", 112 "Holley", "buddy@gmail.com", "Decca",
113 "123 Apple St.", "unit 6", "Lubbock", 113 "123 Apple St.", "unit 6", "Lubbock",
114 "Texas", "79401", "USA", "23456789012", 114 "Texas", "79401", "USA", "23456789012");
115 "");
116 profile->set_guid("00000000-0000-0000-0000-000000000002"); 115 profile->set_guid("00000000-0000-0000-0000-000000000002");
117 profiles->push_back(profile); 116 profiles->push_back(profile);
118 profile = new AutofillProfile; 117 profile = new AutofillProfile;
119 autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", 118 autofill_test::SetProfileInfo(profile, "", "", "", "", "", "", "", "", "",
120 "", "", "", "", "", ""); 119 "", "", "");
121 profile->set_guid("00000000-0000-0000-0000-000000000003"); 120 profile->set_guid("00000000-0000-0000-0000-000000000003");
122 profiles->push_back(profile); 121 profiles->push_back(profile);
123 } 122 }
124 123
125 void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) { 124 void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) {
126 CreditCard* credit_card = new CreditCard; 125 CreditCard* credit_card = new CreditCard;
127 autofill_test::SetCreditCardInfo(credit_card, "Elvis Presley", 126 autofill_test::SetCreditCardInfo(credit_card, "Elvis Presley",
128 "4234 5678 9012 3456", // Visa 127 "4234 5678 9012 3456", // Visa
129 "04", "2012"); 128 "04", "2012");
130 credit_card->set_guid("00000000-0000-0000-0000-000000000004"); 129 credit_card->set_guid("00000000-0000-0000-0000-000000000004");
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 autofill_test::CreateTestFormField( 180 autofill_test::CreateTestFormField(
182 "Postal Code", "zipcode", "", "text", &field); 181 "Postal Code", "zipcode", "", "text", &field);
183 form->fields.push_back(field); 182 form->fields.push_back(field);
184 autofill_test::CreateTestFormField( 183 autofill_test::CreateTestFormField(
185 "Country", "country", "", "text", &field); 184 "Country", "country", "", "text", &field);
186 form->fields.push_back(field); 185 form->fields.push_back(field);
187 autofill_test::CreateTestFormField( 186 autofill_test::CreateTestFormField(
188 "Phone Number", "phonenumber", "", "tel", &field); 187 "Phone Number", "phonenumber", "", "tel", &field);
189 form->fields.push_back(field); 188 form->fields.push_back(field);
190 autofill_test::CreateTestFormField( 189 autofill_test::CreateTestFormField(
191 "Fax", "fax", "", "text", &field);
192 form->fields.push_back(field);
193 autofill_test::CreateTestFormField(
194 "Email", "email", "", "email", &field); 190 "Email", "email", "", "email", &field);
195 form->fields.push_back(field); 191 form->fields.push_back(field);
196 } 192 }
197 193
198 // Populates |form| with data corresponding to a simple credit card form. 194 // Populates |form| with data corresponding to a simple credit card form.
199 // Note that this actually appends fields to the form data, which can be useful 195 // Note that this actually appends fields to the form data, which can be useful
200 // for building up more complex test forms. 196 // for building up more complex test forms.
201 void CreateTestCreditCardFormData(FormData* form, 197 void CreateTestCreditCardFormData(FormData* form,
202 bool is_https, 198 bool is_https,
203 bool use_month_type) { 199 bool use_month_type) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 const char* first, 276 const char* first,
281 const char* middle, 277 const char* middle,
282 const char* last, 278 const char* last,
283 const char* address1, 279 const char* address1,
284 const char* address2, 280 const char* address2,
285 const char* city, 281 const char* city,
286 const char* state, 282 const char* state,
287 const char* postal_code, 283 const char* postal_code,
288 const char* country, 284 const char* country,
289 const char* phone, 285 const char* phone,
290 const char* fax,
291 const char* email, 286 const char* email,
292 const char* name_on_card, 287 const char* name_on_card,
293 const char* card_number, 288 const char* card_number,
294 const char* expiration_month, 289 const char* expiration_month,
295 const char* expiration_year, 290 const char* expiration_year,
296 bool has_address_fields, 291 bool has_address_fields,
297 bool has_credit_card_fields, 292 bool has_credit_card_fields,
298 bool use_month_type) { 293 bool use_month_type) {
299 // The number of fields in the address and credit card forms created above. 294 // The number of fields in the address and credit card forms created above.
300 const size_t kAddressFormSize = 12; 295 const size_t kAddressFormSize = 11;
301 const size_t kCreditCardFormSize = use_month_type ? 3 : 4; 296 const size_t kCreditCardFormSize = use_month_type ? 3 : 4;
302 297
303 EXPECT_EQ(expected_page_id, page_id); 298 EXPECT_EQ(expected_page_id, page_id);
304 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name); 299 EXPECT_EQ(ASCIIToUTF16("MyForm"), filled_form.name);
305 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method); 300 EXPECT_EQ(ASCIIToUTF16("POST"), filled_form.method);
306 if (has_credit_card_fields) { 301 if (has_credit_card_fields) {
307 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin); 302 EXPECT_EQ(GURL("https://myform.com/form.html"), filled_form.origin);
308 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action); 303 EXPECT_EQ(GURL("https://myform.com/submit.html"), filled_form.action);
309 } else { 304 } else {
310 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin); 305 EXPECT_EQ(GURL("http://myform.com/form.html"), filled_form.origin);
(...skipping 22 matching lines...) Expand all
333 ExpectFilledField("City", "city", city, "text", 328 ExpectFilledField("City", "city", city, "text",
334 filled_form.fields[5]); 329 filled_form.fields[5]);
335 ExpectFilledField("State", "state", state, "text", 330 ExpectFilledField("State", "state", state, "text",
336 filled_form.fields[6]); 331 filled_form.fields[6]);
337 ExpectFilledField("Postal Code", "zipcode", postal_code, "text", 332 ExpectFilledField("Postal Code", "zipcode", postal_code, "text",
338 filled_form.fields[7]); 333 filled_form.fields[7]);
339 ExpectFilledField("Country", "country", country, "text", 334 ExpectFilledField("Country", "country", country, "text",
340 filled_form.fields[8]); 335 filled_form.fields[8]);
341 ExpectFilledField("Phone Number", "phonenumber", phone, "tel", 336 ExpectFilledField("Phone Number", "phonenumber", phone, "tel",
342 filled_form.fields[9]); 337 filled_form.fields[9]);
343 ExpectFilledField("Fax", "fax", fax, "text", 338 ExpectFilledField("Email", "email", email, "email",
344 filled_form.fields[10]); 339 filled_form.fields[10]);
345 ExpectFilledField("Email", "email", email, "email",
346 filled_form.fields[11]);
347 } 340 }
348 341
349 if (has_credit_card_fields) { 342 if (has_credit_card_fields) {
350 size_t offset = has_address_fields? kAddressFormSize : 0; 343 size_t offset = has_address_fields? kAddressFormSize : 0;
351 ExpectFilledField("Name on Card", "nameoncard", name_on_card, "text", 344 ExpectFilledField("Name on Card", "nameoncard", name_on_card, "text",
352 filled_form.fields[offset + 0]); 345 filled_form.fields[offset + 0]);
353 ExpectFilledField("Card Number", "cardnumber", card_number, "text", 346 ExpectFilledField("Card Number", "cardnumber", card_number, "text",
354 filled_form.fields[offset + 1]); 347 filled_form.fields[offset + 1]);
355 if (use_month_type) { 348 if (use_month_type) {
356 std::string exp_year = expiration_year; 349 std::string exp_year = expiration_year;
(...skipping 12 matching lines...) Expand all
369 } 362 }
370 } 363 }
371 } 364 }
372 365
373 void ExpectFilledAddressFormElvis(int page_id, 366 void ExpectFilledAddressFormElvis(int page_id,
374 const FormData& filled_form, 367 const FormData& filled_form,
375 int expected_page_id, 368 int expected_page_id,
376 bool has_credit_card_fields) { 369 bool has_credit_card_fields) {
377 ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron", 370 ExpectFilledForm(page_id, filled_form, expected_page_id, "Elvis", "Aaron",
378 "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis", 371 "Presley", "3734 Elvis Presley Blvd.", "Apt. 10", "Memphis",
379 "Tennessee", "38116", "United States", "12345678901", "", 372 "Tennessee", "38116", "United States", "12345678901",
380 "theking@gmail.com", "", "", "", "", true, 373 "theking@gmail.com", "", "", "", "", true,
381 has_credit_card_fields, false); 374 has_credit_card_fields, false);
382 } 375 }
383 376
384 void ExpectFilledCreditCardFormElvis(int page_id, 377 void ExpectFilledCreditCardFormElvis(int page_id,
385 const FormData& filled_form, 378 const FormData& filled_form,
386 int expected_page_id, 379 int expected_page_id,
387 bool has_address_fields) { 380 bool has_address_fields) {
388 ExpectFilledForm(page_id, filled_form, expected_page_id, 381 ExpectFilledForm(page_id, filled_form, expected_page_id,
389 "", "", "", "", "", "", "", "", "", "", "", "", 382 "", "", "", "", "", "", "", "", "", "", "",
390 "Elvis Presley", "4234567890123456", "04", "2012", 383 "Elvis Presley", "4234567890123456", "04", "2012",
391 has_address_fields, true, false); 384 has_address_fields, true, false);
392 } 385 }
393 386
394 void ExpectFilledCreditCardYearMonthWithYearMonth(int page_id, 387 void ExpectFilledCreditCardYearMonthWithYearMonth(int page_id,
395 const FormData& filled_form, 388 const FormData& filled_form,
396 int expected_page_id, 389 int expected_page_id,
397 bool has_address_fields, 390 bool has_address_fields,
398 const char* year, 391 const char* year,
399 const char* month) { 392 const char* month) {
400 ExpectFilledForm(page_id, filled_form, expected_page_id, 393 ExpectFilledForm(page_id, filled_form, expected_page_id,
401 "", "", "", "", "", "", "", "", "", "", "", "", 394 "", "", "", "", "", "", "", "", "", "", "",
402 "Miku Hatsune", "4234567890654321", month, year, 395 "Miku Hatsune", "4234567890654321", month, year,
403 has_address_fields, true, true); 396 has_address_fields, true, true);
404 } 397 }
405 398
406 class TestAutofillManager : public AutofillManager { 399 class TestAutofillManager : public AutofillManager {
407 public: 400 public:
408 TestAutofillManager(TabContentsWrapper* tab_contents, 401 TestAutofillManager(TabContentsWrapper* tab_contents,
409 TestPersonalDataManager* personal_manager) 402 TestPersonalDataManager* personal_manager)
410 : AutofillManager(tab_contents, personal_manager), 403 : AutofillManager(tab_contents, personal_manager),
411 autofill_enabled_(true) { 404 autofill_enabled_(true) {
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 // filling an already filled field. 1357 // filling an already filled field.
1365 TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) { 1358 TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
1366 // Set up our form data. 1359 // Set up our form data.
1367 FormData form; 1360 FormData form;
1368 CreateTestAddressFormData(&form); 1361 CreateTestAddressFormData(&form);
1369 std::vector<FormData> forms(1, form); 1362 std::vector<FormData> forms(1, form);
1370 FormsSeen(forms); 1363 FormsSeen(forms);
1371 1364
1372 // |profile| will be owned by the mock PersonalDataManager. 1365 // |profile| will be owned by the mock PersonalDataManager.
1373 AutofillProfile* profile = new AutofillProfile; 1366 AutofillProfile* profile = new AutofillProfile;
1374 autofill_test::SetProfileInfo(profile, "Elvis", "", "", "", "", 1367 autofill_test::SetProfileInfo(profile, "Elvis", "", "", "", "", "", "", "",
1375 "", "", "", "", "", "", "", ""); 1368 "", "", "", "");
1376 profile->set_guid("00000000-0000-0000-0000-000000000101"); 1369 profile->set_guid("00000000-0000-0000-0000-000000000101");
1377 autofill_manager_->AddProfile(profile); 1370 autofill_manager_->AddProfile(profile);
1378 1371
1379 FormField& field = form.fields[0]; 1372 FormField& field = form.fields[0];
1380 field.is_autofilled = true; 1373 field.is_autofilled = true;
1381 field.value = ASCIIToUTF16("Elvis"); 1374 field.value = ASCIIToUTF16("Elvis");
1382 GetAutofillSuggestions(form, field); 1375 GetAutofillSuggestions(form, field);
1383 1376
1384 // No suggestions provided, so send an empty vector as the results. 1377 // No suggestions provided, so send an empty vector as the results.
1385 // This triggers the combined message send. 1378 // This triggers the combined message send.
(...skipping 22 matching lines...) Expand all
1408 TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileUnfilled) { 1401 TEST_F(AutofillManagerTest, GetFieldSuggestionsForMultiValuedProfileUnfilled) {
1409 // Set up our form data. 1402 // Set up our form data.
1410 FormData form; 1403 FormData form;
1411 CreateTestAddressFormData(&form); 1404 CreateTestAddressFormData(&form);
1412 std::vector<FormData> forms(1, form); 1405 std::vector<FormData> forms(1, form);
1413 FormsSeen(forms); 1406 FormsSeen(forms);
1414 1407
1415 // |profile| will be owned by the mock PersonalDataManager. 1408 // |profile| will be owned by the mock PersonalDataManager.
1416 AutofillProfile* profile = new AutofillProfile; 1409 AutofillProfile* profile = new AutofillProfile;
1417 autofill_test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "", 1410 autofill_test::SetProfileInfo(profile, "Elvis", "", "Presley", "me@x.com", "",
1418 "", "", "", "", "", "", "", ""); 1411 "", "", "", "", "", "", "");
1419 profile->set_guid("00000000-0000-0000-0000-000000000101"); 1412 profile->set_guid("00000000-0000-0000-0000-000000000101");
1420 std::vector<string16> multi_values(2); 1413 std::vector<string16> multi_values(2);
1421 multi_values[0] = ASCIIToUTF16("Elvis Presley"); 1414 multi_values[0] = ASCIIToUTF16("Elvis Presley");
1422 multi_values[1] = ASCIIToUTF16("Elena Love"); 1415 multi_values[1] = ASCIIToUTF16("Elena Love");
1423 profile->SetMultiInfo(NAME_FULL, multi_values); 1416 profile->SetMultiInfo(NAME_FULL, multi_values);
1424 test_personal_data_->ClearAutofillProfiles(); 1417 test_personal_data_->ClearAutofillProfiles();
1425 autofill_manager_->AddProfile(profile); 1418 autofill_manager_->AddProfile(profile);
1426 1419
1427 { 1420 {
1428 // Get the first name field. 1421 // Get the first name field.
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 FillAutofillFormData( 2046 FillAutofillFormData(
2054 kDefaultPageID, form, *form.fields.begin(), 2047 kDefaultPageID, form, *form.fields.begin(),
2055 autofill_manager_->PackGUIDs(empty, guid)); 2048 autofill_manager_->PackGUIDs(empty, guid));
2056 2049
2057 int page_id = 0; 2050 int page_id = 0;
2058 FormData results; 2051 FormData results;
2059 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); 2052 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results));
2060 { 2053 {
2061 SCOPED_TRACE("Address"); 2054 SCOPED_TRACE("Address");
2062 ExpectFilledForm(page_id, results, kDefaultPageID, 2055 ExpectFilledForm(page_id, results, kDefaultPageID,
2063 "Elvis", "", "", "", "", "", "", "", "", "", "", "", 2056 "Elvis", "", "", "", "", "", "", "", "", "", "", "", "",
2064 "", "", "", "", true, true, false); 2057 "", "", true, true, false);
2065 } 2058 }
2066 2059
2067 // Now fill the credit card data. 2060 // Now fill the credit card data.
2068 const int kPageID2 = 2; 2061 const int kPageID2 = 2;
2069 GUIDPair guid2("00000000-0000-0000-0000-000000000004", 0); 2062 GUIDPair guid2("00000000-0000-0000-0000-000000000004", 0);
2070 FillAutofillFormData( 2063 FillAutofillFormData(
2071 kPageID2, form, form.fields.back(), 2064 kPageID2, form, form.fields.back(),
2072 autofill_manager_->PackGUIDs(guid2, empty)); 2065 autofill_manager_->PackGUIDs(guid2, empty));
2073 2066
2074 page_id = 0; 2067 page_id = 0;
(...skipping 14 matching lines...) Expand all
2089 const int kPageID3 = 3; 2082 const int kPageID3 = 3;
2090 FillAutofillFormData( 2083 FillAutofillFormData(
2091 kPageID3, form, *form.fields.rbegin(), 2084 kPageID3, form, *form.fields.rbegin(),
2092 autofill_manager_->PackGUIDs(guid2, empty)); 2085 autofill_manager_->PackGUIDs(guid2, empty));
2093 2086
2094 page_id = 0; 2087 page_id = 0;
2095 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); 2088 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results));
2096 { 2089 {
2097 SCOPED_TRACE("Credit card 2"); 2090 SCOPED_TRACE("Credit card 2");
2098 ExpectFilledForm(page_id, results, kPageID3, 2091 ExpectFilledForm(page_id, results, kPageID3,
2099 "", "", "", "", "", "", "", "", "", "", "", "", 2092 "", "", "", "", "", "", "", "", "", "", "", "", "", "",
2100 "", "", "", "2012", true, true, false); 2093 "2012", true, true, false);
2101 } 2094 }
2102 } 2095 }
2103 2096
2104 // Test that we correctly fill a phone number split across multiple fields. 2097 // Test that we correctly fill a phone number split across multiple fields.
2105 TEST_F(AutofillManagerTest, FillPhoneNumber) { 2098 TEST_F(AutofillManagerTest, FillPhoneNumber) {
2106 // In one form, rely on the maxlength attribute to imply phone number parts. 2099 // In one form, rely on the maxlength attribute to imply phone number parts.
2107 // In the other form, rely on the autocompletetype attribute. 2100 // In the other form, rely on the autocompletetype attribute.
2108 FormData form_with_maxlength; 2101 FormData form_with_maxlength;
2109 form_with_maxlength.name = ASCIIToUTF16("MyMaxlengthPhoneForm"); 2102 form_with_maxlength.name = ASCIIToUTF16("MyMaxlengthPhoneForm");
2110 form_with_maxlength.method = ASCIIToUTF16("POST"); 2103 form_with_maxlength.method = ASCIIToUTF16("POST");
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 autofill_manager_->PackGUIDs(empty, guid)); 2241 autofill_manager_->PackGUIDs(empty, guid));
2249 2242
2250 int page_id = 0; 2243 int page_id = 0;
2251 FormData results; 2244 FormData results;
2252 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results)); 2245 EXPECT_TRUE(GetAutofillFormDataFilledMessage(&page_id, &results));
2253 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false); 2246 ExpectFilledAddressFormElvis(page_id, results, kDefaultPageID, false);
2254 } 2247 }
2255 2248
2256 // Test that we can still fill a form when a field has been added to it. 2249 // Test that we can still fill a form when a field has been added to it.
2257 TEST_F(AutofillManagerTest, FormChangesAddField) { 2250 TEST_F(AutofillManagerTest, FormChangesAddField) {
2258 // The offset of the fax field in the address form. 2251 // The offset of the phone field in the address form.
2259 const int kFaxFieldOffset = 10; 2252 const int kPhoneFieldOffset = 9;
2260 2253
2261 // Set up our form data. 2254 // Set up our form data.
2262 FormData form; 2255 FormData form;
2263 CreateTestAddressFormData(&form); 2256 CreateTestAddressFormData(&form);
2264 2257
2265 // Remove the fax field -- we'll add it back later. 2258 // Remove the phone field -- we'll add it back later.
2266 std::vector<FormField>::iterator pos = form.fields.begin() + kFaxFieldOffset; 2259 std::vector<FormField>::iterator pos =
2260 form.fields.begin() + kPhoneFieldOffset;
2267 FormField field = *pos; 2261 FormField field = *pos;
2268 pos = form.fields.erase(pos); 2262 pos = form.fields.erase(pos);
2269 2263
2270 std::vector<FormData> forms(1, form); 2264 std::vector<FormData> forms(1, form);
2271 FormsSeen(forms); 2265 FormsSeen(forms);
2272 2266
2273 // Now, after the call to |FormsSeen|, we restore the field before filling. 2267 // Now, after the call to |FormsSeen|, we restore the field before filling.
2274 form.fields.insert(pos, field); 2268 form.fields.insert(pos, field);
2275 2269
2276 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0); 2270 GUIDPair guid("00000000-0000-0000-0000-000000000001", 0);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 autofill_test::SetProfileInfo(profile, 2734 autofill_test::SetProfileInfo(profile,
2741 StringPrintf("John%d", i).c_str(), 2735 StringPrintf("John%d", i).c_str(),
2742 "", 2736 "",
2743 StringPrintf("Doe%d", i).c_str(), 2737 StringPrintf("Doe%d", i).c_str(),
2744 StringPrintf("JohnDoe%d@somesite.com", 2738 StringPrintf("JohnDoe%d@somesite.com",
2745 i).c_str(), 2739 i).c_str(),
2746 "", 2740 "",
2747 StringPrintf("%d 1st st.", i).c_str(), 2741 StringPrintf("%d 1st st.", i).c_str(),
2748 "", 2742 "",
2749 "Memphis", "Tennessee", "38116", "USA", 2743 "Memphis", "Tennessee", "38116", "USA",
2750 StringPrintf("650234%04d", i).c_str(), 2744 StringPrintf("650234%04d", i).c_str());
2751 "");
2752 profile->set_guid( 2745 profile->set_guid(
2753 StringPrintf("00000000-0000-0000-0001-00000000%04d", i).c_str()); 2746 StringPrintf("00000000-0000-0000-0001-00000000%04d", i).c_str());
2754 test_personal_data_->AddProfile(profile); 2747 test_personal_data_->AddProfile(profile);
2755 } 2748 }
2756 FormData form; 2749 FormData form;
2757 CreateTestAddressFormData(&form); 2750 CreateTestAddressFormData(&form);
2758 ASSERT_LT(3U, form.fields.size()); 2751 ASSERT_LT(3U, form.fields.size());
2759 form.fields[0].value = ASCIIToUTF16("6502340001"); 2752 form.fields[0].value = ASCIIToUTF16("6502340001");
2760 form.fields[1].value = ASCIIToUTF16("John1"); 2753 form.fields[1].value = ASCIIToUTF16("John1");
2761 form.fields[2].value = ASCIIToUTF16("12345"); 2754 form.fields[2].value = ASCIIToUTF16("12345");
(...skipping 10 matching lines...) Expand all
2772 const FieldTypeSet& possible_types1 = 2765 const FieldTypeSet& possible_types1 =
2773 form_structure.field(1)->possible_types(); 2766 form_structure.field(1)->possible_types();
2774 EXPECT_EQ(1U, possible_types1.size()); 2767 EXPECT_EQ(1U, possible_types1.size());
2775 EXPECT_TRUE(possible_types1.find(NAME_FIRST) != possible_types1.end()); 2768 EXPECT_TRUE(possible_types1.find(NAME_FIRST) != possible_types1.end());
2776 const FieldTypeSet& possible_types2 = 2769 const FieldTypeSet& possible_types2 =
2777 form_structure.field(2)->possible_types(); 2770 form_structure.field(2)->possible_types();
2778 EXPECT_EQ(1U, possible_types2.size()); 2771 EXPECT_EQ(1U, possible_types2.size());
2779 EXPECT_TRUE(possible_types2.find(UNKNOWN_TYPE) != 2772 EXPECT_TRUE(possible_types2.find(UNKNOWN_TYPE) !=
2780 possible_types2.end()); 2773 possible_types2.end());
2781 } 2774 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/autofill/autofill_merge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698