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

Unified Diff: chrome/browser/autofill/auxiliary_profile_impl_unittest.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: Rebased Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/auxiliary_profile_impl_unittest.cc
diff --git a/chrome/browser/autofill/auxiliary_profile_impl_unittest.cc b/chrome/browser/autofill/auxiliary_profile_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..71240263dc81b75f748c5a690f4ced317e789aff
--- /dev/null
+++ b/chrome/browser/autofill/auxiliary_profile_impl_unittest.cc
@@ -0,0 +1,175 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/scoped_vector.h"
+#include "base/string16.h"
+#include "chrome/browser/autofill/autofill_profile.h"
+#include "chrome/browser/autofill/auxiliary_profile_impl_android.h"
+#include "chrome/browser/autofill/auxiliary_profile_loader_mock.h"
+#include "chrome/browser/autofill/i_auxiliary_profile_loader.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class TestContext {
+ public:
+ TestContext() : profileLoader_(AuxiliaryProfileLoaderMock()) {}
+
+ AutofillProfile* GetAndLoadProfile() {
+ AuxiliaryProfilesImpl impl(&profiles_,
+ (IAuxiliaryProfileLoader*)&profileLoader_);
+ impl.GetContactsProfile();
+ AutofillProfile * profile = *profiles_.begin();
David Trainor- moved to gerrit 2013/02/27 07:49:28 No space between AutofillProfile and *.
+ return profile;
+ }
+
+ AuxiliaryProfileLoaderMock profileLoader_;
+ private:
+ ScopedVector<AutofillProfile> profiles_;
+};
+
+} // namespace
+
+TEST(AuxiliaryProfileLoaderAndroid, SetNameInfo) {
+ TestContext ctx;
+
+ string16 firstName = ASCIIToUTF16("John");
+ string16 middleName = ASCIIToUTF16("H.");
+ string16 lastName = ASCIIToUTF16("Waston");
+
+ ctx.profileLoader_.SetFirstName(firstName);
+ ctx.profileLoader_.SetMiddleName(middleName);
+ ctx.profileLoader_.SetLastName(lastName);
+
+ AutofillProfile* profile = ctx.GetAndLoadProfile();
+
+ EXPECT_EQ(profile->GetRawInfo(NAME_FIRST), firstName);
+ EXPECT_EQ(profile->GetRawInfo(NAME_MIDDLE), middleName);
+ EXPECT_EQ(profile->GetRawInfo(NAME_LAST), lastName);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetNameInfoEmpty) {
+ TestContext ctx;
+ AutofillProfile * profile = ctx.GetAndLoadProfile();
+
+ EXPECT_EQ(profile->GetRawInfo(NAME_FIRST), string16());
+ EXPECT_EQ(profile->GetRawInfo(NAME_MIDDLE), string16());
+ EXPECT_EQ(profile->GetRawInfo(NAME_LAST), string16());
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetEmailInfo) {
+ TestContext ctx;
+
+ std::vector<string16> emailAddresses;
+ emailAddresses.push_back(ASCIIToUTF16("sherlock@holmes.com"));
+ emailAddresses.push_back(ASCIIToUTF16("watson@holmes.com"));
+ ctx.profileLoader_.SetEmailAddresses(emailAddresses);
+
+ AutofillProfile * profile = ctx.GetAndLoadProfile();
+ std::vector<string16> loadedEmailAddresses;
+ profile->GetRawMultiInfo(EMAIL_ADDRESS, &loadedEmailAddresses);
+ EXPECT_EQ(loadedEmailAddresses, emailAddresses);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetEmailInfoEmpty) {
+ TestContext ctx;
+
+ std::vector<string16> expectedEmailAddresses;
+ expectedEmailAddresses.push_back(string16());
+ std::vector<string16> loadedEmailAddresses;
+ AutofillProfile * profile = ctx.GetAndLoadProfile();
+ profile->GetRawMultiInfo(EMAIL_ADDRESS, &loadedEmailAddresses);
+ EXPECT_EQ(loadedEmailAddresses, expectedEmailAddresses);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetPhoneInfo) {
+ TestContext ctx;
+
+ std::vector<string16> phoneNumbers;
+ phoneNumbers.push_back(ASCIIToUTF16("6502530000"));
+ ctx.profileLoader_.SetPhoneNumbers(phoneNumbers);
+
+ std::vector<string16> loadedPhoneNumbers;
+ AutofillProfile * profile = ctx.GetAndLoadProfile();
+ profile->GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &loadedPhoneNumbers);
+ EXPECT_EQ(loadedPhoneNumbers, phoneNumbers);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetPhoneInfoEmpty) {
+ TestContext ctx;
+
+ std::vector<string16> expectedPhoneNumbers;
+ expectedPhoneNumbers.push_back(string16());
+
+ std::vector<string16> loadedPhoneNumbers;
+ AutofillProfile * profile = ctx.GetAndLoadProfile();
+ profile->GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &loadedPhoneNumbers);
+ EXPECT_EQ(loadedPhoneNumbers, expectedPhoneNumbers);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetAddressInfo) {
+ TestContext ctx;
+
+ string16 street = ASCIIToUTF16("221 B Baker Street");
+ string16 city = ASCIIToUTF16("London");
+ string16 postalCode = ASCIIToUTF16("123456");
+ string16 region = ASCIIToUTF16("Georgian Terrace");
+ string16 country = ASCIIToUTF16("England");
+
+ ctx.profileLoader_.SetStreet(street);
+ ctx.profileLoader_.SetCity(city);
+ ctx.profileLoader_.SetPostalCode(postalCode);
+ ctx.profileLoader_.SetRegion(region);
+ ctx.profileLoader_.SetCountry(country);
+
+ AutofillProfile* profile = ctx.GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE1), street);
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_CITY), city);
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_ZIP), postalCode);
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_STATE), region);
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_COUNTRY), country);
+}
+
+/*
+ * Android user's profile contact does not prase its address
+ * into constituent parts. Instead we just Get a long string blob.
+ * Disable address population tests until we implement a way to parse the
+ * data.
+ *
+string16 pobox = ASCIIToUTF16("222");
+string16 neighborhood = ASCIIToUTF16("Doyle");
+TEST(AuxiliaryProfileLoaderAndroid, SetAddressInfoCompoundFields1) {
+ TestContext ctx;
+ ctx.profileLoader_.SetPobox(pobox);
+ ctx.profileLoader_.SetNeighborhood(neighborhood);
+ string16 expectedLine2= ASCIIToUTF16("222, Doyle");
+ AutofillProfile* profile = ctx.GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), expectedLine2);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetAddressInfoCompoundFields2) {
+ TestContext ctx;
+ ctx.profileLoader_.SetPobox(pobox);
+ AutofillProfile* profile = ctx.GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), pobox);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetAddressInfoCompoundFields3) {
+ TestContext ctx;
+ ctx.profileLoader_.SetNeighborhood(neighborhood);
+ AutofillProfile* profile = ctx.GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), neighborhood);
+}
+
+TEST(AuxiliaryProfileLoaderAndroid, SetAddressInfoEmpty) {
+ TestContext ctx;
+ AutofillProfile* profile = ctx.GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE1), string16());
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), string16());
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_CITY), string16());
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_ZIP), string16());
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_STATE), string16());
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_COUNTRY), string16());
+}
+*/

Powered by Google App Engine
This is Rietveld 408576698