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

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

Issue 387983004: sync: Support non-blocking initial sync in proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + fix comment Created 6 years, 5 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 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 "sync/engine/get_updates_processor.h" 5 #include "sync/engine/get_updates_processor.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/get_updates_delegate.h" 9 #include "sync/engine/get_updates_delegate.h"
10 #include "sync/engine/update_handler.h" 10 #include "sync/engine/update_handler.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 EXPECT_TRUE(progress_marker.has_notification_hint()); 180 EXPECT_TRUE(progress_marker.has_notification_hint());
181 EXPECT_FALSE(progress_marker.notification_hint().empty()); 181 EXPECT_FALSE(progress_marker.notification_hint().empty());
182 EXPECT_EQ(1, gu_trigger.notification_hint_size()); 182 EXPECT_EQ(1, gu_trigger.notification_hint_size());
183 } else { 183 } else {
184 EXPECT_FALSE(progress_marker.has_notification_hint()); 184 EXPECT_FALSE(progress_marker.has_notification_hint());
185 EXPECT_EQ(0, gu_trigger.notification_hint_size()); 185 EXPECT_EQ(0, gu_trigger.notification_hint_size());
186 } 186 }
187 } 187 }
188 } 188 }
189 189
190 // Basic test to ensure initial sync requests are expressed in the request.
191 TEST_F(GetUpdatesProcessorTest, InitialSyncRequest) {
192 sessions::NudgeTracker nudge_tracker;
193 nudge_tracker.RecordInitialSyncRequired(AUTOFILL);
194 nudge_tracker.RecordInitialSyncRequired(PREFERENCES);
195
196 ModelTypeSet initial_sync_types = ModelTypeSet(AUTOFILL, PREFERENCES);
197
198 sync_pb::ClientToServerMessage message;
199 NormalGetUpdatesDelegate normal_delegate(nudge_tracker);
200 scoped_ptr<GetUpdatesProcessor> processor(
201 BuildGetUpdatesProcessor(normal_delegate));
202 processor->PrepareGetUpdates(enabled_types(), &message);
203
204 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
205 EXPECT_EQ(sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH,
206 gu_msg.caller_info().source());
207 EXPECT_EQ(sync_pb::SyncEnums::GU_TRIGGER, gu_msg.get_updates_origin());
208 for (int i = 0; i < gu_msg.from_progress_marker_size(); ++i) {
209 syncer::ModelType type = GetModelTypeFromSpecificsFieldNumber(
210 gu_msg.from_progress_marker(i).data_type_id());
211
212 const sync_pb::DataTypeProgressMarker& progress_marker =
213 gu_msg.from_progress_marker(i);
214 const sync_pb::GetUpdateTriggers& gu_trigger =
215 progress_marker.get_update_triggers();
216
217 // We perform some basic tests of GU trigger and source fields here. The
218 // more complicated scenarios are tested by the NudgeTracker tests.
219 if (initial_sync_types.Has(type)) {
220 EXPECT_TRUE(gu_trigger.initial_sync_in_progress());
221 } else {
222 EXPECT_TRUE(gu_trigger.has_initial_sync_in_progress());
223 EXPECT_FALSE(gu_trigger.initial_sync_in_progress());
224 }
225 }
226 }
227
190 TEST_F(GetUpdatesProcessorTest, ConfigureTest) { 228 TEST_F(GetUpdatesProcessorTest, ConfigureTest) {
191 sync_pb::ClientToServerMessage message; 229 sync_pb::ClientToServerMessage message;
192 ConfigureGetUpdatesDelegate configure_delegate( 230 ConfigureGetUpdatesDelegate configure_delegate(
193 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION); 231 sync_pb::GetUpdatesCallerInfo::RECONFIGURATION);
194 scoped_ptr<GetUpdatesProcessor> processor( 232 scoped_ptr<GetUpdatesProcessor> processor(
195 BuildGetUpdatesProcessor(configure_delegate)); 233 BuildGetUpdatesProcessor(configure_delegate));
196 processor->PrepareGetUpdates(enabled_types(), &message); 234 processor->PrepareGetUpdates(enabled_types(), &message);
197 235
198 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates(); 236 const sync_pb::GetUpdatesMessage& gu_msg = message.get_updates();
199 EXPECT_EQ(sync_pb::SyncEnums::RECONFIGURATION, gu_msg.get_updates_origin()); 237 EXPECT_EQ(sync_pb::SyncEnums::RECONFIGURATION, gu_msg.get_updates_origin());
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) { 505 TEST_F(DownloadUpdatesDebugInfoTest, VerifyCopyOverwrites) {
468 sync_pb::DebugInfo debug_info; 506 sync_pb::DebugInfo debug_info;
469 AddDebugEvent(); 507 AddDebugEvent();
470 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); 508 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info);
471 EXPECT_EQ(1, debug_info.events_size()); 509 EXPECT_EQ(1, debug_info.events_size());
472 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info); 510 GetUpdatesProcessor::CopyClientDebugInfo(debug_info_getter(), &debug_info);
473 EXPECT_EQ(1, debug_info.events_size()); 511 EXPECT_EQ(1, debug_info.events_size());
474 } 512 }
475 513
476 } // namespace syncer 514 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698