#include "components/autofill/core/browser/webdata/addresses/autofill_profile_sync_bridge.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "base/uuid.h"
#include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/data_model/autofill_profile_test_api.h"
#include "components/autofill/core/browser/test_autofill_clock.h"
#include "components/autofill/core/browser/webdata/addresses/address_autofill_table.h"
#include "components/autofill/core/browser/webdata/addresses/autofill_profile_sync_util.h"
#include "components/autofill/core/browser/webdata/autofill_change.h"
#include "components/autofill/core/browser/webdata/autofill_sync_metadata_table.h"
#include "components/autofill/core/browser/webdata/mock_autofill_webdata_backend.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/engine/data_type_activation_response.h"
#include "components/sync/model/client_tag_based_data_type_processor.h"
#include "components/sync/model/data_batch.h"
#include "components/sync/model/data_type_activation_request.h"
#include "components/sync/model/sync_data.h"
#include "components/sync/protocol/autofill_specifics.pb.h"
#include "components/sync/protocol/data_type_state.pb.h"
#include "components/sync/protocol/entity_data.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/test/mock_commit_queue.h"
#include "components/sync/test/mock_data_type_local_change_processor.h"
#include "components/webdata/common/web_database.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace autofill {
ScopedTempDir;
UTF16ToUTF8;
UTF8ToUTF16;
AutofillProfileSpecifics;
DataBatch;
DataType;
EntityChange;
EntityChangeList;
EntityData;
KeyAndData;
MockDataTypeLocalChangeProcessor;
_;
DoAll;
ElementsAre;
Eq;
Property;
Return;
UnorderedElementsAre;
namespace {
const char kGuidA[] = …;
const char kGuidB[] = …;
const char kGuidC[] = …;
const char kGuidD[] = …;
const char kGuidInvalid[] = …;
const int kValidityStateBitfield = …;
const char kLocaleString[] = …;
const base::Time kJune2017 = …;
AutofillProfile CreateAutofillProfile(
const AutofillProfileSpecifics& specifics) { … }
AutofillProfileSpecifics CreateAutofillProfileSpecifics(
const AutofillProfile& entry) { … }
AutofillProfileSpecifics CreateAutofillProfileSpecifics(
const std::string& guid) { … }
MATCHER_P(HasSpecifics, expected, "") { … }
MATCHER_P(WithUsageStats, expected, "") { … }
void ExtractAutofillProfilesFromDataBatch(
std::unique_ptr<DataBatch> batch,
std::vector<AutofillProfile>* output) { … }
AutofillProfile ConstructCompleteProfile() { … }
AutofillProfileSpecifics ConstructCompleteSpecifics() { … }
}
class AutofillProfileSyncBridgeTest : public testing::Test { … };
TEST_F(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Added) { … }
TEST_F(AutofillProfileSyncBridgeTest,
AutofillProfileChanged_Added_LanguageCodePropagates) { … }
TEST_F(AutofillProfileSyncBridgeTest,
AutofillProfileChanged_Added_LocalValidityBitfieldPropagates) { … }
TEST_F(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Updated) { … }
TEST_F(AutofillProfileSyncBridgeTest,
AutofillProfileChanged_Updated_UsageStatsOverwrittenByClient) { … }
TEST_F(AutofillProfileSyncBridgeTest, AutofillProfileChanged_Deleted) { … }
TEST_F(AutofillProfileSyncBridgeTest, GetAllDataForDebugging) { … }
TEST_F(AutofillProfileSyncBridgeTest, GetDataForCommit) { … }
TEST_F(AutofillProfileSyncBridgeTest, MergeFullSyncData) { … }
TEST_F(AutofillProfileSyncBridgeTest, ProfileMigration) { … }
TEST_F(AutofillProfileSyncBridgeTest, MergeFullSyncData_SyncAllFieldsToServer) { … }
TEST_F(AutofillProfileSyncBridgeTest, MergeFullSyncData_SyncAllFieldsToClient) { … }
TEST_F(AutofillProfileSyncBridgeTest, MergeFullSyncData_IdenticalProfiles) { … }
TEST_F(AutofillProfileSyncBridgeTest, MergeFullSyncData_NonSimilarProfiles) { … }
TEST_F(AutofillProfileSyncBridgeTest, MergeFullSyncData_SimilarProfiles) { … }
TEST_F(AutofillProfileSyncBridgeTest,
MergeFullSyncData_SimilarProfiles_OlderUseDate) { … }
TEST_F(AutofillProfileSyncBridgeTest,
MergeFullSyncData_SimilarProfiles_NewerUseDate) { … }
TEST_F(AutofillProfileSyncBridgeTest,
MergeFullSyncData_SimilarProfiles_NonZeroUseCounts) { … }
TEST_F(AutofillProfileSyncBridgeTest, ApplyIncrementalSyncChanges) { … }
TEST_F(AutofillProfileSyncBridgeTest,
ApplyIncrementalSyncChanges_OmitsInvalidSpecifics) { … }
TEST_F(AutofillProfileSyncBridgeTest, StreetAddress_SplitAutomatically) { … }
TEST_F(AutofillProfileSyncBridgeTest, StreetAddress_JointAutomatically) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_StreetAddress_TakesPrecedenceOverAddressLines) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_StreetAddress_NoUpdateToEmptyStreetAddressSyncedUp) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_LanguageCode_MissingCodesNoSync) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_LanguageCode_ExistingRemoteWinsOverMissingLocal) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_LanguageCode_ExistingRemoteWinsOverExistingLocal) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_LanguageCode_ExistingLocalWinsOverMissingRemote) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_ValidityState_DefaultValueNoSync) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_ValidityState_ExistingRemoteWinsOverMissingLocal) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_ValidityState_ExistingRemoteWinsOverExistingLocal) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_ValidityState_ExistingLocalWinsOverMissingRemote) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_FullName_MissingValueNoSync) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_FullName_ExistingLocalWinsOverMissingRemote) { … }
TEST_F(AutofillProfileSyncBridgeTest,
RemoteWithSameGuid_UsageStats_MissingValueNoSync) { … }
struct UpdatesUsageStatsTestCase { … };
class AutofillProfileSyncBridgeUpdatesUsageStatsTest
: public AutofillProfileSyncBridgeTest,
public testing::WithParamInterface<UpdatesUsageStatsTestCase> { … };
TEST_P(AutofillProfileSyncBridgeUpdatesUsageStatsTest, UpdatesUsageStats) { … }
INSTANTIATE_TEST_SUITE_P(…);
}