Rename GetIconID to GetIconId
[chromium-blink-merge.git] / components / autofill / core / browser / autofill_test_utils.h
blobe82f8930fed5cc35397c15f8ade4784c95aa4967
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 <vector>
10 #include "base/memory/scoped_ptr.h"
11 #include "components/autofill/core/browser/field_types.h"
13 class PrefService;
15 namespace autofill {
17 class AutofillProfile;
18 class AutofillTable;
19 class CreditCard;
20 struct FormData;
21 struct FormFieldData;
23 // Common utilities shared amongst Autofill tests.
24 namespace test {
26 // Returns a PrefService that can be used for Autofill-related testing in
27 // contexts where the PrefService would otherwise have to be constructed
28 // manually (e.g., in unit tests within Autofill core code). The returned
29 // PrefService has had Autofill preferences registered on its associated
30 // registry.
31 scoped_ptr<PrefService> PrefServiceForTesting();
33 // Provides a quick way to populate a FormField with c-strings.
34 void CreateTestFormField(const char* label,
35 const char* name,
36 const char* value,
37 const char* type,
38 FormFieldData* field);
40 // Populates |form| with data corresponding to a simple address form.
41 // Note that this actually appends fields to the form data, which can be useful
42 // for building up more complex test forms. Another version of the function is
43 // provided in case the caller wants the vector of expected field |types|.
44 void CreateTestAddressFormData(FormData* form);
45 void CreateTestAddressFormData(FormData* form,
46 std::vector<ServerFieldTypeSet>* types);
48 // Returns a profile full of dummy info.
49 AutofillProfile GetFullProfile();
51 // Returns a profile full of dummy info, different to the above.
52 AutofillProfile GetFullProfile2();
54 // Returns a verified profile full of dummy info.
55 AutofillProfile GetVerifiedProfile();
57 // Returns a verified profile full of dummy info, different to the above.
58 AutofillProfile GetVerifiedProfile2();
60 // Returns a credit card full of dummy info.
61 CreditCard GetCreditCard();
63 // Returns a credit card full of dummy info, different to the above.
64 CreditCard GetCreditCard2();
66 // Returns a verified credit card full of dummy info.
67 CreditCard GetVerifiedCreditCard();
69 // Returns a verified credit card full of dummy info, different to the above.
70 CreditCard GetVerifiedCreditCard2();
72 // Returns a masked server card full of dummy info.
73 CreditCard GetMaskedServerCard();
74 CreditCard GetMaskedServerCardAmex();
76 // A unit testing utility that is common to a number of the Autofill unit
77 // tests. |SetProfileInfo| provides a quick way to populate a profile with
78 // c-strings.
79 void SetProfileInfo(AutofillProfile* profile,
80 const char* first_name, const char* middle_name,
81 const char* last_name, const char* email, const char* company,
82 const char* address1, const char* address2, const char* city,
83 const char* state, const char* zipcode, const char* country,
84 const char* phone);
86 void SetProfileInfoWithGuid(AutofillProfile* profile,
87 const char* guid, const char* first_name, const char* middle_name,
88 const char* last_name, const char* email, const char* company,
89 const char* address1, const char* address2, const char* city,
90 const char* state, const char* zipcode, const char* country,
91 const char* phone);
93 // A unit testing utility that is common to a number of the Autofill unit
94 // tests. |SetCreditCardInfo| provides a quick way to populate a credit card
95 // with c-strings.
96 void SetCreditCardInfo(CreditCard* credit_card,
97 const char* name_on_card, const char* card_number,
98 const char* expiration_month, const char* expiration_year);
100 // TODO(isherman): We should do this automatically for all tests, not manually
101 // on a per-test basis: http://crbug.com/57221
102 // Disables or mocks out code that would otherwise reach out to system services.
103 void DisableSystemServices(PrefService* prefs);
105 // Sets |cards| for |table|. |cards| may contain full, unmasked server cards,
106 // whereas AutofillTable::SetServerCreditCards can only contain masked cards.
107 void SetServerCreditCards(AutofillTable* table,
108 const std::vector<CreditCard>& cards);
110 } // namespace test
111 } // namespace autofill
113 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_TEST_UTILS_H_