chromium/components/sync/service/data_type_manager_impl_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/service/data_type_manager_impl.h"

#include <memory>
#include <utility>

#include "base/functional/callback.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/base/sync_mode.h"
#include "components/sync/engine/configure_reason.h"
#include "components/sync/engine/data_type_activation_response.h"
#include "components/sync/service/configure_context.h"
#include "components/sync/service/data_type_encryption_handler.h"
#include "components/sync/service/data_type_manager_observer.h"
#include "components/sync/service/data_type_status_table.h"
#include "components/sync/test/fake_data_type_controller.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace syncer {

namespace {

_;
ElementsAre;
Pair;
UnorderedElementsAre;

// Helpers for unioning with control types.
DataTypeSet AddControlTypesTo(DataTypeSet types) {}

ConfigureContext BuildConfigureContext(ConfigureReason reason,
                                       SyncMode sync_mode = SyncMode::kFull) {}

class MockDataTypeManagerObserver : public DataTypeManagerObserver {};

MATCHER_P(ConfigureSucceededWithFailedTypes, error_map, "") {}

MATCHER(ConfigureSucceeded, "") {}

MATCHER(ConfigureAborted, "") {}

MATCHER(IsCryptoError, "") {}

MATCHER(IsDataTypeError, "") {}

MATCHER(IsPolicyError, "") {}

MATCHER(IsUnreadyError, "") {}

// Fake DataTypeConfigurer implementation that allows the test body to control
// when downloads complete and whether failures occurred.
class FakeDataTypeConfigurer : public DataTypeConfigurer {};

class FakeDataTypeEncryptionHandler : public DataTypeEncryptionHandler {};

bool FakeDataTypeEncryptionHandler::HasCryptoError() const {}

DataTypeSet FakeDataTypeEncryptionHandler::GetAllEncryptedDataTypes() const {}

class DataTypeManagerImplTest : public testing::Test {};

// Set up a DTM with no controllers, configure it, finish downloading,
// and then stop it.
TEST_F(DataTypeManagerImplTest, NoControllers) {}

// Set up a DTM with a single controller, configure it, finish
// downloading, finish starting the controller, and then stop the DTM.
TEST_F(DataTypeManagerImplTest, ConfigureOne) {}

TEST_F(DataTypeManagerImplTest, ConfigureOneThatSkipsEngineConnection) {}

// Set up a DTM with a single controller, configure it, but stop it
// before finishing the download.  It should still be safe to run the
// download callback even after the DTM is stopped and destroyed.
TEST_F(DataTypeManagerImplTest, ConfigureOneStopWhileDownloadPending) {}

// Set up a DTM with a single controller, configure it, finish
// downloading, but stop the DTM before the controller finishes
// starting up.  It should still be safe to finish starting up the
// controller even after the DTM is stopped.
TEST_F(DataTypeManagerImplTest, ConfigureOneStopWhileStartingModel) {}

// Set up a DTM with a single controller.  Then:
//
//   1) Configure.
//   2) Finish the download for step 1.
//   3) The download determines a crypto error.
//   4) Complete download for the reconfiguration without the controller.
//   5) Stop the DTM.
TEST_F(DataTypeManagerImplTest, OneWaitingForCrypto) {}

// Set up a DTM with two controllers.  Then:
//
//   1) Configure with first controller.
//   2) Finish the download for step 1.
//   3) Configure with both controllers.
//   4) Finish the download for step 3.
//   5) Stop the DTM.
TEST_F(DataTypeManagerImplTest, ConfigureOneThenBoth) {}

// Set up a DTM with two controllers.  Then:
//
//   1) Configure with first controller.
//   2) Finish the download for step 1.
//   3) Configure with second controller.
//   4) Finish the download for step 3.
//   5) Stop the DTM.
TEST_F(DataTypeManagerImplTest, ConfigureOneThenSwitch) {}

TEST_F(DataTypeManagerImplTest, ConfigureModelLoading) {}

// Set up a DTM with one controller. Then configure and start the controller
// with a datatype error. DTM should proceed without the affected datatype.
TEST_F(DataTypeManagerImplTest, OneFailingController) {}

// Set up a DTM with two controllers.  Then:
//
//   1) Configure with first controller.
//   2) Configure with both controllers.
//   3) Finish the download for step 1.
//   4) Finish the download for step 2.
//   5) Stop the DTM.
TEST_F(DataTypeManagerImplTest, ConfigureWhileDownloadPending) {}

// Set up a DTM with two controllers.  Then:
//   1) Configure with first controller.
//   2) Configure with both controllers.
//   3) Finish the download for step 1 with a failed data type.
//   4) Finish the download for step 2 successfully.
//   5) Stop the DTM.
//
// The failure from step 3 should be ignored since there's a
// reconfigure pending from step 2.
TEST_F(DataTypeManagerImplTest, ConfigureWhileDownloadPendingWithFailure) {}

// Tests a Purge then Configure.  This is similar to the sequence of
// operations that would be invoked by the BackendMigrator.
TEST_F(DataTypeManagerImplTest, MigrateAll) {}

// Test receipt of a Configure request while a purge is in flight.
TEST_F(DataTypeManagerImplTest, ConfigureDuringPurge) {}

TEST_F(DataTypeManagerImplTest, PrioritizedConfiguration) {}

TEST_F(DataTypeManagerImplTest, GetDataTypesForTransportOnlyMode) {}

TEST_F(DataTypeManagerImplTest, ShouldPrioritizePasswordsOverInvitations) {}

TEST_F(DataTypeManagerImplTest, PrioritizedConfigurationReconfigure) {}

TEST_F(DataTypeManagerImplTest, PrioritizedConfigurationStop) {}

TEST_F(DataTypeManagerImplTest, PrioritizedConfigurationDownloadError) {}

TEST_F(DataTypeManagerImplTest, FilterDesiredTypes) {}

TEST_F(DataTypeManagerImplTest, FailingPreconditionKeepData) {}

TEST_F(DataTypeManagerImplTest, FailingPreconditionClearData) {}

// Tests that unready types are not started after ResetDataTypeErrors and
// reconfiguration.
TEST_F(DataTypeManagerImplTest, UnreadyTypeResetReconfigure) {}

TEST_F(DataTypeManagerImplTest, UnreadyTypeLaterReady) {}

TEST_F(DataTypeManagerImplTest, MultipleUnreadyTypesLaterReadyAtTheSameTime) {}

TEST_F(DataTypeManagerImplTest, MultipleUnreadyTypesLaterOneOfThemReady) {}

TEST_F(DataTypeManagerImplTest,
       NoOpDataTypePreconditionChangedWhileStillUnready) {}

TEST_F(DataTypeManagerImplTest,
       NoOpDataTypePreconditionChangedWhileStillReady) {}

TEST_F(DataTypeManagerImplTest, ModelLoadError) {}

// Checks that DTM handles the case when a controller is already in a FAILED
// state at the time the DTM is created. Regression test for crbug.com/967344.
TEST_F(DataTypeManagerImplTest, ErrorBeforeStartup) {}

// Test that sync configures properly if all types are already downloaded.
TEST_F(DataTypeManagerImplTest, AllTypesReady) {}

// Test that DataTypeManagerImpl delays configuration until all data types
// loaded their models.
TEST_F(DataTypeManagerImplTest, DelayConfigureForUSSTypes) {}

// Test that when encryption fails for a given type, the corresponding
// data type is not activated.
TEST_F(DataTypeManagerImplTest, ConnectDataTypeOnEncryptionError) {}

// Test that Connect is not called for datatypes that failed
// LoadModels().
TEST_F(DataTypeManagerImplTest, ConnectDataTypeAfterLoadModelsError) {}

// Test that Stop with DISABLE_SYNC_AND_CLEAR_DATA calls DTC Stop with
// CLEAR_METADATA for active data types.
TEST_F(DataTypeManagerImplTest, StopWithDisableSync) {}

TEST_F(DataTypeManagerImplTest, PurgeDataOnStarting) {}

TEST_F(DataTypeManagerImplTest, PurgeDataOnReconfiguring) {}

TEST_F(DataTypeManagerImplTest, ShouldRecordInitialConfigureTimeHistogram) {}

TEST_F(DataTypeManagerImplTest, ShouldRecordSubsequentConfigureTimeHistogram) {}

// Regression test for crbug.com/1286204: Reentrant calls to Configure()
// shouldn't crash (or trigger DCHECKs).
TEST_F(DataTypeManagerImplTest, ReentrantConfigure) {}

TEST_F(DataTypeManagerImplTest, ProvideDebugInfo) {}

TEST_F(DataTypeManagerImplTest, ShouldDoNothingForAlreadyStoppedTypes) {}

TEST_F(DataTypeManagerImplTest, ShouldDoNothingForAlreadyFailedTypes) {}

// Tests that data types which time out are ultimately skipped during
// configuration.
TEST_F(DataTypeManagerImplTest, ShouldFinishConfigureIfSomeTypesTimeout) {}

// Tests that if the load-models timeout triggers after a Stop(), this doesn't
// have any adverse effects.
// Regression test for crbug.com/333865298.
TEST_F(DataTypeManagerImplTest, TimeoutAfterStop) {}

TEST_F(DataTypeManagerImplTest, ShouldUpdateDataTypeStatusWhileStopped) {}

TEST_F(DataTypeManagerImplTest, ShouldReconfigureOnPreconditionChanged) {}

// Tests that failure of data type in STOPPING state is handled during
// configuration.
// Regression test for crbug.com/1477324.
TEST_F(DataTypeManagerImplTest, ShouldHandleStoppingTypesFailure) {}

// Tests that failure of data type in NOT_RUNNING state is handled during
// configuration.
// Regression test for crbug.com/1477324.
TEST_F(DataTypeManagerImplTest, ShouldHandleStoppedTypesFailure) {}

TEST_F(DataTypeManagerImplTest, ClearMetadataWhileStoppedExceptFor) {}

}  // namespace

}  // namespace syncer