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

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

Issue 261013010: autocomplete: add ability to get full address (hidden behind a flag). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: self review Created 6 years, 7 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 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 "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/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 TEST(AutofillProfileTest, SetInfoTrimsWhitespace) { 846 TEST(AutofillProfileTest, SetInfoTrimsWhitespace) {
847 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/"); 847 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
848 848
849 profile.SetInfo(AutofillType(EMAIL_ADDRESS), 849 profile.SetInfo(AutofillType(EMAIL_ADDRESS),
850 ASCIIToUTF16("\tuser@example.com "), 850 ASCIIToUTF16("\tuser@example.com "),
851 "en-US"); 851 "en-US");
852 EXPECT_EQ(ASCIIToUTF16("user@example.com"), 852 EXPECT_EQ(ASCIIToUTF16("user@example.com"),
853 profile.GetRawInfo(EMAIL_ADDRESS)); 853 profile.GetRawInfo(EMAIL_ADDRESS));
854 } 854 }
855 855
856 TEST(AutofillProfileTest, FullAddress) {
857 AutofillProfile profile(base::GenerateGUID(), "https://www.example.com/");
858 test::SetProfileInfo(&profile, "Marion", "Mitchell", "Morrison",
859 "marion@me.xyz", "Fox", "123 Zoo St.", "unit 5",
860 "Hollywood", "CA", "91601", "US",
861 "12345678910");
862
863 AutofillType full_address(HTML_TYPE_FULL_ADDRESS, HTML_MODE_NONE);
864 base::string16 formatted_address(ASCIIToUTF16(
865 "Marion Mitchell Morrison\n"
866 "123 Zoo St.\n"
867 "unit 5\n"
868 "Hollywood, CA 91601"));
869 EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US"));
870 // This should fail and leave the profile unchanged.
871 EXPECT_FALSE(profile.SetInfo(full_address, ASCIIToUTF16("foobar"), "en-US"));
872 EXPECT_EQ(formatted_address, profile.GetInfo(full_address, "en-US"));
873
874 // Some things can be missing...
875 profile.SetInfo(AutofillType(ADDRESS_HOME_LINE2),
876 base::string16(),
877 "en-US");
878 profile.SetInfo(AutofillType(EMAIL_ADDRESS),
879 base::string16(),
880 "en-US");
881 EXPECT_EQ(ASCIIToUTF16("Marion Mitchell Morrison\n"
882 "123 Zoo St.\n"
883 "Hollywood, CA 91601"),
884 profile.GetInfo(full_address, "en-US"));
885
886 // ...but nothing comes out if a required field is missing.
887 profile.SetInfo(AutofillType(ADDRESS_HOME_STATE), base::string16(), "en-US");
888 EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty());
889
890 // Restore the state but remove country. This should also fail.
891 profile.SetInfo(AutofillType(ADDRESS_HOME_STATE),
892 ASCIIToUTF16("CA"),
893 "en-US");
894 EXPECT_FALSE(profile.GetInfo(full_address, "en-US").empty());
895 profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY),
896 base::string16(),
897 "en-US");
898 EXPECT_TRUE(profile.GetInfo(full_address, "en-US").empty());
899 }
900
856 } // namespace autofill 901 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_profile.cc ('k') | components/autofill/core/browser/autofill_type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698