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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 data4["ADDRESS_HOME_STATE"] = "CA"; | 614 data4["ADDRESS_HOME_STATE"] = "CA"; |
615 data4["ADDRESS_HOME_ZIP"] = "95510"; | 615 data4["ADDRESS_HOME_ZIP"] = "95510"; |
616 data4["ADDRESS_HOME_COUNTRY"] = "Germany"; | 616 data4["ADDRESS_HOME_COUNTRY"] = "Germany"; |
617 data4["PHONE_HOME_WHOLE_NUMBER"] = "+21 08450 777 777"; | 617 data4["PHONE_HOME_WHOLE_NUMBER"] = "+21 08450 777 777"; |
618 profiles.push_back(data4); | 618 profiles.push_back(data4); |
619 | 619 |
620 for (size_t i = 0; i < profiles.size(); ++i) | 620 for (size_t i = 0; i < profiles.size(); ++i) |
621 FillFormAndSubmit("autofill_test_form.html", profiles[i]); | 621 FillFormAndSubmit("autofill_test_form.html", profiles[i]); |
622 | 622 |
623 ASSERT_EQ(2u, personal_data_manager()->GetProfiles().size()); | 623 ASSERT_EQ(2u, personal_data_manager()->GetProfiles().size()); |
624 ASSERT_EQ(ASCIIToUTF16("408-871-4567"), | 624 ASSERT_EQ(ASCIIToUTF16("(408) 871-4567"), |
625 personal_data_manager()->GetProfiles()[0]->GetRawInfo( | 625 personal_data_manager()->GetProfiles()[0]->GetRawInfo( |
626 PHONE_HOME_WHOLE_NUMBER)); | 626 PHONE_HOME_WHOLE_NUMBER)); |
627 ASSERT_EQ(ASCIIToUTF16("+49 40-80-81-79-000"), | 627 ASSERT_EQ(ASCIIToUTF16("+49 40 808179000"), |
628 personal_data_manager()->GetProfiles()[1]->GetRawInfo( | 628 personal_data_manager()->GetProfiles()[1]->GetRawInfo( |
629 PHONE_HOME_WHOLE_NUMBER)); | 629 PHONE_HOME_WHOLE_NUMBER)); |
630 } | 630 } |
631 | 631 |
632 // Prepend country codes when formatting phone numbers, but only if the user | 632 // Test Autofill appends country codes to aggregated phone numbers. |
633 // provided one in the first place. | 633 // The country code is added for the following case: |
| 634 // The phone number contains the correct national number size and |
| 635 // is a valid format. |
634 IN_PROC_BROWSER_TEST_F(AutofillTest, AppendCountryCodeForAggregatedPhones) { | 636 IN_PROC_BROWSER_TEST_F(AutofillTest, AppendCountryCodeForAggregatedPhones) { |
635 ASSERT_TRUE(test_server()->Start()); | 637 ASSERT_TRUE(test_server()->Start()); |
636 FormMap data; | 638 FormMap data; |
637 data["NAME_FIRST"] = "Bob"; | 639 data["NAME_FIRST"] = "Bob"; |
638 data["NAME_LAST"] = "Smith"; | 640 data["NAME_LAST"] = "Smith"; |
639 data["ADDRESS_HOME_LINE1"] = "1234 H St."; | 641 data["ADDRESS_HOME_LINE1"] = "1234 H St."; |
640 data["ADDRESS_HOME_CITY"] = "San Jose"; | 642 data["ADDRESS_HOME_CITY"] = "San Jose"; |
641 data["ADDRESS_HOME_STATE"] = "CA"; | 643 data["ADDRESS_HOME_STATE"] = "CA"; |
642 data["ADDRESS_HOME_ZIP"] = "95110"; | 644 data["ADDRESS_HOME_ZIP"] = "95110"; |
643 data["ADDRESS_HOME_COUNTRY"] = "Germany"; | 645 data["ADDRESS_HOME_COUNTRY"] = "Germany"; |
644 data["PHONE_HOME_WHOLE_NUMBER"] = "+4908450777777"; | 646 data["PHONE_HOME_WHOLE_NUMBER"] = "(08) 450 777-777"; |
645 FillFormAndSubmit("autofill_test_form.html", data); | 647 FillFormAndSubmit("autofill_test_form.html", data); |
646 | 648 |
647 data["ADDRESS_HOME_LINE1"] = "4321 H St."; | 649 ASSERT_EQ(1u, personal_data_manager()->GetProfiles().size()); |
648 data["PHONE_HOME_WHOLE_NUMBER"] = "08450777777"; | 650 base::string16 phone = personal_data_manager()->GetProfiles()[0]->GetRawInfo( |
649 FillFormAndSubmit("autofill_test_form.html", data); | 651 PHONE_HOME_WHOLE_NUMBER); |
650 | 652 ASSERT_TRUE(StartsWith(phone, ASCIIToUTF16("+49"), true)); |
651 ASSERT_EQ(2u, personal_data_manager()->GetProfiles().size()); | |
652 EXPECT_EQ(ASCIIToUTF16("+49 8450 777777"), | |
653 personal_data_manager()->GetProfiles()[0]->GetRawInfo( | |
654 PHONE_HOME_WHOLE_NUMBER)); | |
655 | |
656 FillFormAndSubmit("autofill_test_form.html", data); | |
657 EXPECT_EQ(ASCIIToUTF16("08450 777777"), | |
658 personal_data_manager()->GetProfiles()[1]->GetRawInfo( | |
659 PHONE_HOME_WHOLE_NUMBER)); | |
660 } | 653 } |
661 | 654 |
662 // Test CC info not offered to be saved when autocomplete=off for CC field. | 655 // Test CC info not offered to be saved when autocomplete=off for CC field. |
663 // If the credit card number field has autocomplete turned off, then the credit | 656 // If the credit card number field has autocomplete turned off, then the credit |
664 // card infobar should not offer to save the credit card info. The credit card | 657 // card infobar should not offer to save the credit card info. The credit card |
665 // number must be a valid Luhn number. | 658 // number must be a valid Luhn number. |
666 IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { | 659 IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { |
667 #if defined(OS_WIN) && defined(USE_ASH) | 660 #if defined(OS_WIN) && defined(USE_ASH) |
668 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 661 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
669 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 662 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 IN_PROC_BROWSER_TEST_F(AutofillTest, | 725 IN_PROC_BROWSER_TEST_F(AutofillTest, |
733 DISABLED_MergeAggregatedDuplicatedProfiles) { | 726 DISABLED_MergeAggregatedDuplicatedProfiles) { |
734 int num_of_profiles = | 727 int num_of_profiles = |
735 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); | 728 AggregateProfilesIntoAutofillPrefs("dataset_duplicated_profiles.txt"); |
736 | 729 |
737 ASSERT_GT(num_of_profiles, | 730 ASSERT_GT(num_of_profiles, |
738 static_cast<int>(personal_data_manager()->GetProfiles().size())); | 731 static_cast<int>(personal_data_manager()->GetProfiles().size())); |
739 } | 732 } |
740 | 733 |
741 } // namespace autofill | 734 } // namespace autofill |
OLD | NEW |