| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/sessions/test_util.h" | 5 #include "chrome/browser/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 session->status_controller()->update_conflicts_resolved(true); | 13 session->status_controller()->update_conflicts_resolved(true); |
| 13 ASSERT_TRUE(session->HasMoreToSync()); | 14 ASSERT_TRUE(session->HasMoreToSync()); |
| 14 } | 15 } |
| 15 | 16 |
| 16 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session) { | 17 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session, |
| 18 SyncerStep begin, SyncerStep end) { |
| 17 // Note that a non-zero value of changes_remaining once a session has | 19 // Note that a non-zero value of changes_remaining once a session has |
| 18 // completed implies that the Syncer was unable to exhaust this count during | 20 // completed implies that the Syncer was unable to exhaust this count during |
| 19 // the GetUpdates cycle. This is an indication that an error occurred. | 21 // the GetUpdates cycle. This is an indication that an error occurred. |
| 20 session->status_controller()->set_num_server_changes_remaining(1); | 22 session->status_controller()->set_num_server_changes_remaining(1); |
| 21 } | 23 } |
| 22 | 24 |
| 23 void SimulateCommitFailed(sessions::SyncSession* session) { | 25 void SimulateCommitFailed(sessions::SyncSession* session, |
| 26 SyncerStep begin, SyncerStep end) { |
| 24 // Note that a non-zero number of unsynced handles once a session has | 27 // Note that a non-zero number of unsynced handles once a session has |
| 25 // completed implies that the Syncer was unable to make forward progress | 28 // completed implies that the Syncer was unable to make forward progress |
| 26 // during a commit, indicating an error occurred. | 29 // during a commit, indicating an error occurred. |
| 27 // See implementation of SyncSession::HasMoreToSync. | 30 // See implementation of SyncSession::HasMoreToSync. |
| 28 std::vector<int64> handles; | 31 std::vector<int64> handles; |
| 29 handles.push_back(1); | 32 handles.push_back(1); |
| 30 session->status_controller()->set_unsynced_handles(handles); | 33 session->status_controller()->set_unsynced_handles(handles); |
| 31 } | 34 } |
| 32 | 35 |
| 33 void SimulateSuccess(sessions::SyncSession* session) { | 36 void SimulateSuccess(sessions::SyncSession* session, |
| 37 SyncerStep begin, SyncerStep end) { |
| 34 if (session->HasMoreToSync()) { | 38 if (session->HasMoreToSync()) { |
| 35 ADD_FAILURE() << "Shouldn't have more to sync"; | 39 ADD_FAILURE() << "Shouldn't have more to sync"; |
| 36 } | 40 } |
| 37 ASSERT_EQ(0U, session->status_controller()->num_server_changes_remaining()); | 41 ASSERT_EQ(0U, session->status_controller()->num_server_changes_remaining()); |
| 38 ASSERT_EQ(0U, session->status_controller()->unsynced_handles().size()); | 42 ASSERT_EQ(0U, session->status_controller()->unsynced_handles().size()); |
| 39 } | 43 } |
| 40 | 44 |
| 41 void SimulateThrottledImpl(sessions::SyncSession* session, | 45 void SimulateThrottledImpl(sessions::SyncSession* session, |
| 42 const base::TimeDelta& delta) { | 46 const base::TimeDelta& delta) { |
| 43 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta); | 47 session->delegate()->OnSilencedUntil(base::TimeTicks::Now() + delta); |
| 44 } | 48 } |
| 45 | 49 |
| 46 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, | 50 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, |
| 47 const base::TimeDelta& new_poll) { | 51 const base::TimeDelta& new_poll) { |
| 48 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); | 52 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll); |
| 49 } | 53 } |
| 50 | 54 |
| 51 } // namespace test_util | 55 } // namespace test_util |
| 52 } // namespace sessions | 56 } // namespace sessions |
| 53 } // namespace browser_sync | 57 } // namespace browser_sync |
| OLD | NEW |