OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/engine/download.h" | 5 #include "sync/engine/download.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "sync/engine/sync_directory_update_handler.h" | 9 #include "sync/engine/sync_directory_update_handler.h" |
10 #include "sync/internal_api/public/base/model_type_test_util.h" | 10 #include "sync/internal_api/public/base/model_type_test_util.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 212 |
213 ModelTypeSet progress_types; | 213 ModelTypeSet progress_types; |
214 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | 214 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { |
215 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | 215 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( |
216 gu_msg.from_progress_marker(i).data_type_id()); | 216 gu_msg.from_progress_marker(i).data_type_id()); |
217 progress_types.Put(type); | 217 progress_types.Put(type); |
218 } | 218 } |
219 EXPECT_TRUE(proto_request_types().Equals(progress_types)); | 219 EXPECT_TRUE(proto_request_types().Equals(progress_types)); |
220 } | 220 } |
221 | 221 |
222 TEST_F(DownloadUpdatesTest, RetryTest) { | |
223 sync_pb::ClientToServerMessage msg; | |
224 download::BuildDownloadUpdatesForRetryImpl( | |
225 proto_request_types(), | |
226 update_handler_map(), | |
227 msg.mutable_get_updates()); | |
228 | |
229 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); | |
230 | |
231 EXPECT_EQ(sync_pb::SyncEnums::RETRY, gu_msg.get_updates_origin()); | |
232 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RETRY, | |
233 gu_msg.caller_info().source()); | |
234 EXPECT_TRUE(gu_msg.is_retry()); | |
235 | |
236 ModelTypeSet progress_types; | |
237 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | |
238 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | |
239 gu_msg.from_progress_marker(i).data_type_id()); | |
240 progress_types.Put(type); | |
241 } | |
242 EXPECT_TRUE(proto_request_types().Equals(progress_types)); | |
243 } | |
244 | |
245 TEST_F(DownloadUpdatesTest, NudgeWithRetryTest) { | |
246 sessions::NudgeTracker nudge_tracker; | |
247 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | |
248 nudge_tracker.set_next_retry_time( | |
249 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1)); | |
250 | |
251 sync_pb::ClientToServerMessage msg; | |
252 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), | |
253 update_handler_map(), | |
254 nudge_tracker, | |
255 msg.mutable_get_updates()); | |
256 EXPECT_TRUE(msg.get_updates().is_retry()); | |
257 } | |
258 | |
259 // Verify that a bogus response message is detected. | 222 // Verify that a bogus response message is detected. |
260 TEST_F(DownloadUpdatesTest, InvalidResponse) { | 223 TEST_F(DownloadUpdatesTest, InvalidResponse) { |
261 sync_pb::GetUpdatesResponse gu_response; | 224 sync_pb::GetUpdatesResponse gu_response; |
262 InitFakeUpdateResponse(&gu_response); | 225 InitFakeUpdateResponse(&gu_response); |
263 | 226 |
264 // This field is essential for making the client stop looping. If it's unset | 227 // This field is essential for making the client stop looping. If it's unset |
265 // then something is very wrong. The client should detect this. | 228 // then something is very wrong. The client should detect this. |
266 gu_response.clear_changes_remaining(); | 229 gu_response.clear_changes_remaining(); |
267 | 230 |
268 sessions::StatusController status; | 231 sessions::StatusController status; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { | 297 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { |
335 sync_pb::DebugInfo debug_info; | 298 sync_pb::DebugInfo debug_info; |
336 AddDebugEvent(); | 299 AddDebugEvent(); |
337 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 300 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
338 EXPECT_EQ(1, debug_info.events_size()); | 301 EXPECT_EQ(1, debug_info.events_size()); |
339 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 302 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
340 EXPECT_EQ(1, debug_info.events_size()); | 303 EXPECT_EQ(1, debug_info.events_size()); |
341 } | 304 } |
342 | 305 |
343 } // namespace syncer | 306 } // namespace syncer |
OLD | NEW |