Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/sync/test/integration/autofill_helper.cc

Issue 1850253002: Revert of [Sync] Eliminate verifier profile from sync_integration_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/sync/test/integration/autofill_helper.h" 5 #include "chrome/browser/sync/test/integration/autofill_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" 10 #include "chrome/browser/autofill/personal_data_manager_factory.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 EXPECT_CALL(observer, OnPersonalDataChanged()). 308 EXPECT_CALL(observer, OnPersonalDataChanged()).
309 WillOnce(QuitUIMessageLoop()); 309 WillOnce(QuitUIMessageLoop());
310 PersonalDataManager* pdm = GetPersonalDataManager(profile); 310 PersonalDataManager* pdm = GetPersonalDataManager(profile);
311 pdm->AddObserver(&observer); 311 pdm->AddObserver(&observer);
312 pdm->SetCreditCards(credit_cards); 312 pdm->SetCreditCards(credit_cards);
313 base::MessageLoop::current()->Run(); 313 base::MessageLoop::current()->Run();
314 pdm->RemoveObserver(&observer); 314 pdm->RemoveObserver(&observer);
315 } 315 }
316 316
317 void AddProfile(int profile, const AutofillProfile& autofill_profile) { 317 void AddProfile(int profile, const AutofillProfile& autofill_profile) {
318 const std::vector<AutofillProfile*>& all_profiles = 318 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
319 GetAllAutoFillProfiles(profile);
320 std::vector<AutofillProfile> autofill_profiles; 319 std::vector<AutofillProfile> autofill_profiles;
321 for (size_t i = 0; i < all_profiles.size(); ++i) 320 for (size_t i = 0; i < all_profiles.size(); ++i)
322 autofill_profiles.push_back(*all_profiles[i]); 321 autofill_profiles.push_back(*all_profiles[i]);
323 autofill_profiles.push_back(autofill_profile); 322 autofill_profiles.push_back(autofill_profile);
324 autofill_helper::SetProfiles(profile, &autofill_profiles); 323 autofill_helper::SetProfiles(profile, &autofill_profiles);
325 } 324 }
326 325
327 void RemoveProfile(int profile, const std::string& guid) { 326 void RemoveProfile(int profile, const std::string& guid) {
328 const std::vector<AutofillProfile*>& all_profiles = 327 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
329 GetAllAutoFillProfiles(profile);
330 std::vector<AutofillProfile> autofill_profiles; 328 std::vector<AutofillProfile> autofill_profiles;
331 for (size_t i = 0; i < all_profiles.size(); ++i) { 329 for (size_t i = 0; i < all_profiles.size(); ++i) {
332 if (all_profiles[i]->guid() != guid) 330 if (all_profiles[i]->guid() != guid)
333 autofill_profiles.push_back(*all_profiles[i]); 331 autofill_profiles.push_back(*all_profiles[i]);
334 } 332 }
335 autofill_helper::SetProfiles(profile, &autofill_profiles); 333 autofill_helper::SetProfiles(profile, &autofill_profiles);
336 } 334 }
337 335
338 void UpdateProfile(int profile, 336 void UpdateProfile(int profile,
339 const std::string& guid, 337 const std::string& guid,
340 const AutofillType& type, 338 const AutofillType& type,
341 const base::string16& value) { 339 const base::string16& value) {
342 const std::vector<AutofillProfile*>& all_profiles = 340 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile);
343 GetAllAutoFillProfiles(profile);
344 std::vector<AutofillProfile> profiles; 341 std::vector<AutofillProfile> profiles;
345 for (size_t i = 0; i < all_profiles.size(); ++i) { 342 for (size_t i = 0; i < all_profiles.size(); ++i) {
346 profiles.push_back(*all_profiles[i]); 343 profiles.push_back(*all_profiles[i]);
347 if (all_profiles[i]->guid() == guid) 344 if (all_profiles[i]->guid() == guid)
348 profiles.back().SetRawInfo(type.GetStorableType(), value); 345 profiles.back().SetRawInfo(type.GetStorableType(), value);
349 } 346 }
350 autofill_helper::SetProfiles(profile, &profiles); 347 autofill_helper::SetProfiles(profile, &profiles);
351 } 348 }
352 349
353 const std::vector<AutofillProfile*>& GetAllAutoFillProfiles( 350 const std::vector<AutofillProfile*>& GetAllProfiles(
354 int profile) { 351 int profile) {
355 MockPersonalDataManagerObserver observer; 352 MockPersonalDataManagerObserver observer;
356 EXPECT_CALL(observer, OnPersonalDataChanged()). 353 EXPECT_CALL(observer, OnPersonalDataChanged()).
357 WillOnce(QuitUIMessageLoop()); 354 WillOnce(QuitUIMessageLoop());
358 PersonalDataManager* pdm = GetPersonalDataManager(profile); 355 PersonalDataManager* pdm = GetPersonalDataManager(profile);
359 pdm->AddObserver(&observer); 356 pdm->AddObserver(&observer);
360 pdm->Refresh(); 357 pdm->Refresh();
361 base::MessageLoop::current()->Run(); 358 base::MessageLoop::current()->Run();
362 pdm->RemoveObserver(&observer); 359 pdm->RemoveObserver(&observer);
363 return pdm->web_profiles(); 360 return pdm->web_profiles();
364 } 361 }
365 362
366 int GetProfileCount(int profile) { 363 int GetProfileCount(int profile) {
367 return GetAllAutoFillProfiles(profile).size(); 364 return GetAllProfiles(profile).size();
368 } 365 }
369 366
370 int GetKeyCount(int profile) { 367 int GetKeyCount(int profile) {
371 return GetAllKeys(profile).size(); 368 return GetAllKeys(profile).size();
372 } 369 }
373 370
374 namespace { 371 namespace {
375 372
376 bool ProfilesMatchImpl( 373 bool ProfilesMatchImpl(
377 int profile_a, 374 int profile_a,
(...skipping 27 matching lines...) Expand all
405 << profile_b << "."; 402 << profile_b << ".";
406 return false; 403 return false;
407 } 404 }
408 return true; 405 return true;
409 } 406 }
410 407
411 } // namespace 408 } // namespace
412 409
413 bool ProfilesMatch(int profile_a, int profile_b) { 410 bool ProfilesMatch(int profile_a, int profile_b) {
414 const std::vector<AutofillProfile*>& autofill_profiles_a = 411 const std::vector<AutofillProfile*>& autofill_profiles_a =
415 GetAllAutoFillProfiles(profile_a); 412 GetAllProfiles(profile_a);
416 const std::vector<AutofillProfile*>& autofill_profiles_b = 413 const std::vector<AutofillProfile*>& autofill_profiles_b =
417 GetAllAutoFillProfiles(profile_b); 414 GetAllProfiles(profile_b);
418 return ProfilesMatchImpl( 415 return ProfilesMatchImpl(
419 profile_a, autofill_profiles_a, profile_b, autofill_profiles_b); 416 profile_a, autofill_profiles_a, profile_b, autofill_profiles_b);
420 } 417 }
421 418
422 bool AllProfilesMatch() { 419 bool AllProfilesMatch() {
423 for (int i = 1; i < test()->num_clients(); ++i) { 420 for (int i = 1; i < test()->num_clients(); ++i) {
424 if (!ProfilesMatch(0, i)) { 421 if (!ProfilesMatch(0, i)) {
425 DVLOG(1) << "Profile " << i << "does not contain the same autofill " 422 DVLOG(1) << "Profile " << i << "does not contain the same autofill "
426 "profiles as profile 0."; 423 "profiles as profile 0.";
427 return false; 424 return false;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 503
507 } // namespace 504 } // namespace
508 505
509 bool AwaitProfilesMatch(int a, int b) { 506 bool AwaitProfilesMatch(int a, int b) {
510 ProfilesMatchStatusChecker checker(a, b); 507 ProfilesMatchStatusChecker checker(a, b);
511 checker.Wait(); 508 checker.Wait();
512 return !checker.TimedOut(); 509 return !checker.TimedOut();
513 } 510 }
514 511
515 } // namespace autofill_helper 512 } // namespace autofill_helper
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/autofill_helper.h ('k') | chrome/browser/sync/test/integration/extensions_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698