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

Unified 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, 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/android/auxiliary_profile_unittest_android.cc
diff --git a/chrome/browser/autofill/android/auxiliary_profile_unittest_android.cc b/chrome/browser/autofill/android/auxiliary_profile_unittest_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0049c613a6e7a698a7d3008d7cc11b201c46ec07
--- /dev/null
+++ b/chrome/browser/autofill/android/auxiliary_profile_unittest_android.cc
@@ -0,0 +1,163 @@
+// 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 "base/utf_string_conversions.h"
+#include "chrome/browser/autofill/android/auxiliary_profile_loader_android.h"
+#include "chrome/browser/autofill/android/auxiliary_profiles_android.h"
+#include "chrome/browser/autofill/android/test_auxiliary_profile_loader_android.h"
+#include "chrome/browser/autofill/autofill_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+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.
+
+class AuxiliaryProfileAndroidTest : public testing::Test {
+ public:
+ 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.
+ TestAuxiliaryProfileLoader()) {}
+
+ AutofillProfile* GetAndLoadProfile() {
+ autofill::AuxiliaryProfilesAndroid impl(profile_loader_);
+ impl.LoadContactsProfile(&profiles_);
+ return *profiles_.begin();
+ }
+
+ TestAuxiliaryProfileLoader& profile_loader() {
+ return profile_loader_;
+ }
+
+ private:
+ TestAuxiliaryProfileLoader profile_loader_;
+ 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
+};
+
+} // namespace
+
+TEST_F(AuxiliaryProfileAndroidTest, SetNameInfo) {
+ string16 firstName = ASCIIToUTF16("John");
+ string16 middleName = ASCIIToUTF16("H.");
+ string16 lastName = ASCIIToUTF16("Waston");
+
+ profile_loader().SetFirstName(firstName);
+ profile_loader().SetMiddleName(middleName);
+ profile_loader().SetLastName(lastName);
+
+ AutofillProfile* profile = GetAndLoadProfile();
+
+ EXPECT_EQ(profile->GetRawInfo(NAME_FIRST), firstName);
+ EXPECT_EQ(profile->GetRawInfo(NAME_MIDDLE), middleName);
+ EXPECT_EQ(profile->GetRawInfo(NAME_LAST), lastName);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetNameInfoEmpty) {
+ 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.
+
+ EXPECT_EQ(profile->GetRawInfo(NAME_FIRST), string16());
+ EXPECT_EQ(profile->GetRawInfo(NAME_MIDDLE), string16());
+ EXPECT_EQ(profile->GetRawInfo(NAME_LAST), string16());
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetEmailInfo) {
+ std::vector<string16> emailAddresses;
+ emailAddresses.push_back(ASCIIToUTF16("sherlock@holmes.com"));
+ emailAddresses.push_back(ASCIIToUTF16("watson@holmes.com"));
+ profile_loader().SetEmailAddresses(emailAddresses);
+
+ AutofillProfile * profile = GetAndLoadProfile();
+ std::vector<string16> loadedEmailAddresses;
+ profile->GetRawMultiInfo(EMAIL_ADDRESS, &loadedEmailAddresses);
+ EXPECT_EQ(loadedEmailAddresses, emailAddresses);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetEmailInfoEmpty) {
+ std::vector<string16> expectedEmailAddresses;
+ expectedEmailAddresses.push_back(string16());
+ std::vector<string16> loadedEmailAddresses;
+ AutofillProfile * profile = GetAndLoadProfile();
+ profile->GetRawMultiInfo(EMAIL_ADDRESS, &loadedEmailAddresses);
+ EXPECT_EQ(loadedEmailAddresses, expectedEmailAddresses);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetPhoneInfo) {
+ std::vector<string16> phoneNumbers;
+ phoneNumbers.push_back(ASCIIToUTF16("6502530000"));
+ profile_loader().SetPhoneNumbers(phoneNumbers);
+
+ std::vector<string16> loadedPhoneNumbers;
+ AutofillProfile * profile = GetAndLoadProfile();
+ profile->GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &loadedPhoneNumbers);
+ EXPECT_EQ(loadedPhoneNumbers, phoneNumbers);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetPhoneInfoEmpty) {
+ std::vector<string16> expectedPhoneNumbers;
+ expectedPhoneNumbers.push_back(string16());
+
+ std::vector<string16> loadedPhoneNumbers;
+ AutofillProfile * profile = GetAndLoadProfile();
+ profile->GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &loadedPhoneNumbers);
+ EXPECT_EQ(loadedPhoneNumbers, expectedPhoneNumbers);
+}
+
+/*
+ * 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.
+ *
Ilya Sherman 2013/03/05 00:42:38 nit: Use "// "-style comments.
apiccion 2013/03/09 00:53:41 Done.
+ *
+TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfo) {
+ string16 street = ASCIIToUTF16("221 B Baker Street");
+ string16 city = ASCIIToUTF16("London");
+ string16 postalCode = ASCIIToUTF16("123456");
+ string16 region = ASCIIToUTF16("Georgian Terrace");
+ string16 country = ASCIIToUTF16("England");
+
+ profile_loader().SetStreet(street);
+ profile_loader().SetCity(city);
+ profile_loader().SetPostalCode(postalCode);
+ profile_loader().SetRegion(region);
+ profile_loader().SetCountry(country);
+
+ AutofillProfile* profile = 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);
+}
+
+string16 pobox = ASCIIToUTF16("222");
+string16 neighborhood = ASCIIToUTF16("Doyle");
+TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoCompoundFields1) {
+ profile_loader().SetPobox(pobox);
+ profile_loader().SetNeighborhood(neighborhood);
+ string16 expectedLine2= ASCIIToUTF16("222, Doyle");
+ AutofillProfile* profile = GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), expectedLine2);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoCompoundFields2) {
+ profile_loader().SetPobox(pobox);
+ AutofillProfile* profile = GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), pobox);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoCompoundFields3) {
+ profile_loader().SetNeighborhood(neighborhood);
+ AutofillProfile* profile = GetAndLoadProfile();
+ EXPECT_EQ(profile->GetRawInfo(ADDRESS_HOME_LINE2), neighborhood);
+}
+
+TEST_F(AuxiliaryProfileAndroidTest, SetAddressInfoEmpty) {
+ AutofillProfile* profile = 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