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 // Utils to simulate various outcomes of a sync session. | 5 // Utils to simulate various outcomes of a sync session. |
6 #ifndef SYNC_SESSIONS_TEST_UTIL_H_ | 6 #ifndef SYNC_SESSIONS_TEST_UTIL_H_ |
7 #define SYNC_SESSIONS_TEST_UTIL_H_ | 7 #define SYNC_SESSIONS_TEST_UTIL_H_ |
8 | 8 |
9 #include "sync/engine/syncer.h" | 9 #include "sync/engine/syncer.h" |
10 #include "sync/sessions/sync_session.h" | 10 #include "sync/sessions/sync_session.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace syncer { | 14 namespace syncer { |
15 namespace sessions { | 15 namespace sessions { |
16 namespace test_util { | 16 namespace test_util { |
17 | 17 |
| 18 // Configure sync cycle successes and failures. |
18 void SimulateGetEncryptionKeyFailed(sessions::SyncSession* session, | 19 void SimulateGetEncryptionKeyFailed(sessions::SyncSession* session, |
19 SyncerStep begin, SyncerStep end); | 20 ModelTypeSet requested_types); |
| 21 void SimulateConfigureSuccess(sessions::SyncSession* session, |
| 22 ModelTypeSet requested_types); |
| 23 void SimulateConfigureFailed(sessions::SyncSession* session, |
| 24 ModelTypeSet requested_types); |
| 25 void SimulateConfigureConnectionFailure(sessions::SyncSession* session, |
| 26 ModelTypeSet requested_types); |
| 27 |
| 28 // Normal mode sync cycle successes and failures. |
| 29 void SimulateNormalSuccess(sessions::SyncSession* session, |
| 30 ModelTypeSet requested_types, |
| 31 const sessions::NudgeTracker& nudge_tracker); |
20 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session, | 32 void SimulateDownloadUpdatesFailed(sessions::SyncSession* session, |
21 SyncerStep begin, SyncerStep end); | 33 ModelTypeSet requested_types, |
| 34 const sessions::NudgeTracker& nudge_tracker); |
22 void SimulateCommitFailed(sessions::SyncSession* session, | 35 void SimulateCommitFailed(sessions::SyncSession* session, |
23 SyncerStep begin, SyncerStep end); | 36 ModelTypeSet requested_types, |
| 37 const sessions::NudgeTracker& nudge_tracker); |
24 void SimulateConnectionFailure(sessions::SyncSession* session, | 38 void SimulateConnectionFailure(sessions::SyncSession* session, |
25 SyncerStep begin, SyncerStep end); | 39 ModelTypeSet requested_types, |
26 void SimulateSuccess(sessions::SyncSession* session, | 40 const sessions::NudgeTracker& nudge_tracker); |
27 SyncerStep begin, SyncerStep end); | 41 |
| 42 // Poll successes and failures. |
| 43 void SimulatePollSuccess(sessions::SyncSession* session, |
| 44 ModelTypeSet requested_types); |
| 45 void SimulatePollFailed(sessions::SyncSession* session, |
| 46 ModelTypeSet requested_types); |
| 47 |
28 void SimulateThrottledImpl(sessions::SyncSession* session, | 48 void SimulateThrottledImpl(sessions::SyncSession* session, |
29 const base::TimeDelta& delta); | 49 const base::TimeDelta& delta); |
| 50 |
30 void SimulateTypesThrottledImpl( | 51 void SimulateTypesThrottledImpl( |
31 sessions::SyncSession* session, | 52 sessions::SyncSession* session, |
32 ModelTypeSet types, | 53 ModelTypeSet types, |
33 const base::TimeDelta& delta); | 54 const base::TimeDelta& delta); |
34 void SimulatePollIntervalUpdateImpl(sessions::SyncSession* session, | 55 |
| 56 // Works with poll cycles. |
| 57 void SimulatePollIntervalUpdateImpl( |
| 58 sessions::SyncSession* session, |
| 59 ModelTypeSet requested_types, |
35 const base::TimeDelta& new_poll); | 60 const base::TimeDelta& new_poll); |
36 void SimulateSessionsCommitDelayUpdateImpl(sessions::SyncSession* session, | 61 |
| 62 // Works with normal cycles. |
| 63 void SimulateSessionsCommitDelayUpdateImpl( |
| 64 sessions::SyncSession* session, |
| 65 ModelTypeSet requested_types, |
| 66 const sessions::NudgeTracker& nudge_tracker, |
37 const base::TimeDelta& new_delay); | 67 const base::TimeDelta& new_delay); |
38 | 68 |
39 ACTION_P(SimulateThrottled, throttle) { | 69 ACTION_P(SimulateThrottled, throttle) { |
40 SimulateThrottledImpl(arg0, throttle); | 70 SimulateThrottledImpl(arg0, throttle); |
41 } | 71 } |
42 | 72 |
43 ACTION_P2(SimulateTypesThrottled, types, throttle) { | 73 ACTION_P2(SimulateTypesThrottled, types, throttle) { |
44 SimulateTypesThrottledImpl(arg0, types, throttle); | 74 SimulateTypesThrottledImpl(arg0, types, throttle); |
45 } | 75 } |
46 | 76 |
47 ACTION_P(SimulatePollIntervalUpdate, poll) { | 77 ACTION_P(SimulatePollIntervalUpdate, poll) { |
48 SimulatePollIntervalUpdateImpl(arg0, poll); | 78 SimulatePollIntervalUpdateImpl(arg0, arg1, poll); |
49 } | 79 } |
50 | 80 |
51 ACTION_P(SimulateSessionsCommitDelayUpdate, poll) { | 81 ACTION_P(SimulateSessionsCommitDelayUpdate, poll) { |
52 SimulateSessionsCommitDelayUpdateImpl(arg0, poll); | 82 SimulateSessionsCommitDelayUpdateImpl(arg0, arg1, arg2, poll); |
53 } | 83 } |
54 | 84 |
55 } // namespace test_util | 85 } // namespace test_util |
56 } // namespace sessions | 86 } // namespace sessions |
57 } // namespace syncer | 87 } // namespace syncer |
58 | 88 |
59 #endif // SYNC_SESSIONS_TEST_UTIL_H_ | 89 #endif // SYNC_SESSIONS_TEST_UTIL_H_ |
OLD | NEW |