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

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

Issue 1851243002: [Sync] Eliminate verifier profile from sync_integration_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not remove AwaitQuiescence() 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 = GetAllProfiles(profile); 318 const std::vector<AutofillProfile*>& all_profiles =
319 GetAllAutoFillProfiles(profile);
319 std::vector<AutofillProfile> autofill_profiles; 320 std::vector<AutofillProfile> autofill_profiles;
320 for (size_t i = 0; i < all_profiles.size(); ++i) 321 for (size_t i = 0; i < all_profiles.size(); ++i)
321 autofill_profiles.push_back(*all_profiles[i]); 322 autofill_profiles.push_back(*all_profiles[i]);
322 autofill_profiles.push_back(autofill_profile); 323 autofill_profiles.push_back(autofill_profile);
323 autofill_helper::SetProfiles(profile, &autofill_profiles); 324 autofill_helper::SetProfiles(profile, &autofill_profiles);
324 } 325 }
325 326
326 void RemoveProfile(int profile, const std::string& guid) { 327 void RemoveProfile(int profile, const std::string& guid) {
327 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile); 328 const std::vector<AutofillProfile*>& all_profiles =
329 GetAllAutoFillProfiles(profile);
328 std::vector<AutofillProfile> autofill_profiles; 330 std::vector<AutofillProfile> autofill_profiles;
329 for (size_t i = 0; i < all_profiles.size(); ++i) { 331 for (size_t i = 0; i < all_profiles.size(); ++i) {
330 if (all_profiles[i]->guid() != guid) 332 if (all_profiles[i]->guid() != guid)
331 autofill_profiles.push_back(*all_profiles[i]); 333 autofill_profiles.push_back(*all_profiles[i]);
332 } 334 }
333 autofill_helper::SetProfiles(profile, &autofill_profiles); 335 autofill_helper::SetProfiles(profile, &autofill_profiles);
334 } 336 }
335 337
336 void UpdateProfile(int profile, 338 void UpdateProfile(int profile,
337 const std::string& guid, 339 const std::string& guid,
338 const AutofillType& type, 340 const AutofillType& type,
339 const base::string16& value) { 341 const base::string16& value) {
340 const std::vector<AutofillProfile*>& all_profiles = GetAllProfiles(profile); 342 const std::vector<AutofillProfile*>& all_profiles =
343 GetAllAutoFillProfiles(profile);
341 std::vector<AutofillProfile> profiles; 344 std::vector<AutofillProfile> profiles;
342 for (size_t i = 0; i < all_profiles.size(); ++i) { 345 for (size_t i = 0; i < all_profiles.size(); ++i) {
343 profiles.push_back(*all_profiles[i]); 346 profiles.push_back(*all_profiles[i]);
344 if (all_profiles[i]->guid() == guid) 347 if (all_profiles[i]->guid() == guid)
345 profiles.back().SetRawInfo(type.GetStorableType(), value); 348 profiles.back().SetRawInfo(type.GetStorableType(), value);
346 } 349 }
347 autofill_helper::SetProfiles(profile, &profiles); 350 autofill_helper::SetProfiles(profile, &profiles);
348 } 351 }
349 352
350 const std::vector<AutofillProfile*>& GetAllProfiles( 353 const std::vector<AutofillProfile*>& GetAllAutoFillProfiles(
351 int profile) { 354 int profile) {
352 MockPersonalDataManagerObserver observer; 355 MockPersonalDataManagerObserver observer;
353 EXPECT_CALL(observer, OnPersonalDataChanged()). 356 EXPECT_CALL(observer, OnPersonalDataChanged()).
354 WillOnce(QuitUIMessageLoop()); 357 WillOnce(QuitUIMessageLoop());
355 PersonalDataManager* pdm = GetPersonalDataManager(profile); 358 PersonalDataManager* pdm = GetPersonalDataManager(profile);
356 pdm->AddObserver(&observer); 359 pdm->AddObserver(&observer);
357 pdm->Refresh(); 360 pdm->Refresh();
358 base::MessageLoop::current()->Run(); 361 base::MessageLoop::current()->Run();
359 pdm->RemoveObserver(&observer); 362 pdm->RemoveObserver(&observer);
360 return pdm->web_profiles(); 363 return pdm->web_profiles();
361 } 364 }
362 365
363 int GetProfileCount(int profile) { 366 int GetProfileCount(int profile) {
364 return GetAllProfiles(profile).size(); 367 return GetAllAutoFillProfiles(profile).size();
365 } 368 }
366 369
367 int GetKeyCount(int profile) { 370 int GetKeyCount(int profile) {
368 return GetAllKeys(profile).size(); 371 return GetAllKeys(profile).size();
369 } 372 }
370 373
371 namespace { 374 namespace {
372 375
373 bool ProfilesMatchImpl( 376 bool ProfilesMatchImpl(
374 int profile_a, 377 int profile_a,
(...skipping 27 matching lines...) Expand all
402 << profile_b << "."; 405 << profile_b << ".";
403 return false; 406 return false;
404 } 407 }
405 return true; 408 return true;
406 } 409 }
407 410
408 } // namespace 411 } // namespace
409 412
410 bool ProfilesMatch(int profile_a, int profile_b) { 413 bool ProfilesMatch(int profile_a, int profile_b) {
411 const std::vector<AutofillProfile*>& autofill_profiles_a = 414 const std::vector<AutofillProfile*>& autofill_profiles_a =
412 GetAllProfiles(profile_a); 415 GetAllAutoFillProfiles(profile_a);
413 const std::vector<AutofillProfile*>& autofill_profiles_b = 416 const std::vector<AutofillProfile*>& autofill_profiles_b =
414 GetAllProfiles(profile_b); 417 GetAllAutoFillProfiles(profile_b);
415 return ProfilesMatchImpl( 418 return ProfilesMatchImpl(
416 profile_a, autofill_profiles_a, profile_b, autofill_profiles_b); 419 profile_a, autofill_profiles_a, profile_b, autofill_profiles_b);
417 } 420 }
418 421
419 bool AllProfilesMatch() { 422 bool AllProfilesMatch() {
420 for (int i = 1; i < test()->num_clients(); ++i) { 423 for (int i = 1; i < test()->num_clients(); ++i) {
421 if (!ProfilesMatch(0, i)) { 424 if (!ProfilesMatch(0, i)) {
422 DVLOG(1) << "Profile " << i << "does not contain the same autofill " 425 DVLOG(1) << "Profile " << i << "does not contain the same autofill "
423 "profiles as profile 0."; 426 "profiles as profile 0.";
424 return false; 427 return false;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 506
504 } // namespace 507 } // namespace
505 508
506 bool AwaitProfilesMatch(int a, int b) { 509 bool AwaitProfilesMatch(int a, int b) {
507 ProfilesMatchStatusChecker checker(a, b); 510 ProfilesMatchStatusChecker checker(a, b);
508 checker.Wait(); 511 checker.Wait();
509 return !checker.TimedOut(); 512 return !checker.TimedOut();
510 } 513 }
511 514
512 } // namespace autofill_helper 515 } // 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