OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ |
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ | 6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "chrome/browser/sync/test/integration/multi_client_status_change_checke
r.h" |
15 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 16 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 17 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
16 | 18 |
17 namespace autofill { | 19 namespace autofill { |
18 class AutofillEntry; | 20 class AutofillEntry; |
19 class AutofillKey; | 21 class AutofillKey; |
20 class AutofillProfile; | 22 class AutofillProfile; |
21 class AutofillType; | 23 class AutofillType; |
22 class AutofillWebDataService; | 24 class AutofillWebDataService; |
23 class CreditCard; | 25 class CreditCard; |
24 class PersonalDataManager; | 26 class PersonalDataManager; |
25 } // namespace autofill | 27 } // namespace autofill |
(...skipping 26 matching lines...) Expand all Loading... |
52 // Removes all of the keys from the WebDataService of sync profile |profile|. | 54 // Removes all of the keys from the WebDataService of sync profile |profile|. |
53 void RemoveKeys(int profile); | 55 void RemoveKeys(int profile); |
54 | 56 |
55 // Gets all the form fields in the WebDataService of sync profile |profile|. | 57 // Gets all the form fields in the WebDataService of sync profile |profile|. |
56 std::set<autofill::AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT; | 58 std::set<autofill::AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT; |
57 | 59 |
58 // Compares the form fields in the WebDataServices of sync profiles | 60 // Compares the form fields in the WebDataServices of sync profiles |
59 // |profile_a| and |profile_b|. Returns true if they match. | 61 // |profile_a| and |profile_b|. Returns true if they match. |
60 bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; | 62 bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; |
61 | 63 |
62 // Allows syncers to run until KeysMatch() returns true. | |
63 bool AwaitKeysMatch(int profile_a, int profile_b); | |
64 | |
65 // Replaces the Autofill profiles in sync profile |profile| with | 64 // Replaces the Autofill profiles in sync profile |profile| with |
66 // |autofill_profiles|. | 65 // |autofill_profiles|. |
67 void SetProfiles(int profile, | 66 void SetProfiles(int profile, |
68 std::vector<autofill::AutofillProfile>* autofill_profiles); | 67 std::vector<autofill::AutofillProfile>* autofill_profiles); |
69 | 68 |
70 // Replaces the CreditCard profiles in sync profile |profile| with | 69 // Replaces the CreditCard profiles in sync profile |profile| with |
71 // |credit_cards|. | 70 // |credit_cards|. |
72 void SetCreditCards(int profile, | 71 void SetCreditCards(int profile, |
73 std::vector<autofill::CreditCard>* credit_cards); | 72 std::vector<autofill::CreditCard>* credit_cards); |
74 | 73 |
(...skipping 24 matching lines...) Expand all Loading... |
99 int GetKeyCount(int profile); | 98 int GetKeyCount(int profile); |
100 | 99 |
101 // Compares the Autofill profiles in the PersonalDataManagers of sync profiles | 100 // Compares the Autofill profiles in the PersonalDataManagers of sync profiles |
102 // |profile_a| and |profile_b|. Returns true if they match. | 101 // |profile_a| and |profile_b|. Returns true if they match. |
103 bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; | 102 bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; |
104 | 103 |
105 // Compares the autofill profiles for all sync profiles, and returns true if | 104 // Compares the autofill profiles for all sync profiles, and returns true if |
106 // they all match. | 105 // they all match. |
107 bool AllProfilesMatch() WARN_UNUSED_RESULT; | 106 bool AllProfilesMatch() WARN_UNUSED_RESULT; |
108 | 107 |
109 // Allows the syncers to run until ProfilesMatch() returns true. | |
110 bool AwaitProfilesMatch(int profile_a, int profile_b); | |
111 | |
112 // Creates a test autofill profile based on the persona specified in |type|. | 108 // Creates a test autofill profile based on the persona specified in |type|. |
113 autofill::AutofillProfile CreateAutofillProfile(ProfileType type); | 109 autofill::AutofillProfile CreateAutofillProfile(ProfileType type); |
114 | 110 |
115 // Creates a test autofill profile with a unique GUID | 111 // Creates a test autofill profile with a unique GUID |
116 autofill::AutofillProfile CreateUniqueAutofillProfile(); | 112 autofill::AutofillProfile CreateUniqueAutofillProfile(); |
117 | 113 |
118 } // namespace autofill_helper | 114 } // namespace autofill_helper |
119 | 115 |
| 116 // Checker to block until autofill keys match on both profiles. |
| 117 class AutofillKeysChecker : public MultiClientStatusChangeChecker { |
| 118 public: |
| 119 AutofillKeysChecker(int profile_a, int profile_b); |
| 120 |
| 121 // StatusChangeChecker implementation. |
| 122 bool IsExitConditionSatisfied() override; |
| 123 std::string GetDebugMessage() const override; |
| 124 |
| 125 private: |
| 126 const int profile_a_; |
| 127 const int profile_b_; |
| 128 }; |
| 129 |
| 130 // Checker to block until autofill profiles match on both profiles. |
| 131 class AutofillProfileChecker : public StatusChangeChecker, |
| 132 public autofill::PersonalDataManagerObserver { |
| 133 public: |
| 134 AutofillProfileChecker(int profile_a, int profile_b); |
| 135 ~AutofillProfileChecker() override; |
| 136 |
| 137 // StatusChangeChecker implementation. |
| 138 bool Wait() override; |
| 139 bool IsExitConditionSatisfied() override; |
| 140 std::string GetDebugMessage() const override; |
| 141 |
| 142 // autofill::PersonalDataManager implementation. |
| 143 void OnPersonalDataChanged() override; |
| 144 |
| 145 private: |
| 146 const int profile_a_; |
| 147 const int profile_b_; |
| 148 }; |
| 149 |
120 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ | 150 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_AUTOFILL_HELPER_H_ |
OLD | NEW |