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

Side by Side Diff: chrome/browser/sync/glue/non_ui_data_type_controller_unittest.cc

Issue 16290004: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/sync/glue/non_ui_data_type_controller.h" 5 #include "chrome/browser/sync/glue/non_ui_data_type_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 &done)); 182 &done));
183 done.TimedWait(TestTimeouts::action_timeout()); 183 done.TimedWait(TestTimeouts::action_timeout());
184 if (!done.IsSignaled()) { 184 if (!done.IsSignaled()) {
185 ADD_FAILURE() << "Timed out waiting for DB thread to finish."; 185 ADD_FAILURE() << "Timed out waiting for DB thread to finish.";
186 } 186 }
187 base::MessageLoop::current()->RunUntilIdle(); 187 base::MessageLoop::current()->RunUntilIdle();
188 } 188 }
189 189
190 protected: 190 protected:
191 void SetStartExpectations() { 191 void SetStartExpectations() {
192 EXPECT_CALL(*dtc_mock_, StartModels()).WillOnce(Return(true)); 192 EXPECT_CALL(*dtc_mock_.get(), StartModels()).WillOnce(Return(true));
193 EXPECT_CALL(model_load_callback_, Run(_, _)); 193 EXPECT_CALL(model_load_callback_, Run(_, _));
194 EXPECT_CALL(*profile_sync_factory_, 194 EXPECT_CALL(*profile_sync_factory_,
195 CreateSharedChangeProcessor()). 195 CreateSharedChangeProcessor()).
196 WillOnce(Return(change_processor_.get())); 196 WillOnce(Return(change_processor_.get()));
197 } 197 }
198 198
199 void SetAssociateExpectations() { 199 void SetAssociateExpectations() {
200 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 200 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
201 WillOnce(GetWeakPtrToSyncableService(&syncable_service_)); 201 .WillOnce(GetWeakPtrToSyncableService(&syncable_service_));
202 EXPECT_CALL(*change_processor_, CryptoReadyIfNecessary()). 202 EXPECT_CALL(*change_processor_.get(), CryptoReadyIfNecessary())
203 WillOnce(Return(true)); 203 .WillOnce(Return(true));
204 EXPECT_CALL(*change_processor_, ActivateDataType(_)); 204 EXPECT_CALL(*change_processor_.get(), ActivateDataType(_));
205 EXPECT_CALL(*change_processor_, SyncModelHasUserCreatedNodes(_)). 205 EXPECT_CALL(*change_processor_.get(), SyncModelHasUserCreatedNodes(_))
206 WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true))); 206 .WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true)));
207 EXPECT_CALL(*change_processor_, GetSyncData(_)). 207 EXPECT_CALL(*change_processor_.get(), GetSyncData(_))
208 WillOnce(Return(syncer::SyncError())); 208 .WillOnce(Return(syncer::SyncError()));
209 EXPECT_CALL(*change_processor_, GetSyncCount()).WillOnce(Return(0)); 209 EXPECT_CALL(*change_processor_.get(), GetSyncCount()).WillOnce(Return(0));
210 EXPECT_CALL(*dtc_mock_, RecordAssociationTime(_)); 210 EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_));
211 } 211 }
212 212
213 void SetActivateExpectations(DataTypeController::StartResult result) { 213 void SetActivateExpectations(DataTypeController::StartResult result) {
214 EXPECT_CALL(start_callback_, Run(result,_,_)); 214 EXPECT_CALL(start_callback_, Run(result,_,_));
215 } 215 }
216 216
217 void SetStopExpectations() { 217 void SetStopExpectations() {
218 EXPECT_CALL(*dtc_mock_, StopModels()); 218 EXPECT_CALL(*dtc_mock_.get(), StopModels());
219 EXPECT_CALL(*change_processor_, Disconnect()).WillOnce(Return(true)); 219 EXPECT_CALL(*change_processor_.get(), Disconnect()).WillOnce(Return(true));
220 EXPECT_CALL(service_, DeactivateDataType(_)); 220 EXPECT_CALL(service_, DeactivateDataType(_));
221 } 221 }
222 222
223 void SetStartFailExpectations(DataTypeController::StartResult result) { 223 void SetStartFailExpectations(DataTypeController::StartResult result) {
224 EXPECT_CALL(*dtc_mock_, StopModels()).Times(AtLeast(1)); 224 EXPECT_CALL(*dtc_mock_.get(), StopModels()).Times(AtLeast(1));
225 if (DataTypeController::IsUnrecoverableResult(result)) 225 if (DataTypeController::IsUnrecoverableResult(result))
226 EXPECT_CALL(*dtc_mock_, RecordUnrecoverableError(_, _)); 226 EXPECT_CALL(*dtc_mock_.get(), RecordUnrecoverableError(_, _));
227 EXPECT_CALL(*dtc_mock_, RecordStartFailure(result)); 227 EXPECT_CALL(*dtc_mock_.get(), RecordStartFailure(result));
228 EXPECT_CALL(start_callback_, Run(result,_,_)); 228 EXPECT_CALL(start_callback_, Run(result, _, _));
229 } 229 }
230 230
231 void Start() { 231 void Start() {
232 non_ui_dtc_->LoadModels( 232 non_ui_dtc_->LoadModels(
233 base::Bind(&ModelLoadCallbackMock::Run, 233 base::Bind(&ModelLoadCallbackMock::Run,
234 base::Unretained(&model_load_callback_))); 234 base::Unretained(&model_load_callback_)));
235 non_ui_dtc_->StartAssociating( 235 non_ui_dtc_->StartAssociating(
236 base::Bind(&StartCallbackMock::Run, 236 base::Bind(&StartCallbackMock::Run,
237 base::Unretained(&start_callback_))); 237 base::Unretained(&start_callback_)));
238 } 238 }
(...skipping 23 matching lines...) Expand all
262 SetAssociateExpectations(); 262 SetAssociateExpectations();
263 SetActivateExpectations(DataTypeController::OK); 263 SetActivateExpectations(DataTypeController::OK);
264 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 264 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
265 Start(); 265 Start();
266 WaitForDTC(); 266 WaitForDTC();
267 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state()); 267 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state());
268 } 268 }
269 269
270 TEST_F(SyncNonUIDataTypeControllerTest, StartFirstRun) { 270 TEST_F(SyncNonUIDataTypeControllerTest, StartFirstRun) {
271 SetStartExpectations(); 271 SetStartExpectations();
272 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 272 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
273 WillOnce(GetWeakPtrToSyncableService(&syncable_service_)); 273 .WillOnce(GetWeakPtrToSyncableService(&syncable_service_));
274 EXPECT_CALL(*change_processor_, CryptoReadyIfNecessary()). 274 EXPECT_CALL(*change_processor_.get(), CryptoReadyIfNecessary())
275 WillOnce(Return(true)); 275 .WillOnce(Return(true));
276 EXPECT_CALL(*change_processor_, SyncModelHasUserCreatedNodes(_)). 276 EXPECT_CALL(*change_processor_.get(), SyncModelHasUserCreatedNodes(_))
277 WillOnce(DoAll(SetArgumentPointee<0>(false), Return(true))); 277 .WillOnce(DoAll(SetArgumentPointee<0>(false), Return(true)));
278 EXPECT_CALL(*change_processor_, GetSyncData(_)). 278 EXPECT_CALL(*change_processor_.get(), GetSyncData(_))
279 WillOnce(Return(syncer::SyncError())); 279 .WillOnce(Return(syncer::SyncError()));
280 EXPECT_CALL(*dtc_mock_, RecordAssociationTime(_)); 280 EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_));
281 SetActivateExpectations(DataTypeController::OK_FIRST_RUN); 281 SetActivateExpectations(DataTypeController::OK_FIRST_RUN);
282 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 282 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
283 Start(); 283 Start();
284 WaitForDTC(); 284 WaitForDTC();
285 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state()); 285 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state());
286 } 286 }
287 287
288 // Start the DTC and have StartModels() return false. Then, stop the 288 // Start the DTC and have StartModels() return false. Then, stop the
289 // DTC without finishing model startup. It should stop cleanly. 289 // DTC without finishing model startup. It should stop cleanly.
290 TEST_F(SyncNonUIDataTypeControllerTest, AbortDuringStartModels) { 290 TEST_F(SyncNonUIDataTypeControllerTest, AbortDuringStartModels) {
291 EXPECT_CALL(*profile_sync_factory_, 291 EXPECT_CALL(*profile_sync_factory_,
292 CreateSharedChangeProcessor()). 292 CreateSharedChangeProcessor()).
293 WillOnce(Return(change_processor_.get())); 293 WillOnce(Return(change_processor_.get()));
294 EXPECT_CALL(*dtc_mock_, StartModels()).WillOnce(Return(false)); 294 EXPECT_CALL(*dtc_mock_.get(), StartModels()).WillOnce(Return(false));
295 EXPECT_CALL(*dtc_mock_, StopModels()); 295 EXPECT_CALL(*dtc_mock_.get(), StopModels());
296 EXPECT_CALL(model_load_callback_, Run(_, _)); 296 EXPECT_CALL(model_load_callback_, Run(_, _));
297 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 297 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
298 non_ui_dtc_->LoadModels( 298 non_ui_dtc_->LoadModels(
299 base::Bind(&ModelLoadCallbackMock::Run, 299 base::Bind(&ModelLoadCallbackMock::Run,
300 base::Unretained(&model_load_callback_))); 300 base::Unretained(&model_load_callback_)));
301 WaitForDTC(); 301 WaitForDTC();
302 EXPECT_EQ(DataTypeController::MODEL_STARTING, non_ui_dtc_->state()); 302 EXPECT_EQ(DataTypeController::MODEL_STARTING, non_ui_dtc_->state());
303 non_ui_dtc_->Stop(); 303 non_ui_dtc_->Stop();
304 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 304 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
305 } 305 }
306 306
307 // Start the DTC and have MergeDataAndStartSyncing() return an error. 307 // Start the DTC and have MergeDataAndStartSyncing() return an error.
308 // The DTC should become disabled, and the DTC should still stop 308 // The DTC should become disabled, and the DTC should still stop
309 // cleanly. 309 // cleanly.
310 TEST_F(SyncNonUIDataTypeControllerTest, StartAssociationFailed) { 310 TEST_F(SyncNonUIDataTypeControllerTest, StartAssociationFailed) {
311 SetStartExpectations(); 311 SetStartExpectations();
312 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 312 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
313 WillOnce(GetWeakPtrToSyncableService(&syncable_service_)); 313 .WillOnce(GetWeakPtrToSyncableService(&syncable_service_));
314 EXPECT_CALL(*change_processor_, CryptoReadyIfNecessary()). 314 EXPECT_CALL(*change_processor_.get(), CryptoReadyIfNecessary())
315 WillOnce(Return(true)); 315 .WillOnce(Return(true));
316 EXPECT_CALL(*change_processor_, SyncModelHasUserCreatedNodes(_)). 316 EXPECT_CALL(*change_processor_.get(), SyncModelHasUserCreatedNodes(_))
317 WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true))); 317 .WillOnce(DoAll(SetArgumentPointee<0>(true), Return(true)));
318 EXPECT_CALL(*change_processor_, GetSyncData(_)). 318 EXPECT_CALL(*change_processor_.get(), GetSyncData(_))
319 WillOnce(Return(syncer::SyncError())); 319 .WillOnce(Return(syncer::SyncError()));
320 EXPECT_CALL(*dtc_mock_, RecordAssociationTime(_)); 320 EXPECT_CALL(*dtc_mock_.get(), RecordAssociationTime(_));
321 SetStartFailExpectations(DataTypeController::ASSOCIATION_FAILED); 321 SetStartFailExpectations(DataTypeController::ASSOCIATION_FAILED);
322 // Set up association to fail with an association failed error. 322 // Set up association to fail with an association failed error.
323 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 323 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
324 syncable_service_.set_merge_data_and_start_syncing_error( 324 syncable_service_.set_merge_data_and_start_syncing_error(
325 syncer::SyncError(FROM_HERE, 325 syncer::SyncError(FROM_HERE,
326 "Sync Error", non_ui_dtc_->type())); 326 "Sync Error", non_ui_dtc_->type()));
327 Start(); 327 Start();
328 WaitForDTC(); 328 WaitForDTC();
329 EXPECT_EQ(DataTypeController::DISABLED, non_ui_dtc_->state()); 329 EXPECT_EQ(DataTypeController::DISABLED, non_ui_dtc_->state());
330 non_ui_dtc_->Stop(); 330 non_ui_dtc_->Stop();
331 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 331 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
332 } 332 }
333 333
334 TEST_F(SyncNonUIDataTypeControllerTest, 334 TEST_F(SyncNonUIDataTypeControllerTest,
335 StartAssociationTriggersUnrecoverableError) { 335 StartAssociationTriggersUnrecoverableError) {
336 SetStartExpectations(); 336 SetStartExpectations();
337 SetStartFailExpectations(DataTypeController::UNRECOVERABLE_ERROR); 337 SetStartFailExpectations(DataTypeController::UNRECOVERABLE_ERROR);
338 // Set up association to fail with an unrecoverable error. 338 // Set up association to fail with an unrecoverable error.
339 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 339 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
340 WillOnce(GetWeakPtrToSyncableService(&syncable_service_)); 340 .WillOnce(GetWeakPtrToSyncableService(&syncable_service_));
341 EXPECT_CALL(*change_processor_, CryptoReadyIfNecessary()). 341 EXPECT_CALL(*change_processor_.get(), CryptoReadyIfNecessary())
342 WillRepeatedly(Return(true)); 342 .WillRepeatedly(Return(true));
343 EXPECT_CALL(*change_processor_, SyncModelHasUserCreatedNodes(_)). 343 EXPECT_CALL(*change_processor_.get(), SyncModelHasUserCreatedNodes(_))
344 WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false))); 344 .WillRepeatedly(DoAll(SetArgumentPointee<0>(false), Return(false)));
345 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 345 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
346 Start(); 346 Start();
347 WaitForDTC(); 347 WaitForDTC();
348 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 348 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
349 } 349 }
350 350
351 TEST_F(SyncNonUIDataTypeControllerTest, 351 TEST_F(SyncNonUIDataTypeControllerTest,
352 StartAssociationCryptoNotReady) { 352 StartAssociationCryptoNotReady) {
353 SetStartExpectations(); 353 SetStartExpectations();
354 SetStartFailExpectations(DataTypeController::NEEDS_CRYPTO); 354 SetStartFailExpectations(DataTypeController::NEEDS_CRYPTO);
355 // Set up association to fail with a NEEDS_CRYPTO error. 355 // Set up association to fail with a NEEDS_CRYPTO error.
356 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 356 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
357 WillOnce(GetWeakPtrToSyncableService(&syncable_service_)); 357 .WillOnce(GetWeakPtrToSyncableService(&syncable_service_));
358 EXPECT_CALL(*change_processor_, CryptoReadyIfNecessary()). 358 EXPECT_CALL(*change_processor_.get(), CryptoReadyIfNecessary())
359 WillRepeatedly(Return(false)); 359 .WillRepeatedly(Return(false));
360 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 360 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
361 Start(); 361 Start();
362 WaitForDTC(); 362 WaitForDTC();
363 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 363 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
364 } 364 }
365 365
366 // Trigger a Stop() call when we check if the model associator has user created 366 // Trigger a Stop() call when we check if the model associator has user created
367 // nodes. 367 // nodes.
368 TEST_F(SyncNonUIDataTypeControllerTest, AbortDuringAssociation) { 368 TEST_F(SyncNonUIDataTypeControllerTest, AbortDuringAssociation) {
369 WaitableEvent wait_for_db_thread_pause(false, false); 369 WaitableEvent wait_for_db_thread_pause(false, false);
370 WaitableEvent pause_db_thread(false, false); 370 WaitableEvent pause_db_thread(false, false);
371 371
372 SetStartExpectations(); 372 SetStartExpectations();
373 SetStartFailExpectations(DataTypeController::ABORTED); 373 SetStartFailExpectations(DataTypeController::ABORTED);
374 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 374 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
375 WillOnce(GetWeakPtrToSyncableService(&syncable_service_)); 375 .WillOnce(GetWeakPtrToSyncableService(&syncable_service_));
376 EXPECT_CALL(*change_processor_, CryptoReadyIfNecessary()). 376 EXPECT_CALL(*change_processor_.get(), CryptoReadyIfNecessary())
377 WillOnce(Return(true)); 377 .WillOnce(Return(true));
378 EXPECT_CALL(*change_processor_, SyncModelHasUserCreatedNodes(_)). 378 EXPECT_CALL(*change_processor_.get(), SyncModelHasUserCreatedNodes(_))
379 WillOnce(DoAll( 379 .WillOnce(DoAll(SignalEvent(&wait_for_db_thread_pause),
380 SignalEvent(&wait_for_db_thread_pause), 380 WaitOnEvent(&pause_db_thread),
381 WaitOnEvent(&pause_db_thread), 381 SetArgumentPointee<0>(true),
382 SetArgumentPointee<0>(true), 382 Return(true)));
383 Return(true))); 383 EXPECT_CALL(*change_processor_.get(), GetSyncData(_)).WillOnce(
384 EXPECT_CALL(*change_processor_, GetSyncData(_)). 384 Return(syncer::SyncError(FROM_HERE, "Disconnected.", AUTOFILL_PROFILE)));
385 WillOnce( 385 EXPECT_CALL(*change_processor_.get(), Disconnect())
386 Return( 386 .WillOnce(DoAll(SignalEvent(&pause_db_thread), Return(true)));
387 syncer::SyncError(FROM_HERE, "Disconnected.", AUTOFILL_PROFILE)));
388 EXPECT_CALL(*change_processor_, Disconnect()).
389 WillOnce(DoAll(SignalEvent(&pause_db_thread), Return(true)));
390 EXPECT_CALL(service_, DeactivateDataType(_)); 387 EXPECT_CALL(service_, DeactivateDataType(_));
391 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 388 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
392 Start(); 389 Start();
393 wait_for_db_thread_pause.Wait(); 390 wait_for_db_thread_pause.Wait();
394 non_ui_dtc_->Stop(); 391 non_ui_dtc_->Stop();
395 WaitForDTC(); 392 WaitForDTC();
396 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 393 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
397 } 394 }
398 395
399 // Start the DTC while the backend tasks are blocked. Then stop the DTC before 396 // Start the DTC while the backend tasks are blocked. Then stop the DTC before
400 // the backend tasks get a chance to run. The DTC should have no interaction 397 // the backend tasks get a chance to run. The DTC should have no interaction
401 // with the profile sync factory or profile sync service once stopped. 398 // with the profile sync factory or profile sync service once stopped.
402 TEST_F(SyncNonUIDataTypeControllerTest, StartAfterSyncShutdown) { 399 TEST_F(SyncNonUIDataTypeControllerTest, StartAfterSyncShutdown) {
403 non_ui_dtc_->BlockBackendTasks(); 400 non_ui_dtc_->BlockBackendTasks();
404 401
405 SetStartExpectations(); 402 SetStartExpectations();
406 // We don't expect StopSyncing to be called because local_service_ will never 403 // We don't expect StopSyncing to be called because local_service_ will never
407 // have been set. 404 // have been set.
408 EXPECT_CALL(*change_processor_, Disconnect()).WillOnce(Return(true)); 405 EXPECT_CALL(*change_processor_.get(), Disconnect()).WillOnce(Return(true));
409 EXPECT_CALL(*dtc_mock_, StopModels()); 406 EXPECT_CALL(*dtc_mock_.get(), StopModels());
410 EXPECT_CALL(service_, DeactivateDataType(_)); 407 EXPECT_CALL(service_, DeactivateDataType(_));
411 EXPECT_CALL(*dtc_mock_, RecordStartFailure(DataTypeController::ABORTED)); 408 EXPECT_CALL(*dtc_mock_.get(),
409 RecordStartFailure(DataTypeController::ABORTED));
412 EXPECT_CALL(start_callback_, Run(DataTypeController::ABORTED, _, _)); 410 EXPECT_CALL(start_callback_, Run(DataTypeController::ABORTED, _, _));
413 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 411 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
414 Start(); 412 Start();
415 non_ui_dtc_->Stop(); 413 non_ui_dtc_->Stop();
416 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 414 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
417 Mock::VerifyAndClearExpectations(&profile_sync_factory_); 415 Mock::VerifyAndClearExpectations(&profile_sync_factory_);
418 Mock::VerifyAndClearExpectations(&service_); 416 Mock::VerifyAndClearExpectations(&service_);
419 Mock::VerifyAndClearExpectations(change_processor_); 417 Mock::VerifyAndClearExpectations(change_processor_.get());
420 Mock::VerifyAndClearExpectations(dtc_mock_); 418 Mock::VerifyAndClearExpectations(dtc_mock_.get());
421 419
422 EXPECT_CALL(*change_processor_, Connect(_,_,_,_,_)). 420 EXPECT_CALL(*change_processor_.get(), Connect(_, _, _, _, _))
423 WillOnce(Return(base::WeakPtr<syncer::SyncableService>())); 421 .WillOnce(Return(base::WeakPtr<syncer::SyncableService>()));
424 non_ui_dtc_->UnblockBackendTasks(); 422 non_ui_dtc_->UnblockBackendTasks();
425 WaitForDTC(); 423 WaitForDTC();
426 } 424 }
427 425
428 TEST_F(SyncNonUIDataTypeControllerTest, Stop) { 426 TEST_F(SyncNonUIDataTypeControllerTest, Stop) {
429 SetStartExpectations(); 427 SetStartExpectations();
430 SetAssociateExpectations(); 428 SetAssociateExpectations();
431 SetActivateExpectations(DataTypeController::OK); 429 SetActivateExpectations(DataTypeController::OK);
432 SetStopExpectations(); 430 SetStopExpectations();
433 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 431 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
(...skipping 30 matching lines...) Expand all
464 462
465 WaitForDTC(); 463 WaitForDTC();
466 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state()); 464 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state());
467 } 465 }
468 466
469 TEST_F(SyncNonUIDataTypeControllerTest, 467 TEST_F(SyncNonUIDataTypeControllerTest,
470 OnSingleDatatypeUnrecoverableError) { 468 OnSingleDatatypeUnrecoverableError) {
471 SetStartExpectations(); 469 SetStartExpectations();
472 SetAssociateExpectations(); 470 SetAssociateExpectations();
473 SetActivateExpectations(DataTypeController::OK); 471 SetActivateExpectations(DataTypeController::OK);
474 EXPECT_CALL(*dtc_mock_, RecordUnrecoverableError(_, "Test")); 472 EXPECT_CALL(*dtc_mock_.get(), RecordUnrecoverableError(_, "Test"));
475 EXPECT_CALL(service_, DisableBrokenDatatype(_,_,_)).WillOnce( 473 EXPECT_CALL(service_, DisableBrokenDatatype(_, _, _)).WillOnce(
476 InvokeWithoutArgs(non_ui_dtc_.get(), 474 InvokeWithoutArgs(non_ui_dtc_.get(), &NonUIDataTypeController::Stop));
477 &NonUIDataTypeController::Stop));
478 SetStopExpectations(); 475 SetStopExpectations();
479 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 476 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
480 Start(); 477 Start();
481 WaitForDTC(); 478 WaitForDTC();
482 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state()); 479 EXPECT_EQ(DataTypeController::RUNNING, non_ui_dtc_->state());
483 // This should cause non_ui_dtc_->Stop() to be called. 480 // This should cause non_ui_dtc_->Stop() to be called.
484 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, base::Bind( 481 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, base::Bind(
485 &NonUIDataTypeControllerFake:: 482 &NonUIDataTypeControllerFake::
486 OnSingleDatatypeUnrecoverableError, 483 OnSingleDatatypeUnrecoverableError,
487 non_ui_dtc_.get(), 484 non_ui_dtc_.get(),
488 FROM_HERE, 485 FROM_HERE,
489 std::string("Test"))); 486 std::string("Test")));
490 WaitForDTC(); 487 WaitForDTC();
491 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state()); 488 EXPECT_EQ(DataTypeController::NOT_RUNNING, non_ui_dtc_->state());
492 } 489 }
493 490
494 } // namespace 491 } // namespace
495 492
496 } // namespace browser_sync 493 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/non_ui_data_type_controller.cc ('k') | chrome/browser/sync/glue/password_model_worker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698