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