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