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

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

Issue 2013063002: Remove diacritics when normalizing autofill profile strings for comparison. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify normalization loop and expand test cases. Created 4 years, 6 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
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 3496 matching lines...) Expand 10 before | Expand all | Expand 10 after
3507 "+1 (234) 567-8901"); 3507 "+1 (234) 567-8901");
3508 profile.set_guid("00000000-0000-0000-0000-000000000001"); 3508 profile.set_guid("00000000-0000-0000-0000-000000000001");
3509 profiles.push_back(profile); 3509 profiles.push_back(profile);
3510 test::SetProfileInfo(&profile, "Charles", "", "Holley", "buddy@gmail.com", 3510 test::SetProfileInfo(&profile, "Charles", "", "Holley", "buddy@gmail.com",
3511 "Decca", "123 Apple St.", "unit 6", "Lubbock", "TX", 3511 "Decca", "123 Apple St.", "unit 6", "Lubbock", "TX",
3512 "79401", "US", "5142821292"); 3512 "79401", "US", "5142821292");
3513 profile.set_guid("00000000-0000-0000-0000-000000000002"); 3513 profile.set_guid("00000000-0000-0000-0000-000000000002");
3514 profiles.push_back(profile); 3514 profiles.push_back(profile);
3515 test::SetProfileInfo(&profile, "Charles", "", "Baudelaire", 3515 test::SetProfileInfo(&profile, "Charles", "", "Baudelaire",
3516 "lesfleursdumal@gmail.com", "", "108 Rue Saint-Lazare", 3516 "lesfleursdumal@gmail.com", "", "108 Rue Saint-Lazare",
3517 "Apt. 10", "Paris", "Ile de France", "75008", "FR", 3517 "Apt. 10", "Paris", "Île de France", "75008", "FR",
3518 "+33 2 49 19 70 70"); 3518 "+33 2 49 19 70 70");
3519 profile.set_guid("00000000-0000-0000-0000-000000000001"); 3519 profile.set_guid("00000000-0000-0000-0000-000000000001");
3520 profiles.push_back(profile); 3520 profiles.push_back(profile);
3521 3521
3522 // Set up the test credit cards. 3522 // Set up the test credit cards.
3523 std::vector<CreditCard> credit_cards; 3523 std::vector<CreditCard> credit_cards;
3524 CreditCard credit_card; 3524 CreditCard credit_card;
3525 test::SetCreditCardInfo(&credit_card, "John Doe", "4234-5678-9012-3456", "04", 3525 test::SetCreditCardInfo(&credit_card, "John Doe", "4234-5678-9012-3456", "04",
3526 "2999"); 3526 "2999");
3527 credit_card.set_guid("00000000-0000-0000-0000-000000000003"); 3527 credit_card.set_guid("00000000-0000-0000-0000-000000000003");
(...skipping 23 matching lines...) Expand all
3551 {"12345678901", PHONE_HOME_WHOLE_NUMBER}, 3551 {"12345678901", PHONE_HOME_WHOLE_NUMBER},
3552 {"+1 (234) 567-8901", PHONE_HOME_WHOLE_NUMBER}, 3552 {"+1 (234) 567-8901", PHONE_HOME_WHOLE_NUMBER},
3553 {"(234)567-8901", PHONE_HOME_CITY_AND_NUMBER}, 3553 {"(234)567-8901", PHONE_HOME_CITY_AND_NUMBER},
3554 {"2345678901", PHONE_HOME_CITY_AND_NUMBER}, 3554 {"2345678901", PHONE_HOME_CITY_AND_NUMBER},
3555 {"1", PHONE_HOME_COUNTRY_CODE}, 3555 {"1", PHONE_HOME_COUNTRY_CODE},
3556 {"234", PHONE_HOME_CITY_CODE}, 3556 {"234", PHONE_HOME_CITY_CODE},
3557 {"5678901", PHONE_HOME_NUMBER}, 3557 {"5678901", PHONE_HOME_NUMBER},
3558 {"567", PHONE_HOME_NUMBER}, 3558 {"567", PHONE_HOME_NUMBER},
3559 {"8901", PHONE_HOME_NUMBER}, 3559 {"8901", PHONE_HOME_NUMBER},
3560 3560
3561 // Test an european profile. 3561 // Test a European profile.
3562 {"Paris", ADDRESS_HOME_CITY}, 3562 {"Paris", ADDRESS_HOME_CITY},
3563 {"Ile de France", ADDRESS_HOME_STATE}, 3563 {"Île de France", ADDRESS_HOME_STATE}, // Exact match
3564 {"Ile de France", ADDRESS_HOME_STATE}, // Missing accent.
3565 {"-Ile-de-France-", ADDRESS_HOME_STATE}, // Extra punctuation.
3566 {"île dÉ FrÃÑÇË", ADDRESS_HOME_STATE}, // Other accents & case mismatch.
3564 {"75008", ADDRESS_HOME_ZIP}, 3567 {"75008", ADDRESS_HOME_ZIP},
3565 {"FR", ADDRESS_HOME_COUNTRY}, 3568 {"FR", ADDRESS_HOME_COUNTRY},
3566 {"France", ADDRESS_HOME_COUNTRY}, 3569 {"France", ADDRESS_HOME_COUNTRY},
3567 {"33249197070", PHONE_HOME_WHOLE_NUMBER}, 3570 {"33249197070", PHONE_HOME_WHOLE_NUMBER},
3568 {"+33 2 49 19 70 70", PHONE_HOME_WHOLE_NUMBER}, 3571 {"+33 2 49 19 70 70", PHONE_HOME_WHOLE_NUMBER},
3569 {"2 49 19 70 70", PHONE_HOME_CITY_AND_NUMBER}, 3572 {"2 49 19 70 70", PHONE_HOME_CITY_AND_NUMBER},
3570 {"249197070", PHONE_HOME_CITY_AND_NUMBER}, 3573 {"249197070", PHONE_HOME_CITY_AND_NUMBER},
3571 {"33", PHONE_HOME_COUNTRY_CODE}, 3574 {"33", PHONE_HOME_COUNTRY_CODE},
3572 {"2", PHONE_HOME_CITY_CODE}, 3575 {"2", PHONE_HOME_CITY_CODE},
3573 3576
3574 // Credit card fields matches. 3577 // Credit card fields matches.
3575 {"John Doe", CREDIT_CARD_NAME_FULL}, 3578 {"John Doe", CREDIT_CARD_NAME_FULL},
3576 {"John", CREDIT_CARD_NAME_FIRST}, 3579 {"John", CREDIT_CARD_NAME_FIRST},
3577 {"Doe", CREDIT_CARD_NAME_LAST}, 3580 {"Doe", CREDIT_CARD_NAME_LAST},
3578 {"4234-5678-9012-3456", CREDIT_CARD_NUMBER}, 3581 {"4234-5678-9012-3456", CREDIT_CARD_NUMBER},
3579 {"04", CREDIT_CARD_EXP_MONTH}, 3582 {"04", CREDIT_CARD_EXP_MONTH},
3580 {"April", CREDIT_CARD_EXP_MONTH}, 3583 {"April", CREDIT_CARD_EXP_MONTH},
3581 {"2999", CREDIT_CARD_EXP_4_DIGIT_YEAR}, 3584 {"2999", CREDIT_CARD_EXP_4_DIGIT_YEAR},
3582 {"99", CREDIT_CARD_EXP_2_DIGIT_YEAR}, 3585 {"99", CREDIT_CARD_EXP_2_DIGIT_YEAR},
3583 {"04/2999", CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR}, 3586 {"04/2999", CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR},
3584 3587
3585 // Make sure whitespaces and invalid characters are handled properly. 3588 // Make sure whitespace and invalid characters are handled properly.
3586 {"", EMPTY_TYPE}, 3589 {"", EMPTY_TYPE},
3587 {" ", EMPTY_TYPE}, 3590 {" ", EMPTY_TYPE},
3588 {"***", UNKNOWN_TYPE}, 3591 {"***", UNKNOWN_TYPE},
3589 {" Elvis", NAME_FIRST}, 3592 {" Elvis", NAME_FIRST},
3590 {"Elvis ", NAME_FIRST}, 3593 {"Elvis ", NAME_FIRST},
3591 3594
3592 // Make sure fields that differ by case match. 3595 // Make sure fields that differ by case match.
3593 {"elvis ", NAME_FIRST}, 3596 {"elvis ", NAME_FIRST},
3594 {"UnItEd StAtEs", ADDRESS_HOME_COUNTRY}, 3597 {"UnItEd StAtEs", ADDRESS_HOME_COUNTRY},
3595 3598
(...skipping 19 matching lines...) Expand all
3615 {"901", UNKNOWN_TYPE}}; 3618 {"901", UNKNOWN_TYPE}};
3616 3619
3617 for (TestCase test_case : test_cases) { 3620 for (TestCase test_case : test_cases) {
3618 FormData form; 3621 FormData form;
3619 form.name = ASCIIToUTF16("MyForm"); 3622 form.name = ASCIIToUTF16("MyForm");
3620 form.origin = GURL("http://myform.com/form.html"); 3623 form.origin = GURL("http://myform.com/form.html");
3621 form.action = GURL("http://myform.com/submit.html"); 3624 form.action = GURL("http://myform.com/submit.html");
3622 3625
3623 FormFieldData field; 3626 FormFieldData field;
3624 test::CreateTestFormField("", "1", "", "text", &field); 3627 test::CreateTestFormField("", "1", "", "text", &field);
3625 field.value = ASCIIToUTF16(test_case.input_value); 3628 field.value = UTF8ToUTF16(test_case.input_value);
3626 form.fields.push_back(field); 3629 form.fields.push_back(field);
3627 3630
3628 FormStructure form_structure(form); 3631 FormStructure form_structure(form);
3629 3632
3630 AutofillManager::DeterminePossibleFieldTypesForUpload( 3633 AutofillManager::DeterminePossibleFieldTypesForUpload(
3631 profiles, credit_cards, "en-us", &form_structure); 3634 profiles, credit_cards, "en-us", &form_structure);
3632 3635
3633 ASSERT_EQ(1U, form_structure.field_count()); 3636 ASSERT_EQ(1U, form_structure.field_count());
3634 ServerFieldTypeSet possible_types = 3637 ServerFieldTypeSet possible_types =
3635 form_structure.field(0)->possible_types(); 3638 form_structure.field(0)->possible_types();
3636 EXPECT_EQ(1U, possible_types.size()); 3639 EXPECT_EQ(1U, possible_types.size());
3637 3640
3638 EXPECT_NE(possible_types.end(), possible_types.find(test_case.field_type)); 3641 EXPECT_NE(possible_types.end(), possible_types.find(test_case.field_type))
3642 << "Failed to determine type for: \"" << test_case.input_value << "\"";
3639 } 3643 }
3640 } 3644 }
3641 3645
3642 // Tests that DeterminePossibleFieldTypesForUpload is called when a form is 3646 // Tests that DeterminePossibleFieldTypesForUpload is called when a form is
3643 // submitted. 3647 // submitted.
3644 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload_IsTriggered) { 3648 TEST_F(AutofillManagerTest, DeterminePossibleFieldTypesForUpload_IsTriggered) {
3645 FormData form; 3649 FormData form;
3646 form.name = ASCIIToUTF16("MyForm"); 3650 form.name = ASCIIToUTF16("MyForm");
3647 form.origin = GURL("http://myform.com/form.html"); 3651 form.origin = GURL("http://myform.com/form.html");
3648 form.action = GURL("http://myform.com/submit.html"); 3652 form.action = GURL("http://myform.com/submit.html");
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 FormsSeen(mixed_forms); 5035 FormsSeen(mixed_forms);
5032 5036
5033 // Suggestions should always be displayed. 5037 // Suggestions should always be displayed.
5034 for (const FormFieldData& field : mixed_form.fields) { 5038 for (const FormFieldData& field : mixed_form.fields) {
5035 GetAutofillSuggestions(mixed_form, field); 5039 GetAutofillSuggestions(mixed_form, field);
5036 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 5040 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
5037 } 5041 }
5038 } 5042 }
5039 5043
5040 } // namespace autofill 5044 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698