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

#include <memory>

#include "base/test/task_environment.h"
#include "components/sync/base/sync_stop_metadata_fate.h"
#include "components/sync/service/configure_context.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 {

ConfigureContext BuildConfigureContext(SyncMode sync_mode = SyncMode::kFull) {}

}  // namespace

class MockModelLoadManagerDelegate : public ModelLoadManagerDelegate {};

class SyncModelLoadManagerTest : public testing::Test {};

// Start a type and make sure ModelLoadManager callst the |Start|
// method and calls the callback when it is done.
TEST_F(SyncModelLoadManagerTest, SimpleModelStart) {}

// Start a type, let it finish and then call stop.
TEST_F(SyncModelLoadManagerTest, StopAfterFinish) {}

// Test that a model that failed to load is reported and stopped properly.
TEST_F(SyncModelLoadManagerTest, ModelLoadFail) {}

// Test that a runtime error is handled by stopping the type.
TEST_F(SyncModelLoadManagerTest, StopAfterConfiguration) {}

// Test that OnAllDataTypesReadyForConfigure is called when all datatypes that
// require LoadModels before configuration are loaded.
TEST_F(SyncModelLoadManagerTest, OnAllDataTypesReadyForConfigure) {}

// Test that OnAllDataTypesReadyForConfigure() is called correctly after
// LoadModels fails for one of datatypes.
TEST_F(SyncModelLoadManagerTest,
       OnAllDataTypesReadyForConfigure_FailedLoadModels) {}

// Test that if one of the types fails while another is still being loaded then
// OnAllDataTypesReadyForConfgiure is still called correctly.
TEST_F(SyncModelLoadManagerTest,
       OnAllDataTypesReadyForConfigure_TypeFailedAfterLoadModels) {}

// Test that Stop clears metadata for disabled type.
TEST_F(SyncModelLoadManagerTest, StopClearMetadata) {}

// Test that stopping a single type clears the metadata for the disabled type.
TEST_F(SyncModelLoadManagerTest, StopDataType) {}

// Test that stopping a single type is ignored when the type is not running.
TEST_F(SyncModelLoadManagerTest, StopDataType_NotRunning) {}

// Test that Configure stops controllers with KEEP_METADATA for preferred
// types.
TEST_F(SyncModelLoadManagerTest, KeepsMetadataForPreferredDataType) {}

// Test that Configure stops controllers with CLEAR_METADATA for
// no-longer-preferred types.
TEST_F(SyncModelLoadManagerTest, ClearsMetadataForNotPreferredDataType) {}

TEST_F(SyncModelLoadManagerTest,
       SwitchFromFullSyncToTransportModeRestartsTypes) {}

TEST_F(SyncModelLoadManagerTest,
       SwitchFromTransportOnlyToFullSyncRestartsTypes) {}

TEST_F(SyncModelLoadManagerTest, ShouldClearMetadataAfterStopped) {}

TEST_F(SyncModelLoadManagerTest, ShouldClearMetadataIfNotRunning) {}

TEST_F(SyncModelLoadManagerTest, ShouldNotClearMetadataIfFailed) {}

// Test that Configure waits for desired types in STOPPING state to stop and
// reload before notifying data type manager.
TEST_F(SyncModelLoadManagerTest,
       ShouldWaitForStoppingDesiredTypesBeforeLoading) {}

// Test that Configure will not wait for no-longer-desired types in STOPPING
// state to stop before loading.
TEST_F(SyncModelLoadManagerTest,
       ShouldNotWaitForStoppingUndesiredTypesBeforeLoading) {}

// Test that if one of the type is stuck at loading,
// OnAllDataTypesReadyForConfigure will get called after a timeout.
TEST_F(SyncModelLoadManagerTest, ShouldTimeoutIfNotAllTypesLoaded) {}

// Test that if Stop() is called before all data types finish loading,
// OnAllDataTypesReadyForConfigure will *not* get called after a timeout.
// Regression test for crbug.com/333865298.
TEST_F(SyncModelLoadManagerTest, ShouldNotTimeoutAfterStop) {}

// Regression test for crbug.com/1506701.
// Tests that if LoadModels is called for a failed type, it's a no-op.
TEST_F(SyncModelLoadManagerTest, ShouldNotStartFailedTypesUponLoadModels) {}

// Regression test for crbug.com/1519806.
// Tests that stop callbacks for a type which is not in NOT_RUNNING state
// anymore are ignored.
TEST_F(SyncModelLoadManagerTest,
       ShouldHandleMultipleStopCallbacksForStoppingType) {}

}  // namespace syncer