| 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 browser_sync { | 7 namespace browser_sync { |
| 8 namespace sessions { | 8 namespace sessions { |
| 9 namespace test_util { | 9 namespace test_util { |
| 10 | 10 |
| 11 void SimulateHasMoreToSync(sessions::SyncSession* session, | 11 void SimulateHasMoreToSync(sessions::SyncSession* session, |
| 12 SyncerStep begin, SyncerStep end) { | 12 SyncerStep begin, SyncerStep end) { |
| 13 session->mutable_status_controller()->update_conflicts_resolved(true); | 13 session->mutable_status_controller()->update_conflicts_resolved(true); |
| 14 ASSERT_TRUE(session->HasMoreToSync()); | 14 ASSERT_TRUE(session->HasMoreToSync()); |
| 15 } | 15 } |
| 16 | 16 |
| 17 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session, | 17 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session, |
| 18 SyncerStep begin, SyncerStep end) { | 18 SyncerStep begin, SyncerStep end) { |
| 19 session->mutable_status_controller()->set_last_download_updates_result( | 19 session->mutable_status_controller()->set_last_download_updates_result( |
| 20 SERVER_RETURN_TRANSIENT_ERROR); | 20 SERVER_RETURN_TRANSIENT_ERROR); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void SimulateCommitFailed(sessions::SyncSession* session, | 23 void SimulateCommitFailed(sessions::SyncSession* session, |
| 24 SyncerStep begin, SyncerStep end) { | 24 SyncerStep begin, SyncerStep end) { |
| 25 session->mutable_status_controller()->set_last_post_commit_result( | 25 session->mutable_status_controller()->set_commit_result( |
| 26 SERVER_RETURN_TRANSIENT_ERROR); | 26 SERVER_RETURN_TRANSIENT_ERROR); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void SimulateConnectionFailure(sessions::SyncSession* session, | 29 void SimulateConnectionFailure(sessions::SyncSession* session, |
| 30 SyncerStep begin, SyncerStep end) { | 30 SyncerStep begin, SyncerStep end) { |
| 31 session->mutable_status_controller()->set_last_download_updates_result( | 31 session->mutable_status_controller()->set_last_download_updates_result( |
| 32 NETWORK_CONNECTION_UNAVAILABLE); | 32 NETWORK_CONNECTION_UNAVAILABLE); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void SimulateSuccess(sessions::SyncSession* session, | 35 void SimulateSuccess(sessions::SyncSession* session, |
| 36 SyncerStep begin, SyncerStep end) { | 36 SyncerStep begin, SyncerStep end) { |
| 37 if (session->HasMoreToSync()) { | 37 if (session->HasMoreToSync()) { |
| 38 ADD_FAILURE() << "Shouldn't have more to sync"; | 38 ADD_FAILURE() << "Shouldn't have more to sync"; |
| 39 } | 39 } |
| 40 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); | 40 ASSERT_EQ(0U, session->status_controller().num_server_changes_remaining()); |
| 41 session->SetFinished(); | 41 session->SetFinished(); |
| 42 if (end == SYNCER_END) { | 42 if (end == SYNCER_END) { |
| 43 session->mutable_status_controller()->set_last_download_updates_result( | 43 session->mutable_status_controller()->set_last_download_updates_result( |
| 44 SYNCER_OK); | 44 SYNCER_OK); |
| 45 session->mutable_status_controller()->set_last_post_commit_result( | 45 session->mutable_status_controller()->set_commit_result(SYNCER_OK); |
| 46 SYNCER_OK); | |
| 47 session->mutable_status_controller()-> | |
| 48 set_last_process_commit_response_result(SYNCER_OK); | |
| 49 } | 46 } |
| 50 } | 47 } |
| 51 | 48 |
| 52 void SimulateThrottledImpl(sessions::SyncSession* session, | 49 void SimulateThrottledImpl(sessions::SyncSession* session, |
| 53 const base::TimeDelta& delta) { | 50 const base::TimeDelta& delta) { |
| 54 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta); | 51 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta); |
| 55 } | 52 } |
| 56 | 53 |
| 57 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, | 54 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, |
| 58 const base::TimeDelta& new_poll) { | 55 const base::TimeDelta& new_poll) { |
| 59 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); | 56 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); |
| 60 } | 57 } |
| 61 | 58 |
| 62 void SimulateSessionsCommitDelayUpdateImpl(sessions::SyncSession* session, | 59 void SimulateSessionsCommitDelayUpdateImpl(sessions::SyncSession* session, |
| 63 const base::TimeDelta& new_delay) { | 60 const base::TimeDelta& new_delay) { |
| 64 session->delegate()->OnReceivedSessionsCommitDelay(new_delay); | 61 session->delegate()->OnReceivedSessionsCommitDelay(new_delay); |
| 65 } | 62 } |
| 66 | 63 |
| 67 } // namespace test_util | 64 } // namespace test_util |
| 68 } // namespace sessions | 65 } // namespace sessions |
| 69 } // namespace browser_sync | 66 } // namespace browser_sync |
| OLD | NEW |