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