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

Side by Side Diff: components/sync/engine_impl/get_updates_processor_unittest.cc

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/sync/engine_impl/get_updates_processor.h" 5 #include "components/sync/engine_impl/get_updates_processor.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory>
9 #include <set> 10 #include <set>
10 #include <string> 11 #include <string>
12 #include <utility>
11 13
12 #include "base/macros.h" 14 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
15 #include "components/sync/base/model_type_test_util.h" 17 #include "components/sync/base/model_type_test_util.h"
16 #include "components/sync/engine_impl/cycle/debug_info_getter.h" 18 #include "components/sync/engine_impl/cycle/debug_info_getter.h"
17 #include "components/sync/engine_impl/cycle/mock_debug_info_getter.h" 19 #include "components/sync/engine_impl/cycle/mock_debug_info_getter.h"
18 #include "components/sync/engine_impl/cycle/nudge_tracker.h" 20 #include "components/sync/engine_impl/cycle/nudge_tracker.h"
19 #include "components/sync/engine_impl/cycle/status_controller.h" 21 #include "components/sync/engine_impl/cycle/status_controller.h"
20 #include "components/sync/engine_impl/get_updates_delegate.h" 22 #include "components/sync/engine_impl/get_updates_delegate.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); 108 NormalGetUpdatesDelegate normal_delegate(nudge_tracker);
107 std::unique_ptr<GetUpdatesProcessor> processor( 109 std::unique_ptr<GetUpdatesProcessor> processor(
108 BuildGetUpdatesProcessor(normal_delegate)); 110 BuildGetUpdatesProcessor(normal_delegate));
109 processor->PrepareGetUpdates(enabled_types(), &message); 111 processor->PrepareGetUpdates(enabled_types(), &message);
110 112
111 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 113 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
112 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::LOCAL, 114 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::LOCAL,
113 gu_msg.caller_info().source()); 115 gu_msg.caller_info().source());
114 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); 116 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin());
115 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { 117 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
116 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( 118 ModelType type = GetModelTypeFromSpecificsFieldNumber(
117 gu_msg.from_progress_marker(i).data_type_id()); 119 gu_msg.from_progress_marker(i).data_type_id());
118 120
119 const sync_pb::DataTypeProgressMarker& progress_marker = 121 const sync_pb::DataTypeProgressMarker& progress_marker =
120 gu_msg.from_progress_marker(i); 122 gu_msg.from_progress_marker(i);
121 const sync_pb::GetUpdateTriggers& gu_trigger = 123 const sync_pb::GetUpdateTriggers& gu_trigger =
122 progress_marker.get_update_triggers(); 124 progress_marker.get_update_triggers();
123 125
124 // We perform some basic tests of GU trigger and source fields here. The 126 // We perform some basic tests of GU trigger and source fields here. The
125 // more complicated scenarios are tested by the NudgeTracker tests. 127 // more complicated scenarios are tested by the NudgeTracker tests.
126 if (type == BOOKMARKS) { 128 if (type == BOOKMARKS) {
(...skipping 27 matching lines...) Expand all
154 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); 156 NormalGetUpdatesDelegate normal_delegate(nudge_tracker);
155 std::unique_ptr<GetUpdatesProcessor> processor( 157 std::unique_ptr<GetUpdatesProcessor> processor(
156 BuildGetUpdatesProcessor(normal_delegate)); 158 BuildGetUpdatesProcessor(normal_delegate));
157 processor->PrepareGetUpdates(enabled_types(), &message); 159 processor->PrepareGetUpdates(enabled_types(), &message);
158 160
159 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 161 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
160 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION, 162 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::NOTIFICATION,
161 gu_msg.caller_info().source()); 163 gu_msg.caller_info().source());
162 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); 164 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin());
163 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { 165 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
164 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( 166 ModelType type = GetModelTypeFromSpecificsFieldNumber(
165 gu_msg.from_progress_marker(i).data_type_id()); 167 gu_msg.from_progress_marker(i).data_type_id());
166 168
167 const sync_pb::DataTypeProgressMarker& progress_marker = 169 const sync_pb::DataTypeProgressMarker& progress_marker =
168 gu_msg.from_progress_marker(i); 170 gu_msg.from_progress_marker(i);
169 const sync_pb::GetUpdateTriggers& gu_trigger = 171 const sync_pb::GetUpdateTriggers& gu_trigger =
170 progress_marker.get_update_triggers(); 172 progress_marker.get_update_triggers();
171 173
172 // We perform some basic tests of GU trigger and source fields here. The 174 // We perform some basic tests of GU trigger and source fields here. The
173 // more complicated scenarios are tested by the NudgeTracker tests. 175 // more complicated scenarios are tested by the NudgeTracker tests.
174 if (notified_types.Has(type)) { 176 if (notified_types.Has(type)) {
(...skipping 19 matching lines...) Expand all
194 NormalGetUpdatesDelegate normal_delegate(nudge_tracker); 196 NormalGetUpdatesDelegate normal_delegate(nudge_tracker);
195 std::unique_ptr<GetUpdatesProcessor> processor( 197 std::unique_ptr<GetUpdatesProcessor> processor(
196 BuildGetUpdatesProcessor(normal_delegate)); 198 BuildGetUpdatesProcessor(normal_delegate));
197 processor->PrepareGetUpdates(enabled_types(), &message); 199 processor->PrepareGetUpdates(enabled_types(), &message);
198 200
199 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 201 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
200 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH, 202 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH,
201 gu_msg.caller_info().source()); 203 gu_msg.caller_info().source());
202 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin()); 204 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin());
203 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { 205 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
204 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( 206 ModelType type = GetModelTypeFromSpecificsFieldNumber(
205 gu_msg.from_progress_marker(i).data_type_id()); 207 gu_msg.from_progress_marker(i).data_type_id());
206 208
207 const sync_pb::DataTypeProgressMarker& progress_marker = 209 const sync_pb::DataTypeProgressMarker& progress_marker =
208 gu_msg.from_progress_marker(i); 210 gu_msg.from_progress_marker(i);
209 const sync_pb::GetUpdateTriggers& gu_trigger = 211 const sync_pb::GetUpdateTriggers& gu_trigger =
210 progress_marker.get_update_triggers(); 212 progress_marker.get_update_triggers();
211 213
212 // We perform some basic tests of GU trigger and source fields here. The 214 // We perform some basic tests of GU trigger and source fields here. The
213 // more complicated scenarios are tested by the NudgeTracker tests. 215 // more complicated scenarios are tested by the NudgeTracker tests.
214 if (initial_sync_types.Has(type)) { 216 if (initial_sync_types.Has(type)) {
(...skipping 13 matching lines...) Expand all
228 BuildGetUpdatesProcessor(configure_delegate)); 230 BuildGetUpdatesProcessor(configure_delegate));
229 processor->PrepareGetUpdates(enabled_types(), &message); 231 processor->PrepareGetUpdates(enabled_types(), &message);
230 232
231 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 233 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
232 EXPECT_EQ(sync_pb::SyncEnums::RECONFIGURATION, gu_msg.get_updates_origin()); 234 EXPECT_EQ(sync_pb::SyncEnums::RECONFIGURATION, gu_msg.get_updates_origin());
233 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION, 235 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RECONFIGURATION,
234 gu_msg.caller_info().source()); 236 gu_msg.caller_info().source());
235 237
236 ModelTypeSet progress_types; 238 ModelTypeSet progress_types;
237 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { 239 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
238 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( 240 ModelType type = GetModelTypeFromSpecificsFieldNumber(
239 gu_msg.from_progress_marker(i).data_type_id()); 241 gu_msg.from_progress_marker(i).data_type_id());
240 progress_types.Put(type); 242 progress_types.Put(type);
241 } 243 }
242 EXPECT_EQ(enabled_types(), progress_types); 244 EXPECT_EQ(enabled_types(), progress_types);
243 } 245 }
244 246
245 TEST_F(GetUpdatesProcessorTest, PollTest) { 247 TEST_F(GetUpdatesProcessorTest, PollTest) {
246 sync_pb::ClientToServerMessage message; 248 sync_pb::ClientToServerMessage message;
247 PollGetUpdatesDelegate poll_delegate; 249 PollGetUpdatesDelegate poll_delegate;
248 std::unique_ptr<GetUpdatesProcessor> processor( 250 std::unique_ptr<GetUpdatesProcessor> processor(
249 BuildGetUpdatesProcessor(poll_delegate)); 251 BuildGetUpdatesProcessor(poll_delegate));
250 processor->PrepareGetUpdates(enabled_types(), &message); 252 processor->PrepareGetUpdates(enabled_types(), &message);
251 253
252 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 254 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
253 EXPECT_EQ(sync_pb::SyncEnums::PERIODIC, gu_msg.get_updates_origin()); 255 EXPECT_EQ(sync_pb::SyncEnums::PERIODIC, gu_msg.get_updates_origin());
254 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC, 256 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::PERIODIC,
255 gu_msg.caller_info().source()); 257 gu_msg.caller_info().source());
256 258
257 ModelTypeSet progress_types; 259 ModelTypeSet progress_types;
258 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { 260 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
259 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( 261 ModelType type = GetModelTypeFromSpecificsFieldNumber(
260 gu_msg.from_progress_marker(i).data_type_id()); 262 gu_msg.from_progress_marker(i).data_type_id());
261 progress_types.Put(type); 263 progress_types.Put(type);
262 } 264 }
263 EXPECT_EQ(enabled_types(), progress_types); 265 EXPECT_EQ(enabled_types(), progress_types);
264 } 266 }
265 267
266 TEST_F(GetUpdatesProcessorTest, RetryTest) { 268 TEST_F(GetUpdatesProcessorTest, RetryTest) {
267 NudgeTracker nudge_tracker; 269 NudgeTracker nudge_tracker;
268 270
269 // Schedule a retry. 271 // Schedule a retry.
(...skipping 10 matching lines...) Expand all
280 processor->PrepareGetUpdates(enabled_types(), &message); 282 processor->PrepareGetUpdates(enabled_types(), &message);
281 283
282 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 284 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
283 EXPECT_EQ(sync_pb::SyncEnums::RETRY, gu_msg.get_updates_origin()); 285 EXPECT_EQ(sync_pb::SyncEnums::RETRY, gu_msg.get_updates_origin());
284 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RETRY, 286 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::RETRY,
285 gu_msg.caller_info().source()); 287 gu_msg.caller_info().source());
286 EXPECT_TRUE(gu_msg.is_retry()); 288 EXPECT_TRUE(gu_msg.is_retry());
287 289
288 ModelTypeSet progress_types; 290 ModelTypeSet progress_types;
289 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) { 291 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
290 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber( 292 ModelType type = GetModelTypeFromSpecificsFieldNumber(
291 gu_msg.from_progress_marker(i).data_type_id()); 293 gu_msg.from_progress_marker(i).data_type_id());
292 progress_types.Put(type); 294 progress_types.Put(type);
293 } 295 }
294 EXPECT_EQ(enabled_types(), progress_types); 296 EXPECT_EQ(enabled_types(), progress_types);
295 } 297 }
296 298
297 TEST_F(GetUpdatesProcessorTest, NudgeWithRetryTest) { 299 TEST_F(GetUpdatesProcessorTest, NudgeWithRetryTest) {
298 NudgeTracker nudge_tracker; 300 NudgeTracker nudge_tracker;
299 301
300 // Schedule a retry. 302 // Schedule a retry.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { 493 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) {
492 sync_pb::DebugInfo debug_info; 494 sync_pb::DebugInfo debug_info;
493 AddDebugEvent(); 495 AddDebugEvent();
494 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); 496 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info);
495 EXPECT_EQ(1, debug_info.events_size()); 497 EXPECT_EQ(1, debug_info.events_size());
496 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); 498 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info);
497 EXPECT_EQ(1, debug_info.events_size()); 499 EXPECT_EQ(1, debug_info.events_size());
498 } 500 }
499 501
500 } // namespace syncer 502 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/engine_impl/get_updates_processor.cc ('k') | components/sync/engine_impl/model_type_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698