Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_test_utils.h
blobfd550a44c6f814b86e00c96182f062bd7363e6b7
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.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TEST_UTILS_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TEST_UTILS_H_
8 #include "base/memory/scoped_ptr.h"
10 class PrefService;
12 namespace autofill {
14 class AutofillProfile;
15 class CreditCard;
16 struct FormData;
17 struct FormFieldData;
19 // Common utilities shared amongst Autofill tests.
20 namespace test {
22 // Returns a PrefService that can be used for Autofill-related testing in
23 // contexts where the PrefService would otherwise have to be constructed
24 // manually (e.g., in unit tests within Autofill core code). The returned
25 // PrefService has had Autofill preferences registered on its associated
26 // registry.
27 scoped_ptr<PrefService> PrefServiceForTesting();
29 // Provides a quick way to populate a FormField with c-strings.
30 void CreateTestFormField(const char* label,
31 const char* name,
32 const char* value,
33 const char* type,
34 FormFieldData* field);
36 // Populates |form| with data corresponding to a simple address form.
37 // Note that this actually appends fields to the form data, which can be useful
38 // for building up more complex test forms.
39 void CreateTestAddressFormData(FormData* form);
41 // Returns a profile full of dummy info.
42 AutofillProfile GetFullProfile();
44 // Returns a profile full of dummy info, different to the above.
45 AutofillProfile GetFullProfile2();
47 // Returns a verified profile full of dummy info.
48 AutofillProfile GetVerifiedProfile();
50 // Returns a verified profile full of dummy info, different to the above.
51 AutofillProfile GetVerifiedProfile2();
53 // Returns a credit card full of dummy info.
54 CreditCard GetCreditCard();
56 // Returns a credit card full of dummy info, different to the above.
57 CreditCard GetCreditCard2();
59 // Returns a verified credit card full of dummy info.
60 CreditCard GetVerifiedCreditCard();
62 // Returns a verified credit card full of dummy info, different to the above.
63 CreditCard GetVerifiedCreditCard2();
65 // A unit testing utility that is common to a number of the Autofill unit
66 // tests. |SetProfileInfo| provides a quick way to populate a profile with
67 // c-strings.
68 void SetProfileInfo(AutofillProfile* profile,
69 const char* first_name, const char* middle_name,
70 const char* last_name, const char* email, const char* company,
71 const char* address1, const char* address2, const char* city,
72 const char* state, const char* zipcode, const char* country,
73 const char* phone);
75 void SetProfileInfoWithGuid(AutofillProfile* profile,
76 const char* guid, const char* first_name, const char* middle_name,
77 const char* last_name, const char* email, const char* company,
78 const char* address1, const char* address2, const char* city,
79 const char* state, const char* zipcode, const char* country,
80 const char* phone);
82 // A unit testing utility that is common to a number of the Autofill unit
83 // tests. |SetCreditCardInfo| provides a quick way to populate a credit card
84 // with c-strings.
85 void SetCreditCardInfo(CreditCard* credit_card,
86 const char* name_on_card, const char* card_number,
87 const char* expiration_month, const char* expiration_year);
89 // TODO(isherman): We should do this automatically for all tests, not manually
90 // on a per-test basis: http://crbug.com/57221
91 // Disables or mocks out code that would otherwise reach out to system services.
92 void DisableSystemServices(PrefService* prefs);
94 } // namespace test
95 } // namespace autofill
97 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TEST_UTILS_H_