| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sync/sessions/test_util.h" | 5 #include "sync/sessions/test_util.h" |
| 6 | 6 |
| 7 namespace syncer { | 7 namespace syncer { |
| 8 namespace sessions { | 8 namespace sessions { |
| 9 namespace test_util { | 9 namespace test_util { |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 } | 74 } |
| 75 | 75 |
| 76 void SimulateConnectionFailure( | 76 void SimulateConnectionFailure( |
| 77 ModelTypeSet requested_types, | 77 ModelTypeSet requested_types, |
| 78 const sessions::NudgeTracker& nudge_tracker, | 78 const sessions::NudgeTracker& nudge_tracker, |
| 79 sessions::SyncSession* session) { | 79 sessions::SyncSession* session) { |
| 80 session->mutable_status_controller()->set_last_download_updates_result( | 80 session->mutable_status_controller()->set_last_download_updates_result( |
| 81 NETWORK_CONNECTION_UNAVAILABLE); | 81 NETWORK_CONNECTION_UNAVAILABLE); |
| 82 } | 82 } |
| 83 | 83 |
| 84 void SimulatePollSuccess(ModelTypeSet requested_types, | 84 void SimulatePollRetrySuccess(ModelTypeSet requested_types, |
| 85 sessions::SyncSession* session) { | 85 sessions::SyncSession* session) { |
| 86 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); | 86 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); |
| 87 session->mutable_status_controller()->set_last_download_updates_result( | 87 session->mutable_status_controller()->set_last_download_updates_result( |
| 88 SYNCER_OK); | 88 SYNCER_OK); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void SimulatePollFailed(ModelTypeSet requested_types, | 91 void SimulatePollRetryFailed(ModelTypeSet requested_types, |
| 92 sessions::SyncSession* session) { | 92 sessions::SyncSession* session) { |
| 93 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); | 93 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); |
| 94 session->mutable_status_controller()->set_last_download_updates_result( | 94 session->mutable_status_controller()->set_last_download_updates_result( |
| 95 SERVER_RETURN_TRANSIENT_ERROR); | 95 SERVER_RETURN_TRANSIENT_ERROR); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void SimulateThrottledImpl( | 98 void SimulateThrottledImpl( |
| 99 sessions::SyncSession* session, | 99 sessions::SyncSession* session, |
| 100 const base::TimeDelta& delta) { | 100 const base::TimeDelta& delta) { |
| 101 session->mutable_status_controller()->set_last_download_updates_result( | 101 session->mutable_status_controller()->set_last_download_updates_result( |
| 102 SERVER_RETURN_THROTTLED); | 102 SERVER_RETURN_THROTTLED); |
| 103 session->delegate()->OnThrottled(delta); | 103 session->delegate()->OnThrottled(delta); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void SimulateTypesThrottledImpl( | 106 void SimulateTypesThrottledImpl( |
| 107 sessions::SyncSession* session, | 107 sessions::SyncSession* session, |
| 108 ModelTypeSet types, | 108 ModelTypeSet types, |
| 109 const base::TimeDelta& delta) { | 109 const base::TimeDelta& delta) { |
| 110 session->mutable_status_controller()->set_last_download_updates_result( | 110 session->mutable_status_controller()->set_last_download_updates_result( |
| 111 SERVER_RETURN_THROTTLED); | 111 SERVER_RETURN_THROTTLED); |
| 112 session->delegate()->OnTypesThrottled(types, delta); | 112 session->delegate()->OnTypesThrottled(types, delta); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void SimulatePollIntervalUpdateImpl( | 115 void SimulatePollIntervalUpdateImpl( |
| 116 ModelTypeSet requested_types, | 116 ModelTypeSet requested_types, |
| 117 sessions::SyncSession* session, | 117 sessions::SyncSession* session, |
| 118 const base::TimeDelta& new_poll) { | 118 const base::TimeDelta& new_poll) { |
| 119 SimulatePollSuccess(requested_types, session); | 119 SimulatePollRetrySuccess(requested_types, session); |
| 120 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); | 120 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void SimulateSessionsCommitDelayUpdateImpl( | 123 void SimulateSessionsCommitDelayUpdateImpl( |
| 124 ModelTypeSet requested_types, | 124 ModelTypeSet requested_types, |
| 125 const sessions::NudgeTracker& nudge_tracker, | 125 const sessions::NudgeTracker& nudge_tracker, |
| 126 sessions::SyncSession* session, | 126 sessions::SyncSession* session, |
| 127 const base::TimeDelta& new_delay) { | 127 const base::TimeDelta& new_delay) { |
| 128 SimulateNormalSuccess(requested_types, nudge_tracker, session); | 128 SimulateNormalSuccess(requested_types, nudge_tracker, session); |
| 129 session->delegate()->OnReceivedSessionsCommitDelay(new_delay); | 129 session->delegate()->OnReceivedSessionsCommitDelay(new_delay); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void SimulateGuRetryDelayCommandImpl(sessions::SyncSession* session, |
| 133 base::TimeDelta delay) { |
| 134 session->mutable_status_controller()->set_last_download_updates_result( |
| 135 SYNCER_OK); |
| 136 session->delegate()->OnReceivedGuRetryDelay(delay); |
| 137 } |
| 138 |
| 132 } // namespace test_util | 139 } // namespace test_util |
| 133 } // namespace sessions | 140 } // namespace sessions |
| 134 } // namespace syncer | 141 } // namespace syncer |
| OLD | NEW |