Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: sync/engine/download_unittest.cc

Issue 124083002: Client-side changes to support retry GU. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
222 // Verify that a bogus response message is detected. 259 // Verify that a bogus response message is detected.
223 TEST_F(DownloadUpdatesTest, InvalidResponse) { 260 TEST_F(DownloadUpdatesTest, InvalidResponse) {
224 sync_pb::GetUpdatesResponse gu_response; 261 sync_pb::GetUpdatesResponse gu_response;
225 InitFakeUpdateResponse(&gu_response); 262 InitFakeUpdateResponse(&gu_response);
226 263
227 // This field is essential for making the client stop looping. If it's unset 264 // This field is essential for making the client stop looping. If it's unset
228 // then something is very wrong. The client should detect this. 265 // then something is very wrong. The client should detect this.
229 gu_response.clear_changes_remaining(); 266 gu_response.clear_changes_remaining();
230 267
231 sessions::StatusController status; 268 sessions::StatusController status;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { 334 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) {
298 sync_pb::DebugInfo debug_info; 335 sync_pb::DebugInfo debug_info;
299 AddDebugEvent(); 336 AddDebugEvent();
300 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); 337 download::CopyClientDebugInfo(debug_info_getter(), &debug_info);
301 EXPECT_EQ(1, debug_info.events_size()); 338 EXPECT_EQ(1, debug_info.events_size());
302 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); 339 download::CopyClientDebugInfo(debug_info_getter(), &debug_info);
303 EXPECT_EQ(1, debug_info.events_size()); 340 EXPECT_EQ(1, debug_info.events_size());
304 } 341 }
305 342
306 } // namespace syncer 343 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698