| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/sync/engine_impl/cycle/test_util.h" |
| 6 |
| 7 #include <map> |
| 8 |
| 9 namespace syncer { |
| 10 namespace test_util { |
| 11 |
| 12 void SimulateGetEncryptionKeyFailed( |
| 13 ModelTypeSet requsted_types, |
| 14 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 15 SyncCycle* cycle) { |
| 16 cycle->mutable_status_controller()->set_last_get_key_result( |
| 17 SERVER_RESPONSE_VALIDATION_FAILED); |
| 18 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 19 SYNCER_OK); |
| 20 } |
| 21 |
| 22 void SimulateConfigureSuccess( |
| 23 ModelTypeSet requsted_types, |
| 24 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 25 SyncCycle* cycle) { |
| 26 cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK); |
| 27 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 28 SYNCER_OK); |
| 29 } |
| 30 |
| 31 void SimulateConfigureFailed( |
| 32 ModelTypeSet requsted_types, |
| 33 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 34 SyncCycle* cycle) { |
| 35 cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK); |
| 36 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 37 SERVER_RETURN_TRANSIENT_ERROR); |
| 38 } |
| 39 |
| 40 void SimulateConfigureConnectionFailure( |
| 41 ModelTypeSet requsted_types, |
| 42 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source, |
| 43 SyncCycle* cycle) { |
| 44 cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK); |
| 45 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 46 NETWORK_CONNECTION_UNAVAILABLE); |
| 47 } |
| 48 |
| 49 void SimulateNormalSuccess(ModelTypeSet requested_types, |
| 50 NudgeTracker* nudge_tracker, |
| 51 SyncCycle* cycle) { |
| 52 cycle->mutable_status_controller()->set_commit_result(SYNCER_OK); |
| 53 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 54 SYNCER_OK); |
| 55 } |
| 56 |
| 57 void SimulateDownloadUpdatesFailed(ModelTypeSet requested_types, |
| 58 NudgeTracker* nudge_tracker, |
| 59 SyncCycle* cycle) { |
| 60 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 61 SERVER_RETURN_TRANSIENT_ERROR); |
| 62 } |
| 63 |
| 64 void SimulateCommitFailed(ModelTypeSet requested_types, |
| 65 NudgeTracker* nudge_tracker, |
| 66 SyncCycle* cycle) { |
| 67 cycle->mutable_status_controller()->set_last_get_key_result(SYNCER_OK); |
| 68 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 69 SYNCER_OK); |
| 70 cycle->mutable_status_controller()->set_commit_result( |
| 71 SERVER_RETURN_TRANSIENT_ERROR); |
| 72 } |
| 73 |
| 74 void SimulateConnectionFailure(ModelTypeSet requested_types, |
| 75 NudgeTracker* nudge_tracker, |
| 76 SyncCycle* cycle) { |
| 77 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 78 NETWORK_CONNECTION_UNAVAILABLE); |
| 79 } |
| 80 |
| 81 void SimulatePollSuccess(ModelTypeSet requested_types, SyncCycle* cycle) { |
| 82 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 83 SYNCER_OK); |
| 84 } |
| 85 |
| 86 void SimulatePollFailed(ModelTypeSet requested_types, SyncCycle* cycle) { |
| 87 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 88 SERVER_RETURN_TRANSIENT_ERROR); |
| 89 } |
| 90 |
| 91 void SimulateThrottledImpl(SyncCycle* cycle, const base::TimeDelta& delta) { |
| 92 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 93 SERVER_RETURN_THROTTLED); |
| 94 cycle->delegate()->OnThrottled(delta); |
| 95 } |
| 96 |
| 97 void SimulateTypesThrottledImpl(SyncCycle* cycle, |
| 98 ModelTypeSet types, |
| 99 const base::TimeDelta& delta) { |
| 100 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 101 SERVER_RETURN_THROTTLED); |
| 102 cycle->delegate()->OnTypesThrottled(types, delta); |
| 103 } |
| 104 |
| 105 void SimulatePollIntervalUpdateImpl(ModelTypeSet requested_types, |
| 106 SyncCycle* cycle, |
| 107 const base::TimeDelta& new_poll) { |
| 108 SimulatePollSuccess(requested_types, cycle); |
| 109 cycle->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); |
| 110 } |
| 111 |
| 112 void SimulateSessionsCommitDelayUpdateImpl(ModelTypeSet requested_types, |
| 113 NudgeTracker* nudge_tracker, |
| 114 SyncCycle* cycle, |
| 115 const base::TimeDelta& new_delay) { |
| 116 SimulateNormalSuccess(requested_types, nudge_tracker, cycle); |
| 117 std::map<ModelType, base::TimeDelta> delay_map; |
| 118 delay_map[SESSIONS] = new_delay; |
| 119 cycle->delegate()->OnReceivedCustomNudgeDelays(delay_map); |
| 120 } |
| 121 |
| 122 void SimulateGuRetryDelayCommandImpl(SyncCycle* cycle, base::TimeDelta delay) { |
| 123 cycle->mutable_status_controller()->set_last_download_updates_result( |
| 124 SYNCER_OK); |
| 125 cycle->delegate()->OnReceivedGuRetryDelay(delay); |
| 126 } |
| 127 |
| 128 } // namespace test_util |
| 129 } // namespace syncer |
| OLD | NEW |