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

Side by Side Diff: components/autofill/core/browser/form_structure_unittest.cc

Issue 1774153002: [Autofill] Add the phone extension type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and adapt heuristic output Created 4 years, 9 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
OLDNEW
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 "components/autofill/core/browser/form_structure.h" 5 #include "components/autofill/core/browser/form_structure.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 field.name = ASCIIToUTF16("Submit"); 399 field.name = ASCIIToUTF16("Submit");
400 field.form_control_type = "submit"; 400 field.form_control_type = "submit";
401 form.fields.push_back(field); 401 form.fields.push_back(field);
402 402
403 form_structure.reset(new FormStructure(form)); 403 form_structure.reset(new FormStructure(form));
404 form_structure->DetermineHeuristicTypes(); 404 form_structure->DetermineHeuristicTypes();
405 EXPECT_TRUE(form_structure->IsAutofillable()); 405 EXPECT_TRUE(form_structure->IsAutofillable());
406 406
407 // Expect the correct number of fields. 407 // Expect the correct number of fields.
408 ASSERT_EQ(9U, form_structure->field_count()); 408 ASSERT_EQ(9U, form_structure->field_count());
409 ASSERT_EQ(7U, form_structure->autofill_count()); 409 ASSERT_EQ(8U, form_structure->autofill_count());
410 410
411 // First name. 411 // First name.
412 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type()); 412 EXPECT_EQ(NAME_FIRST, form_structure->field(0)->heuristic_type());
413 // Last name. 413 // Last name.
414 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type()); 414 EXPECT_EQ(NAME_LAST, form_structure->field(1)->heuristic_type());
415 // Email. 415 // Email.
416 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type()); 416 EXPECT_EQ(EMAIL_ADDRESS, form_structure->field(2)->heuristic_type());
417 // Phone. 417 // Phone.
418 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, 418 EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER,
419 form_structure->field(3)->heuristic_type()); 419 form_structure->field(3)->heuristic_type());
420 // Phone extension. 420 // Phone extension.
421 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(4)->heuristic_type()); 421 EXPECT_EQ(PHONE_HOME_EXTENSION, form_structure->field(4)->heuristic_type());
422 // Address. 422 // Address.
423 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(5)->heuristic_type()); 423 EXPECT_EQ(ADDRESS_HOME_LINE1, form_structure->field(5)->heuristic_type());
424 // City. 424 // City.
425 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(6)->heuristic_type()); 425 EXPECT_EQ(ADDRESS_HOME_CITY, form_structure->field(6)->heuristic_type());
426 // Zip. 426 // Zip.
427 EXPECT_EQ(ADDRESS_HOME_ZIP, form_structure->field(7)->heuristic_type()); 427 EXPECT_EQ(ADDRESS_HOME_ZIP, form_structure->field(7)->heuristic_type());
428 // Submit. 428 // Submit.
429 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(8)->heuristic_type()); 429 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(8)->heuristic_type());
430 } 430 }
431 431
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 1646
1647 field.label = ASCIIToUTF16("ext.:"); 1647 field.label = ASCIIToUTF16("ext.:");
1648 field.name = ASCIIToUTF16("dayphone4"); 1648 field.name = ASCIIToUTF16("dayphone4");
1649 field.max_length = 0; 1649 field.max_length = 0;
1650 form.fields.push_back(field); 1650 form.fields.push_back(field);
1651 1651
1652 form_structure.reset(new FormStructure(form)); 1652 form_structure.reset(new FormStructure(form));
1653 form_structure->DetermineHeuristicTypes(); 1653 form_structure->DetermineHeuristicTypes();
1654 EXPECT_TRUE(form_structure->IsAutofillable()); 1654 EXPECT_TRUE(form_structure->IsAutofillable());
1655 ASSERT_EQ(4U, form_structure->field_count()); 1655 ASSERT_EQ(4U, form_structure->field_count());
1656 ASSERT_EQ(3U, form_structure->autofill_count()); 1656 ASSERT_EQ(4U, form_structure->autofill_count());
1657 1657
1658 // Area code. 1658 // Area code.
1659 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type()); 1659 EXPECT_EQ(PHONE_HOME_CITY_CODE, form_structure->field(0)->heuristic_type());
1660 // Phone number suffix. 1660 // Phone number suffix.
1661 EXPECT_EQ(PHONE_HOME_NUMBER, 1661 EXPECT_EQ(PHONE_HOME_NUMBER,
1662 form_structure->field(1)->heuristic_type()); 1662 form_structure->field(1)->heuristic_type());
1663 // Phone number suffix. 1663 // Phone number suffix.
1664 EXPECT_EQ(PHONE_HOME_NUMBER, 1664 EXPECT_EQ(PHONE_HOME_NUMBER,
1665 form_structure->field(2)->heuristic_type()); 1665 form_structure->field(2)->heuristic_type());
1666 // Unknown. 1666 // Phone extension.
1667 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type()); 1667 EXPECT_EQ(PHONE_HOME_EXTENSION, form_structure->field(3)->heuristic_type());
1668 } 1668 }
1669 1669
1670 TEST_F(FormStructureTest, HeuristicsInfernoCC) { 1670 TEST_F(FormStructureTest, HeuristicsInfernoCC) {
1671 scoped_ptr<FormStructure> form_structure; 1671 scoped_ptr<FormStructure> form_structure;
1672 FormData form; 1672 FormData form;
1673 1673
1674 FormFieldData field; 1674 FormFieldData field;
1675 field.form_control_type = "text"; 1675 field.form_control_type = "text";
1676 1676
1677 field.label = ASCIIToUTF16("Name on Card"); 1677 field.label = ASCIIToUTF16("Name on Card");
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
3581 prefix = FormStructure::FindLongestCommonPrefix(strings); 3581 prefix = FormStructure::FindLongestCommonPrefix(strings);
3582 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); 3582 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix);
3583 3583
3584 // Empty vector. 3584 // Empty vector.
3585 strings.clear(); 3585 strings.clear();
3586 prefix = FormStructure::FindLongestCommonPrefix(strings); 3586 prefix = FormStructure::FindLongestCommonPrefix(strings);
3587 EXPECT_EQ(ASCIIToUTF16(""), prefix); 3587 EXPECT_EQ(ASCIIToUTF16(""), prefix);
3588 } 3588 }
3589 3589
3590 } // namespace autofill 3590 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/form_structure.cc ('k') | components/autofill/core/browser/phone_field.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698