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.
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_
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"
20 class AutofillProfile
;
22 class AutofillWebDataService
;
24 class PersonalDataManager
;
25 } // namespace autofill
27 namespace autofill_helper
{
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
;
40 // Used to access the personal data manager within a particular sync profile.
41 autofill::PersonalDataManager
* GetPersonalDataManager(
42 int index
) WARN_UNUSED_RESULT
;
44 // Adds the form fields in |keys| to the WebDataService of sync profile
46 void AddKeys(int profile
, const std::set
<autofill::AutofillKey
>& keys
);
48 // Removes the form field in |key| from the WebDataService of sync profile
50 void RemoveKey(int profile
, const autofill::AutofillKey
& key
);
52 // Removes all of the keys from the WebDataService of sync profile |profile|.
53 void RemoveKeys(int profile
);
55 // Gets all the form fields in the WebDataService of sync profile |profile|.
56 std::set
<autofill::AutofillEntry
> GetAllKeys(int profile
) WARN_UNUSED_RESULT
;
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
;
62 // Allows syncers to run until KeysMatch() returns true.
63 bool AwaitKeysMatch(int profile_a
, int profile_b
);
65 // Replaces the Autofill profiles in sync profile |profile| with
66 // |autofill_profiles|.
67 void SetProfiles(int profile
,
68 std::vector
<autofill::AutofillProfile
>* autofill_profiles
);
70 // Replaces the CreditCard profiles in sync profile |profile| with
72 void SetCreditCards(int profile
,
73 std::vector
<autofill::CreditCard
>* credit_cards
);
75 // Adds the autofill profile |autofill_profile| to sync profile |profile|.
76 void AddProfile(int profile
, const autofill::AutofillProfile
& autofill_profile
);
78 // Removes the autofill profile with guid |guid| from sync profile
80 void RemoveProfile(int profile
, const std::string
& guid
);
82 // Updates the autofill profile with guid |guid| in sync profile |profile|
83 // to |type| and |value|.
84 void UpdateProfile(int profile
,
85 const std::string
& guid
,
86 const autofill::AutofillType
& type
,
87 const base::string16
& value
);
89 // Gets all the Autofill profiles in the PersonalDataManager of sync profile
91 const std::vector
<autofill::AutofillProfile
*>& GetAllProfiles(
92 int profile
) WARN_UNUSED_RESULT
;
94 // Returns the number of autofill profiles contained by sync profile
96 int GetProfileCount(int profile
);
98 // Returns the number of autofill keys contained by sync profile |profile|.
99 int GetKeyCount(int profile
);
101 // Compares the Autofill profiles in the PersonalDataManagers of sync profiles
102 // |profile_a| and |profile_b|. Returns true if they match.
103 bool ProfilesMatch(int profile_a
, int profile_b
) WARN_UNUSED_RESULT
;
105 // Compares the autofill profiles for all sync profiles, and returns true if
107 bool AllProfilesMatch() WARN_UNUSED_RESULT
;
109 // Allows the syncers to run until ProfilesMatch() returns true.
110 bool AwaitProfilesMatch(int profile_a
, int profile_b
);
112 // Creates a test autofill profile based on the persona specified in |type|.
113 autofill::AutofillProfile
CreateAutofillProfile(ProfileType type
);
115 // Creates a test autofill profile with a unique GUID
116 autofill::AutofillProfile
CreateUniqueAutofillProfile();
118 } // namespace autofill_helper
120 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_