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

Unified Diff: components/sync/engine_impl/cycle/test_util.cc

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 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
Index: components/sync/engine_impl/cycle/test_util.cc
diff --git a/components/sync/engine_impl/cycle/test_util.cc b/components/sync/engine_impl/cycle/test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..347c994918655e586c1234cd583059f2c67337f4
--- /dev/null
+++ b/components/sync/engine_impl/cycle/test_util.cc
@@ -0,0 +1,129 @@
+// 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 "components/sync/engine_impl/cycle/test_util.h"
+
+#include <map>
+
+namespace syncer {
+namespace test_util {
+
+void SimulateGetEncryptionKeyFailed(
+ ModelTypeSet requsted_types,
+ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_get_key_result(
+ SERVER_RESPONSE_VALIDATION_FAILED);
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SYNCER_OK);
+}
+
+void SimulateConfigureSuccess(
+ ModelTypeSet requsted_types,
+ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SYNCER_OK);
+}
+
+void SimulateConfigureFailed(
+ ModelTypeSet requsted_types,
+ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SERVER_RETURN_TRANSIENT_ERROR);
+}
+
+void SimulateConfigureConnectionFailure(
+ ModelTypeSet requsted_types,
+ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ NETWORK_CONNECTION_UNAVAILABLE);
+}
+
+void SimulateNormalSuccess(ModelTypeSet requested_types,
+ NudgeTracker* nudge_tracker,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_commit_result(SYNCER_OK);
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SYNCER_OK);
+}
+
+void SimulateDownloadUpdatesFailed(ModelTypeSet requested_types,
+ NudgeTracker* nudge_tracker,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SERVER_RETURN_TRANSIENT_ERROR);
+}
+
+void SimulateCommitFailed(ModelTypeSet requested_types,
+ NudgeTracker* nudge_tracker,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SYNCER_OK);
+ cycle->mutable_status_controller()->set_commit_result(
+ SERVER_RETURN_TRANSIENT_ERROR);
+}
+
+void SimulateConnectionFailure(ModelTypeSet requested_types,
+ NudgeTracker* nudge_tracker,
+ SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ NETWORK_CONNECTION_UNAVAILABLE);
+}
+
+void SimulatePollSuccess(ModelTypeSet requested_types, SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SYNCER_OK);
+}
+
+void SimulatePollFailed(ModelTypeSet requested_types, SyncCycle* cycle) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SERVER_RETURN_TRANSIENT_ERROR);
+}
+
+void SimulateThrottledImpl(SyncCycle* cycle, const base::TimeDelta& delta) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SERVER_RETURN_THROTTLED);
+ cycle->delegate()->OnThrottled(delta);
+}
+
+void SimulateTypesThrottledImpl(SyncCycle* cycle,
+ ModelTypeSet types,
+ const base::TimeDelta& delta) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SERVER_RETURN_THROTTLED);
+ cycle->delegate()->OnTypesThrottled(types, delta);
+}
+
+void SimulatePollIntervalUpdateImpl(ModelTypeSet requested_types,
+ SyncCycle* cycle,
+ const base::TimeDelta& new_poll) {
+ SimulatePollSuccess(requested_types, cycle);
+ cycle->delegate()->OnReceivedLongPollIntervalUpdate(new_poll);
+}
+
+void SimulateSessionsCommitDelayUpdateImpl(ModelTypeSet requested_types,
+ NudgeTracker* nudge_tracker,
+ SyncCycle* cycle,
+ const base::TimeDelta& new_delay) {
+ SimulateNormalSuccess(requested_types, nudge_tracker, cycle);
+ std::map<ModelType, base::TimeDelta> delay_map;
+ delay_map[SESSIONS] = new_delay;
+ cycle->delegate()->OnReceivedCustomNudgeDelays(delay_map);
+}
+
+void SimulateGuRetryDelayCommandImpl(SyncCycle* cycle, base::TimeDelta delay) {
+ cycle->mutable_status_controller()->set_last_download_updates_result(
+ SYNCER_OK);
+ cycle->delegate()->OnReceivedGuRetryDelay(delay);
+}
+
+} // namespace test_util
+} // namespace syncer
« no previous file with comments | « components/sync/engine_impl/cycle/test_util.h ('k') | components/sync/engine_impl/directory_commit_contribution.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698