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

Side by Side Diff: components/browser_sync/profile_sync_service_unittest.cc

Issue 2782553004: Move TestingPrefService to use unique_ptr<Value> (Closed)
Patch Set: comments Created 3 years, 8 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 (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 "components/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 TEST_F(ProfileSyncServiceTest, InitialState) { 363 TEST_F(ProfileSyncServiceTest, InitialState) {
364 CreateService(ProfileSyncService::AUTO_START); 364 CreateService(ProfileSyncService::AUTO_START);
365 InitializeForNthSync(); 365 InitializeForNthSync();
366 const std::string& url = service()->sync_service_url().spec(); 366 const std::string& url = service()->sync_service_url().spec();
367 EXPECT_TRUE(url == syncer::internal::kSyncServerUrl || 367 EXPECT_TRUE(url == syncer::internal::kSyncServerUrl ||
368 url == syncer::internal::kSyncDevServerUrl); 368 url == syncer::internal::kSyncDevServerUrl);
369 } 369 }
370 370
371 // Verify a successful initialization. 371 // Verify a successful initialization.
372 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) { 372 TEST_F(ProfileSyncServiceTest, SuccessfulInitialization) {
373 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, new base::Value(false)); 373 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
374 base::MakeUnique<base::Value>(false));
374 IssueTestTokens(); 375 IssueTestTokens();
375 CreateService(ProfileSyncService::AUTO_START); 376 CreateService(ProfileSyncService::AUTO_START);
376 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); 377 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
377 ExpectSyncEngineCreation(1); 378 ExpectSyncEngineCreation(1);
378 InitializeForNthSync(); 379 InitializeForNthSync();
379 EXPECT_FALSE(service()->IsManaged()); 380 EXPECT_FALSE(service()->IsManaged());
380 EXPECT_TRUE(service()->IsSyncActive()); 381 EXPECT_TRUE(service()->IsSyncActive());
381 } 382 }
382 383
383 // Verify a successful initialization. 384 // Verify a successful initialization.
384 TEST_F(ProfileSyncServiceTest, SuccessfulLocalBackendInitialization) { 385 TEST_F(ProfileSyncServiceTest, SuccessfulLocalBackendInitialization) {
385 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, new base::Value(false)); 386 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
387 base::MakeUnique<base::Value>(false));
386 IssueTestTokens(); 388 IssueTestTokens();
387 CreateServiceWithLocalSyncBackend(); 389 CreateServiceWithLocalSyncBackend();
388 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); 390 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
389 ExpectSyncEngineCreation(1); 391 ExpectSyncEngineCreation(1);
390 InitializeForNthSync(); 392 InitializeForNthSync();
391 EXPECT_FALSE(service()->IsManaged()); 393 EXPECT_FALSE(service()->IsManaged());
392 EXPECT_TRUE(service()->IsSyncActive()); 394 EXPECT_TRUE(service()->IsSyncActive());
393 } 395 }
394 396
395 // Verify that an initialization where first setup is not complete does not 397 // Verify that an initialization where first setup is not complete does not
396 // start up the backend. 398 // start up the backend.
397 TEST_F(ProfileSyncServiceTest, NeedsConfirmation) { 399 TEST_F(ProfileSyncServiceTest, NeedsConfirmation) {
398 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, new base::Value(false)); 400 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
401 base::MakeUnique<base::Value>(false));
399 IssueTestTokens(); 402 IssueTestTokens();
400 CreateService(ProfileSyncService::MANUAL_START); 403 CreateService(ProfileSyncService::MANUAL_START);
401 syncer::SyncPrefs sync_prefs(prefs()); 404 syncer::SyncPrefs sync_prefs(prefs());
402 base::Time now = base::Time::Now(); 405 base::Time now = base::Time::Now();
403 sync_prefs.SetLastSyncedTime(now); 406 sync_prefs.SetLastSyncedTime(now);
404 sync_prefs.SetKeepEverythingSynced(true); 407 sync_prefs.SetKeepEverythingSynced(true);
405 service()->Initialize(); 408 service()->Initialize();
406 EXPECT_FALSE(service()->IsSyncActive()); 409 EXPECT_FALSE(service()->IsSyncActive());
407 410
408 // The last sync time shouldn't be cleared. 411 // The last sync time shouldn't be cleared.
(...skipping 14 matching lines...) Expand all
423 auto sync_blocker = service()->GetSetupInProgressHandle(); 426 auto sync_blocker = service()->GetSetupInProgressHandle();
424 EXPECT_TRUE(observer.setup_in_progress()); 427 EXPECT_TRUE(observer.setup_in_progress());
425 sync_blocker.reset(); 428 sync_blocker.reset();
426 EXPECT_FALSE(observer.setup_in_progress()); 429 EXPECT_FALSE(observer.setup_in_progress());
427 430
428 service()->RemoveObserver(&observer); 431 service()->RemoveObserver(&observer);
429 } 432 }
430 433
431 // Verify that disable by enterprise policy works. 434 // Verify that disable by enterprise policy works.
432 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) { 435 TEST_F(ProfileSyncServiceTest, DisabledByPolicyBeforeInit) {
433 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, new base::Value(true)); 436 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
437 base::MakeUnique<base::Value>(true));
434 IssueTestTokens(); 438 IssueTestTokens();
435 CreateService(ProfileSyncService::AUTO_START); 439 CreateService(ProfileSyncService::AUTO_START);
436 InitializeForNthSync(); 440 InitializeForNthSync();
437 EXPECT_TRUE(service()->IsManaged()); 441 EXPECT_TRUE(service()->IsManaged());
438 EXPECT_FALSE(service()->IsSyncActive()); 442 EXPECT_FALSE(service()->IsSyncActive());
439 } 443 }
440 444
441 // Verify that disable by enterprise policy works even after the backend has 445 // Verify that disable by enterprise policy works even after the backend has
442 // been initialized. 446 // been initialized.
443 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) { 447 TEST_F(ProfileSyncServiceTest, DisabledByPolicyAfterInit) {
444 IssueTestTokens(); 448 IssueTestTokens();
445 CreateService(ProfileSyncService::AUTO_START); 449 CreateService(ProfileSyncService::AUTO_START);
446 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); 450 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
447 ExpectSyncEngineCreation(1); 451 ExpectSyncEngineCreation(1);
448 InitializeForNthSync(); 452 InitializeForNthSync();
449 453
450 EXPECT_FALSE(service()->IsManaged()); 454 EXPECT_FALSE(service()->IsManaged());
451 EXPECT_TRUE(service()->IsSyncActive()); 455 EXPECT_TRUE(service()->IsSyncActive());
452 456
453 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, new base::Value(true)); 457 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
458 base::MakeUnique<base::Value>(true));
454 459
455 EXPECT_TRUE(service()->IsManaged()); 460 EXPECT_TRUE(service()->IsManaged());
456 EXPECT_FALSE(service()->IsSyncActive()); 461 EXPECT_FALSE(service()->IsSyncActive());
457 } 462 }
458 463
459 // Exercies the ProfileSyncService's code paths related to getting shut down 464 // Exercies the ProfileSyncService's code paths related to getting shut down
460 // before the backend initialize call returns. 465 // before the backend initialize call returns.
461 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) { 466 TEST_F(ProfileSyncServiceTest, AbortedByShutdown) {
462 CreateService(ProfileSyncService::AUTO_START); 467 CreateService(ProfileSyncService::AUTO_START);
463 PrepareDelayedInitSyncEngine(); 468 PrepareDelayedInitSyncEngine();
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 // Progress the controller to RUNNING first, which is how the service 963 // Progress the controller to RUNNING first, which is how the service
959 // determines whether a type is enabled. 964 // determines whether a type is enabled.
960 controller->StartAssociating(base::Bind(&DoNothing)); 965 controller->StartAssociating(base::Bind(&DoNothing));
961 controller->FinishStart(DataTypeController::OK_FIRST_RUN); 966 controller->FinishStart(DataTypeController::OK_FIRST_RUN);
962 service()->RegisterDataTypeController(std::move(controller)); 967 service()->RegisterDataTypeController(std::move(controller));
963 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate()); 968 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate());
964 } 969 }
965 970
966 } // namespace 971 } // namespace
967 } // namespace browser_sync 972 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698