chromium/components/sync/engine/syncer_unittest.cc

// Copyright 2012 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/engine/syncer.h"

#include <stddef.h>

#include <algorithm>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/extensions_activity.h"
#include "components/sync/base/features.h"
#include "components/sync/base/time.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/engine/active_devices_invalidation_info.h"
#include "components/sync/engine/backoff_delay_provider.h"
#include "components/sync/engine/cancelation_signal.h"
#include "components/sync/engine/cycle/sync_cycle_context.h"
#include "components/sync/engine/data_type_activation_response.h"
#include "components/sync/engine/forwarding_data_type_processor.h"
#include "components/sync/engine/net/server_connection_manager.h"
#include "components/sync/engine/nigori/keystore_keys_handler.h"
#include "components/sync/engine/sync_scheduler_impl.h"
#include "components/sync/engine/syncer_proto_util.h"
#include "components/sync/protocol/bookmark_specifics.pb.h"
#include "components/sync/protocol/client_commands.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/preference_specifics.pb.h"
#include "components/sync/protocol/sync.pb.h"
#include "components/sync/protocol/sync_enums.pb.h"
#include "components/sync/test/fake_sync_encryption_handler.h"
#include "components/sync/test/mock_connection_manager.h"
#include "components/sync/test/mock_data_type_processor.h"
#include "components/sync/test/mock_debug_info_getter.h"
#include "components/sync/test/mock_nudge_handler.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace syncer {

namespace {

ElementsAre;
IsEmpty;
UnorderedElementsAre;

sync_pb::EntitySpecifics MakeSpecifics(DataType data_type) {}

sync_pb::EntitySpecifics MakeBookmarkSpecificsToCommit() {}

}  // namespace

// Syncer unit tests. Unfortunately a lot of these tests
// are outdated and need to be reworked and updated.
class SyncerTest : public testing::Test,
                   public SyncCycle::Delegate,
                   public SyncEngineEventListener {};

TEST_F(SyncerTest, CommitFiltersThrottledEntries) {}

TEST_F(SyncerTest, GetUpdatesPartialThrottled) {}

TEST_F(SyncerTest, GetUpdatesPartialFailure) {}

TEST_F(SyncerTest, TestSimpleCommit) {}

TEST_F(SyncerTest, TestSimpleGetUpdates) {}

// Committing more than kDefaultMaxCommitBatchSize items requires that
// we post more than one commit command to the server.  This test makes
// sure that scenario works as expected.
TEST_F(SyncerTest, CommitManyItemsInOneGo_Success) {}

// Test that a single failure to contact the server will cause us to exit the
// commit loop immediately.
TEST_F(SyncerTest, CommitManyItemsInOneGo_PostBufferFail) {}

// Test that a single conflict response from the server will cause us to exit
// the commit loop immediately.
TEST_F(SyncerTest, CommitManyItemsInOneGo_CommitConflict) {}

// Tests that sending debug info events works.
TEST_F(SyncerTest, SendDebugInfoEventsOnGetUpdates_HappyCase) {}

// Tests that debug info events are dropped on server error.
TEST_F(SyncerTest, SendDebugInfoEventsOnGetUpdates_PostFailsDontDrop) {}

// Tests that commit failure with conflict will trigger GetUpdates for next
// cycle of sync
TEST_F(SyncerTest, CommitFailureWithConflict) {}

// Tests that sending debug info events on Commit works.
TEST_F(SyncerTest, SendDebugInfoEventsOnCommit_HappyCase) {}

// Tests that debug info events are not dropped on server error.
TEST_F(SyncerTest, SendDebugInfoEventsOnCommit_PostFailsDontDrop) {}

TEST_F(SyncerTest, TestClientCommandDuringUpdate) {}

TEST_F(SyncerTest, TestClientCommandDuringCommit) {}

TEST_F(SyncerTest, ShouldPopulateSingleClientFlag) {}

TEST_F(SyncerTest,
       ShouldPopulateSingleClientFlagForStandaloneInvalidationsOnly) {}

TEST_F(SyncerTest, ShouldPopulateSingleClientForOldInvalidations) {}

TEST_F(SyncerTest, ShouldPopulateFcmRegistrationTokens) {}

TEST_F(SyncerTest, ShouldPopulateFcmRegistrationTokensForInterestedTypesOnly) {}

TEST_F(SyncerTest, ShouldNotPopulateTooManyFcmRegistrationTokens) {}

TEST_F(SyncerTest,
       ShouldNotPopulateOptimizationFlagsIfDeviceInfoRecentlyUpdated) {}

TEST_F(SyncerTest, ClientTagServerCreatedUpdatesWork) {}

TEST_F(SyncerTest, GetUpdatesSetsRequestedTypes) {}

// A typical scenario: server and client each have one update for the other.
// This is the "happy path" alternative to UpdateFailsThenDontCommit.
TEST_F(SyncerTest, UpdateThenCommit) {}

// Same as above, but this time we fail to download updates.
// We should not attempt to commit anything unless we successfully downloaded
// updates, otherwise we risk causing a server-side conflict.
TEST_F(SyncerTest, UpdateFailsThenDontCommit) {}

// Downloads two updates successfully.
// This is the "happy path" alternative to ConfigureFailsDontApplyUpdates.
TEST_F(SyncerTest, ConfigureDownloadsTwoBatchesSuccess) {}

// Same as the above case, but this time the second batch fails to download.
TEST_F(SyncerTest, ConfigureFailsDontApplyUpdates) {}

// Tests that if type is not registered with DataTypeRegistry (e.g. because
// type's LoadModels failed), Syncer::ConfigureSyncShare runs without triggering
// DCHECK.
TEST_F(SyncerTest, ConfigureFailedUnregisteredType) {}

TEST_F(SyncerTest, GetKeySuccess) {}

TEST_F(SyncerTest, GetKeyEmpty) {}

// Verify that commit only types are never requested in GetUpdates, but still
// make it into the commit messages. Additionally, make sure failing GU types
// are correctly removed before commit.
TEST_F(SyncerTest, CommitOnlyTypes) {}

enum {};

class MixedResult : public SyncerTest,
                    public ::testing::WithParamInterface<int> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(MixedResult, ExtensionsActivity) {}

}  // namespace syncer