| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_LIVE_SYNC_LIVE_AUTOFILL_SYNC_TEST_H_ | 5 #ifndef CHROME_TEST_LIVE_SYNC_AUTOFILL_HELPER_H_ |
| 6 #define CHROME_TEST_LIVE_SYNC_LIVE_AUTOFILL_SYNC_TEST_H_ | 6 #define CHROME_TEST_LIVE_SYNC_AUTOFILL_HELPER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "chrome/browser/autofill/personal_data_manager.h" | 13 #include "chrome/browser/autofill/personal_data_manager.h" |
| 14 #include "chrome/test/live_sync/live_sync_test.h" | 14 #include "chrome/test/live_sync/sync_datatype_helper.h" |
| 15 | 15 |
| 16 class AutofillEntry; | 16 class AutofillEntry; |
| 17 class AutofillKey; | 17 class AutofillKey; |
| 18 class AutofillProfile; | 18 class AutofillProfile; |
| 19 class WebDataService; | 19 class WebDataService; |
| 20 | 20 |
| 21 class LiveAutofillSyncTest : public LiveSyncTest { | 21 class AutofillHelper : public SyncDatatypeHelper { |
| 22 public: | 22 public: |
| 23 enum ProfileType { | 23 enum ProfileType { |
| 24 PROFILE_MARION, | 24 PROFILE_MARION, |
| 25 PROFILE_HOMER, | 25 PROFILE_HOMER, |
| 26 PROFILE_FRASIER, | 26 PROFILE_FRASIER, |
| 27 PROFILE_NULL | 27 PROFILE_NULL |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 explicit LiveAutofillSyncTest(TestType test_type); | |
| 31 virtual ~LiveAutofillSyncTest(); | |
| 32 | |
| 33 // Used to access the web data service within a particular sync profile. | 30 // Used to access the web data service within a particular sync profile. |
| 34 WebDataService* GetWebDataService(int index) WARN_UNUSED_RESULT; | 31 static WebDataService* GetWebDataService(int index) WARN_UNUSED_RESULT; |
| 35 | 32 |
| 36 // Used to access the personal data manager within a particular sync profile. | 33 // Used to access the personal data manager within a particular sync profile. |
| 37 PersonalDataManager* GetPersonalDataManager(int index) WARN_UNUSED_RESULT; | 34 static PersonalDataManager* GetPersonalDataManager( |
| 35 int index) WARN_UNUSED_RESULT; |
| 38 | 36 |
| 39 // Adds the form fields in |keys| to the WebDataService of sync profile | 37 // Adds the form fields in |keys| to the WebDataService of sync profile |
| 40 // |profile|. | 38 // |profile|. |
| 41 void AddKeys(int profile, const std::set<AutofillKey>& keys); | 39 static void AddKeys(int profile, const std::set<AutofillKey>& keys); |
| 40 |
| 42 // Removes the form field in |key| from the WebDataService of sync profile | 41 // Removes the form field in |key| from the WebDataService of sync profile |
| 43 // |profile|. | 42 // |profile|. |
| 44 void RemoveKey(int profile, const AutofillKey& key); | 43 static void RemoveKey(int profile, const AutofillKey& key); |
| 45 | 44 |
| 46 // Gets all the form fields in the WebDataService of sync profile |profile|. | 45 // Gets all the form fields in the WebDataService of sync profile |profile|. |
| 47 std::set<AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT; | 46 static std::set<AutofillEntry> GetAllKeys(int profile) WARN_UNUSED_RESULT; |
| 48 | 47 |
| 49 // Compares the form fields in the WebDataServices of sync profiles | 48 // Compares the form fields in the WebDataServices of sync profiles |
| 50 // |profile_a| and |profile_b|. Returns true if they match. | 49 // |profile_a| and |profile_b|. Returns true if they match. |
| 51 bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; | 50 static bool KeysMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; |
| 52 | 51 |
| 53 // Replaces the Autofill profiles in sync profile |profile| with | 52 // Replaces the Autofill profiles in sync profile |profile| with |
| 54 // |autofill_profiles|. | 53 // |autofill_profiles|. |
| 55 void SetProfiles( | 54 static void SetProfiles(int profile, |
| 56 int profile, std::vector<AutofillProfile>* autofill_profiles); | 55 std::vector<AutofillProfile>* autofill_profiles); |
| 57 | 56 |
| 58 // Adds the autofill profile |autofill_profile| to sync profile |profile|. | 57 // Adds the autofill profile |autofill_profile| to sync profile |profile|. |
| 59 void AddProfile(int profile, const AutofillProfile& autofill_profile); | 58 static void AddProfile(int profile, const AutofillProfile& autofill_profile); |
| 60 | 59 |
| 61 // Removes the autofill profile with guid |guid| from sync profile | 60 // Removes the autofill profile with guid |guid| from sync profile |
| 62 // |profile|. | 61 // |profile|. |
| 63 void RemoveProfile(int profile, const std::string& guid); | 62 static void RemoveProfile(int profile, const std::string& guid); |
| 64 | 63 |
| 65 // Updates the autofill profile with guid |guid| in sync profile |profile| | 64 // Updates the autofill profile with guid |guid| in sync profile |profile| |
| 66 // to |type| and |value|. | 65 // to |type| and |value|. |
| 67 void UpdateProfile(int profile, | 66 static void UpdateProfile(int profile, |
| 68 const std::string& guid, | 67 const std::string& guid, |
| 69 const AutofillType& type, | 68 const AutofillType& type, |
| 70 const string16& value); | 69 const string16& value); |
| 71 | 70 |
| 72 // Gets all the Autofill profiles in the PersonalDataManager of sync profile | 71 // Gets all the Autofill profiles in the PersonalDataManager of sync profile |
| 73 // |profile|. | 72 // |profile|. |
| 74 const std::vector<AutofillProfile*>& GetAllProfiles(int profile) | 73 static const std::vector<AutofillProfile*>& GetAllProfiles( |
| 75 WARN_UNUSED_RESULT; | 74 int profile) WARN_UNUSED_RESULT; |
| 76 | 75 |
| 77 // Returns the number of autofill profiles contained by sync profile | 76 // Returns the number of autofill profiles contained by sync profile |
| 78 // |profile|. | 77 // |profile|. |
| 79 int GetProfileCount(int profile); | 78 static int GetProfileCount(int profile); |
| 80 | 79 |
| 81 // Compares the Autofill profiles in the PersonalDataManagers of sync profiles | 80 // Compares the Autofill profiles in the PersonalDataManagers of sync profiles |
| 82 // |profile_a| and |profile_b|. Returns true if they match. | 81 // |profile_a| and |profile_b|. Returns true if they match. |
| 83 bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; | 82 static bool ProfilesMatch(int profile_a, int profile_b) WARN_UNUSED_RESULT; |
| 84 | 83 |
| 85 // Compares the autofill profiles for all sync profiles, and returns true if | 84 // Compares the autofill profiles for all sync profiles, and returns true if |
| 86 // they all match. | 85 // they all match. |
| 87 bool AllProfilesMatch() WARN_UNUSED_RESULT; | 86 static bool AllProfilesMatch() WARN_UNUSED_RESULT; |
| 87 |
| 88 // Creates a test autofill profile based on the persona specified in |type|. |
| 89 static AutofillProfile CreateAutofillProfile(ProfileType type); |
| 90 protected: |
| 91 AutofillHelper(); |
| 92 virtual ~AutofillHelper(); |
| 88 | 93 |
| 89 private: | 94 private: |
| 90 DISALLOW_COPY_AND_ASSIGN(LiveAutofillSyncTest); | 95 DISALLOW_COPY_AND_ASSIGN(AutofillHelper); |
| 91 }; | 96 }; |
| 92 | 97 |
| 93 AutofillProfile CreateAutofillProfile(LiveAutofillSyncTest::ProfileType type); | 98 #endif // CHROME_TEST_LIVE_SYNC_AUTOFILL_HELPER_H_ |
| 94 | |
| 95 class TwoClientLiveAutofillSyncTest : public LiveAutofillSyncTest { | |
| 96 public: | |
| 97 TwoClientLiveAutofillSyncTest() : LiveAutofillSyncTest(TWO_CLIENT) {} | |
| 98 virtual ~TwoClientLiveAutofillSyncTest() {} | |
| 99 | |
| 100 private: | |
| 101 DISALLOW_COPY_AND_ASSIGN(TwoClientLiveAutofillSyncTest); | |
| 102 }; | |
| 103 | |
| 104 #endif // CHROME_TEST_LIVE_SYNC_LIVE_AUTOFILL_SYNC_TEST_H_ | |
| OLD | NEW |