1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
// 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_commit_result(SYNCER_OK);
cycle->delegate()->OnTypesThrottled(types, delta);
}
void SimulatePartialFailureImpl(SyncCycle* cycle, ModelTypeSet types) {
cycle->mutable_status_controller()->set_commit_result(SYNCER_OK);
cycle->delegate()->OnTypesBackedOff(types);
}
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
|