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

Side by Side Diff: components/autofill/browser/autofill_profile_unittest.cc

Issue 13697002: Make autofill's Address store country using the country code so that app locale isn't needed for th… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/guid.h" 6 #include "base/guid.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 // Phone numbers are compared by the full number, including the area code. 582 // Phone numbers are compared by the full number, including the area code.
583 // This is a regression test for http://crbug.com/163024 583 // This is a regression test for http://crbug.com/163024
584 autofill_test::SetProfileInfo(&a, NULL, NULL, NULL, NULL, 584 autofill_test::SetProfileInfo(&a, NULL, NULL, NULL, NULL,
585 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321"); 585 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "650.555.4321");
586 autofill_test::SetProfileInfo(&b, NULL, NULL, NULL, NULL, 586 autofill_test::SetProfileInfo(&b, NULL, NULL, NULL, NULL,
587 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321"); 587 NULL, NULL, NULL, NULL, NULL, NULL, NULL, "408.555.4321");
588 EXPECT_GT(0, a.Compare(b)); 588 EXPECT_GT(0, a.Compare(b));
589 EXPECT_LT(0, b.Compare(a)); 589 EXPECT_LT(0, b.Compare(a));
590 } 590 }
591 591
592 TEST(AutofillProfileTest, CountryCode) {
593 AutofillProfile profile;
594 EXPECT_EQ(std::string(), profile.CountryCode());
595
596 profile.SetCountryCode("US");
597 EXPECT_EQ("US", profile.CountryCode());
598 }
599
600 TEST(AutofillProfileTest, MultiValueNames) { 592 TEST(AutofillProfileTest, MultiValueNames) {
601 AutofillProfile p; 593 AutofillProfile p;
602 const string16 kJohnDoe(ASCIIToUTF16("John Doe")); 594 const string16 kJohnDoe(ASCIIToUTF16("John Doe"));
603 const string16 kJohnPDoe(ASCIIToUTF16("John P. Doe")); 595 const string16 kJohnPDoe(ASCIIToUTF16("John P. Doe"));
604 std::vector<string16> set_values; 596 std::vector<string16> set_values;
605 set_values.push_back(kJohnDoe); 597 set_values.push_back(kJohnDoe);
606 set_values.push_back(kJohnPDoe); 598 set_values.push_back(kJohnPDoe);
607 p.SetRawMultiInfo(NAME_FULL, set_values); 599 p.SetRawMultiInfo(NAME_FULL, set_values);
608 600
609 // Expect regular |GetInfo| returns the first element. 601 // Expect regular |GetInfo| returns the first element.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 725 }
734 726
735 FormFieldData field; 727 FormFieldData field;
736 field.form_control_type = "select-one"; 728 field.form_control_type = "select-one";
737 field.option_values = options; 729 field.option_values = options;
738 field.option_contents = options; 730 field.option_contents = options;
739 731
740 AutofillProfile profile; 732 AutofillProfile profile;
741 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA")); 733 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
742 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, &field); 734 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, &field);
743 EXPECT_EQ(ASCIIToUTF16("Canada"), field.value); 735 EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
Ilya Sherman 2013/04/05 05:18:01 This should remain "Canada". "CA" isn't actually
jam 2013/04/05 06:45:54 Done.
744 } 736 }
745 737
746 TEST(AutofillProfileTest, AddressCountryAbbrev) { 738 TEST(AutofillProfileTest, AddressCountryAbbrev) {
747 const char* const kCountries[] = { 739 const char* const kCountries[] = {
748 "AL", "CA" 740 "AL", "CA"
749 }; 741 };
750 std::vector<string16> options(arraysize(kCountries)); 742 std::vector<string16> options(arraysize(kCountries));
751 for (size_t i = 0; i < arraysize(kCountries); ++i) { 743 for (size_t i = 0; i < arraysize(kCountries); ++i) {
752 options[i] = ASCIIToUTF16(kCountries[i]); 744 options[i] = ASCIIToUTF16(kCountries[i]);
753 } 745 }
754 746
755 FormFieldData field; 747 FormFieldData field;
756 field.form_control_type = "select-one"; 748 field.form_control_type = "select-one";
757 field.option_values = options; 749 field.option_values = options;
758 field.option_contents = options; 750 field.option_contents = options;
759 751
760 AutofillProfile profile; 752 AutofillProfile profile;
761 profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Canada"), "en-US"); 753 profile.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"), "en-US");
Ilya Sherman 2013/04/05 05:18:01 nit: Might as well use SetRawInfo now.
jam 2013/04/05 06:45:54 Done.
762 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, &field); 754 profile.FillSelectControl(ADDRESS_HOME_COUNTRY, &field);
763 EXPECT_EQ(ASCIIToUTF16("CA"), field.value); 755 EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
764 } 756 }
765 757
766 TEST(AutofillProfileTest, AddressStateFull) { 758 TEST(AutofillProfileTest, AddressStateFull) {
767 const char* const kStates[] = { 759 const char* const kStates[] = {
768 "Alabama", "California" 760 "Alabama", "California"
769 }; 761 };
770 std::vector<string16> options(arraysize(kStates)); 762 std::vector<string16> options(arraysize(kStates));
771 for (size_t i = 0; i < arraysize(kStates); ++i) { 763 for (size_t i = 0; i < arraysize(kStates); ++i) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 FormFieldData field; 831 FormFieldData field;
840 field.form_control_type = "select-one"; 832 field.form_control_type = "select-one";
841 field.option_values = values; 833 field.option_values = values;
842 field.option_contents = contents; 834 field.option_contents = contents;
843 835
844 AutofillProfile profile; 836 AutofillProfile profile;
845 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California")); 837 profile.SetRawInfo(ADDRESS_HOME_STATE, ASCIIToUTF16("California"));
846 profile.FillSelectControl(ADDRESS_HOME_STATE, &field); 838 profile.FillSelectControl(ADDRESS_HOME_STATE, &field);
847 EXPECT_EQ(ASCIIToUTF16("2"), field.value); 839 EXPECT_EQ(ASCIIToUTF16("2"), field.value);
848 } 840 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698