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

Unified Diff: chrome/browser/autofill/autofill_common_unittest.cc

Issue 2818033: AutoFill: Aggregate profile data. Remove the AutoFill InfoBar. (Closed)
Patch Set: Comment. Created 10 years, 6 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/autofill_common_unittest.cc
diff --git a/chrome/browser/autofill/autofill_common_unittest.cc b/chrome/browser/autofill/autofill_common_unittest.cc
index 2e2fd6139eae7aceb1a3def1822dfefe79ca80ca..b7997ccafc5f2339bc6d4e75b2b770cae9f8a41d 100644
--- a/chrome/browser/autofill/autofill_common_unittest.cc
+++ b/chrome/browser/autofill/autofill_common_unittest.cc
@@ -3,11 +3,28 @@
// found in the LICENSE file.
#include "chrome/browser/autofill/autofill_common_unittest.h"
+
#include "chrome/browser/autofill/autofill_profile.h"
#include "chrome/browser/autofill/credit_card.h"
+#include "webkit/glue/form_field.h"
namespace autofill_unittest {
+void CreateTestFormField(const char* label,
+ const char* name,
+ const char* value,
+ const char* type,
+ webkit_glue::FormField* field) {
+ *field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name),
+ ASCIIToUTF16(value), ASCIIToUTF16(type), 0);
+}
+
+inline void check_and_set(
+ FormGroup* profile, AutoFillFieldType type, const char* value) {
+ if (value)
+ profile->SetInfo(AutoFillType(type), ASCIIToUTF16(value));
+}
+
void SetProfileInfo(AutoFillProfile* profile,
const char* label, const char* first_name, const char* middle_name,
const char* last_name, const char* email, const char* company,
@@ -15,40 +32,33 @@ void SetProfileInfo(AutoFillProfile* profile,
const char* state, const char* zipcode, const char* country,
const char* phone, const char* fax) {
profile->set_label(ASCIIToUTF16(label));
- profile->SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16(first_name));
- profile->SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16(middle_name));
- profile->SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16(last_name));
- profile->SetInfo(AutoFillType(EMAIL_ADDRESS), ASCIIToUTF16(email));
- profile->SetInfo(AutoFillType(COMPANY_NAME), ASCIIToUTF16(company));
- profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1), ASCIIToUTF16(address1));
- profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE2), ASCIIToUTF16(address2));
- profile->SetInfo(AutoFillType(ADDRESS_HOME_CITY), ASCIIToUTF16(city));
- profile->SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16(state));
- profile->SetInfo(AutoFillType(ADDRESS_HOME_ZIP), ASCIIToUTF16(zipcode));
- profile->SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16(country));
- profile->SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), ASCIIToUTF16(phone));
- profile->SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), ASCIIToUTF16(fax));
+ check_and_set(profile, NAME_FIRST, first_name);
+ check_and_set(profile, NAME_MIDDLE, middle_name);
+ check_and_set(profile, NAME_LAST, last_name);
+ check_and_set(profile, EMAIL_ADDRESS, email);
+ check_and_set(profile, COMPANY_NAME, company);
+ check_and_set(profile, ADDRESS_HOME_LINE1, address1);
+ check_and_set(profile, ADDRESS_HOME_LINE2, address2);
+ check_and_set(profile, ADDRESS_HOME_CITY, city);
+ check_and_set(profile, ADDRESS_HOME_STATE, state);
+ check_and_set(profile, ADDRESS_HOME_ZIP, zipcode);
+ check_and_set(profile, ADDRESS_HOME_COUNTRY, country);
+ check_and_set(profile, PHONE_HOME_WHOLE_NUMBER, phone);
+ check_and_set(profile, PHONE_FAX_WHOLE_NUMBER, fax);
}
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, const char* verification_code,
- const char* billing_address, const char* shipping_address) {
+ const char* expiration_year, const char* billing_address) {
credit_card->set_label(ASCIIToUTF16(label));
- credit_card->SetInfo(AutoFillType(CREDIT_CARD_NAME),
- ASCIIToUTF16(name_on_card));
- credit_card->SetInfo(AutoFillType(CREDIT_CARD_TYPE), ASCIIToUTF16(type));
- credit_card->SetInfo(AutoFillType(CREDIT_CARD_NUMBER),
- ASCIIToUTF16(card_number));
- credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH),
- ASCIIToUTF16(expiration_month));
- credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR),
- ASCIIToUTF16(expiration_year));
- credit_card->SetInfo(AutoFillType(CREDIT_CARD_VERIFICATION_CODE),
- ASCIIToUTF16(verification_code));
- credit_card->set_billing_address(ASCIIToUTF16(billing_address));
- credit_card->set_shipping_address(ASCIIToUTF16(shipping_address));
+ 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);
+ if (billing_address)
+ credit_card->set_billing_address(ASCIIToUTF16(billing_address));
}
-} // namespace
+} // namespace autofill_unittest
« no previous file with comments | « chrome/browser/autofill/autofill_common_unittest.h ('k') | chrome/browser/autofill/autofill_credit_card_model_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698