#include "components/sync/model/processor_entity.h"
#include <utility>
#include "base/hash/hash.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/protobuf_matchers.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/deletion_origin.h"
#include "components/sync/base/features.h"
#include "components/sync/base/hash_util.h"
#include "components/sync/base/time.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/engine/commit_and_get_updates_types.h"
#include "components/sync/protocol/entity_metadata.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/unique_position.pb.h"
#include "components/version_info/version_info.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
namespace {
EqualsProto;
Not;
const char kKey[] = …;
const ClientTagHash kHash = …;
const char kId[] = …;
const char kName[] = …;
const char kValue1[] = …;
const char kValue2[] = …;
const char kValue3[] = …;
sync_pb::EntitySpecifics GenerateSpecifics(const std::string& name,
const std::string& value) { … }
std::unique_ptr<EntityData> GenerateEntityData(const ClientTagHash& hash,
const std::string& name,
const std::string& value) { … }
sync_pb::EntitySpecifics GenerateSharedTabGroupDataSpecifics(
const std::string& guid) { … }
std::unique_ptr<EntityData> GenerateSharedTabGroupDataEntityData(
const ClientTagHash& hash,
const std::string& guid,
const std::string& collaboration_id) { … }
UpdateResponseData GenerateSharedTabGroupDataUpdate(
const ProcessorEntity& entity,
const ClientTagHash& hash,
const std::string& server_id,
const std::string& guid,
const base::Time& mtime,
int64_t version,
const std::string& collaboration_id) { … }
UpdateResponseData GenerateUpdate(const ProcessorEntity& entity,
const ClientTagHash& hash,
const std::string& id,
const std::string& name,
const std::string& value,
const base::Time& mtime,
int64_t version) { … }
UpdateResponseData GenerateTombstone(const ProcessorEntity& entity,
const ClientTagHash& hash,
const std::string& id,
const std::string& name,
const base::Time& mtime,
int64_t version) { … }
CommitResponseData GenerateAckData(const CommitRequestData& request,
const std::string id,
int64_t version) { … }
sync_pb::UniquePosition GenerateUniquePosition(const ClientTagHash& hash) { … }
}
class ProcessorEntityTest : public ::testing::Test { … };
TEST_F(ProcessorEntityTest, DefaultEntity) { … }
TEST_F(ProcessorEntityTest, NewLocalItem) { … }
TEST_F(ProcessorEntityTest, ShouldStoreUniquePositionForNewLocalItem) { … }
TEST_F(ProcessorEntityTest,
ShouldIgnoreCommitResponseWithInvalidServerVersion) { … }
TEST_F(ProcessorEntityTest, NewServerItem) { … }
TEST_F(ProcessorEntityTest, ShouldStoreUniquePositionForNewServerItem) { … }
TEST_F(ProcessorEntityTest, NewServerItem_EmptyStorageKey) { … }
TEST_F(ProcessorEntityTest, NewServerTombstone) { … }
TEST_F(ProcessorEntityTest, ServerTombstone) { … }
TEST_F(ProcessorEntityTest, ShouldResetUniquePositionOnServerUpdate) { … }
TEST_F(ProcessorEntityTest, LocalChange) { … }
TEST_F(ProcessorEntityTest, ShouldStoreNewUniquePositionOnLocalUpdate) { … }
TEST_F(ProcessorEntityTest, ShouldResetUniquePositionOnLocalUpdate) { … }
TEST_F(ProcessorEntityTest, LocalDeletion) { … }
TEST_F(ProcessorEntityTest, ShouldResetUniquePositionOnLocalDeletion) { … }
TEST_F(ProcessorEntityTest, LocalDeletionWithSpecifiedOrigin) { … }
TEST_F(ProcessorEntityTest, LocalUndeletion) { … }
TEST_F(ProcessorEntityTest, ShouldStoreUniquePositionForLocalUndeletion) { … }
TEST_F(ProcessorEntityTest, LocalChangesInterleaved) { … }
TEST_F(ProcessorEntityTest, NewLocalChangeUpdatedId) { … }
TEST_F(ProcessorEntityTest, RestoredLocalChangeWithUpdatedSpecifics) { … }
TEST_F(ProcessorEntityTest, LocalCreationConflictsWithServerTombstone) { … }
TEST_F(ProcessorEntityTest, UpdatesSpecificsCacheOnRemoteUpdates) { … }
TEST_F(ProcessorEntityTest, UpdatesSpecificsCacheOnLocalUpdates) { … }
TEST_F(ProcessorEntityTest,
LocalDeletionDoesNotRecordVersionInfoIfFeatureIsDisabled) { … }
TEST_F(ProcessorEntityTest, LocalDeletionRecordsVersionInfoIfFeatureIsEnabled) { … }
TEST_F(ProcessorEntityTest, ShouldCreateAndCommitNewLocalSharedItem) { … }
TEST_F(ProcessorEntityTest, ShouldCreateNewRemoteSharedItem) { … }
TEST_F(ProcessorEntityTest, ShouldMatchEntitiesByCollaborations) { … }
TEST_F(ProcessorEntityTest, ShouldPopulateCollaborationForTombstones) { … }
}