1 // Copyright 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_ 7 8 namespace content { 9 class BrowserContext; 10 } 11 12 namespace autofill { 13 14 class AutofillProfile; 15 class CreditCard; 16 struct FormData; 17 struct FormFieldData; 18 19 // Common utilities shared amongst Autofill tests. 20 namespace test { 21 22 // Provides a quick way to populate a FormField with c-strings. 23 void CreateTestFormField(const char* label, 24 const char* name, 25 const char* value, 26 const char* type, 27 FormFieldData* field); 28 29 // Populates |form| with data corresponding to a simple address form. 30 // Note that this actually appends fields to the form data, which can be useful 31 // for building up more complex test forms. 32 void CreateTestAddressFormData(FormData* form); 33 34 // Returns a profile full of dummy info. 35 AutofillProfile GetFullProfile(); 36 37 // Returns a profile full of dummy info, different to the above. 38 AutofillProfile GetFullProfile2(); 39 40 // Returns a verified profile full of dummy info. 41 AutofillProfile GetVerifiedProfile(); 42 43 // Returns a verified profile full of dummy info, different to the above. 44 AutofillProfile GetVerifiedProfile2(); 45 46 // Returns a credit card full of dummy info. 47 CreditCard GetCreditCard(); 48 49 // Returns a verified credit card full of dummy info. 50 CreditCard GetVerifiedCreditCard(); 51 52 // A unit testing utility that is common to a number of the Autofill unit 53 // tests. |SetProfileInfo| provides a quick way to populate a profile with 54 // c-strings. 55 void SetProfileInfo(AutofillProfile* profile, 56 const char* first_name, const char* middle_name, 57 const char* last_name, const char* email, const char* company, 58 const char* address1, const char* address2, const char* city, 59 const char* state, const char* zipcode, const char* country, 60 const char* phone); 61 62 void SetProfileInfoWithGuid(AutofillProfile* profile, 63 const char* guid, const char* first_name, const char* middle_name, 64 const char* last_name, const char* email, const char* company, 65 const char* address1, const char* address2, const char* city, 66 const char* state, const char* zipcode, const char* country, 67 const char* phone); 68 69 // A unit testing utility that is common to a number of the Autofill unit 70 // tests. |SetCreditCardInfo| provides a quick way to populate a credit card 71 // with c-strings. 72 void SetCreditCardInfo(CreditCard* credit_card, 73 const char* name_on_card, const char* card_number, 74 const char* expiration_month, const char* expiration_year); 75 76 // TODO(isherman): We should do this automatically for all tests, not manually 77 // on a per-test basis: http://crbug.com/57221 78 // Disables or mocks out code that would otherwise reach out to system services. 79 void DisableSystemServices(content::BrowserContext* browser_context); 80 81 } // namespace test 82 } // namespace autofill 83 84 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_COMMON_TEST_H_ 85