#include "components/sync/engine/sync_scheduler_impl.h"
#include <stddef.h>
#include <stdint.h>
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "components/sync/base/extensions_activity.h"
#include "components/sync/engine/backoff_delay_provider.h"
#include "components/sync/engine/cancelation_signal.h"
#include "components/sync/engine/data_type_activation_response.h"
#include "components/sync/test/data_type_test_util.h"
#include "components/sync/test/fake_data_type_processor.h"
#include "components/sync/test/fake_sync_encryption_handler.h"
#include "components/sync/test/mock_connection_manager.h"
#include "components/sync/test/mock_invalidation.h"
#include "components/sync/test/mock_nudge_handler.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
TimeTicks;
_;
AtLeast;
DoAll;
Eq;
Invoke;
Mock;
Return;
WithArg;
WithArgs;
WithoutArgs;
namespace syncer {
namespace {
base::OnceClosure g_quit_closure_;
void SimulatePollSuccess(DataTypeSet requested_types, SyncCycle* cycle) { … }
void SimulatePollFailed(DataTypeSet requested_types, SyncCycle* cycle) { … }
ACTION_P(SimulateThrottled, throttle) { … }
ACTION_P2(SimulateTypeThrottled, type, throttle) { … }
ACTION_P(SimulatePartialFailure, type) { … }
ACTION_P(SimulatePollIntervalUpdate, new_poll) { … }
ACTION_P(SimulateGuRetryDelayCommand, delay) { … }
void SimulateGetEncryptionKeyFailed(DataTypeSet requsted_types,
sync_pb::SyncEnums::GetUpdatesOrigin origin,
SyncCycle* cycle) { … }
void SimulateConfigureSuccess(DataTypeSet requsted_types,
sync_pb::SyncEnums::GetUpdatesOrigin origin,
SyncCycle* cycle) { … }
void SimulateConfigureFailed(DataTypeSet requsted_types,
sync_pb::SyncEnums::GetUpdatesOrigin origin,
SyncCycle* cycle) { … }
void SimulateConfigureConnectionFailure(
DataTypeSet requsted_types,
sync_pb::SyncEnums::GetUpdatesOrigin origin,
SyncCycle* cycle) { … }
void SimulateNormalSuccess(DataTypeSet requested_types,
NudgeTracker* nudge_tracker,
SyncCycle* cycle) { … }
void SimulateDownloadUpdatesFailed(DataTypeSet requested_types,
NudgeTracker* nudge_tracker,
SyncCycle* cycle) { … }
void SimulateCommitFailed(DataTypeSet requested_types,
NudgeTracker* nudge_tracker,
SyncCycle* cycle) { … }
void SimulateConnectionFailure(DataTypeSet requested_types,
NudgeTracker* nudge_tracker,
SyncCycle* cycle) { … }
class MockSyncer : public Syncer { … };
std::unique_ptr<DataTypeActivationResponse> MakeFakeActivationResponse(
DataType data_type) { … }
MockSyncer::MockSyncer() : … { … }
SyncShareTimes;
void QuitLoopNow() { … }
void RunLoop() { … }
void PumpLoop() { … }
static const size_t kMinNumSamples = …;
}
class SyncSchedulerImplTest : public testing::Test { … };
const base::TickClock* SyncSchedulerImplTest::tick_clock_ = …;
void RecordSyncShareImpl(SyncShareTimes* times) { … }
ACTION_P2(RecordSyncShare, times, success) { … }
ACTION_P3(RecordSyncShareMultiple, times, quit_after, success) { … }
ACTION_P(StopScheduler, scheduler) { … }
ACTION(AddFailureAndQuitLoopNow) { … }
ACTION_P(QuitLoopNowAction, success) { … }
TEST_F(SyncSchedulerImplTest, Nudge) { … }
TEST_F(SyncSchedulerImplTest, NudgeForDisabledType) { … }
TEST_F(SyncSchedulerImplTest, Config) { … }
TEST_F(SyncSchedulerImplTest, ConfigWithBackingOff) { … }
TEST_F(SyncSchedulerImplTest, ConfigWithStop) { … }
TEST_F(SyncSchedulerImplTest, ConfigNoAccessToken) { … }
TEST_F(SyncSchedulerImplTest, ConfigNoAccessTokenLocalSync) { … }
TEST_F(SyncSchedulerImplTest, NudgeWithConfigWithBackingOff) { … }
TEST_F(SyncSchedulerImplTest, NudgeCoalescing) { … }
TEST_F(SyncSchedulerImplTest, NudgeCoalescingWithDifferentTimings) { … }
TEST_F(SyncSchedulerImplTest, NudgeWithStates) { … }
TEST_F(SyncSchedulerImplTest, Polling) { … }
TEST_F(SyncSchedulerImplTest, ShouldPollOnBrowserStartup) { … }
TEST_F(SyncSchedulerImplTest, ShouldUseInitialPollIntervalFromContext) { … }
TEST_F(SyncSchedulerImplTest, PollingPersistence) { … }
TEST_F(SyncSchedulerImplTest, PollingPersistenceBadClock) { … }
TEST_F(SyncSchedulerImplTest, PollIntervalUpdate) { … }
TEST_F(SyncSchedulerImplTest, ThrottlingDoesThrottle) { … }
TEST_F(SyncSchedulerImplTest, ThrottlingExpiresFromPoll) { … }
TEST_F(SyncSchedulerImplTest, ThrottlingExpiresFromNudge) { … }
TEST_F(SyncSchedulerImplTest, ThrottlingExpiresFromConfigure) { … }
TEST_F(SyncSchedulerImplTest, TypeThrottlingBlocksNudge) { … }
TEST_F(SyncSchedulerImplTest, TypeBackingOffBlocksNudge) { … }
TEST_F(SyncSchedulerImplTest, TypeBackingOffWillExpire) { … }
TEST_F(SyncSchedulerImplTest, TypeBackingOffAndThrottling) { … }
TEST_F(SyncSchedulerImplTest, TypeThrottlingBackingOffBlocksNudge) { … }
TEST_F(SyncSchedulerImplTest, TypeThrottlingDoesBlockOtherSources) { … }
TEST_F(SyncSchedulerImplTest, TypeBackingOffDoesBlockOtherSources) { … }
TEST_F(SyncSchedulerImplTest, ConfigurationMode) { … }
class BackoffTriggersSyncSchedulerImplTest : public SyncSchedulerImplTest { … };
TEST_F(BackoffTriggersSyncSchedulerImplTest, FailCommitOnce) { … }
TEST_F(BackoffTriggersSyncSchedulerImplTest, FailDownloadOnceThenSucceed) { … }
TEST_F(BackoffTriggersSyncSchedulerImplTest, FailCommitOnceThenSucceed) { … }
TEST_F(BackoffTriggersSyncSchedulerImplTest, FailDownloadTwice) { … }
TEST_F(BackoffTriggersSyncSchedulerImplTest, FailGetEncryptionKey) { … }
TEST_F(SyncSchedulerImplTest, BackoffDropsJobs) { … }
TEST_F(SyncSchedulerImplTest, BackoffElevation) { … }
TEST_F(SyncSchedulerImplTest, BackoffRelief) { … }
TEST_F(SyncSchedulerImplTest, TransientPollFailure) { … }
TEST_F(SyncSchedulerImplTest, StartWhenNotConnected) { … }
TEST_F(SyncSchedulerImplTest, SyncShareNotCalledWhenDisconnected) { … }
TEST_F(SyncSchedulerImplTest, ServerConnectionChangeDuringBackoff) { … }
TEST_F(SyncSchedulerImplTest, DoubleConnectionChangeDuringConfigure) { … }
TEST_F(SyncSchedulerImplTest, PollAfterAuthError) { … }
TEST_F(SyncSchedulerImplTest, SuccessfulRetry) { … }
TEST_F(SyncSchedulerImplTest, FailedRetry) { … }
ACTION_P2(VerifyRetryTimerDelay, scheduler_test, expected_delay) { … }
TEST_F(SyncSchedulerImplTest, ReceiveNewRetryDelay) { … }
TEST_F(SyncSchedulerImplTest, PartialFailureWillExponentialBackoff) { … }
TEST_F(SyncSchedulerImplTest, TypeBackoffAndSuccessfulSync) { … }
TEST_F(SyncSchedulerImplTest, TypeBackingOffAndFailureSync) { … }
TEST_F(SyncSchedulerImplTest, InterleavedNudgesStillRestart) { … }
}