| 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 #include "chrome/test/live_sync/autofill_helper.h" | 5 #include "chrome/test/live_sync/autofill_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autofill/autofill_common_test.h" | 7 #include "chrome/browser/autofill/autofill_common_test.h" |
| 8 #include "chrome/browser/autofill/autofill_profile.h" | 8 #include "chrome/browser/autofill/autofill_profile.h" |
| 9 #include "chrome/browser/autofill/autofill_type.h" | 9 #include "chrome/browser/autofill/autofill_type.h" |
| 10 #include "chrome/browser/autofill/personal_data_manager.h" | 10 #include "chrome/browser/autofill/personal_data_manager.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 } | 123 } |
| 124 | 124 |
| 125 WebDataService* GetWebDataService(int index) { | 125 WebDataService* GetWebDataService(int index) { |
| 126 return test()->GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS); | 126 return test()->GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS); |
| 127 } | 127 } |
| 128 | 128 |
| 129 PersonalDataManager* GetPersonalDataManager(int index) { | 129 PersonalDataManager* GetPersonalDataManager(int index) { |
| 130 return test()->GetProfile(index)->GetPersonalDataManager(); | 130 return test()->GetProfile(index)->GetPersonalDataManager(); |
| 131 } | 131 } |
| 132 | 132 |
| 133 void AddKeys(int profile, | 133 void AddKeys(int profile, const std::set<AutofillKey>& keys) { |
| 134 const std::set<AutofillKey>& keys) { | |
| 135 std::vector<webkit_glue::FormField> form_fields; | 134 std::vector<webkit_glue::FormField> form_fields; |
| 136 for (std::set<AutofillKey>::const_iterator i = keys.begin(); | 135 for (std::set<AutofillKey>::const_iterator i = keys.begin(); |
| 137 i != keys.end(); | 136 i != keys.end(); |
| 138 ++i) { | 137 ++i) { |
| 139 webkit_glue::FormField field; | 138 webkit_glue::FormField field; |
| 140 field.name = i->name(); | 139 field.name = i->name(); |
| 141 field.value = i->value(); | 140 field.value = i->value(); |
| 142 form_fields.push_back(field); | 141 form_fields.push_back(field); |
| 143 } | 142 } |
| 144 | 143 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 pdm->Refresh(); | 238 pdm->Refresh(); |
| 240 MessageLoop::current()->Run(); | 239 MessageLoop::current()->Run(); |
| 241 pdm->RemoveObserver(&observer); | 240 pdm->RemoveObserver(&observer); |
| 242 return pdm->web_profiles(); | 241 return pdm->web_profiles(); |
| 243 } | 242 } |
| 244 | 243 |
| 245 int GetProfileCount(int profile) { | 244 int GetProfileCount(int profile) { |
| 246 return GetAllProfiles(profile).size(); | 245 return GetAllProfiles(profile).size(); |
| 247 } | 246 } |
| 248 | 247 |
| 248 int GetKeyCount(int profile) { |
| 249 return GetAllKeys(profile).size(); |
| 250 } |
| 251 |
| 249 bool ProfilesMatch(int profile_a, int profile_b) { | 252 bool ProfilesMatch(int profile_a, int profile_b) { |
| 250 const std::vector<AutofillProfile*>& autofill_profiles_a = | 253 const std::vector<AutofillProfile*>& autofill_profiles_a = |
| 251 GetAllProfiles(profile_a); | 254 GetAllProfiles(profile_a); |
| 252 std::map<std::string, AutofillProfile> autofill_profiles_a_map; | 255 std::map<std::string, AutofillProfile> autofill_profiles_a_map; |
| 253 for (size_t i = 0; i < autofill_profiles_a.size(); ++i) { | 256 for (size_t i = 0; i < autofill_profiles_a.size(); ++i) { |
| 254 const AutofillProfile* p = autofill_profiles_a[i]; | 257 const AutofillProfile* p = autofill_profiles_a[i]; |
| 255 autofill_profiles_a_map[p->guid()] = *p; | 258 autofill_profiles_a_map[p->guid()] = *p; |
| 256 } | 259 } |
| 257 | 260 |
| 258 const std::vector<AutofillProfile*>& autofill_profiles_b = | 261 const std::vector<AutofillProfile*>& autofill_profiles_b = |
| (...skipping 27 matching lines...) Expand all Loading... |
| 286 if (!ProfilesMatch(0, i)) { | 289 if (!ProfilesMatch(0, i)) { |
| 287 LOG(ERROR) << "Profile " << i << "does not contain the same autofill " | 290 LOG(ERROR) << "Profile " << i << "does not contain the same autofill " |
| 288 "profiles as profile 0."; | 291 "profiles as profile 0."; |
| 289 return false; | 292 return false; |
| 290 } | 293 } |
| 291 } | 294 } |
| 292 return true; | 295 return true; |
| 293 } | 296 } |
| 294 | 297 |
| 295 } // namespace autofill_helper | 298 } // namespace autofill_helper |
| OLD | NEW |