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

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 16207005: Fix remaining uses of WeakPtr<T>'s operator T* conversion (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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 EXPECT_FALSE(harness_.service->sync_initialized()); 314 EXPECT_FALSE(harness_.service->sync_initialized());
315 } 315 }
316 316
317 #endif // !defined(OS_CHROMEOS) 317 #endif // !defined(OS_CHROMEOS)
318 318
319 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) { 319 TEST_F(ProfileSyncServiceTest, JsControllerHandlersBasic) {
320 harness_.StartSyncService(); 320 harness_.StartSyncService();
321 EXPECT_TRUE(harness_.service->sync_initialized()); 321 EXPECT_TRUE(harness_.service->sync_initialized());
322 EXPECT_TRUE(harness_.service->GetBackendForTest() != NULL); 322 EXPECT_TRUE(harness_.service->GetBackendForTest() != NULL);
323 323
324 syncer::JsController* js_controller = harness_.service->GetJsController(); 324 base::WeakPtr<syncer::JsController> js_controller =
325 harness_.service->GetJsController();
325 StrictMock<syncer::MockJsEventHandler> event_handler; 326 StrictMock<syncer::MockJsEventHandler> event_handler;
326 js_controller->AddJsEventHandler(&event_handler); 327 js_controller->AddJsEventHandler(&event_handler);
327 js_controller->RemoveJsEventHandler(&event_handler); 328 js_controller->RemoveJsEventHandler(&event_handler);
328 } 329 }
329 330
330 TEST_F(ProfileSyncServiceTest, 331 TEST_F(ProfileSyncServiceTest,
331 JsControllerHandlersDelayedBackendInitialization) { 332 JsControllerHandlersDelayedBackendInitialization) {
332 harness_.StartSyncServiceAndSetInitialSyncEnded(true, false, false, true, 333 harness_.StartSyncServiceAndSetInitialSyncEnded(true, false, false, true,
333 syncer::STORAGE_IN_MEMORY); 334 syncer::STORAGE_IN_MEMORY);
334 335
335 StrictMock<syncer::MockJsEventHandler> event_handler; 336 StrictMock<syncer::MockJsEventHandler> event_handler;
336 EXPECT_CALL(event_handler, HandleJsEvent(_, _)).Times(AtLeast(1)); 337 EXPECT_CALL(event_handler, HandleJsEvent(_, _)).Times(AtLeast(1));
337 338
338 EXPECT_EQ(NULL, harness_.service->GetBackendForTest()); 339 EXPECT_EQ(NULL, harness_.service->GetBackendForTest());
339 EXPECT_FALSE(harness_.service->sync_initialized()); 340 EXPECT_FALSE(harness_.service->sync_initialized());
340 341
341 syncer::JsController* js_controller = harness_.service->GetJsController(); 342 base::WeakPtr<syncer::JsController> js_controller =
343 harness_.service->GetJsController();
342 js_controller->AddJsEventHandler(&event_handler); 344 js_controller->AddJsEventHandler(&event_handler);
343 // Since we're doing synchronous initialization, backend should be 345 // Since we're doing synchronous initialization, backend should be
344 // initialized by this call. 346 // initialized by this call.
345 harness_.IssueTestTokens(); 347 harness_.IssueTestTokens();
346 EXPECT_TRUE(harness_.service->sync_initialized()); 348 EXPECT_TRUE(harness_.service->sync_initialized());
347 js_controller->RemoveJsEventHandler(&event_handler); 349 js_controller->RemoveJsEventHandler(&event_handler);
348 } 350 }
349 351
350 TEST_F(ProfileSyncServiceTest, JsControllerProcessJsMessageBasic) { 352 TEST_F(ProfileSyncServiceTest, JsControllerProcessJsMessageBasic) {
351 harness_.StartSyncService(); 353 harness_.StartSyncService();
352 354
353 StrictMock<syncer::MockJsReplyHandler> reply_handler; 355 StrictMock<syncer::MockJsReplyHandler> reply_handler;
354 356
355 ListValue arg_list1; 357 ListValue arg_list1;
356 arg_list1.Append(Value::CreateStringValue("TRANSIENT_INVALIDATION_ERROR")); 358 arg_list1.Append(Value::CreateStringValue("TRANSIENT_INVALIDATION_ERROR"));
357 syncer::JsArgList args1(&arg_list1); 359 syncer::JsArgList args1(&arg_list1);
358 EXPECT_CALL(reply_handler, 360 EXPECT_CALL(reply_handler,
359 HandleJsReply("getNotificationState", HasArgs(args1))); 361 HandleJsReply("getNotificationState", HasArgs(args1)));
360 362
361 { 363 {
362 syncer::JsController* js_controller = harness_.service->GetJsController(); 364 base::WeakPtr<syncer::JsController> js_controller =
365 harness_.service->GetJsController();
363 js_controller->ProcessJsMessage("getNotificationState", args1, 366 js_controller->ProcessJsMessage("getNotificationState", args1,
364 reply_handler.AsWeakHandle()); 367 reply_handler.AsWeakHandle());
365 } 368 }
366 369
367 // This forces the sync thread to process the message and reply. 370 // This forces the sync thread to process the message and reply.
368 harness_.TearDown(); 371 harness_.TearDown();
369 } 372 }
370 373
371 TEST_F(ProfileSyncServiceTest, 374 TEST_F(ProfileSyncServiceTest,
372 JsControllerProcessJsMessageBasicDelayedBackendInitialization) { 375 JsControllerProcessJsMessageBasicDelayedBackendInitialization) {
373 harness_.StartSyncServiceAndSetInitialSyncEnded(true, false, false, true, 376 harness_.StartSyncServiceAndSetInitialSyncEnded(true, false, false, true,
374 syncer::STORAGE_IN_MEMORY); 377 syncer::STORAGE_IN_MEMORY);
375 378
376 StrictMock<syncer::MockJsReplyHandler> reply_handler; 379 StrictMock<syncer::MockJsReplyHandler> reply_handler;
377 380
378 ListValue arg_list1; 381 ListValue arg_list1;
379 arg_list1.Append(Value::CreateStringValue("TRANSIENT_INVALIDATION_ERROR")); 382 arg_list1.Append(Value::CreateStringValue("TRANSIENT_INVALIDATION_ERROR"));
380 syncer::JsArgList args1(&arg_list1); 383 syncer::JsArgList args1(&arg_list1);
381 EXPECT_CALL(reply_handler, 384 EXPECT_CALL(reply_handler,
382 HandleJsReply("getNotificationState", HasArgs(args1))); 385 HandleJsReply("getNotificationState", HasArgs(args1)));
383 386
384 { 387 {
385 syncer::JsController* js_controller = harness_.service->GetJsController(); 388 base::WeakPtr<syncer::JsController> js_controller =
389 harness_.service->GetJsController();
386 js_controller->ProcessJsMessage("getNotificationState", 390 js_controller->ProcessJsMessage("getNotificationState",
387 args1, reply_handler.AsWeakHandle()); 391 args1, reply_handler.AsWeakHandle());
388 } 392 }
389 393
390 harness_.IssueTestTokens(); 394 harness_.IssueTestTokens();
391 395
392 // This forces the sync thread to process the message and reply. 396 // This forces the sync thread to process the message and reply.
393 harness_.TearDown(); 397 harness_.TearDown();
394 } 398 }
395 399
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 namespace syncer { 633 namespace syncer {
630 namespace { 634 namespace {
631 635
632 // ProfileSyncService should behave just like an invalidator. 636 // ProfileSyncService should behave just like an invalidator.
633 INSTANTIATE_TYPED_TEST_CASE_P( 637 INSTANTIATE_TYPED_TEST_CASE_P(
634 ProfileSyncServiceInvalidatorTest, InvalidatorTest, 638 ProfileSyncServiceInvalidatorTest, InvalidatorTest,
635 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate); 639 ::browser_sync::ProfileSyncServiceInvalidatorTestDelegate);
636 640
637 } // namespace 641 } // namespace
638 } // namespace syncer 642 } // namespace syncer
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service.cc ('k') | chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698