#include "components/autofill/core/browser/webdata/autocomplete/autocomplete_sync_bridge.h"
#include <algorithm>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/autofill/core/browser/webdata/autocomplete/autocomplete_entry.h"
#include "components/autofill/core/browser/webdata/autocomplete/autocomplete_table.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/sync/base/client_tag_hash.h"
#include "components/sync/base/data_type.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/metadata_batch.h"
#include "components/sync/model/model_error.h"
#include "components/sync/protocol/autofill_specifics.pb.h"
#include "components/sync/protocol/data_type_state.pb.h"
#include "components/sync/protocol/entity_metadata.pb.h"
#include "components/sync/test/mock_commit_queue.h"
#include "components/sync/test/mock_data_type_local_change_processor.h"
#include "components/sync/test/test_matchers.h"
#include "components/webdata/common/web_database.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
ScopedTempDir;
Time;
UTF8ToUTF16;
AutofillSpecifics;
DataTypeState;
EntityMetadata;
DataBatch;
DataType;
DataTypeLocalChangeProcessor;
DataTypeSyncBridge;
EntityChange;
EntityChangeList;
EntityData;
HasInitialSyncDone;
IsEmptyMetadataBatch;
KeyAndData;
MockDataTypeLocalChangeProcessor;
ModelError;
_;
IsEmpty;
Not;
Return;
SizeIs;
namespace autofill {
namespace {
const char kNameFormat[] = …;
const char kValueFormat[] = …;
MATCHER_P(HasSpecifics, expected, "") { … }
void VerifyDataBatch(std::map<std::string, AutofillSpecifics> expected,
std::unique_ptr<DataBatch> batch) { … }
AutocompleteEntry CreateAutocompleteEntry(
const AutofillSpecifics& autofill_specifics) { … }
}
class AutocompleteSyncBridgeTest : public testing::Test { … };
TEST_F(AutocompleteSyncBridgeTest, GetClientTag) { … }
TEST_F(AutocompleteSyncBridgeTest, GetClientTagNotAffectedByTimestamp) { … }
TEST_F(AutocompleteSyncBridgeTest, GetClientTagRespectsNullCharacter) { … }
TEST_F(AutocompleteSyncBridgeTest, GetClientTagFixed) { … }
TEST_F(AutocompleteSyncBridgeTest, GetStorageKey) { … }
TEST_F(AutocompleteSyncBridgeTest, GetStorageKeyNotAffectedByTimestamp) { … }
TEST_F(AutocompleteSyncBridgeTest, GetStorageKeyRespectsNullCharacter) { … }
TEST_F(AutocompleteSyncBridgeTest, GetStorageKeyFixed) { … }
TEST_F(AutocompleteSyncBridgeTest, GetDataForCommit) { … }
TEST_F(AutocompleteSyncBridgeTest, GetDataForCommitNotExist) { … }
TEST_F(AutocompleteSyncBridgeTest, GetAllData) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesEmpty) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesSimple) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesWrongChangeType) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesThreeTimestamps) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesWrongOrder) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesRepeatedTime) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesNoTime) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesNoValue) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesNoName) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesUTF) { … }
TEST_F(AutocompleteSyncBridgeTest,
ApplyIncrementalSyncChangesMinMaxTimestamps) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesBadStorageKey) { … }
TEST_F(AutocompleteSyncBridgeTest, ApplyIncrementalSyncChangesDatabaseFailure) { … }
TEST_F(AutocompleteSyncBridgeTest, LocalEntriesAdded) { … }
TEST_F(AutocompleteSyncBridgeTest, LocalEntryAddedThenUpdated) { … }
TEST_F(AutocompleteSyncBridgeTest, LocalEntryDeleted) { … }
TEST_F(AutocompleteSyncBridgeTest, LocalEntryExpired) { … }
TEST_F(AutocompleteSyncBridgeTest, LoadMetadataCalled) { … }
TEST_F(AutocompleteSyncBridgeTest, LoadMetadataReportsErrorForMissingDB) { … }
TEST_F(AutocompleteSyncBridgeTest, MergeFullSyncDataEmpty) { … }
TEST_F(AutocompleteSyncBridgeTest, MergeFullSyncDataRemoteOnly) { … }
TEST_F(AutocompleteSyncBridgeTest, MergeFullSyncDataLocalOnly) { … }
TEST_F(AutocompleteSyncBridgeTest, MergeFullSyncDataAllMerged) { … }
TEST_F(AutocompleteSyncBridgeTest, MergeFullSyncDataMixed) { … }
}