Chromium Code Reviews

Side by Side 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, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autofill/autofill_common_unittest.h" 5 #include "chrome/browser/autofill/autofill_common_unittest.h"
6
6 #include "chrome/browser/autofill/autofill_profile.h" 7 #include "chrome/browser/autofill/autofill_profile.h"
7 #include "chrome/browser/autofill/credit_card.h" 8 #include "chrome/browser/autofill/credit_card.h"
9 #include "webkit/glue/form_field.h"
8 10
9 namespace autofill_unittest { 11 namespace autofill_unittest {
10 12
13 void CreateTestFormField(const char* label,
14 const char* name,
15 const char* value,
16 const char* type,
17 webkit_glue::FormField* field) {
18 *field = webkit_glue::FormField(ASCIIToUTF16(label), ASCIIToUTF16(name),
19 ASCIIToUTF16(value), ASCIIToUTF16(type), 0);
20 }
21
22 inline void check_and_set(
23 FormGroup* profile, AutoFillFieldType type, const char* value) {
24 if (value)
25 profile->SetInfo(AutoFillType(type), ASCIIToUTF16(value));
26 }
27
11 void SetProfileInfo(AutoFillProfile* profile, 28 void SetProfileInfo(AutoFillProfile* profile,
12 const char* label, const char* first_name, const char* middle_name, 29 const char* label, const char* first_name, const char* middle_name,
13 const char* last_name, const char* email, const char* company, 30 const char* last_name, const char* email, const char* company,
14 const char* address1, const char* address2, const char* city, 31 const char* address1, const char* address2, const char* city,
15 const char* state, const char* zipcode, const char* country, 32 const char* state, const char* zipcode, const char* country,
16 const char* phone, const char* fax) { 33 const char* phone, const char* fax) {
17 profile->set_label(ASCIIToUTF16(label)); 34 profile->set_label(ASCIIToUTF16(label));
18 profile->SetInfo(AutoFillType(NAME_FIRST), ASCIIToUTF16(first_name)); 35 check_and_set(profile, NAME_FIRST, first_name);
19 profile->SetInfo(AutoFillType(NAME_MIDDLE), ASCIIToUTF16(middle_name)); 36 check_and_set(profile, NAME_MIDDLE, middle_name);
20 profile->SetInfo(AutoFillType(NAME_LAST), ASCIIToUTF16(last_name)); 37 check_and_set(profile, NAME_LAST, last_name);
21 profile->SetInfo(AutoFillType(EMAIL_ADDRESS), ASCIIToUTF16(email)); 38 check_and_set(profile, EMAIL_ADDRESS, email);
22 profile->SetInfo(AutoFillType(COMPANY_NAME), ASCIIToUTF16(company)); 39 check_and_set(profile, COMPANY_NAME, company);
23 profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1), ASCIIToUTF16(address1)); 40 check_and_set(profile, ADDRESS_HOME_LINE1, address1);
24 profile->SetInfo(AutoFillType(ADDRESS_HOME_LINE2), ASCIIToUTF16(address2)); 41 check_and_set(profile, ADDRESS_HOME_LINE2, address2);
25 profile->SetInfo(AutoFillType(ADDRESS_HOME_CITY), ASCIIToUTF16(city)); 42 check_and_set(profile, ADDRESS_HOME_CITY, city);
26 profile->SetInfo(AutoFillType(ADDRESS_HOME_STATE), ASCIIToUTF16(state)); 43 check_and_set(profile, ADDRESS_HOME_STATE, state);
27 profile->SetInfo(AutoFillType(ADDRESS_HOME_ZIP), ASCIIToUTF16(zipcode)); 44 check_and_set(profile, ADDRESS_HOME_ZIP, zipcode);
28 profile->SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16(country)); 45 check_and_set(profile, ADDRESS_HOME_COUNTRY, country);
29 profile->SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), ASCIIToUTF16(phone)); 46 check_and_set(profile, PHONE_HOME_WHOLE_NUMBER, phone);
30 profile->SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), ASCIIToUTF16(fax)); 47 check_and_set(profile, PHONE_FAX_WHOLE_NUMBER, fax);
31 } 48 }
32 49
33 void SetCreditCardInfo(CreditCard* credit_card, 50 void SetCreditCardInfo(CreditCard* credit_card,
34 const char* label, const char* name_on_card, const char* type, 51 const char* label, const char* name_on_card, const char* type,
35 const char* card_number, const char* expiration_month, 52 const char* card_number, const char* expiration_month,
36 const char* expiration_year, const char* verification_code, 53 const char* expiration_year, const char* billing_address) {
37 const char* billing_address, const char* shipping_address) {
38 credit_card->set_label(ASCIIToUTF16(label)); 54 credit_card->set_label(ASCIIToUTF16(label));
39 credit_card->SetInfo(AutoFillType(CREDIT_CARD_NAME), 55 check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card);
40 ASCIIToUTF16(name_on_card)); 56 check_and_set(credit_card, CREDIT_CARD_TYPE, type);
41 credit_card->SetInfo(AutoFillType(CREDIT_CARD_TYPE), ASCIIToUTF16(type)); 57 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number);
42 credit_card->SetInfo(AutoFillType(CREDIT_CARD_NUMBER), 58 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month);
43 ASCIIToUTF16(card_number)); 59 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year);
44 credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), 60 if (billing_address)
45 ASCIIToUTF16(expiration_month)); 61 credit_card->set_billing_address(ASCIIToUTF16(billing_address));
46 credit_card->SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR),
47 ASCIIToUTF16(expiration_year));
48 credit_card->SetInfo(AutoFillType(CREDIT_CARD_VERIFICATION_CODE),
49 ASCIIToUTF16(verification_code));
50 credit_card->set_billing_address(ASCIIToUTF16(billing_address));
51 credit_card->set_shipping_address(ASCIIToUTF16(shipping_address));
52 } 62 }
53 63
54 } // namespace 64 } // namespace autofill_unittest
OLDNEW
« 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