- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / test / integration / autofill_helper.h
1 // Copyright (c) 2012 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 CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_
7
8 #include <set>
9 #include <string>
10 #include <vector>
11
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/strings/string16.h"
15 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
16
17 namespace autofill {
18 class AutofillEntry;
19 class AutofillKey;
20 class AutofillProfile;
21 class AutofillType;
22 class AutofillWebDataService;
23 class CreditCard;
24 class PersonalDataManager;
25 }  // namespace autofill
26
27 namespace autofill_helper {
28
29 enum ProfileType {
30   PROFILE_MARION,
31   PROFILE_HOMER,
32   PROFILE_FRASIER,
33   PROFILE_NULL
34 };
35
36 // Used to access the web data service within a particular sync profile.
37 scoped_refptr<autofill::AutofillWebDataService> GetWebDataService(
38     int index) WARN_UNUSED_RESULT;
39
40 // Used to access the personal data manager within a particular sync profile.
41 autofill::PersonalDataManager* GetPersonalDataManager(
42     int index) WARN_UNUSED_RESULT;
43
44 // Adds the form fields in |keys| to the WebDataService of sync profile
45 // |profile|.
46 void AddKeys(int profile, const std::set<autofill::AutofillKey>& keys);
47
48 // Removes the form field in |key| from the WebDataService of sync profile
49 // |profile|.
50 void RemoveKey(int profile, const autofill::AutofillKey& key);
51
52 // Removes all of the keys from the WebDataService of sync profile |profile|.
53 void RemoveKeys(int profile);
54
55 // Gets all the form fields in the WebDataService of sync profile |profile|.
56 std::set<autofill::AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT;
57
58 // Compares the form fields in the WebDataServices of sync profiles
59 // |profile_a| and |profile_b|. Returns true if they match.
60 bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
61
62 // Replaces the Autofill profiles in sync profile |profile| with
63 // |autofill_profiles|.
64 void SetProfiles(int profile,
65                  std::vector<autofill::AutofillProfile>* autofill_profiles);
66
67 // Replaces the CreditCard profiles in sync profile |profile| with
68 // |credit_cards|.
69 void SetCreditCards(int profile,
70                     std::vector<autofill::CreditCard>* credit_cards);
71
72 // Adds the autofill profile |autofill_profile| to sync profile |profile|.
73 void AddProfile(int profile, const autofill::AutofillProfile& autofill_profile);
74
75 // Removes the autofill profile with guid |guid| from sync profile
76 // |profile|.
77 void RemoveProfile(int profile, const std::string& guid);
78
79 // Updates the autofill profile with guid |guid| in sync profile |profile|
80 // to |type| and |value|.
81 void UpdateProfile(int profile,
82                    const std::string& guid,
83                    const autofill::AutofillType& type,
84                    const string16& value);
85
86 // Gets all the Autofill profiles in the PersonalDataManager of sync profile
87 // |profile|.
88 const std::vector<autofill::AutofillProfile*>& GetAllProfiles(
89     int profile) WARN_UNUSED_RESULT;
90
91 // Returns the number of autofill profiles contained by sync profile
92 // |profile|.
93 int GetProfileCount(int profile);
94
95 // Returns the number of autofill keys contained by sync profile |profile|.
96 int GetKeyCount(int profile);
97
98 // Compares the Autofill profiles in the PersonalDataManagers of sync profiles
99 // |profile_a| and |profile_b|. Returns true if they match.
100 bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT;
101
102 // Compares the autofill profiles for all sync profiles, and returns true if
103 // they all match.
104 bool AllProfilesMatch() WARN_UNUSED_RESULT;
105
106 // Creates a test autofill profile based on the persona specified in |type|.
107 autofill::AutofillProfile CreateAutofillProfile(ProfileType type);
108
109 }  // namespace autofill_helper
110
111 #endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_