Revert of Implement IPC::ParamTraits<mojo::MessagePipeHandle> (patchset #4 id:60001...
[chromium-blink-merge.git] / sync / sessions / test_util.cc
blobc226a12d846072c9c8b9ba6e278d8105f1ed5064
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 #include "sync/sessions/test_util.h"
7 namespace syncer {
8 namespace sessions {
9 namespace test_util {
11 void SimulateGetEncryptionKeyFailed(
12 ModelTypeSet requsted_types,
13 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
14 sessions::SyncSession* session) {
15 session->mutable_status_controller()->set_last_get_key_result(
16 SERVER_RESPONSE_VALIDATION_FAILED);
17 session->mutable_status_controller()->set_last_download_updates_result(
18 SYNCER_OK);
21 void SimulateConfigureSuccess(
22 ModelTypeSet requsted_types,
23 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
24 sessions::SyncSession* session) {
25 session->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
26 session->mutable_status_controller()->set_last_download_updates_result(
27 SYNCER_OK);
30 void SimulateConfigureFailed(
31 ModelTypeSet requsted_types,
32 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
33 sessions::SyncSession* session) {
34 session->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
35 session->mutable_status_controller()->set_last_download_updates_result(
36 SERVER_RETURN_TRANSIENT_ERROR);
39 void SimulateConfigureConnectionFailure(
40 ModelTypeSet requsted_types,
41 sync_pb::GetUpdatesCallerInfo::GetUpdatesSource source,
42 sessions::SyncSession* session) {
43 session->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
44 session->mutable_status_controller()->set_last_download_updates_result(
45 NETWORK_CONNECTION_UNAVAILABLE);
48 void SimulateNormalSuccess(ModelTypeSet requested_types,
49 sessions::NudgeTracker* nudge_tracker,
50 sessions::SyncSession* session) {
51 session->mutable_status_controller()->set_commit_result(SYNCER_OK);
52 session->mutable_status_controller()->set_last_download_updates_result(
53 SYNCER_OK);
56 void SimulateDownloadUpdatesFailed(ModelTypeSet requested_types,
57 sessions::NudgeTracker* nudge_tracker,
58 sessions::SyncSession* session) {
59 session->mutable_status_controller()->set_last_download_updates_result(
60 SERVER_RETURN_TRANSIENT_ERROR);
63 void SimulateCommitFailed(ModelTypeSet requested_types,
64 sessions::NudgeTracker* nudge_tracker,
65 sessions::SyncSession* session) {
66 session->mutable_status_controller()->set_last_get_key_result(SYNCER_OK);
67 session->mutable_status_controller()->set_last_download_updates_result(
68 SYNCER_OK);
69 session->mutable_status_controller()->set_commit_result(
70 SERVER_RETURN_TRANSIENT_ERROR);
73 void SimulateConnectionFailure(ModelTypeSet requested_types,
74 sessions::NudgeTracker* nudge_tracker,
75 sessions::SyncSession* session) {
76 session->mutable_status_controller()->set_last_download_updates_result(
77 NETWORK_CONNECTION_UNAVAILABLE);
80 void SimulatePollSuccess(ModelTypeSet requested_types,
81 sessions::SyncSession* session) {
82 session->mutable_status_controller()->set_last_download_updates_result(
83 SYNCER_OK);
86 void SimulatePollFailed(ModelTypeSet requested_types,
87 sessions::SyncSession* session) {
88 session->mutable_status_controller()->set_last_download_updates_result(
89 SERVER_RETURN_TRANSIENT_ERROR);
92 void SimulateThrottledImpl(
93 sessions::SyncSession* session,
94 const base::TimeDelta& delta) {
95 session->mutable_status_controller()->set_last_download_updates_result(
96 SERVER_RETURN_THROTTLED);
97 session->delegate()->OnThrottled(delta);
100 void SimulateTypesThrottledImpl(
101 sessions::SyncSession* session,
102 ModelTypeSet types,
103 const base::TimeDelta& delta) {
104 session->mutable_status_controller()->set_last_download_updates_result(
105 SERVER_RETURN_THROTTLED);
106 session->delegate()->OnTypesThrottled(types, delta);
109 void SimulatePollIntervalUpdateImpl(
110 ModelTypeSet requested_types,
111 sessions::SyncSession* session,
112 const base::TimeDelta& new_poll) {
113 SimulatePollSuccess(requested_types, session);
114 session->delegate()->OnReceivedLongPollIntervalUpdate(new_poll);
117 void SimulateSessionsCommitDelayUpdateImpl(
118 ModelTypeSet requested_types,
119 sessions::NudgeTracker* nudge_tracker,
120 sessions::SyncSession* session,
121 const base::TimeDelta& new_delay) {
122 SimulateNormalSuccess(requested_types, nudge_tracker, session);
123 std::map<ModelType, base::TimeDelta> delay_map;
124 delay_map[SESSIONS] = new_delay;
125 session->delegate()->OnReceivedCustomNudgeDelays(delay_map);
128 void SimulateGuRetryDelayCommandImpl(sessions::SyncSession* session,
129 base::TimeDelta delay) {
130 session->mutable_status_controller()->set_last_download_updates_result(
131 SYNCER_OK);
132 session->delegate()->OnReceivedGuRetryDelay(delay);
135 } // namespace test_util
136 } // namespace sessions
137 } // namespace syncer