| Index: chrome/browser/sync/test/integration/autofill_helper.cc
|
| diff --git a/chrome/browser/sync/test/integration/autofill_helper.cc b/chrome/browser/sync/test/integration/autofill_helper.cc
|
| index f88a9e7d5604f7c5c0cc2f6b509ad3162406ef2e..9e885e412a41734144c29c4a54add24a16d9b5ac 100644
|
| --- a/chrome/browser/sync/test/integration/autofill_helper.cc
|
| +++ b/chrome/browser/sync/test/integration/autofill_helper.cc
|
| @@ -6,13 +6,14 @@
|
|
|
| #include <stddef.h>
|
|
|
| +#include <map>
|
| +
|
| #include "base/guid.h"
|
| #include "base/run_loop.h"
|
| #include "chrome/browser/autofill/personal_data_manager_factory.h"
|
| #include "chrome/browser/chrome_notification_types.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sync/profile_sync_test_util.h"
|
| -#include "chrome/browser/sync/test/integration/multi_client_status_change_checker.h"
|
| #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
|
| #include "chrome/browser/sync/test/integration/sync_test.h"
|
| #include "chrome/browser/web_data_service_factory.h"
|
| @@ -20,7 +21,6 @@
|
| #include "components/autofill/core/browser/autofill_test_utils.h"
|
| #include "components/autofill/core/browser/autofill_type.h"
|
| #include "components/autofill/core/browser/personal_data_manager.h"
|
| -#include "components/autofill/core/browser/personal_data_manager_observer.h"
|
| #include "components/autofill/core/browser/webdata/autofill_entry.h"
|
| #include "components/autofill/core/browser/webdata/autofill_table.h"
|
| #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
|
| @@ -255,47 +255,6 @@ bool KeysMatch(int profile_a, int profile_b) {
|
| return GetAllKeys(profile_a) == GetAllKeys(profile_b);
|
| }
|
|
|
| -namespace {
|
| -
|
| -class KeysMatchStatusChecker : public MultiClientStatusChangeChecker {
|
| - public:
|
| - KeysMatchStatusChecker(int profile_a, int profile_b);
|
| - ~KeysMatchStatusChecker() override;
|
| -
|
| - bool IsExitConditionSatisfied() override;
|
| - std::string GetDebugMessage() const override;
|
| -
|
| - private:
|
| - const int profile_a_;
|
| - const int profile_b_;
|
| -};
|
| -
|
| -KeysMatchStatusChecker::KeysMatchStatusChecker(int profile_a, int profile_b)
|
| - : MultiClientStatusChangeChecker(
|
| - sync_datatype_helper::test()->GetSyncServices()),
|
| - profile_a_(profile_a),
|
| - profile_b_(profile_b) {
|
| -}
|
| -
|
| -KeysMatchStatusChecker::~KeysMatchStatusChecker() {
|
| -}
|
| -
|
| -bool KeysMatchStatusChecker::IsExitConditionSatisfied() {
|
| - return KeysMatch(profile_a_, profile_b_);
|
| -}
|
| -
|
| -std::string KeysMatchStatusChecker::GetDebugMessage() const {
|
| - return "Waiting for matching autofill keys";
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| -bool AwaitKeysMatch(int a, int b) {
|
| - KeysMatchStatusChecker checker(a, b);
|
| - checker.Wait();
|
| - return !checker.TimedOut();
|
| -}
|
| -
|
| void SetProfiles(int profile, std::vector<AutofillProfile>* autofill_profiles) {
|
| MockPersonalDataManagerObserver observer;
|
| EXPECT_CALL(observer, OnPersonalDataChanged()).
|
| @@ -434,86 +393,52 @@ bool AllProfilesMatch() {
|
| return true;
|
| }
|
|
|
| -namespace {
|
| -
|
| -class ProfilesMatchStatusChecker : public StatusChangeChecker,
|
| - public PersonalDataManagerObserver {
|
| - public:
|
| - ProfilesMatchStatusChecker(int profile_a, int profile_b);
|
| - ~ProfilesMatchStatusChecker() override;
|
| -
|
| - // StatusChangeChecker implementation.
|
| - bool IsExitConditionSatisfied() override;
|
| - std::string GetDebugMessage() const override;
|
| +} // namespace autofill_helper
|
|
|
| - // PersonalDataManager implementation.
|
| - void OnPersonalDataChanged() override;
|
| +AutofillKeysChecker::AutofillKeysChecker(int profile_a, int profile_b)
|
| + : MultiClientStatusChangeChecker(
|
| + sync_datatype_helper::test()->GetSyncServices()),
|
| + profile_a_(profile_a),
|
| + profile_b_(profile_b) {}
|
|
|
| - // Wait for conidtion to beome true.
|
| - void Wait();
|
| +bool AutofillKeysChecker::IsExitConditionSatisfied() {
|
| + return autofill_helper::KeysMatch(profile_a_, profile_b_);
|
| +}
|
|
|
| - private:
|
| - const int profile_a_;
|
| - const int profile_b_;
|
| - bool registered_;
|
| -};
|
| +std::string AutofillKeysChecker::GetDebugMessage() const {
|
| + return "Waiting for matching autofill keys";
|
| +}
|
|
|
| -ProfilesMatchStatusChecker::ProfilesMatchStatusChecker(int profile_a,
|
| - int profile_b)
|
| - : profile_a_(profile_a), profile_b_(profile_b), registered_(false) {
|
| +AutofillProfileChecker::AutofillProfileChecker(int profile_a, int profile_b)
|
| + : profile_a_(profile_a), profile_b_(profile_b) {
|
| + autofill_helper::GetPersonalDataManager(profile_a_)->AddObserver(this);
|
| + autofill_helper::GetPersonalDataManager(profile_b_)->AddObserver(this);
|
| }
|
|
|
| -ProfilesMatchStatusChecker::~ProfilesMatchStatusChecker() {
|
| - PersonalDataManager* pdm_a = GetPersonalDataManager(profile_a_);
|
| - PersonalDataManager* pdm_b = GetPersonalDataManager(profile_b_);
|
| - if (registered_) {
|
| - pdm_a->RemoveObserver(this);
|
| - pdm_b->RemoveObserver(this);
|
| - }
|
| +AutofillProfileChecker::~AutofillProfileChecker() {
|
| + autofill_helper::GetPersonalDataManager(profile_a_)->RemoveObserver(this);
|
| + autofill_helper::GetPersonalDataManager(profile_b_)->RemoveObserver(this);
|
| }
|
|
|
| -bool ProfilesMatchStatusChecker::IsExitConditionSatisfied() {
|
| - PersonalDataManager* pdm_a = GetPersonalDataManager(profile_a_);
|
| - PersonalDataManager* pdm_b = GetPersonalDataManager(profile_b_);
|
| +bool AutofillProfileChecker::Wait() {
|
| + autofill_helper::GetPersonalDataManager(profile_a_)->Refresh();
|
| + autofill_helper::GetPersonalDataManager(profile_b_)->Refresh();
|
| + return StatusChangeChecker::Wait();
|
| +}
|
|
|
| +bool AutofillProfileChecker::IsExitConditionSatisfied() {
|
| const std::vector<AutofillProfile*>& autofill_profiles_a =
|
| - pdm_a->web_profiles();
|
| + autofill_helper::GetPersonalDataManager(profile_a_)->web_profiles();
|
| const std::vector<AutofillProfile*>& autofill_profiles_b =
|
| - pdm_b->web_profiles();
|
| -
|
| - return ProfilesMatchImpl(
|
| - profile_a_, autofill_profiles_a, profile_b_, autofill_profiles_b);
|
| -}
|
| -
|
| -void ProfilesMatchStatusChecker::Wait() {
|
| - PersonalDataManager* pdm_a = GetPersonalDataManager(profile_a_);
|
| - PersonalDataManager* pdm_b = GetPersonalDataManager(profile_b_);
|
| -
|
| - pdm_a->AddObserver(this);
|
| - pdm_b->AddObserver(this);
|
| -
|
| - pdm_a->Refresh();
|
| - pdm_b->Refresh();
|
| -
|
| - registered_ = true;
|
| -
|
| - StartBlockingWait();
|
| + autofill_helper::GetPersonalDataManager(profile_b_)->web_profiles();
|
| + return autofill_helper::ProfilesMatchImpl(profile_a_, autofill_profiles_a,
|
| + profile_b_, autofill_profiles_b);
|
| }
|
|
|
| -std::string ProfilesMatchStatusChecker::GetDebugMessage() const {
|
| +std::string AutofillProfileChecker::GetDebugMessage() const {
|
| return "Waiting for matching autofill profiles";
|
| }
|
|
|
| -void ProfilesMatchStatusChecker::OnPersonalDataChanged() {
|
| +void AutofillProfileChecker::OnPersonalDataChanged() {
|
| CheckExitCondition();
|
| }
|
| -
|
| -} // namespace
|
| -
|
| -bool AwaitProfilesMatch(int a, int b) {
|
| - ProfilesMatchStatusChecker checker(a, b);
|
| - checker.Wait();
|
| - return !checker.TimedOut();
|
| -}
|
| -
|
| -} // namespace autofill_helper
|
|
|