chromium/components/sync/model/processor_entity_unittest.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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) {}

}  // namespace

// Some simple sanity tests for the ProcessorEntity.
//
// A lot of the more complicated sync logic is implemented in the
// ClientTagBasedDataTypeProcessor that owns the ProcessorEntity.  We
// can't unit test it here.
//
// Instead, we focus on simple tests to make sure that variables are getting
// properly intialized and flags properly set.  Anything more complicated would
// be a redundant and incomplete version of the ClientTagBasedDataTypeProcessor
// tests.
class ProcessorEntityTest : public ::testing::Test {};

// Test the state of the default new entity.
TEST_F(ProcessorEntityTest, DefaultEntity) {}

// Test creating and commiting a new local item.
TEST_F(ProcessorEntityTest, NewLocalItem) {}

TEST_F(ProcessorEntityTest, ShouldStoreUniquePositionForNewLocalItem) {}

// Test handling of invalid server version.
TEST_F(ProcessorEntityTest,
       ShouldIgnoreCommitResponseWithInvalidServerVersion) {}

// Test state for a newly synced server item.
TEST_F(ProcessorEntityTest, NewServerItem) {}

TEST_F(ProcessorEntityTest, ShouldStoreUniquePositionForNewServerItem) {}

// Test creating an entity for new server item with empty storage key, applying
// update and updating storage key.
TEST_F(ProcessorEntityTest, NewServerItem_EmptyStorageKey) {}

// Test state for a tombstone received for a previously unknown item.
TEST_F(ProcessorEntityTest, NewServerTombstone) {}

// Apply a deletion update to a synced item.
TEST_F(ProcessorEntityTest, ServerTombstone) {}

TEST_F(ProcessorEntityTest, ShouldResetUniquePositionOnServerUpdate) {}

// Test a local change of a synced item.
TEST_F(ProcessorEntityTest, LocalChange) {}

TEST_F(ProcessorEntityTest, ShouldStoreNewUniquePositionOnLocalUpdate) {}

TEST_F(ProcessorEntityTest, ShouldResetUniquePositionOnLocalUpdate) {}

// Test a local deletion of a synced item.
TEST_F(ProcessorEntityTest, LocalDeletion) {}

TEST_F(ProcessorEntityTest, ShouldResetUniquePositionOnLocalDeletion) {}

TEST_F(ProcessorEntityTest, LocalDeletionWithSpecifiedOrigin) {}

// Test a local deletion followed by an undeletion (creation).
TEST_F(ProcessorEntityTest, LocalUndeletion) {}

TEST_F(ProcessorEntityTest, ShouldStoreUniquePositionForLocalUndeletion) {}

// Test that hashes and sequence numbers are handled correctly for the "commit
// commit, ack ack" case.
TEST_F(ProcessorEntityTest, LocalChangesInterleaved) {}

// Tests that updating entity id with commit response while next local change is
// pending correctly updates that change's id and version.
TEST_F(ProcessorEntityTest, NewLocalChangeUpdatedId) {}

// Tests that entity restored after restart accepts specifics that don't match
// the ones passed originally to RecordLocalUpdate.
TEST_F(ProcessorEntityTest, RestoredLocalChangeWithUpdatedSpecifics) {}

// Tests the scenario where a local creation conflicts with a remote deletion,
// where usually (and in this test) local wins. In this case, the remote update
// should be ignored but the server IDs should be updated.
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) {}

}  // namespace syncer