#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.h"
#include "build/chromeos_buildflags.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/sync/base/pref_names.h"
#include "components/sync/engine/sync_protocol_error.h"
#include "components/sync/service/sync_service_impl.h"
#include "components/sync/test/fake_data_type_controller.h"
#include "components/sync/test/fake_sync_engine.h"
#include "components/sync/test/fake_sync_engine_factory.h"
#include "components/sync/test/sync_client_mock.h"
#include "components/sync/test/sync_service_impl_bundle.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
ByMove;
Return;
namespace syncer {
namespace {
const char kEmail[] = …;
const char kTimeDeferredHistogram[] = …;
class MockSyncServiceObserver : public SyncServiceObserver { … };
}
class SyncServiceImplStartupTest : public testing::Test { … };
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncServiceImplStartupTest, StartFirstTime) { … }
#endif
TEST_F(SyncServiceImplStartupTest, StartNoCredentials) { … }
TEST_F(SyncServiceImplStartupTest, WebSignoutBeforeInitialization) { … }
TEST_F(SyncServiceImplStartupTest, WebSignoutDuringDeferredStartup) { … }
TEST_F(SyncServiceImplStartupTest, WebSignoutAfterInitialization) { … }
TEST_F(SyncServiceImplStartupTest, StartInvalidCredentials) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncServiceImplStartupTest, StartAshNoCredentials) {
ASSERT_FALSE(
engine_factory()->HasTransportDataIncludingFirstSync(gaia_id_hash()));
SimulateRefreshTokensNotLoadedYet();
SignInWithSyncConsentWithoutRefreshToken();
CreateSyncService();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(SyncService::TransportState::ACTIVE,
sync_service()->GetTransportState());
EXPECT_TRUE(
sync_service()->GetUserSettings()->IsInitialSyncFeatureSetupComplete());
}
TEST_F(SyncServiceImplStartupTest, StartAshFirstTime) {
ASSERT_FALSE(
engine_factory()->HasTransportDataIncludingFirstSync(gaia_id_hash()));
SignInWithSyncConsent();
CreateSyncService();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(SyncService::TransportState::ACTIVE,
sync_service()->GetTransportState());
}
#endif
TEST_F(SyncServiceImplStartupTest, ResetSyncViaDashboard) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncServiceImplStartupTest, HonorsExistingDatatypePrefs) { … }
#endif
TEST_F(SyncServiceImplStartupTest, ManagedStartup) { … }
TEST_F(SyncServiceImplStartupTest, SwitchManaged) { … }
TEST_F(SyncServiceImplStartupTest, StartDownloadFailed) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncServiceImplStartupTest, FullStartupSequenceFirstTime) { … }
#endif
TEST_F(SyncServiceImplStartupTest, FullStartupSequenceNthTime) { … }
TEST_F(SyncServiceImplStartupTest, DeferredStartInterruptedByDataType) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncServiceImplStartupTest, UserTriggeredStartIsNotDeferredStart) { … }
#endif
TEST_F(SyncServiceImplStartupTest,
ShouldClearMetadataForAlreadyDisabledTypesBeforeConfigurationDone) { … }
TEST_F(SyncServiceImplStartupTest,
ShouldClearMetadataForTypesDisabledBeforeInitCompletion) { … }
TEST_F(SyncServiceImplStartupTest,
ShouldClearMetadataForTypesDisabledWhileInit) { … }
}