Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: sync/engine/backoff_delay_provider_unittest.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/backoff_delay_provider.cc ('k') | sync/engine/clear_server_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/backoff_delay_provider_unittest.cc
diff --git a/sync/engine/backoff_delay_provider_unittest.cc b/sync/engine/backoff_delay_provider_unittest.cc
deleted file mode 100644
index 858e55e5bab4fd5b11de7b3592c0cc50497a46fa..0000000000000000000000000000000000000000
--- a/sync/engine/backoff_delay_provider_unittest.cc
+++ /dev/null
@@ -1,130 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "sync/engine/backoff_delay_provider.h"
-
-#include <memory>
-
-#include "base/time/time.h"
-#include "sync/internal_api/public/engine/polling_constants.h"
-#include "sync/internal_api/public/sessions/model_neutral_state.h"
-#include "sync/internal_api/public/util/syncer_error.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using base::TimeDelta;
-
-namespace syncer {
-
-class BackoffDelayProviderTest : public testing::Test {};
-
-TEST_F(BackoffDelayProviderTest, GetRecommendedDelay) {
- std::unique_ptr<BackoffDelayProvider> delay(
- BackoffDelayProvider::FromDefaults());
- EXPECT_EQ(TimeDelta::FromSeconds(1),
- delay->GetDelay(TimeDelta::FromSeconds(0)));
- EXPECT_LE(TimeDelta::FromSeconds(1),
- delay->GetDelay(TimeDelta::FromSeconds(1)));
- EXPECT_LE(TimeDelta::FromSeconds(50),
- delay->GetDelay(TimeDelta::FromSeconds(50)));
- EXPECT_LE(TimeDelta::FromSeconds(10),
- delay->GetDelay(TimeDelta::FromSeconds(10)));
- EXPECT_EQ(TimeDelta::FromSeconds(kMaxBackoffSeconds),
- delay->GetDelay(TimeDelta::FromSeconds(kMaxBackoffSeconds)));
- EXPECT_EQ(TimeDelta::FromSeconds(kMaxBackoffSeconds),
- delay->GetDelay(TimeDelta::FromSeconds(kMaxBackoffSeconds + 1)));
-}
-
-TEST_F(BackoffDelayProviderTest, GetInitialDelay) {
- std::unique_ptr<BackoffDelayProvider> delay(
- BackoffDelayProvider::FromDefaults());
- sessions::ModelNeutralState state;
- state.last_get_key_result = SYNC_SERVER_ERROR;
- EXPECT_EQ(kInitialBackoffRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_get_key_result = UNSET;
- state.last_download_updates_result = SERVER_RETURN_MIGRATION_DONE;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = NETWORK_CONNECTION_UNAVAILABLE;
- EXPECT_EQ(kInitialBackoffRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR;
- EXPECT_EQ(kInitialBackoffRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED;
- EXPECT_EQ(kInitialBackoffRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = DATATYPE_TRIGGERED_RETRY;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = SYNCER_OK;
- // Note that updating credentials triggers a canary job, trumping
- // the initial delay, but in theory we still expect this function to treat
- // it like any other error in the system (except migration).
- state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL;
- EXPECT_EQ(kInitialBackoffRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.commit_result = SERVER_RETURN_MIGRATION_DONE;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.commit_result = NETWORK_CONNECTION_UNAVAILABLE;
- EXPECT_EQ(kInitialBackoffRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.commit_result = SERVER_RETURN_CONFLICT;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-}
-
-TEST_F(BackoffDelayProviderTest, GetInitialDelayWithOverride) {
- std::unique_ptr<BackoffDelayProvider> delay(
- BackoffDelayProvider::WithShortInitialRetryOverride());
- sessions::ModelNeutralState state;
- state.last_get_key_result = SYNC_SERVER_ERROR;
- EXPECT_EQ(kInitialBackoffShortRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_get_key_result = UNSET;
- state.last_download_updates_result = SERVER_RETURN_MIGRATION_DONE;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = SERVER_RETURN_TRANSIENT_ERROR;
- EXPECT_EQ(kInitialBackoffShortRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = SERVER_RESPONSE_VALIDATION_FAILED;
- EXPECT_EQ(kInitialBackoffShortRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = DATATYPE_TRIGGERED_RETRY;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.last_download_updates_result = SYNCER_OK;
- // Note that updating credentials triggers a canary job, trumping
- // the initial delay, but in theory we still expect this function to treat
- // it like any other error in the system (except migration).
- state.commit_result = SERVER_RETURN_INVALID_CREDENTIAL;
- EXPECT_EQ(kInitialBackoffShortRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.commit_result = SERVER_RETURN_MIGRATION_DONE;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-
- state.commit_result = SERVER_RETURN_CONFLICT;
- EXPECT_EQ(kInitialBackoffImmediateRetrySeconds,
- delay->GetInitialDelay(state).InSeconds());
-}
-
-} // namespace syncer
« no previous file with comments | « sync/engine/backoff_delay_provider.cc ('k') | sync/engine/clear_server_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698