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

Side by Side Diff: chrome/browser/autofill/android/auxiliary_profile_unittest_android.cc

Issue 12282004: Added personal_data_manager android implementation for auto-populating auto-fill on android builds … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed assortment of nits Created 7 years, 9 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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/memory/scoped_vector.h"
6 #include "base/string16.h"
7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/autofill/android/auxiliary_profile_loader_android.h"
9 #include "chrome/browser/autofill/android/auxiliary_profiles_android.h"
10 #include "chrome/browser/autofill/android/test_auxiliary_profile_loader_android. h"
11 #include "chrome/browser/autofill/autofill_profile.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace {
Ilya Sherman 2013/03/05 00:42:38 nit: The test fixture class itself should not be i
apiccion 2013/03/09 00:53:41 Done.
15
16 class AuxiliaryProfileAndroidTest : public testing::Test {
17 public:
18 AuxiliaryProfileAndroidTest() : profile_loader_(
Ilya Sherman 2013/03/05 00:42:38 nit: Break the line so that the colon is on the ne
apiccion 2013/03/09 00:53:41 Done.
19 TestAuxiliaryProfileLoader()) {}
20
21 AutofillProfile* GetAndLoadProfile() {
22 autofill::AuxiliaryProfilesAndroid impl(profile_loader_);
23 impl.LoadContactsProfile(&profiles_);
24 return *profiles_.begin();
25 }
26
27 TestAuxiliaryProfileLoader& profile_loader() {
28 return profile_loader_;
29 }
30
31 private:
32 TestAuxiliaryProfileLoader profile_loader_;
33 std::vector<AutofillProfile*> profiles_;
Ilya Sherman 2013/03/05 00:42:38 Shouldn't this be a ScopedVector? Who owns the me
apiccion 2013/03/09 00:53:41 The profiles are owned by the caller to populator
34 };
35
36 } // namespace
37
38 TEST_F(AuxiliaryProfileAndroidTest, SetNameInfo) {
39 string16 firstName = ASCIIToUTF16("John");
40 string16 middleName = ASCIIToUTF16("H.");
41 string16 lastName = ASCIIToUTF16("Waston");
42
43 profile_loader().SetFirstName(firstName);
44 profile_loader().SetMiddleName(middleName);
45 profile_loader().SetLastName(lastName);
46
47 AutofillProfile* profile = GetAndLoadProfile();
48
49 EXPECT_EQ(profile->GetRawInfo(NAME_FIRST), firstName);
50 EXPECT_EQ(profile->GetRawInfo(NAME_MIDDLE), middleName);
51 EXPECT_EQ(profile->GetRawInfo(NAME_LAST), lastName);
52 }
53
54 TEST_F(AuxiliaryProfileAndroidTest, SetNameInfoEmpty) {
55 AutofillProfile * profile = GetAndLoadProfile();
Ilya Sherman 2013/03/05 00:42:38 nit: No space before the asterisk
apiccion 2013/03/09 00:53:41 Done.
56
57 EXPECT_EQ(profile->GetRawInfo(NAME_FIRST), string16());
58 EXPECT_EQ(profile->GetRawInfo(NAME_MIDDLE), string16());
59 EXPECT_EQ(profile->GetRawInfo(NAME_LAST), string16());
60 }
61
62 TEST_F(AuxiliaryProfileAndroidTest, SetEmailInfo) {
63 std::vector<string16> emailAddresses;
64 emailAddresses.push_back(ASCIIToUTF16("sherlock@holmes.com"));
65 emailAddresses.push_back(ASCIIToUTF16("watson@holmes.com"));
66 profile_loader().SetEmailAddresses(emailAddresses);
67
68 AutofillProfile * profile = GetAndLoadProfile();
69 std::vector<string16> loadedEmailAddresses;
70 profile->GetRawMultiInfo(EMAIL_ADDRESS, &loadedEmailAddresses);
71 EXPECT_EQ(loadedEmailAddresses, emailAddresses);
72 }
73
74 TEST_F(AuxiliaryProfileAndroidTest, SetEmailInfoEmpty) {
75 std::vector<string16> expectedEmailAddresses;
76 expectedEmailAddresses.push_back(string16());
77 std::vector<string16> loadedEmailAddresses;
78 AutofillProfile * profile = GetAndLoadProfile();
79 profile->GetRawMultiInfo(EMAIL_ADDRESS, &loadedEmailAddresses);
80 EXPECT_EQ(loadedEmailAddresses, expectedEmailAddresses);
81 }
82
83 TEST_F(AuxiliaryProfileAndroidTest, SetPhoneInfo) {
84 std::vector<string16> phoneNumbers;
85 phoneNumbers.push_back(ASCIIToUTF16("6502530000"));
86 profile_loader().SetPhoneNumbers(phoneNumbers);
87
88 std::vector<string16> loadedPhoneNumbers;
89 AutofillProfile * profile = GetAndLoadProfile();
90 profile->GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &loadedPhoneNumbers);
91 EXPECT_EQ(loadedPhoneNumbers, phoneNumbers);
92 }
93
94 TEST_F(AuxiliaryProfileAndroidTest, SetPhoneInfoEmpty) {
95 std::vector<string16> expectedPhoneNumbers;
96 expectedPhoneNumbers.push_back(string16());
97
98 std::vector<string16> loadedPhoneNumbers;
99 AutofillProfile * profile = GetAndLoadProfile();
100 profile->GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &loadedPhoneNumbers);
101 EXPECT_EQ(loadedPhoneNumbers, expectedPhoneNumbers);
102 }
103
104 /*
105 * Android user's profile contact does not prase its address
106 * into constituent parts. Instead we just Get a long string blob.
107 * Disable address population tests until we implement a way to parse the
108 * data.
109 *
Ilya Sherman 2013/03/05 00:42:38 nit: Use "// "-style comments.
apiccion 2013/03/09 00:53:41 Done.
110 *
111 TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfo) {
112 string16 street = ASCIIToUTF16("221 B Baker Street");
113 string16 city = ASCIIToUTF16("London");
114 string16 postalCode = ASCIIToUTF16("123456");
115 string16 region = ASCIIToUTF16("Georgian Terrace");
116 string16 country = ASCIIToUTF16("England");
117
118 profile_loader().SetStreet(street);
119 profile_loader().SetCity(city);
120 profile_loader().SetPostalCode(postalCode);
121 profile_loader().SetRegion(region);
122 profile_loader().SetCountry(country);
123
124 AutofillProfile* profile = GetAndLoadProfile();
125 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE1), street);
126 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_CITY), city);
127 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_ZIP), postalCode);
128 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_STATE), region);
129 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_COUNTRY), country);
130 }
131
132 string16 pobox = ASCIIToUTF16("222");
133 string16 neighborhood = ASCIIToUTF16("Doyle");
134 TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoCompoundFields1) {
135 profile_loader().SetPobox(pobox);
136 profile_loader().SetNeighborhood(neighborhood);
137 string16 expectedLine2= ASCIIToUTF16("222, Doyle");
138 AutofillProfile* profile = GetAndLoadProfile();
139 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), expectedLine2);
140 }
141
142 TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoCompoundFields2) {
143 profile_loader().SetPobox(pobox);
144 AutofillProfile* profile = GetAndLoadProfile();
145 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), pobox);
146 }
147
148 TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoCompoundFields3) {
149 profile_loader().SetNeighborhood(neighborhood);
150 AutofillProfile* profile = GetAndLoadProfile();
151 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), neighborhood);
152 }
153
154 TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoEmpty) {
155 AutofillProfile* profile = GetAndLoadProfile();
156 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE1), string16());
157 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), string16());
158 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_CITY), string16());
159 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_ZIP), string16());
160 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_STATE), string16());
161 EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_COUNTRY), string16());
162 }
163 */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698