| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_test.h" | 5 #include "chrome/browser/autofill/autofill_common_test.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/autofill_profile.h" | 8 #include "chrome/browser/autofill/autofill_profile.h" |
| 9 #include "chrome/browser/autofill/credit_card.h" | 9 #include "chrome/browser/autofill/credit_card.h" |
| 10 #include "chrome/browser/password_manager/encryptor.h" | 10 #include "chrome/browser/password_manager/encryptor.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 FormGroup* profile, AutofillFieldType type, const char* value) { | 30 FormGroup* profile, AutofillFieldType type, const char* value) { |
| 31 if (value) | 31 if (value) |
| 32 profile->SetInfo(type, UTF8ToUTF16(value)); | 32 profile->SetInfo(type, UTF8ToUTF16(value)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void SetProfileInfo(AutofillProfile* profile, | 35 void SetProfileInfo(AutofillProfile* profile, |
| 36 const char* first_name, const char* middle_name, | 36 const char* first_name, const char* middle_name, |
| 37 const char* last_name, const char* email, const char* company, | 37 const char* last_name, const char* email, const char* company, |
| 38 const char* address1, const char* address2, const char* city, | 38 const char* address1, const char* address2, const char* city, |
| 39 const char* state, const char* zipcode, const char* country, | 39 const char* state, const char* zipcode, const char* country, |
| 40 const char* phone, const char* fax) { | 40 const char* phone) { |
| 41 check_and_set(profile, NAME_FIRST, first_name); | 41 check_and_set(profile, NAME_FIRST, first_name); |
| 42 check_and_set(profile, NAME_MIDDLE, middle_name); | 42 check_and_set(profile, NAME_MIDDLE, middle_name); |
| 43 check_and_set(profile, NAME_LAST, last_name); | 43 check_and_set(profile, NAME_LAST, last_name); |
| 44 check_and_set(profile, EMAIL_ADDRESS, email); | 44 check_and_set(profile, EMAIL_ADDRESS, email); |
| 45 check_and_set(profile, COMPANY_NAME, company); | 45 check_and_set(profile, COMPANY_NAME, company); |
| 46 check_and_set(profile, ADDRESS_HOME_LINE1, address1); | 46 check_and_set(profile, ADDRESS_HOME_LINE1, address1); |
| 47 check_and_set(profile, ADDRESS_HOME_LINE2, address2); | 47 check_and_set(profile, ADDRESS_HOME_LINE2, address2); |
| 48 check_and_set(profile, ADDRESS_HOME_CITY, city); | 48 check_and_set(profile, ADDRESS_HOME_CITY, city); |
| 49 check_and_set(profile, ADDRESS_HOME_STATE, state); | 49 check_and_set(profile, ADDRESS_HOME_STATE, state); |
| 50 check_and_set(profile, ADDRESS_HOME_ZIP, zipcode); | 50 check_and_set(profile, ADDRESS_HOME_ZIP, zipcode); |
| 51 check_and_set(profile, ADDRESS_HOME_COUNTRY, country); | 51 check_and_set(profile, ADDRESS_HOME_COUNTRY, country); |
| 52 check_and_set(profile, PHONE_HOME_WHOLE_NUMBER, phone); | 52 check_and_set(profile, PHONE_HOME_WHOLE_NUMBER, phone); |
| 53 check_and_set(profile, PHONE_FAX_WHOLE_NUMBER, fax); | |
| 54 } | 53 } |
| 55 | 54 |
| 56 void SetProfileInfoWithGuid(AutofillProfile* profile, | 55 void SetProfileInfoWithGuid(AutofillProfile* profile, |
| 57 const char* guid, const char* first_name, const char* middle_name, | 56 const char* guid, const char* first_name, const char* middle_name, |
| 58 const char* last_name, const char* email, const char* company, | 57 const char* last_name, const char* email, const char* company, |
| 59 const char* address1, const char* address2, const char* city, | 58 const char* address1, const char* address2, const char* city, |
| 60 const char* state, const char* zipcode, const char* country, | 59 const char* state, const char* zipcode, const char* country, |
| 61 const char* phone, const char* fax) { | 60 const char* phone) { |
| 62 if (guid) | 61 if (guid) |
| 63 profile->set_guid(guid); | 62 profile->set_guid(guid); |
| 64 SetProfileInfo(profile, first_name, middle_name, last_name, email, | 63 SetProfileInfo(profile, first_name, middle_name, last_name, email, |
| 65 company, address1, address2, city, state, zipcode, country, | 64 company, address1, address2, city, state, zipcode, country, |
| 66 phone, fax); | 65 phone); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void SetCreditCardInfo(CreditCard* credit_card, | 68 void SetCreditCardInfo(CreditCard* credit_card, |
| 70 const char* name_on_card, const char* card_number, | 69 const char* name_on_card, const char* card_number, |
| 71 const char* expiration_month, const char* expiration_year) { | 70 const char* expiration_month, const char* expiration_year) { |
| 72 check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card); | 71 check_and_set(credit_card, CREDIT_CARD_NAME, name_on_card); |
| 73 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); | 72 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); |
| 74 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); | 73 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); |
| 75 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); | 74 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void DisableSystemServices(Profile* profile) { | 77 void DisableSystemServices(Profile* profile) { |
| 79 // Use a mock Keychain rather than the OS one to store credit card data. | 78 // Use a mock Keychain rather than the OS one to store credit card data. |
| 80 #if defined(OS_MACOSX) | 79 #if defined(OS_MACOSX) |
| 81 Encryptor::UseMockKeychain(true); | 80 Encryptor::UseMockKeychain(true); |
| 82 #endif | 81 #endif |
| 83 | 82 |
| 84 // Disable auxiliary profiles for unit testing. These reach out to system | 83 // Disable auxiliary profiles for unit testing. These reach out to system |
| 85 // services on the Mac. | 84 // services on the Mac. |
| 86 if (profile) { | 85 if (profile) { |
| 87 profile->GetPrefs()->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, | 86 profile->GetPrefs()->SetBoolean(prefs::kAutofillAuxiliaryProfilesEnabled, |
| 88 false); | 87 false); |
| 89 } | 88 } |
| 90 } | 89 } |
| 91 | 90 |
| 92 } // namespace autofill_test | 91 } // namespace autofill_test |
| OLD | NEW |