Commit 58093d29 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[AF] Fix integration tests for autofill wallet

This CL fixes problems in sync integration tests introduced by
CL 1388430 and prepares for relanding CL 1538416.

Bug: 836718
Change-Id: I70bc5ee1ff8b62cefc2705aedc399dcd2fe1f089
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1561108
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarFlorian Uunk <feuunk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649607}
parent faae31ac
......@@ -198,6 +198,16 @@ class SingleClientWalletSyncTest : public SyncTest {
~SingleClientWalletSyncTest() override {}
bool SetupClients() override {
// Plug in SyncService into PDM so that it can check we use full sync. We
// need to do it before starting the sync in SetupSync().
if (!SyncTest::SetupClients()) {
return false;
}
GetPersonalDataManager(0)->OnSyncServiceInitialized(GetSyncService(0));
return true;
}
protected:
void RefreshAndWaitForOnPersonalDataChanged(
autofill::PersonalDataManager* pdm) {
......
......@@ -65,6 +65,15 @@ class TwoClientWalletSyncTest : public UssWalletSwitchToggler, public SyncTest {
bool SetupSync() override {
test_clock_.SetNow(kArbitraryDefaultTime);
// Plug in SyncService into PDM so that it can check we use full sync. We
// need to do it before starting the sync in SetupSync(). We need to setup
// the clients before that so we can access their sync service.
if (!SetupClients()) {
return false;
}
GetPersonalDataManager(0)->OnSyncServiceInitialized(GetSyncService(0));
GetPersonalDataManager(1)->OnSyncServiceInitialized(GetSyncService(1));
if (!SyncTest::SetupSync()) {
return false;
}
......
......@@ -20,7 +20,6 @@
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/keyed_service/core/service_access_type.h"
#include "components/sync/driver/profile_sync_service.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/protocol/model_type_state.pb.h"
......@@ -220,13 +219,8 @@ const char kDefaultCustomerID[] = "deadbeef";
const char kDefaultBillingAddressID[] = "billing address entity ID";
PersonalDataManager* GetPersonalDataManager(int index) {
auto* pdm = autofill::PersonalDataManagerFactory::GetForProfile(
return autofill::PersonalDataManagerFactory::GetForProfile(
test()->GetProfile(index));
// Hook the sync service up to the personal data manager.
// This is normally done by autofill_manager, which we don't
// have in our tests.
pdm->OnSyncServiceInitialized(test()->GetSyncService(index));
return pdm;
}
scoped_refptr<AutofillWebDataService> GetProfileWebDataService(int index) {
......@@ -559,9 +553,9 @@ bool AutofillWalletMetadataSizeChecker::IsExitConditionSatisfied() {
std::map<std::string, AutofillMetadata> addresses_metadata_b =
wallet_helper::GetServerAddressesMetadata(profile_b_);
if (addresses_metadata_a.size() != addresses_metadata_b.size()) {
LOG(WARNING) << "Server addresses metadata mismatch, expected "
<< addresses_metadata_a.size()
<< ", found: " << addresses_metadata_b.size();
DVLOG(1) << "Server addresses metadata mismatch, expected "
<< addresses_metadata_a.size()
<< ", found: " << addresses_metadata_b.size();
return false;
}
std::map<std::string, AutofillMetadata> cards_metadata_a =
......@@ -569,9 +563,9 @@ bool AutofillWalletMetadataSizeChecker::IsExitConditionSatisfied() {
std::map<std::string, AutofillMetadata> cards_metadata_b =
wallet_helper::GetServerCardsMetadata(profile_b_);
if (cards_metadata_a.size() != cards_metadata_b.size()) {
LOG(WARNING) << "Server cards metadata mismatch, expected "
<< cards_metadata_a.size() << ", found "
<< cards_metadata_b.size();
DVLOG(1) << "Server cards metadata mismatch, expected "
<< cards_metadata_a.size() << ", found "
<< cards_metadata_b.size();
return false;
}
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment