| 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" |
| 11 #include "sync/protocol/sync.pb.h" | 11 #include "sync/protocol/sync.pb.h" |
| 12 #include "sync/sessions/debug_info_getter.h" | 12 #include "sync/sessions/debug_info_getter.h" |
| 13 #include "sync/sessions/nudge_tracker.h" | 13 #include "sync/sessions/nudge_tracker.h" |
| 14 #include "sync/sessions/status_controller.h" | 14 #include "sync/sessions/status_controller.h" |
| 15 #include "sync/syncable/directory.h" | 15 #include "sync/syncable/directory.h" |
| 16 #include "sync/test/engine/fake_model_worker.h" | 16 #include "sync/test/engine/fake_model_worker.h" |
| 17 #include "sync/test/engine/test_directory_setter_upper.h" | 17 #include "sync/test/engine/test_directory_setter_upper.h" |
| 18 #include "sync/test/sessions/mock_debug_info_getter.h" | 18 #include "sync/test/sessions/mock_debug_info_getter.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace syncer { | 21 namespace syncer { |
| 22 | 22 |
| 23 using sessions::MockDebugInfoGetter; | 23 using sessions::MockDebugInfoGetter; |
| 24 | 24 |
| 25 // A test fixture for tests exercising download updates functions. | 25 // A test fixture for tests exercising download updates functions. |
| 26 class DownloadUpdatesTest : public ::testing::Test { | 26 class DownloadUpdatesTest : public ::testing::Test { |
| 27 protected: | 27 protected: |
| 28 DownloadUpdatesTest() | 28 DownloadUpdatesTest() : update_handler_deleter_(&update_handler_map_) {} |
| 29 : update_handler_map_deleter_(&update_handler_map_) { | |
| 30 } | |
| 31 | 29 |
| 32 virtual void SetUp() { | 30 virtual void SetUp() { |
| 33 dir_maker_.SetUp(); | 31 dir_maker_.SetUp(); |
| 34 | 32 |
| 35 AddUpdateHandler(AUTOFILL, GROUP_DB); | 33 AddUpdateHandler(AUTOFILL, GROUP_DB); |
| 36 AddUpdateHandler(BOOKMARKS, GROUP_UI); | 34 AddUpdateHandler(BOOKMARKS, GROUP_UI); |
| 37 AddUpdateHandler(PREFERENCES, GROUP_UI); | 35 AddUpdateHandler(PREFERENCES, GROUP_UI); |
| 38 } | 36 } |
| 39 | 37 |
| 40 virtual void TearDown() { | 38 virtual void TearDown() { |
| 41 dir_maker_.TearDown(); | 39 dir_maker_.TearDown(); |
| 42 } | 40 } |
| 43 | 41 |
| 44 ModelTypeSet proto_request_types() { | 42 ModelTypeSet proto_request_types() { |
| 45 ModelTypeSet types; | 43 return proto_request_types_; |
| 46 for (UpdateHandlerMap::iterator it = update_handler_map_.begin(); | |
| 47 it != update_handler_map_.end(); ++it) { | |
| 48 types.Put(it->first); | |
| 49 } | |
| 50 return types; | |
| 51 } | 44 } |
| 52 | 45 |
| 53 syncable::Directory* directory() { | 46 syncable::Directory* directory() { |
| 54 return dir_maker_.directory(); | 47 return dir_maker_.directory(); |
| 55 } | 48 } |
| 56 | 49 |
| 57 UpdateHandlerMap* update_handler_map() { | 50 GetUpdatesProcessor* get_updates_processor() { |
| 58 return &update_handler_map_; | 51 return get_updates_processor_.get(); |
| 59 } | 52 } |
| 60 | 53 |
| 61 void InitFakeUpdateResponse(sync_pb::GetUpdatesResponse* response) { | 54 void InitFakeUpdateResponse(sync_pb::GetUpdatesResponse* response) { |
| 62 ModelTypeSet types = proto_request_types(); | 55 ModelTypeSet types = proto_request_types(); |
| 63 | 56 |
| 64 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { | 57 for (ModelTypeSet::Iterator it = types.First(); it.Good(); it.Inc()) { |
| 65 sync_pb::DataTypeProgressMarker* marker = | 58 sync_pb::DataTypeProgressMarker* marker = |
| 66 response->add_new_progress_marker(); | 59 response->add_new_progress_marker(); |
| 67 marker->set_data_type_id(GetSpecificsFieldNumberFromModelType(it.Get())); | 60 marker->set_data_type_id(GetSpecificsFieldNumberFromModelType(it.Get())); |
| 68 marker->set_token("foobarbaz"); | 61 marker->set_token("foobarbaz"); |
| 69 } | 62 } |
| 70 | 63 |
| 71 response->set_changes_remaining(0); | 64 response->set_changes_remaining(0); |
| 72 } | 65 } |
| 73 | 66 |
| 74 private: | 67 private: |
| 75 void AddUpdateHandler(ModelType type, ModelSafeGroup group) { | 68 void AddUpdateHandler(ModelType type, ModelSafeGroup group) { |
| 76 DCHECK(directory()); | 69 DCHECK(directory()); |
| 70 |
| 71 proto_request_types_.Put(type); |
| 72 |
| 77 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(group); | 73 scoped_refptr<ModelSafeWorker> worker = new FakeModelWorker(group); |
| 78 SyncDirectoryUpdateHandler* handler = | 74 SyncDirectoryUpdateHandler* handler = |
| 79 new SyncDirectoryUpdateHandler(directory(), type, worker); | 75 new SyncDirectoryUpdateHandler(directory(), type, worker); |
| 80 update_handler_map_.insert(std::make_pair(type, handler)); | 76 update_handler_map_.insert(std::make_pair(type, handler)); |
| 77 get_updates_processor_.reset(new GetUpdatesProcessor(&update_handler_map_)); |
| 81 } | 78 } |
| 82 | 79 |
| 83 base::MessageLoop loop_; // Needed for directory init. | 80 base::MessageLoop loop_; // Needed for directory init. |
| 84 TestDirectorySetterUpper dir_maker_; | 81 TestDirectorySetterUpper dir_maker_; |
| 85 | 82 |
| 83 ModelTypeSet proto_request_types_; |
| 86 UpdateHandlerMap update_handler_map_; | 84 UpdateHandlerMap update_handler_map_; |
| 87 STLValueDeleter<UpdateHandlerMap> update_handler_map_deleter_; | 85 STLValueDeleter<UpdateHandlerMap> update_handler_deleter_; |
| 86 scoped_ptr<GetUpdatesProcessor> get_updates_processor_; |
| 88 | 87 |
| 89 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesTest); | 88 DISALLOW_COPY_AND_ASSIGN(DownloadUpdatesTest); |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 // Basic test to make sure nudges are expressed properly in the request. | 91 // Basic test to make sure nudges are expressed properly in the request. |
| 93 TEST_F(DownloadUpdatesTest, BookmarkNudge) { | 92 TEST_F(DownloadUpdatesTest, BookmarkNudge) { |
| 94 sessions::NudgeTracker nudge_tracker; | 93 sessions::NudgeTracker nudge_tracker; |
| 95 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 94 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
| 96 | 95 |
| 97 sync_pb::ClientToServerMessage msg; | 96 sync_pb::ClientToServerMessage msg; |
| 98 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), | 97 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), |
| 99 update_handler_map(), | 98 get_updates_processor(), |
| 100 nudge_tracker, | 99 nudge_tracker, |
| 101 msg.mutable_get_updates()); | 100 msg.mutable_get_updates()); |
| 102 | 101 |
| 103 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); | 102 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); |
| 104 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::LOCAL, | 103 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::LOCAL, |
| 105 gu_msg.caller_info().source()); | 104 gu_msg.caller_info().source()); |
| 106 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); | 105 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); |
| 107 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | 106 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { |
| 108 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | 107 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( |
| 109 gu_msg.from_progress_marker(i).data_type_id()); | 108 gu_msg.from_progress_marker(i).data_type_id()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 137 BuildInvalidationMap(BOOKMARKS, 1, "bookmark_payload")); | 136 BuildInvalidationMap(BOOKMARKS, 1, "bookmark_payload")); |
| 138 nudge_tracker.RecordRemoteInvalidation( | 137 nudge_tracker.RecordRemoteInvalidation( |
| 139 BuildInvalidationMap(PREFERENCES, 1, "preferences_payload")); | 138 BuildInvalidationMap(PREFERENCES, 1, "preferences_payload")); |
| 140 ModelTypeSet notified_types; | 139 ModelTypeSet notified_types; |
| 141 notified_types.Put(AUTOFILL); | 140 notified_types.Put(AUTOFILL); |
| 142 notified_types.Put(BOOKMARKS); | 141 notified_types.Put(BOOKMARKS); |
| 143 notified_types.Put(PREFERENCES); | 142 notified_types.Put(PREFERENCES); |
| 144 | 143 |
| 145 sync_pb::ClientToServerMessage msg; | 144 sync_pb::ClientToServerMessage msg; |
| 146 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), | 145 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), |
| 147 update_handler_map(), | 146 get_updates_processor(), |
| 148 nudge_tracker, | 147 nudge_tracker, |
| 149 msg.mutable_get_updates()); | 148 msg.mutable_get_updates()); |
| 150 | 149 |
| 151 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); | 150 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); |
| 152 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION, | 151 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION, |
| 153 gu_msg.caller_info().source()); | 152 gu_msg.caller_info().source()); |
| 154 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); | 153 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); |
| 155 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | 154 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { |
| 156 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | 155 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( |
| 157 gu_msg.from_progress_marker(i).data_type_id()); | 156 gu_msg.from_progress_marker(i).data_type_id()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 171 EXPECT_FALSE(progress_marker.has_notification_hint()); | 170 EXPECT_FALSE(progress_marker.has_notification_hint()); |
| 172 EXPECT_EQ(0, gu_trigger.notification_hint_size()); | 171 EXPECT_EQ(0, gu_trigger.notification_hint_size()); |
| 173 } | 172 } |
| 174 } | 173 } |
| 175 } | 174 } |
| 176 | 175 |
| 177 TEST_F(DownloadUpdatesTest, ConfigureTest) { | 176 TEST_F(DownloadUpdatesTest, ConfigureTest) { |
| 178 sync_pb::ClientToServerMessage msg; | 177 sync_pb::ClientToServerMessage msg; |
| 179 download::BuildDownloadUpdatesForConfigureImpl( | 178 download::BuildDownloadUpdatesForConfigureImpl( |
| 180 proto_request_types(), | 179 proto_request_types(), |
| 181 update_handler_map(), | 180 get_updates_processor(), |
| 182 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, | 181 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, |
| 183 msg.mutable_get_updates()); | 182 msg.mutable_get_updates()); |
| 184 | 183 |
| 185 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); | 184 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); |
| 186 | 185 |
| 187 EXPECT_EQ(sync_pb::SyncEnums::RECONFIGURATION, gu_msg.get_updates_origin()); | 186 EXPECT_EQ(sync_pb::SyncEnums::RECONFIGURATION, gu_msg.get_updates_origin()); |
| 188 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, | 187 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, |
| 189 gu_msg.caller_info().source()); | 188 gu_msg.caller_info().source()); |
| 190 | 189 |
| 191 ModelTypeSet progress_types; | 190 ModelTypeSet progress_types; |
| 192 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | 191 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { |
| 193 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | 192 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( |
| 194 gu_msg.from_progress_marker(i).data_type_id()); | 193 gu_msg.from_progress_marker(i).data_type_id()); |
| 195 progress_types.Put(type); | 194 progress_types.Put(type); |
| 196 } | 195 } |
| 197 EXPECT_TRUE(proto_request_types().Equals(progress_types)); | 196 EXPECT_TRUE(proto_request_types().Equals(progress_types)); |
| 198 } | 197 } |
| 199 | 198 |
| 200 TEST_F(DownloadUpdatesTest, PollTest) { | 199 TEST_F(DownloadUpdatesTest, PollTest) { |
| 201 sync_pb::ClientToServerMessage msg; | 200 sync_pb::ClientToServerMessage msg; |
| 202 download::BuildDownloadUpdatesForPollImpl( | 201 download::BuildDownloadUpdatesForPollImpl( |
| 203 proto_request_types(), | 202 proto_request_types(), |
| 204 update_handler_map(), | 203 get_updates_processor(), |
| 205 msg.mutable_get_updates()); | 204 msg.mutable_get_updates()); |
| 206 | 205 |
| 207 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); | 206 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); |
| 208 | 207 |
| 209 EXPECT_EQ(sync_pb::SyncEnums::PERIODIC, gu_msg.get_updates_origin()); | 208 EXPECT_EQ(sync_pb::SyncEnums::PERIODIC, gu_msg.get_updates_origin()); |
| 210 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC, | 209 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC, |
| 211 gu_msg.caller_info().source()); | 210 gu_msg.caller_info().source()); |
| 212 | 211 |
| 213 ModelTypeSet progress_types; | 212 ModelTypeSet progress_types; |
| 214 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | 213 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { |
| 215 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | 214 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( |
| 216 gu_msg.from_progress_marker(i).data_type_id()); | 215 gu_msg.from_progress_marker(i).data_type_id()); |
| 217 progress_types.Put(type); | 216 progress_types.Put(type); |
| 218 } | 217 } |
| 219 EXPECT_TRUE(proto_request_types().Equals(progress_types)); | 218 EXPECT_TRUE(proto_request_types().Equals(progress_types)); |
| 220 } | 219 } |
| 221 | 220 |
| 222 TEST_F(DownloadUpdatesTest, RetryTest) { | 221 TEST_F(DownloadUpdatesTest, RetryTest) { |
| 223 sync_pb::ClientToServerMessage msg; | 222 sync_pb::ClientToServerMessage msg; |
| 224 download::BuildDownloadUpdatesForRetryImpl( | 223 download::BuildDownloadUpdatesForRetryImpl( |
| 225 proto_request_types(), | 224 proto_request_types(), |
| 226 update_handler_map(), | 225 get_updates_processor(), |
| 227 msg.mutable_get_updates()); | 226 msg.mutable_get_updates()); |
| 228 | 227 |
| 229 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); | 228 const sync_pb::GetUpdatesMessage& gu_msg = msg.get_updates(); |
| 230 | 229 |
| 231 EXPECT_EQ(sync_pb::SyncEnums::RETRY, gu_msg.get_updates_origin()); | 230 EXPECT_EQ(sync_pb::SyncEnums::RETRY, gu_msg.get_updates_origin()); |
| 232 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RETRY, | 231 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RETRY, |
| 233 gu_msg.caller_info().source()); | 232 gu_msg.caller_info().source()); |
| 234 EXPECT_TRUE(gu_msg.is_retry()); | 233 EXPECT_TRUE(gu_msg.is_retry()); |
| 235 | 234 |
| 236 ModelTypeSet progress_types; | 235 ModelTypeSet progress_types; |
| 237 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { | 236 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { |
| 238 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( | 237 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( |
| 239 gu_msg.from_progress_marker(i).data_type_id()); | 238 gu_msg.from_progress_marker(i).data_type_id()); |
| 240 progress_types.Put(type); | 239 progress_types.Put(type); |
| 241 } | 240 } |
| 242 EXPECT_TRUE(proto_request_types().Equals(progress_types)); | 241 EXPECT_TRUE(proto_request_types().Equals(progress_types)); |
| 243 } | 242 } |
| 244 | 243 |
| 245 TEST_F(DownloadUpdatesTest, NudgeWithRetryTest) { | 244 TEST_F(DownloadUpdatesTest, NudgeWithRetryTest) { |
| 246 sessions::NudgeTracker nudge_tracker; | 245 sessions::NudgeTracker nudge_tracker; |
| 247 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); | 246 nudge_tracker.RecordLocalChange(ModelTypeSet(BOOKMARKS)); |
| 248 nudge_tracker.set_next_retry_time( | 247 nudge_tracker.set_next_retry_time( |
| 249 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1)); | 248 base::TimeTicks::Now() - base::TimeDelta::FromSeconds(1)); |
| 250 | 249 |
| 251 sync_pb::ClientToServerMessage msg; | 250 sync_pb::ClientToServerMessage msg; |
| 252 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), | 251 download::BuildNormalDownloadUpdatesImpl(proto_request_types(), |
| 253 update_handler_map(), | 252 get_updates_processor(), |
| 254 nudge_tracker, | 253 nudge_tracker, |
| 255 msg.mutable_get_updates()); | 254 msg.mutable_get_updates()); |
| 256 EXPECT_TRUE(msg.get_updates().is_retry()); | 255 EXPECT_TRUE(msg.get_updates().is_retry()); |
| 257 } | 256 } |
| 258 | 257 |
| 259 // Verify that a bogus response message is detected. | 258 // Verify that a bogus response message is detected. |
| 260 TEST_F(DownloadUpdatesTest, InvalidResponse) { | 259 TEST_F(DownloadUpdatesTest, InvalidResponse) { |
| 261 sync_pb::GetUpdatesResponse gu_response; | 260 sync_pb::GetUpdatesResponse gu_response; |
| 262 InitFakeUpdateResponse(&gu_response); | 261 InitFakeUpdateResponse(&gu_response); |
| 263 | 262 |
| 264 // This field is essential for making the client stop looping. If it's unset | 263 // 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. | 264 // then something is very wrong. The client should detect this. |
| 266 gu_response.clear_changes_remaining(); | 265 gu_response.clear_changes_remaining(); |
| 267 | 266 |
| 268 sessions::StatusController status; | 267 sessions::StatusController status; |
| 269 SyncerError error = download::ProcessResponse(gu_response, | 268 SyncerError error = download::ProcessResponse(gu_response, |
| 270 proto_request_types(), | 269 proto_request_types(), |
| 271 update_handler_map(), | 270 get_updates_processor(), |
| 272 &status); | 271 &status); |
| 273 EXPECT_EQ(error, SERVER_RESPONSE_VALIDATION_FAILED); | 272 EXPECT_EQ(error, SERVER_RESPONSE_VALIDATION_FAILED); |
| 274 } | 273 } |
| 275 | 274 |
| 276 // Verify that we correctly detect when there's more work to be done. | 275 // Verify that we correctly detect when there's more work to be done. |
| 277 TEST_F(DownloadUpdatesTest, MoreToDownloadResponse) { | 276 TEST_F(DownloadUpdatesTest, MoreToDownloadResponse) { |
| 278 sync_pb::GetUpdatesResponse gu_response; | 277 sync_pb::GetUpdatesResponse gu_response; |
| 279 InitFakeUpdateResponse(&gu_response); | 278 InitFakeUpdateResponse(&gu_response); |
| 280 gu_response.set_changes_remaining(1); | 279 gu_response.set_changes_remaining(1); |
| 281 | 280 |
| 282 sessions::StatusController status; | 281 sessions::StatusController status; |
| 283 SyncerError error = download::ProcessResponse(gu_response, | 282 SyncerError error = download::ProcessResponse(gu_response, |
| 284 proto_request_types(), | 283 proto_request_types(), |
| 285 update_handler_map(), | 284 get_updates_processor(), |
| 286 &status); | 285 &status); |
| 287 EXPECT_EQ(error, SERVER_MORE_TO_DOWNLOAD); | 286 EXPECT_EQ(error, SERVER_MORE_TO_DOWNLOAD); |
| 288 } | 287 } |
| 289 | 288 |
| 290 // A simple scenario: No updates returned and nothing more to download. | 289 // A simple scenario: No updates returned and nothing more to download. |
| 291 TEST_F(DownloadUpdatesTest, NormalResponseTest) { | 290 TEST_F(DownloadUpdatesTest, NormalResponseTest) { |
| 292 sync_pb::GetUpdatesResponse gu_response; | 291 sync_pb::GetUpdatesResponse gu_response; |
| 293 InitFakeUpdateResponse(&gu_response); | 292 InitFakeUpdateResponse(&gu_response); |
| 294 gu_response.set_changes_remaining(0); | 293 gu_response.set_changes_remaining(0); |
| 295 | 294 |
| 296 sessions::StatusController status; | 295 sessions::StatusController status; |
| 297 SyncerError error = download::ProcessResponse(gu_response, | 296 SyncerError error = download::ProcessResponse(gu_response, |
| 298 proto_request_types(), | 297 proto_request_types(), |
| 299 update_handler_map(), | 298 get_updates_processor(), |
| 300 &status); | 299 &status); |
| 301 EXPECT_EQ(error, SYNCER_OK); | 300 EXPECT_EQ(error, SYNCER_OK); |
| 302 } | 301 } |
| 303 | 302 |
| 304 class DownloadUpdatesDebugInfoTest : public ::testing::Test { | 303 class DownloadUpdatesDebugInfoTest : public ::testing::Test { |
| 305 public: | 304 public: |
| 306 DownloadUpdatesDebugInfoTest() {} | 305 DownloadUpdatesDebugInfoTest() {} |
| 307 virtual ~DownloadUpdatesDebugInfoTest() {} | 306 virtual ~DownloadUpdatesDebugInfoTest() {} |
| 308 | 307 |
| 309 sessions::StatusController* status() { | 308 sessions::StatusController* status() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 334 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { | 333 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { |
| 335 sync_pb::DebugInfo debug_info; | 334 sync_pb::DebugInfo debug_info; |
| 336 AddDebugEvent(); | 335 AddDebugEvent(); |
| 337 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 336 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
| 338 EXPECT_EQ(1, debug_info.events_size()); | 337 EXPECT_EQ(1, debug_info.events_size()); |
| 339 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); | 338 download::CopyClientDebugInfo(debug_info_getter(), &debug_info); |
| 340 EXPECT_EQ(1, debug_info.events_size()); | 339 EXPECT_EQ(1, debug_info.events_size()); |
| 341 } | 340 } |
| 342 | 341 |
| 343 } // namespace syncer | 342 } // namespace syncer |
| OLD | NEW |