#include "components/sync/model/client_tag_based_remote_update_handler.h"
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/protobuf_matchers.h"
#include "base/test/scoped_feature_list.h"
#include "components/sync/base/client_tag_hash.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/unique_position.h"
#include "components/sync/engine/commit_and_get_updates_types.h"
#include "components/sync/engine/data_type_activation_response.h"
#include "components/sync/engine/forwarding_data_type_processor.h"
#include "components/sync/model/conflict_resolution.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/model/processor_entity.h"
#include "components/sync/model/processor_entity_tracker.h"
#include "components/sync/protocol/data_type_state.pb.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/sync/test/fake_data_type_sync_bridge.h"
#include "components/sync/test/mock_data_type_local_change_processor.h"
#include "components/sync/test/mock_data_type_processor.h"
#include "components/sync/test/mock_data_type_worker.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
namespace {
EqualsProto;
ElementsAre;
IsEmpty;
IsNull;
Not;
NotNull;
const char kKey1[] = …;
const char kKey2[] = …;
const char kValue1[] = …;
const char kValue2[] = …;
sync_pb::DataTypeState GenerateDataTypeState() { … }
std::unique_ptr<DataTypeActivationResponse> GenerateDataTypeActivationResponse(
DataTypeProcessor* processor) { … }
ClientTagHash GetPrefHash(const std::string& key) { … }
ClientTagHash GetSharedTabGroupDataHash(const std::string& key) { … }
sync_pb::EntitySpecifics GeneratePrefSpecifics(const std::string& key,
const std::string& value) { … }
sync_pb::EntitySpecifics GenerateSharedTabGroupSpecifics(
const std::string& guid) { … }
sync_pb::EntitySpecifics GenerateSharedTabGroupTabSpecifics(
const std::string& guid,
sync_pb::UniquePosition unique_position) { … }
sync_pb::UniquePosition ExtractUniquePositionFromSharedTab(
const sync_pb::EntitySpecifics& specifics) { … }
class ClientTagBasedRemoteUpdateHandlerTest : public ::testing::Test { … };
TEST_F(ClientTagBasedRemoteUpdateHandlerTest, ShouldProcessRemoteCreation) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldIgnoreRemoteUpdatesForRootNodes) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldIgnoreRemoteUpdatesWithUnexpectedClientTagHash) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldNotClearTrimmedSpecificsOnNoopRemoteUpdates) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldUpdateMetadataOnNoopRemoteUpdates) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldIgnoreReflectionsOnRemoteUpdates) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest, ShouldProcessRemoteUpdates) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest, ShouldProcessRemoteDeletion) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldIgnoreRemoteDeletionOfUnknownEntity) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldNotTreatMatchingChangesAsConflict) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldPreferRemoteNonDeletionOverLocalTombstoneOnConflict) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldPreferRemoteNonDeletionOverLocalEncryptionOnConflict) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldPreferLocalChangeOverRemoteEncryptionOnConflict) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldNotIssueDeletionUponRemoteDeletion) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldNotProcessInvalidRemoteCreationWithInvalidStorageKey) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest,
ShouldIgnoreInvalidRemoteCreation) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest, ShouldIgnoreInvalidRemoteUpdate) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerTest, ShouldLogFreshnessToUma) { … }
class ClientTagBasedRemoteUpdateHandlerForSharedTest
: public ClientTagBasedRemoteUpdateHandlerTest { … };
TEST_F(ClientTagBasedRemoteUpdateHandlerForSharedTest,
ShouldClearEntitiesForInactiveCollaborations) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerForSharedTest,
ShouldCreateDeletionForActiveCollaborationMembership) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerForSharedTest,
ShouldProcessUniquePositionForRemoteCreation) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerForSharedTest,
ShouldProcessUniquePositionForRemoteUpdate) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerForSharedTest,
ShouldPreferRemoteUniquePositionOverLocalDeletion) { … }
TEST_F(ClientTagBasedRemoteUpdateHandlerForSharedTest,
ShouldPreferRemoteUniquePositionOnConflict) { … }
}
}