summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_common_test.cc7
-rw-r--r--chrome/browser/autofill/autofill_common_test.h5
-rw-r--r--chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm4
-rw-r--r--chrome/browser/autofill/autofill_download.cc4
-rw-r--r--chrome/browser/autofill/autofill_manager.cc190
-rw-r--r--chrome/browser/autofill/autofill_manager.h29
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc591
-rw-r--r--chrome/browser/autofill/credit_card.cc12
-rw-r--r--chrome/browser/autofill/credit_card.h10
-rw-r--r--chrome/browser/autofill/credit_card_unittest.cc10
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc13
11 files changed, 392 insertions, 483 deletions
diff --git a/chrome/browser/autofill/autofill_common_test.cc b/chrome/browser/autofill/autofill_common_test.cc
index 3c7c319..c4c8482 100644
--- a/chrome/browser/autofill/autofill_common_test.cc
+++ b/chrome/browser/autofill/autofill_common_test.cc
@@ -55,16 +55,13 @@ void SetProfileInfo(AutoFillProfile* profile,
}
void SetCreditCardInfo(CreditCard* credit_card,
- const char* label, const char* name_on_card, const char* type,
- const char* card_number, const char* expiration_month,
- const char* expiration_year, int billing_address_id) {
+ const char* label, const char* name_on_card, const char* card_number,
+ const char* expiration_month, const char* expiration_year) {
credit_card->set_label(ASCIIToUTF16(label));
check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card);
- check_and_set(credit_card, CREDIT_CARD_TYPE, type);
check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number);
check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month);
check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year);
- credit_card->set_billing_address_id(billing_address_id);
}
void DisableSystemServices(Profile* profile) {
diff --git a/chrome/browser/autofill/autofill_common_test.h b/chrome/browser/autofill/autofill_common_test.h
index 3b7b83e..dfb7ac6 100644
--- a/chrome/browser/autofill/autofill_common_test.h
+++ b/chrome/browser/autofill/autofill_common_test.h
@@ -38,9 +38,8 @@ void SetProfileInfo(AutoFillProfile* profile,
// tests. |SetCreditCardInfo| provides a quick way to populate a credit card
// with c-strings.
void SetCreditCardInfo(CreditCard* credit_card,
- const char* label, const char* name_on_card, const char* type,
- const char* card_number, const char* expiration_month,
- const char* expiration_year, int billing_address_id);
+ const char* label, const char* name_on_card, const char* card_number,
+ const char* expiration_month, const char* expiration_year);
// TODO(isherman): We should do this automatically for all tests, not manually
// on a per-test basis: http://crbug.com/57221
diff --git a/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm b/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm
index d239f9e..0f10a12 100644
--- a/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm
+++ b/chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm
@@ -27,7 +27,7 @@ TEST(AutoFillCreditCardModelTest, Basic) {
TEST(AutoFillCreditCardModelTest, InitializationFromCreditCard) {
CreditCard credit_card(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card, "Corporate",
- "John Dillinger", "Visa", "123456789012", "01", "2010", 0);
+ "John Dillinger", "123456789012", "01", "2010");
scoped_nsobject<AutoFillCreditCardModel> model(
[[AutoFillCreditCardModel alloc] initWithCreditCard:credit_card]);
EXPECT_TRUE(model.get());
@@ -41,7 +41,7 @@ TEST(AutoFillCreditCardModelTest, InitializationFromCreditCard) {
TEST(AutoFillCreditCardModelTest, CopyModelToCreditCard) {
CreditCard credit_card(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card, "Corporate",
- "John Dillinger", "Visa", "123456789012", "01", "2010", 0);
+ "John Dillinger", "123456789012", "01", "2010");
scoped_nsobject<AutoFillCreditCardModel> model(
[[AutoFillCreditCardModel alloc] initWithCreditCard:credit_card]);
EXPECT_TRUE(model.get());
diff --git a/chrome/browser/autofill/autofill_download.cc b/chrome/browser/autofill/autofill_download.cc
index 10617a3..95ee688 100644
--- a/chrome/browser/autofill/autofill_download.cc
+++ b/chrome/browser/autofill/autofill_download.cc
@@ -238,8 +238,8 @@ void AutoFillDownloadManager::OnURLFetchComplete(const URLFetcher* source,
}
}
- VLOG(1) << "AutoFillDownloadManager: " << type_of_request
- << " request has failed with response" << response_code;
+ LOG(WARNING) << "AutoFillDownloadManager: " << type_of_request
+ << " request has failed with response" << response_code;
if (observer_) {
observer_->OnHeuristicsRequestError(it->second.form_signatures[0],
it->second.request_type,
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index bd0a8b4..d5524ba 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -43,18 +43,6 @@ const int kAutoFillPhoneNumberSuffixCount = 4;
const string16::value_type kCreditCardPrefix[] = {'*',0};
const string16::value_type kLabelSeparator[] = {';',' ','*',0};
-// Combines the |label| string with the last four digits of the credit card
-// |cc|. If one, the other, or both are empty strings we omit the separator.
-string16 CombineLabelAndCreditCard(const string16& label,
- const CreditCard* cc) {
- if (label.empty())
- return kCreditCardPrefix + cc->LastFourDigits();
- else if (cc->LastFourDigits().empty())
- return label;
- else
- return label + kLabelSeparator + cc->LastFourDigits();
-}
-
// Removes duplicate elements whilst preserving original order of |elements| and
// |unique_ids|.
void RemoveDuplicateElements(
@@ -209,19 +197,13 @@ bool AutoFillManager::GetAutoFillSuggestions(int query_id,
std::vector<int> unique_ids;
AutoFillType type(autofill_field->type());
- // If this form is non-HTTPS, treat billing address fields as regular address
- // fields.
- bool handle_billing = FormIsHTTPS(form);
-
- if (type.group() == AutoFillType::CREDIT_CARD)
+ if (type.group() == AutoFillType::CREDIT_CARD) {
GetCreditCardSuggestions(
form, field, type, &values, &labels, &icons, &unique_ids);
- else if (type.group() == AutoFillType::ADDRESS_BILLING)
- GetBillingProfileSuggestions(
+ } else {
+ GetProfileSuggestions(
form, field, type, &values, &labels, &icons, &unique_ids);
- else
- GetProfileSuggestions(form, field, type, handle_billing,
- &values, &labels, &icons, &unique_ids);
+ }
DCHECK_EQ(values.size(), labels.size());
DCHECK_EQ(values.size(), icons.size());
@@ -293,6 +275,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
int cc_id = 0;
int profile_id = 0;
UnpackIDs(unique_id, &cc_id, &profile_id);
+ DCHECK(cc_id == 0 || profile_id == 0);
// Find the profile that matches the |profile_id|, if one is specified.
const AutoFillProfile* profile = NULL;
@@ -304,6 +287,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
break;
}
}
+ DCHECK(profile);
}
// Find the credit card that matches the |cc_id|, if one is specified.
@@ -316,6 +300,7 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
break;
}
}
+ DCHECK(credit_card);
}
if (!profile && !credit_card)
@@ -348,9 +333,6 @@ bool AutoFillManager::FillAutoFillFormData(int query_id,
if (credit_card &&
autofill_type.group() == AutoFillType::CREDIT_CARD) {
FillCreditCardFormField(credit_card, autofill_type, &result.fields[j]);
- } else if (credit_card &&
- autofill_type.group() == AutoFillType::ADDRESS_BILLING) {
- FillBillingFormField(credit_card, autofill_type, &result.fields[j]);
} else if (profile) {
FillFormField(profile, autofill_type, &result.fields[j]);
}
@@ -496,7 +478,6 @@ AutoFillManager::AutoFillManager(TabContents* tab_contents,
void AutoFillManager::GetProfileSuggestions(FormStructure* form,
const FormField& field,
AutoFillType type,
- bool include_cc_labels,
std::vector<string16>* values,
std::vector<string16>* labels,
std::vector<string16>* icons,
@@ -521,106 +502,8 @@ void AutoFillManager::GetProfileSuggestions(FormStructure* form,
AutoFillProfile::CreateInferredLabels(&matched_profiles, labels, 0,
type.field_type());
- if (!include_cc_labels || !form->HasBillingFields() || !FormIsHTTPS(form)) {
- icons->resize(values->size()); // No CC, so no icons.
- return;
- }
-
- size_t i = 0;
- std::vector<string16> expanded_values;
- std::vector<string16> expanded_labels;
- std::vector<int> expanded_ids;
- for (std::vector<AutoFillProfile*>::const_iterator iter =
- matched_profiles.begin(); iter != matched_profiles.end();
- ++iter, ++i) {
- AutoFillProfile* profile = *iter;
- for (std::vector<CreditCard*>::const_iterator cc =
- personal_data_->credit_cards().begin();
- cc != personal_data_->credit_cards().end(); ++cc) {
- expanded_values.push_back((*values)[i]);
- string16 label = CombineLabelAndCreditCard((*labels)[i], *cc);
- expanded_labels.push_back(label);
- icons->push_back((*cc)->type());
- expanded_ids.push_back(PackIDs((*cc)->unique_id(), profile->unique_id()));
- }
- }
-
- expanded_labels.swap(*labels);
- expanded_values.swap(*values);
- expanded_ids.swap(*unique_ids);
-}
-
-void AutoFillManager::GetBillingProfileSuggestions(
- FormStructure* form,
- const FormField& field,
- AutoFillType type,
- std::vector<string16>* values,
- std::vector<string16>* labels,
- std::vector<string16>* icons,
- std::vector<int>* unique_ids) {
-
- // If the form is non-HTTPS, no CC suggestions are provided; however, give the
- // user the option of filling the billing address fields with regular address
- // data.
- if (!FormIsHTTPS(form)) {
- GetProfileSuggestions(
- form, field, type, false, values, icons, labels, unique_ids);
- return;
- }
-
- std::vector<CreditCard*> matching_creditcards;
- std::vector<AutoFillProfile*> matching_profiles;
-
- // Collect matching pairs of credit cards and related profiles, where profile
- // field value matches form field value.
- for (std::vector<CreditCard*>::const_iterator cc =
- personal_data_->credit_cards().begin();
- cc != personal_data_->credit_cards().end(); ++cc) {
- int billing_address_id = (*cc)->billing_address_id();
- AutoFillProfile* billing_profile = NULL;
-
- // The value of the stored data for this field type in the |profile|.
- string16 profile_field_value;
-
- for (std::vector<AutoFillProfile*>::const_iterator iter =
- personal_data_->profiles().begin();
- iter != personal_data_->profiles().end(); ++iter) {
- AutoFillProfile* profile = *iter;
-
- // This assumes that labels are unique.
- if (profile->unique_id() == billing_address_id &&
- !profile->GetFieldText(type).empty() &&
- StartsWith(profile->GetFieldText(type), field.value(), false)) {
- billing_profile = profile;
- break;
- }
- }
-
- if (!billing_profile)
- continue;
-
- matching_creditcards.push_back(*cc);
- matching_profiles.push_back(billing_profile);
- }
-
- std::vector<string16> inferred_labels;
- AutoFillProfile::CreateInferredLabels(&matching_profiles, &inferred_labels, 0,
- type.field_type());
-
- DCHECK_EQ(matching_profiles.size(), matching_creditcards.size());
- DCHECK_EQ(matching_profiles.size(), inferred_labels.size());
-
- // Process the matching pairs into suggested |values|, |labels|, and
- // |unique_ids|.
- for (size_t i = 0; i < matching_profiles.size(); ++i) {
- values->push_back(matching_profiles[i]->GetFieldText(type));
- string16 label = CombineLabelAndCreditCard(inferred_labels[i],
- matching_creditcards[i]);
- labels->push_back(label);
- icons->push_back(matching_creditcards[i]->type());
- unique_ids->push_back(PackIDs(matching_creditcards[i]->unique_id(),
- matching_profiles[i]->unique_id()));
- }
+ // No icons for profile suggestions.
+ icons->resize(values->size());
}
void AutoFillManager::GetCreditCardSuggestions(FormStructure* form,
@@ -646,57 +529,10 @@ void AutoFillManager::GetCreditCardSuggestions(FormStructure* form,
if (type.field_type() == CREDIT_CARD_NUMBER)
creditcard_field_value = credit_card->ObfuscatedNumber();
- if (!form->HasNonBillingFields()) {
- values->push_back(creditcard_field_value);
- labels->push_back(CombineLabelAndCreditCard(string16(), credit_card));
- icons->push_back(credit_card->type());
- unique_ids->push_back(PackIDs(credit_card->unique_id(), 0));
- } else {
- const std::vector<AutoFillProfile*>& profiles
- = personal_data_->profiles();
- std::vector<string16> inferred_labels;
- AutoFillProfile::CreateInferredLabels(&profiles,
- &inferred_labels,
- 0,
- type.field_type());
- DCHECK_EQ(profiles.size(), inferred_labels.size());
-
- for (size_t i = 0; i < profiles.size(); ++i) {
- values->push_back(creditcard_field_value);
-
- string16 label = CombineLabelAndCreditCard(inferred_labels[i],
- credit_card);
- labels->push_back(label);
- icons->push_back(credit_card->type());
- unique_ids->push_back(
- PackIDs(credit_card->unique_id(), profiles[i]->unique_id()));
- }
- }
- }
- }
-}
-
-void AutoFillManager::FillBillingFormField(const CreditCard* credit_card,
- AutoFillType type,
- webkit_glue::FormField* field) {
- DCHECK(credit_card);
- DCHECK(type.group() == AutoFillType::ADDRESS_BILLING);
- DCHECK(field);
-
- int billing_address_id = credit_card->billing_address_id();
- if (billing_address_id != 0) {
- AutoFillProfile* profile = NULL;
- const std::vector<AutoFillProfile*>& profiles = personal_data_->profiles();
- for (std::vector<AutoFillProfile*>::const_iterator iter = profiles.begin();
- iter != profiles.end(); ++iter) {
- if ((*iter)->unique_id() == billing_address_id) {
- profile = *iter;
- break;
- }
- }
-
- if (profile) {
- FillFormField(profile, type, field);
+ values->push_back(creditcard_field_value);
+ labels->push_back(kCreditCardPrefix + credit_card->LastFourDigits());
+ icons->push_back(credit_card->type());
+ unique_ids->push_back(PackIDs(credit_card->unique_id(), 0));
}
}
}
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index 2d1ac71..c5b6f43 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -99,30 +99,15 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
private:
// Returns a list of values from the stored profiles that match |type| and the
// value of |field| and returns the labels of the matching profiles. |labels|
- // is filled with the Profile label and possibly the last four digits of a
- // corresponding credit card: 'Home; *1258' - Home is the Profile label and
- // 1258 is the last four digits of the credit card. If |include_cc_labels| is
- // true, check for billing fields and append CC digits to the labels;
- // otherwise, regular profiles are returned for billing address fields.
+ // is filled with the Profile label.
void GetProfileSuggestions(FormStructure* form,
const webkit_glue::FormField& field,
AutoFillType type,
- bool include_cc_labels,
std::vector<string16>* values,
std::vector<string16>* labels,
std::vector<string16>* icons,
std::vector<int>* unique_ids);
- // Same as GetProfileSuggestions, but the list of stored profiles is limited
- // to the linked billing addresses from the list of credit cards.
- void GetBillingProfileSuggestions(FormStructure* form,
- const webkit_glue::FormField& field,
- AutoFillType type,
- std::vector<string16>* values,
- std::vector<string16>* labels,
- std::vector<string16>* icons,
- std::vector<int>* unique_ids);
-
// Returns a list of values from the stored credit cards that match |type| and
// the value of |field| and returns the labels of the matching credit cards.
void GetCreditCardSuggestions(FormStructure* form,
@@ -134,14 +119,6 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
std::vector<int>* unique_ids);
// Set |field| argument's value based on |type| and contents of the
- // |credit_card|. The |type| field is expected to have main group type of
- // ADDRESS_BILLING. The address information is retrieved from the billing
- // profile associated with the |credit_card|, if there is one set.
- void FillBillingFormField(const CreditCard* credit_card,
- AutoFillType type,
- webkit_glue::FormField* field);
-
- // Set |field| argument's value based on |type| and contents of the
// |credit_card|.
void FillCreditCardFormField(const CreditCard* credit_card,
AutoFillType type,
@@ -202,8 +179,8 @@ class AutoFillManager : public RenderViewHostDelegate::AutoFill,
friend class TestAutoFillManager;
FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillCreditCardForm);
- FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillNonBillingFormSemicolon);
- FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillBillFormSemicolon);
+ FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressForm);
+ FRIEND_TEST_ALL_PREFIXES(AutoFillManagerTest, FillAddressAndCreditCardForm);
DISALLOW_COPY_AND_ASSIGN(AutoFillManager);
};
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 7cc9769..1716f01 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -87,19 +87,18 @@ class TestPersonalDataManager : public PersonalDataManager {
void CreateTestCreditCards(ScopedVector<CreditCard>* credit_cards) {
CreditCard* credit_card = new CreditCard;
autofill_test::SetCreditCardInfo(credit_card, "First", "Elvis Presley",
- "Visa", "1234567890123456",
- "04", "2012", 1);
+ "4234567890123456", // Visa
+ "04", "2012");
credit_card->set_unique_id(4);
credit_cards->push_back(credit_card);
credit_card = new CreditCard;
autofill_test::SetCreditCardInfo(credit_card, "Second", "Buddy Holly",
- "Mastercard", "0987654321098765",
- "10", "2014", 2);
+ "5187654321098765", // Mastercard
+ "10", "2014");
credit_card->set_unique_id(5);
credit_cards->push_back(credit_card);
credit_card = new CreditCard;
- autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", "", "",
- 3);
+ autofill_test::SetCreditCardInfo(credit_card, "Empty", "", "", "", "");
credit_card->set_unique_id(6);
credit_cards->push_back(credit_card);
}
@@ -135,7 +134,10 @@ class TestAutoFillManager : public AutoFillManager {
DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager);
};
-void CreateTestFormData(FormData* form) {
+// Populates |form| with data corresponding to a simple address form.
+// Note that this actually appends fields to the form data, which can be useful
+// for building up more complex test forms.
+void CreateTestAddressFormData(FormData* form) {
form->name = ASCIIToUTF16("MyForm");
form->method = ASCIIToUTF16("POST");
form->origin = GURL("http://myform.com/form.html");
@@ -178,48 +180,23 @@ void CreateTestFormData(FormData* form) {
form->fields.push_back(field);
}
-void CreateTestFormDataBilling(FormData* form) {
+// Populates |form| with data corresponding to a simple credit card form, with.
+// Note that this actually appends fields to the form data, which can be useful
+// for building up more complex test forms.
+void CreateTestCreditCardFormData(FormData* form, bool is_https) {
form->name = ASCIIToUTF16("MyForm");
form->method = ASCIIToUTF16("POST");
- form->origin = GURL("https://myform.com/form.html");
- form->action = GURL("https://myform.com/submit.html");
+ if (is_https) {
+ form->origin = GURL("https://myform.com/form.html");
+ form->action = GURL("https://myform.com/submit.html");
+ } else {
+ form->origin = GURL("http://myform.com/form.html");
+ form->action = GURL("http://myform.com/submit.html");
+ }
form->user_submitted = true;
webkit_glue::FormField field;
autofill_test::CreateTestFormField(
- "First Name", "firstname", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Last Name", "lastname", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Address Line 1", "billingAddr1", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Address Line 2", "billingAddr2", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "City", "billingCity", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "State", "billingState", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Postal Code", "billingZipcode", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Country", "billingCountry", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
- "Email", "email", "", "text", &field);
- form->fields.push_back(field);
- autofill_test::CreateTestFormField(
"Name on Card", "nameoncard", "", "text", &field);
form->fields.push_back(field);
autofill_test::CreateTestFormField(
@@ -254,7 +231,8 @@ class AutoFillManagerTest : public RenderViewHostTestHarness {
bool GetAutoFillSuggestionsMessage(int* page_id,
std::vector<string16>* values,
- std::vector<string16>* labels) {
+ std::vector<string16>* labels,
+ std::vector<string16>* icons) {
const uint32 kMsgID = ViewMsg_AutoFillSuggestionsReturned::ID;
const IPC::Message* message =
process()->sink().GetFirstMessageMatching(kMsgID);
@@ -269,6 +247,8 @@ class AutoFillManagerTest : public RenderViewHostTestHarness {
*values = autofill_param.b;
if (labels)
*labels = autofill_param.c;
+ if (icons)
+ *icons = autofill_param.d;
return true;
}
@@ -295,9 +275,11 @@ class AutoFillManagerTest : public RenderViewHostTestHarness {
DISALLOW_COPY_AND_ASSIGN(AutoFillManagerTest);
};
+// Test that we return all address profile suggestions when all form fields are
+// empty.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) {
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -321,7 +303,9 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
ASSERT_EQ(2U, values.size());
EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
@@ -331,11 +315,16 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) {
// the address #1.
EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
}
+// Test that we return only matching address profile suggestions when the
+// selected form field has been partially filled out.
TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) {
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -359,17 +348,61 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
ASSERT_EQ(1U, values.size());
EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
ASSERT_EQ(1U, labels.size());
EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
+ ASSERT_EQ(1U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+}
+
+// Test that we return no suggestions when the form has no relevant fields.
+TEST_F(AutoFillManagerTest, GetProfileSuggestionsUnknownFields) {
+ FormData form;
+ form.name = ASCIIToUTF16("MyForm");
+ form.method = ASCIIToUTF16("POST");
+ form.origin = GURL("http://myform.com/form.html");
+ form.action = GURL("http://myform.com/submit.html");
+ form.user_submitted = true;
+
+ webkit_glue::FormField field;
+ autofill_test::CreateTestFormField(
+ "Username", "username", "", "text", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Password", "password", "", "password", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Quest", "quest", "", "quest", &field);
+ form.fields.push_back(field);
+ autofill_test::CreateTestFormField(
+ "Color", "color", "", "text", &field);
+ form.fields.push_back(field);
+
+ // Set up our FormStructures.
+ std::vector<FormData> forms;
+ forms.push_back(form);
+ autofill_manager_->FormsSeen(forms);
+
+ // The page ID sent to the AutoFillManager from the RenderView, used to send
+ // an IPC message back to the renderer.
+ const int kPageID = 1;
+
+ autofill_test::CreateTestFormField(
+ "Username", "username", "", "text", &field);
+ EXPECT_FALSE(
+ autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
}
+// Test that we return all credit card profile suggestions when all form fields
+// are empty.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) {
FormData form;
- CreateTestFormDataBilling(&form);
+ CreateTestCreditCardFormData(&form, true);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -393,27 +426,26 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(6U, values.size());
+ ASSERT_EQ(2U, values.size());
EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[2]);
- EXPECT_EQ(ASCIIToUTF16("************8765"), values[3]);
- EXPECT_EQ(ASCIIToUTF16("************8765"), values[4]);
- EXPECT_EQ(ASCIIToUTF16("************8765"), values[5]);
- ASSERT_EQ(6U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *3456"), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[2]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *8765"), labels[3]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *8765"), labels[4]);
- EXPECT_EQ(ASCIIToUTF16("*8765"), labels[5]);
+ EXPECT_EQ(ASCIIToUTF16("************8765"), values[1]);
+ ASSERT_EQ(2U, labels.size());
+ EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
+ EXPECT_EQ(ASCIIToUTF16("*8765"), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
+ EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
}
+// Test that we return only matching credit card profile suggestions when the
+// selected form field has been partially filled out.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) {
FormData form;
- CreateTestFormDataBilling(&form);
+ CreateTestCreditCardFormData(&form, true);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -426,7 +458,7 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) {
webkit_glue::FormField field;
autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "1", "text", &field);
+ "Card Number", "cardnumber", "4", "text", &field);
EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
// No suggestions provided, so send an empty vector as the results.
@@ -437,21 +469,23 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(3U, values.size());
+ ASSERT_EQ(1U, values.size());
EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("************3456"), values[2]);
- ASSERT_EQ(3U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *3456"), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[2]);
+ ASSERT_EQ(1U, labels.size());
+ EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
+ ASSERT_EQ(1U, icons.size());
+ EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
}
+// Test that we return credit card profile suggestions when the selected form
+// field is not the credit card number field.
TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) {
FormData form;
- CreateTestFormDataBilling(&form);
+ CreateTestCreditCardFormData(&form, true);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -475,36 +509,48 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(6U, values.size());
+ ASSERT_EQ(2U, values.size());
EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[2]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[3]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[4]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[5]);
- ASSERT_EQ(6U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *3456"), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[2]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *8765"), labels[3]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *8765"), labels[4]);
- EXPECT_EQ(ASCIIToUTF16("*8765"), labels[5]);
+ EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[1]);
+ ASSERT_EQ(2U, labels.size());
+ EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
+ EXPECT_EQ(ASCIIToUTF16("*8765"), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
+ EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
}
-TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsSemicolon) {
- // |profile| will be owned by the mock PersonalDataManager.
- AutoFillProfile* profile = new AutoFillProfile;
- autofill_test::SetProfileInfo(profile, "Home; 8765", "Joe", "", "Ely",
- "flatlander@gmail.com", "MCA",
- "916 16th St.", "Apt. 6", "Lubbock",
- "Texas", "79401", "USA",
- "12345678901", "");
- autofill_manager_->AddProfile(profile);
+// Test that we return no credit card profile suggestions when the form is not
+// https.
+TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
+ FormData form;
+ CreateTestCreditCardFormData(&form, false);
+
+ // Set up our FormStructures.
+ std::vector<FormData> forms;
+ forms.push_back(form);
+ autofill_manager_->FormsSeen(forms);
+
+ // The page ID sent to the AutoFillManager from the RenderView, used to send
+ // an IPC message back to the renderer.
+ const int kPageID = 1;
+
+ webkit_glue::FormField field;
+ autofill_test::CreateTestFormField(
+ "Card Number", "cardnumber", "", "text", &field);
+ EXPECT_FALSE(
+ autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
+}
+// Test that we return profile and credit card suggestions for combined forms.
+TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
FormData form;
- CreateTestFormDataBilling(&form);
+ CreateTestAddressFormData(&form);
+ CreateTestCreditCardFormData(&form, true);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -517,43 +563,64 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsSemicolon) {
webkit_glue::FormField field;
autofill_test::CreateTestFormField(
- "Name on Card", "nameoncard", "", "text", &field);
+ "First Name", "firstname", "", "text", &field);
EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
// No suggestions provided, so send an empty vector as the results.
// This triggers the combined message send.
rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
- // Test that we sent the right message to the renderer.
+ // Test that we sent the right address suggestions to the renderer.
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(8U, values.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[0]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[1]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[2]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Presley"), values[3]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[4]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[5]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[6]);
- EXPECT_EQ(ASCIIToUTF16("Buddy Holly"), values[7]);
- ASSERT_EQ(8U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *3456"), labels[1]);
- EXPECT_EQ(ASCIIToUTF16("*3456"), labels[2]);
- EXPECT_EQ(ASCIIToUTF16("Joe Ely; *3456"), labels[3]);
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *8765"), labels[4]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *8765"), labels[5]);
- EXPECT_EQ(ASCIIToUTF16("*8765"), labels[6]);
- EXPECT_EQ(ASCIIToUTF16("Joe Ely; *8765"), labels[7]);
+ ASSERT_EQ(2U, values.size());
+ EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
+ EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
+ ASSERT_EQ(2U, labels.size());
+ // Inferred labels now include full first relevant field, which in this case
+ // the address #1.
+ EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
+ EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
+
+ process()->sink().ClearMessages();
+ autofill_test::CreateTestFormField(
+ "Card Number", "cardnumber", "", "text", &field);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
+
+ // No suggestions provided, so send an empty vector as the results.
+ // This triggers the combined message send.
+ rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
+
+ // Test that we sent the credit card suggestions to the renderer.
+ page_id = 0;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
+ EXPECT_EQ(kPageID, page_id);
+ ASSERT_EQ(2U, values.size());
+ EXPECT_EQ(ASCIIToUTF16("************3456"), values[0]);
+ EXPECT_EQ(ASCIIToUTF16("************8765"), values[1]);
+ ASSERT_EQ(2U, labels.size());
+ EXPECT_EQ(ASCIIToUTF16("*3456"), labels[0]);
+ EXPECT_EQ(ASCIIToUTF16("*8765"), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(ASCIIToUTF16("visaCC"), icons[0]);
+ EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
}
-TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
+// Test that for non-https forms with both address and credit card fields, we
+// only return address suggestions.
+TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
FormData form;
- CreateTestFormDataBilling(&form);
- form.origin = GURL("http://myform.com/form.html");
+ CreateTestAddressFormData(&form);
+ CreateTestCreditCardFormData(&form, false);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -566,14 +633,43 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
webkit_glue::FormField field;
autofill_test::CreateTestFormField(
+ "First Name", "firstname", "", "text", &field);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
+
+ // No suggestions provided, so send an empty vector as the results.
+ // This triggers the combined message send.
+ rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
+
+ // Test that we sent the right address suggestions to the renderer.
+ int page_id = 0;
+ std::vector<string16> values;
+ std::vector<string16> labels;
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
+ EXPECT_EQ(kPageID, page_id);
+ ASSERT_EQ(2U, values.size());
+ EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
+ EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]);
+ ASSERT_EQ(2U, labels.size());
+ // Inferred labels now include full first relevant field, which in this case
+ // the address #1.
+ EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), labels[0]);
+ EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
+
+ autofill_test::CreateTestFormField(
"Card Number", "cardnumber", "", "text", &field);
EXPECT_FALSE(
autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
}
+// Test that we correctly combine autofill and autocomplete suggestions.
TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) {
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -600,7 +696,9 @@ TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
ASSERT_EQ(4U, values.size());
EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
@@ -612,11 +710,18 @@ TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) {
EXPECT_EQ(ASCIIToUTF16("123 Apple St."), labels[1]);
EXPECT_EQ(string16(), labels[2]);
EXPECT_EQ(string16(), labels[3]);
+ ASSERT_EQ(4U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
+ EXPECT_EQ(string16(), icons[2]);
+ EXPECT_EQ(string16(), icons[3]);
}
-TEST_F(AutoFillManagerTest, GetFieldSuggestionsFormIsAutoFilled) {
+// Test that we return autocomplete-like suggestions when trying to autofill
+// already filled fields.
+TEST_F(AutoFillManagerTest, GetFieldSuggestionsFieldIsAutoFilled) {
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -640,7 +745,9 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFormIsAutoFilled) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
ASSERT_EQ(2U, values.size());
EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
@@ -648,11 +755,16 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFormIsAutoFilled) {
ASSERT_EQ(2U, labels.size());
EXPECT_EQ(string16(), labels[0]);
EXPECT_EQ(string16(), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
}
+// Test that nothing breaks when there are autocomplete suggestions but no
+// autofill suggestions.
TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -668,10 +780,8 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
"Some Field", "somefield", "", "text", &field);
EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field));
- // No suggestions provided, so send an empty vector as the results.
+ // Add some Autocomplete suggestions.
// This triggers the combined message send.
- // In this case, we're simulating a cancel of Autocomplete with a different
- // page ID and an empty vector of suggestions.
std::vector<string16> suggestions;
suggestions.push_back(ASCIIToUTF16("one"));
suggestions.push_back(ASCIIToUTF16("two"));
@@ -681,7 +791,9 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
ASSERT_EQ(2U, values.size());
ASSERT_EQ(2U, labels.size());
@@ -689,11 +801,16 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
EXPECT_EQ(string16(), labels[0]);
EXPECT_EQ(ASCIIToUTF16("two"), values[1]);
EXPECT_EQ(string16(), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
}
+// Test that we do not return duplicate values drawn from multiple profiles when
+// filling an already filled field.
TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -723,7 +840,9 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
int page_id = 0;
std::vector<string16> values;
std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ std::vector<string16> icons;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
+ &icons));
EXPECT_EQ(kPageID, page_id);
ASSERT_EQ(2U, values.size());
EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]);
@@ -731,47 +850,25 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
ASSERT_EQ(2U, labels.size());
EXPECT_EQ(string16(), labels[0]);
EXPECT_EQ(string16(), labels[1]);
+ ASSERT_EQ(2U, icons.size());
+ EXPECT_EQ(string16(), icons[0]);
+ EXPECT_EQ(string16(), icons[1]);
}
-TEST_F(AutoFillManagerTest, GetBillingSuggestionsAddress1) {
- FormData form;
- CreateTestFormDataBilling(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
- autofill_manager_->FormsSeen(forms);
-
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
-
- webkit_glue::FormField field;
- autofill_test::CreateTestFormField(
- "Address Line 1", "billingAddr1", "", "text", &field);
- EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
-
- // No suggestions provided, so send an empty vector as the results.
- // This triggers the combined message send.
- rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
-
- // Test that we sent the right message to the renderer.
- int page_id = 0;
- std::vector<string16> values;
- std::vector<string16> labels;
- EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
- EXPECT_EQ(kPageID, page_id);
- ASSERT_EQ(2U, values.size());
- EXPECT_EQ(ASCIIToUTF16("3734 Elvis Presley Blvd."), values[0]);
- EXPECT_EQ(ASCIIToUTF16("123 Apple St."), values[1]);
- ASSERT_EQ(2U, labels.size());
- EXPECT_EQ(ASCIIToUTF16("Elvis Aaron Presley; *3456"), labels[0]);
- EXPECT_EQ(ASCIIToUTF16("Charles Hardin Holley; *8765"), labels[1]);
-}
+// Test that we correctly fill an address form.
+TEST_F(AutoFillManagerTest, FillAddressForm) {
+ // |profile| will be owned by the mock PersonalDataManager.
+ AutoFillProfile* profile = new AutoFillProfile;
+ autofill_test::SetProfileInfo(profile, "Home; 8765", "Joe", "", "Ely",
+ "flatlander@gmail.com", "MCA",
+ "916 16th St.", "Apt. 6", "Lubbock",
+ "Texas", "79401", "USA",
+ "12345678901", "");
+ profile->set_unique_id(7);
+ autofill_manager_->AddProfile(profile);
-TEST_F(AutoFillManagerTest, FillCreditCardForm) {
FormData form;
- CreateTestFormDataBilling(&form);
+ CreateTestAddressFormData(&form);
// Set up our FormStructures.
std::vector<FormData> forms;
@@ -782,67 +879,95 @@ TEST_F(AutoFillManagerTest, FillCreditCardForm) {
// an IPC message back to the renderer.
const int kPageID = 1;
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form, AutoFillManager::PackIDs(4, 1)));
+ kPageID, form, AutoFillManager::PackIDs(0, 7)));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("https://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
- ASSERT_EQ(15U, results.fields.size());
+ EXPECT_EQ(GURL("http://myform.com/form.html"), results.origin);
+ EXPECT_EQ(GURL("http://myform.com/submit.html"), results.action);
+ ASSERT_EQ(11U, results.fields.size());
webkit_glue::FormField field;
autofill_test::CreateTestFormField(
- "First Name", "firstname", "Elvis", "text", &field);
+ "First Name", "firstname", "Joe", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
autofill_test::CreateTestFormField(
- "Middle Name", "middlename", "Aaron", "text", &field);
+ "Middle Name", "middlename", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
autofill_test::CreateTestFormField(
- "Last Name", "lastname", "Presley", "text", &field);
+ "Last Name", "lastname", "Ely", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
autofill_test::CreateTestFormField(
- "Address Line 1", "billingAddr1",
- "3734 Elvis Presley Blvd.", "text", &field);
+ "Address Line 1", "addr1", "916 16th St.", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
autofill_test::CreateTestFormField(
- "Address Line 2", "billingAddr2", "Apt. 10", "text", &field);
+ "Address Line 2", "addr2", "Apt. 6", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
autofill_test::CreateTestFormField(
- "City", "billingCity", "Memphis", "text", &field);
+ "City", "city", "Lubbock", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[5]));
autofill_test::CreateTestFormField(
- "State", "billingState", "Tennessee", "text", &field);
+ "State", "state", "Texas", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[6]));
autofill_test::CreateTestFormField(
- "Postal Code", "billingZipcode", "38116", "text", &field);
+ "Postal Code", "zipcode", "79401", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[7]));
autofill_test::CreateTestFormField(
- "Country", "billingCountry", "USA", "text", &field);
+ "Country", "country", "USA", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[8]));
autofill_test::CreateTestFormField(
"Phone Number", "phonenumber", "12345678901", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[9]));
autofill_test::CreateTestFormField(
- "Email", "email", "theking@gmail.com", "text", &field);
+ "Email", "email", "flatlander@gmail.com", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[10]));
+}
+
+// Test that we correctly fill a credit card form.
+TEST_F(AutoFillManagerTest, FillCreditCardForm) {
+ FormData form;
+ CreateTestCreditCardFormData(&form, true);
+
+ // Set up our FormStructures.
+ std::vector<FormData> forms;
+ forms.push_back(form);
+ autofill_manager_->FormsSeen(forms);
+
+ // The page ID sent to the AutoFillManager from the RenderView, used to send
+ // an IPC message back to the renderer.
+ const int kPageID = 1;
+ EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
+ kPageID, form, AutoFillManager::PackIDs(4, 0)));
+
+ int page_id = 0;
+ FormData results;
+ EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
+ EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
+ EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
+ EXPECT_EQ(GURL("https://myform.com/form.html"), results.origin);
+ EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
+ ASSERT_EQ(4U, results.fields.size());
+
+ webkit_glue::FormField field;
autofill_test::CreateTestFormField(
"Name on Card", "nameoncard", "Elvis Presley", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[11]));
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "1234567890123456", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[12]));
+ "Card Number", "cardnumber", "4234567890123456", "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
autofill_test::CreateTestFormField(
"Expiration Date", "ccmonth", "04", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[13]));
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
autofill_test::CreateTestFormField(
"", "ccyear", "2012", "text", &field);
- EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[14]));
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
}
-TEST_F(AutoFillManagerTest, FillNonBillingFormSemicolon) {
+// Test that we correctly fill a combined address and credit card form.
+TEST_F(AutoFillManagerTest, FillAddressAndCreditCardForm) {
// |profile| will be owned by the mock PersonalDataManager.
AutoFillProfile* profile = new AutoFillProfile;
autofill_test::SetProfileInfo(profile, "Home; 8765", "Joe", "", "Ely",
@@ -854,27 +979,29 @@ TEST_F(AutoFillManagerTest, FillNonBillingFormSemicolon) {
autofill_manager_->AddProfile(profile);
FormData form;
- CreateTestFormData(&form);
+ CreateTestAddressFormData(&form);
+ CreateTestCreditCardFormData(&form, true);
// Set up our FormStructures.
std::vector<FormData> forms;
forms.push_back(form);
autofill_manager_->FormsSeen(forms);
+ // First fill the address data.
// The page ID sent to the AutoFillManager from the RenderView, used to send
// an IPC message back to the renderer.
const int kPageID = 1;
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form, AutoFillManager::PackIDs(4, 7)));
+ kPageID, form, AutoFillManager::PackIDs(0, 7)));
int page_id = 0;
FormData results;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
- EXPECT_EQ(GURL("http://myform.com/form.html"), results.origin);
- EXPECT_EQ(GURL("http://myform.com/submit.html"), results.action);
- ASSERT_EQ(11U, results.fields.size());
+ EXPECT_EQ(GURL("https://myform.com/form.html"), results.origin);
+ EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
+ ASSERT_EQ(15U, results.fields.size());
webkit_glue::FormField field;
autofill_test::CreateTestFormField(
@@ -910,35 +1037,26 @@ TEST_F(AutoFillManagerTest, FillNonBillingFormSemicolon) {
autofill_test::CreateTestFormField(
"Email", "email", "flatlander@gmail.com", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[10]));
-}
-
-TEST_F(AutoFillManagerTest, FillBillFormSemicolon) {
- // |profile| will be owned by the mock PersonalDataManager.
- AutoFillProfile* profile = new AutoFillProfile;
- autofill_test::SetProfileInfo(profile, "Home; 8765", "Joe", "", "Ely",
- "flatlander@gmail.com", "MCA",
- "916 16th St.", "Apt. 6", "Lubbock",
- "Texas", "79401", "USA",
- "12345678901", "");
- profile->set_unique_id(7);
- autofill_manager_->AddProfile(profile);
-
- FormData form;
- CreateTestFormDataBilling(&form);
-
- // Set up our FormStructures.
- std::vector<FormData> forms;
- forms.push_back(form);
- autofill_manager_->FormsSeen(forms);
+ autofill_test::CreateTestFormField(
+ "Name on Card", "nameoncard", "", "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[11]));
+ autofill_test::CreateTestFormField(
+ "Card Number", "cardnumber", "", "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[12]));
+ autofill_test::CreateTestFormField(
+ "Expiration Date", "ccmonth", "", "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[13]));
+ autofill_test::CreateTestFormField(
+ "", "ccyear", "", "text", &field);
+ EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[14]));
- // The page ID sent to the AutoFillManager from the RenderView, used to send
- // an IPC message back to the renderer.
- const int kPageID = 1;
+ // Now fill the credit card data.
+ process()->sink().ClearMessages();
EXPECT_TRUE(autofill_manager_->FillAutoFillFormData(
- kPageID, form, AutoFillManager::PackIDs(4, 7)));
+ kPageID, form, AutoFillManager::PackIDs(4, 0)));
- int page_id = 0;
- FormData results;
+
+ page_id = 0;
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
EXPECT_EQ(ASCIIToUTF16("MyForm"), results.name);
EXPECT_EQ(ASCIIToUTF16("POST"), results.method);
@@ -946,46 +1064,44 @@ TEST_F(AutoFillManagerTest, FillBillFormSemicolon) {
EXPECT_EQ(GURL("https://myform.com/submit.html"), results.action);
ASSERT_EQ(15U, results.fields.size());
- webkit_glue::FormField field;
autofill_test::CreateTestFormField(
- "First Name", "firstname", "Joe", "text", &field);
+ "First Name", "firstname", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[0]));
autofill_test::CreateTestFormField(
"Middle Name", "middlename", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[1]));
autofill_test::CreateTestFormField(
- "Last Name", "lastname", "Ely", "text", &field);
+ "Last Name", "lastname", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[2]));
autofill_test::CreateTestFormField(
- "Address Line 1", "billingAddr1",
- "3734 Elvis Presley Blvd.", "text", &field);
+ "Address Line 1", "addr1", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
autofill_test::CreateTestFormField(
- "Address Line 2", "billingAddr2", "Apt. 10", "text", &field);
+ "Address Line 2", "addr2", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4]));
autofill_test::CreateTestFormField(
- "City", "billingCity", "Memphis", "text", &field);
+ "City", "city", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[5]));
autofill_test::CreateTestFormField(
- "State", "billingState", "Tennessee", "text", &field);
+ "State", "state", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[6]));
autofill_test::CreateTestFormField(
- "Postal Code", "billingZipcode", "38116", "text", &field);
+ "Postal Code", "zipcode", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[7]));
autofill_test::CreateTestFormField(
- "Country", "billingCountry", "USA", "text", &field);
+ "Country", "country", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[8]));
autofill_test::CreateTestFormField(
- "Phone Number", "phonenumber", "12345678901", "text", &field);
+ "Phone Number", "phonenumber", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[9]));
autofill_test::CreateTestFormField(
- "Email", "email", "flatlander@gmail.com", "text", &field);
+ "Email", "email", "", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[10]));
autofill_test::CreateTestFormField(
"Name on Card", "nameoncard", "Elvis Presley", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[11]));
autofill_test::CreateTestFormField(
- "Card Number", "cardnumber", "1234567890123456", "text", &field);
+ "Card Number", "cardnumber", "4234567890123456", "text", &field);
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[12]));
autofill_test::CreateTestFormField(
"Expiration Date", "ccmonth", "04", "text", &field);
@@ -995,6 +1111,7 @@ TEST_F(AutoFillManagerTest, FillBillFormSemicolon) {
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[14]));
}
+// Test that we correctly fill a phone number split across multiple fields.
TEST_F(AutoFillManagerTest, FillPhoneNumber) {
FormData form;
@@ -1066,6 +1183,7 @@ TEST_F(AutoFillManagerTest, FillPhoneNumber) {
work_profile->SetInfo(phone_type, saved_phone);
}
+// Test that we can still fill a form when a field has been removed from it.
TEST_F(AutoFillManagerTest, FormChangesRemoveField) {
FormData form;
form.name = ASCIIToUTF16("MyForm");
@@ -1129,6 +1247,7 @@ TEST_F(AutoFillManagerTest, FormChangesRemoveField) {
EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[3]));
}
+// Test that we can still fill a form when a field has been added to it.
TEST_F(AutoFillManagerTest, FormChangesAddField) {
FormData form;
form.name = ASCIIToUTF16("MyForm");
diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc
index a288bf6..67382b7 100644
--- a/chrome/browser/autofill/credit_card.cc
+++ b/chrome/browser/autofill/credit_card.cc
@@ -131,7 +131,6 @@ CreditCard::CreditCard(const string16& label,
: expiration_month_(0),
expiration_year_(0),
label_(label),
- billing_address_id_(0),
unique_id_(unique_id),
guid_(guid::GenerateGUID()) {
}
@@ -139,7 +138,6 @@ CreditCard::CreditCard(const string16& label,
CreditCard::CreditCard(const std::string& guid)
: expiration_month_(0),
expiration_year_(0),
- billing_address_id_(0),
unique_id_(0),
guid_(guid) {
}
@@ -147,7 +145,6 @@ CreditCard::CreditCard(const std::string& guid)
CreditCard::CreditCard()
: expiration_month_(0),
expiration_year_(0),
- billing_address_id_(0),
unique_id_(0),
guid_(guid::GenerateGUID()) {
}
@@ -383,7 +380,6 @@ void CreditCard::operator=(const CreditCard& source) {
expiration_month_ = source.expiration_month_;
expiration_year_ = source.expiration_year_;
label_ = source.label_;
- billing_address_id_ = source.billing_address_id_;
unique_id_ = source.unique_id_;
guid_ = source.guid_;
}
@@ -398,9 +394,7 @@ bool CreditCard::operator==(const CreditCard& creditcard) const {
CREDIT_CARD_EXP_MONTH,
CREDIT_CARD_EXP_4_DIGIT_YEAR };
- if (label_ != creditcard.label_ ||
- unique_id_ != creditcard.unique_id_ ||
- billing_address_id_ != creditcard.billing_address_id_) {
+ if ((label_ != creditcard.label_) || (unique_id_ != creditcard.unique_id_)) {
return false;
}
@@ -446,7 +440,7 @@ bool CreditCard::IsCreditCardNumber(const string16& text) {
bool CreditCard::IsEmpty() const {
FieldTypeSet types;
GetAvailableFieldTypes(&types);
- return types.empty() && billing_address_id_ == 0;
+ return types.empty();
}
@@ -624,8 +618,6 @@ std::ostream& operator<<(std::ostream& os, const CreditCard& creditcard) {
<< " "
<< creditcard.guid()
<< " "
- << creditcard.billing_address_id()
- << " "
<< UTF16ToUTF8(creditcard.GetFieldText(AutoFillType(CREDIT_CARD_NAME)))
<< " "
<< UTF16ToUTF8(creditcard.GetFieldText(AutoFillType(CREDIT_CARD_TYPE)))
diff --git a/chrome/browser/autofill/credit_card.h b/chrome/browser/autofill/credit_card.h
index f437a90..67bfa2f 100644
--- a/chrome/browser/autofill/credit_card.h
+++ b/chrome/browser/autofill/credit_card.h
@@ -45,7 +45,6 @@ class CreditCard : public FormGroup {
string16 LastFourDigits() const;
const string16& type() const { return type_; }
- int billing_address_id() const { return billing_address_id_; }
int unique_id() const { return unique_id_; }
void set_unique_id(int id) { unique_id_ = id; }
@@ -54,11 +53,6 @@ class CreditCard : public FormGroup {
const std::string guid() const { return guid_; }
void set_guid(const std::string& guid) { guid_ = guid; }
- // The caller should verify that the corresponding AutoFillProfile exists.
- void set_billing_address_id(int address_id) {
- billing_address_id_ = address_id;
- }
-
// For use in STL containers.
void operator=(const CreditCard&);
@@ -147,10 +141,6 @@ class CreditCard : public FormGroup {
// This is the display name of the card set by the user, e.g., Amazon Visa.
string16 label_;
- // The billing address. This is the unique ID of the AutoFillProfile that
- // contains the corresponding billing address.
- int billing_address_id_;
-
// The unique ID of this credit card.
int unique_id_;
diff --git a/chrome/browser/autofill/credit_card_unittest.cc b/chrome/browser/autofill/credit_card_unittest.cc
index 5a9a732..aba4bedb 100644
--- a/chrome/browser/autofill/credit_card_unittest.cc
+++ b/chrome/browser/autofill/credit_card_unittest.cc
@@ -24,7 +24,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) {
// Case 00: Empty credit card with empty strings.
CreditCard credit_card00(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card00, "Corporate",
- "John Dillinger", "Visa", "", "", "", 1);
+ "John Dillinger", "", "", "");
string16 summary00 = credit_card00.PreviewSummary();
EXPECT_EQ(string16(), summary00);
string16 obfuscated00 = credit_card00.ObfuscatedNumber();
@@ -33,7 +33,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) {
// Case 1: No credit card number.
CreditCard credit_card1(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card1, "Corporate",
- "John Dillinger", "Visa", "", "01", "2010", 1);
+ "John Dillinger", "", "01", "2010");
string16 summary1 = credit_card1.PreviewSummary();
EXPECT_EQ(string16(), summary1);
string16 obfuscated1 = credit_card1.ObfuscatedNumber();
@@ -42,7 +42,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) {
// Case 2: No month.
CreditCard credit_card2(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card2, "Corporate",
- "John Dillinger", "Visa", "123456789012", "", "2010", 1);
+ "John Dillinger", "123456789012", "", "2010");
string16 summary2 = credit_card2.PreviewSummary();
EXPECT_EQ(string16(ASCIIToUTF16("************9012")), summary2);
string16 obfuscated2 = credit_card2.ObfuscatedNumber();
@@ -51,7 +51,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) {
// Case 3: No year.
CreditCard credit_card3(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card3, "Corporate",
- "John Dillinger", "Visa", "123456789012", "01", "", 1);
+ "John Dillinger", "123456789012", "01", "");
string16 summary3 = credit_card3.PreviewSummary();
EXPECT_EQ(string16(ASCIIToUTF16("************9012")), summary3);
string16 obfuscated3 = credit_card3.ObfuscatedNumber();
@@ -60,7 +60,7 @@ TEST(CreditCardTest, PreviewSummaryAndObfuscatedNumberStrings) {
// Case 4: Have everything.
CreditCard credit_card4(string16(), 0);
autofill_test::SetCreditCardInfo(&credit_card4, "Corporate",
- "John Dillinger", "Visa", "123456789012", "01", "2010", 1);
+ "John Dillinger", "123456789012", "01", "2010");
string16 summary4 = credit_card4.PreviewSummary();
EXPECT_EQ(string16(ASCIIToUTF16("************9012, Exp: 01/2010")), summary4);
string16 obfuscated4 = credit_card4.ObfuscatedNumber();
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index ef4f4a5..1317f82 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -187,15 +187,15 @@ TEST_F(PersonalDataManagerTest, SetProfiles) {
TEST_F(PersonalDataManagerTest, SetCreditCards) {
CreditCard creditcard0(string16(), 0);
autofill_test::SetCreditCardInfo(&creditcard0, "Corporate",
- "John Dillinger", "Visa", "123456789012", "01", "2010", 1);
+ "John Dillinger", "423456789012" /* Visa */, "01", "2010");
CreditCard creditcard1(string16(), 0);
autofill_test::SetCreditCardInfo(&creditcard1, "Personal",
- "Bonnie Parker", "Mastercard", "098765432109", "12", "2012", 2);
+ "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012");
CreditCard creditcard2(string16(), 0);
autofill_test::SetCreditCardInfo(&creditcard2, "Savings",
- "Clyde Barrow", "American Express", "777666888555", "04", "2015", 3);
+ "Clyde Barrow", "347666888555" /* American Express */, "04", "2015");
// This will verify that the web database has been loaded and the notification
// sent out.
@@ -283,11 +283,11 @@ TEST_F(PersonalDataManagerTest, SetProfilesAndCreditCards) {
CreditCard creditcard0(string16(), 0);
autofill_test::SetCreditCardInfo(&creditcard0, "Corporate",
- "John Dillinger", "Visa", "123456789012", "01", "2010", 1);
+ "John Dillinger", "423456789012" /* Visa */, "01", "2010");
CreditCard creditcard1(string16(), 0);
autofill_test::SetCreditCardInfo(&creditcard1, "Personal",
- "Bonnie Parker", "Mastercard", "098765432109", "12", "2012", 2);
+ "Bonnie Parker", "518765432109" /* Mastercard */, "12", "2012");
// This will verify that the web database has been loaded and the notification
// sent out.
@@ -437,8 +437,7 @@ TEST_F(PersonalDataManagerTest, SetEmptyProfile) {
TEST_F(PersonalDataManagerTest, SetEmptyCreditCard) {
CreditCard creditcard0(string16(), 0);
- autofill_test::SetCreditCardInfo(&creditcard0,
- "", "", "", "", "", "", 0);
+ autofill_test::SetCreditCardInfo(&creditcard0, "", "", "", "", "");
// This will verify that the web database has been loaded and the notification
// sent out.