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

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

Issue 2961673002: [sync] Fix IsSyncConfirmationNeeded crash when local backend is enabled (Closed)
Patch Set: Fix cros test Created 3 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
« no previous file with comments | « components/browser_sync/profile_sync_service_startup_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 component_factory_ = profile_sync_service_bundle_.component_factory(); 215 component_factory_ = profile_sync_service_bundle_.component_factory();
216 ProfileSyncServiceBundle::SyncClientBuilder builder( 216 ProfileSyncServiceBundle::SyncClientBuilder builder(
217 &profile_sync_service_bundle_); 217 &profile_sync_service_bundle_);
218 ProfileSyncService::InitParams init_params = 218 ProfileSyncService::InitParams init_params =
219 profile_sync_service_bundle_.CreateBasicInitParams( 219 profile_sync_service_bundle_.CreateBasicInitParams(
220 ProfileSyncService::AUTO_START, builder.Build()); 220 ProfileSyncService::AUTO_START, builder.Build());
221 221
222 prefs()->SetBoolean(syncer::prefs::kEnableLocalSyncBackend, true); 222 prefs()->SetBoolean(syncer::prefs::kEnableLocalSyncBackend, true);
223 init_params.oauth2_token_service = nullptr; 223 init_params.oauth2_token_service = nullptr;
224 init_params.gaia_cookie_manager_service = nullptr; 224 init_params.gaia_cookie_manager_service = nullptr;
225 init_params.signin_wrapper.reset();
225 226
226 service_ = base::MakeUnique<ProfileSyncService>(std::move(init_params)); 227 service_ = base::MakeUnique<ProfileSyncService>(std::move(init_params));
227 service_->RegisterDataTypeController( 228 service_->RegisterDataTypeController(
228 base::MakeUnique<syncer::FakeDataTypeController>(syncer::BOOKMARKS)); 229 base::MakeUnique<syncer::FakeDataTypeController>(syncer::BOOKMARKS));
229 } 230 }
230 231
231 void ShutdownAndDeleteService() { 232 void ShutdownAndDeleteService() {
232 if (service_) 233 if (service_)
233 service_->Shutdown(); 234 service_->Shutdown();
234 service_.reset(); 235 service_.reset();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // Verify a successful initialization. 386 // Verify a successful initialization.
386 TEST_F(ProfileSyncServiceTest, SuccessfulLocalBackendInitialization) { 387 TEST_F(ProfileSyncServiceTest, SuccessfulLocalBackendInitialization) {
387 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, 388 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
388 base::MakeUnique<base::Value>(false)); 389 base::MakeUnique<base::Value>(false));
389 CreateServiceWithLocalSyncBackend(); 390 CreateServiceWithLocalSyncBackend();
390 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback()); 391 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
391 ExpectSyncEngineCreation(1); 392 ExpectSyncEngineCreation(1);
392 InitializeForNthSync(); 393 InitializeForNthSync();
393 EXPECT_FALSE(service()->IsManaged()); 394 EXPECT_FALSE(service()->IsManaged());
394 EXPECT_TRUE(service()->IsSyncActive()); 395 EXPECT_TRUE(service()->IsSyncActive());
396 EXPECT_FALSE(service()->IsSyncConfirmationNeeded());
395 } 397 }
396 398
397 // Verify that an initialization where first setup is not complete does not 399 // Verify that an initialization where first setup is not complete does not
398 // start up the backend. 400 // start up the backend.
399 TEST_F(ProfileSyncServiceTest, NeedsConfirmation) { 401 TEST_F(ProfileSyncServiceTest, NeedsConfirmation) {
400 prefs()->SetManagedPref(syncer::prefs::kSyncManaged, 402 prefs()->SetManagedPref(syncer::prefs::kSyncManaged,
401 base::MakeUnique<base::Value>(false)); 403 base::MakeUnique<base::Value>(false));
402 IssueTestTokens(); 404 IssueTestTokens();
403 CreateService(ProfileSyncService::MANUAL_START); 405 CreateService(ProfileSyncService::MANUAL_START);
406
404 syncer::SyncPrefs sync_prefs(prefs()); 407 syncer::SyncPrefs sync_prefs(prefs());
405 base::Time now = base::Time::Now(); 408 base::Time now = base::Time::Now();
406 sync_prefs.SetLastSyncedTime(now); 409 sync_prefs.SetLastSyncedTime(now);
407 sync_prefs.SetKeepEverythingSynced(true); 410 sync_prefs.SetKeepEverythingSynced(true);
408 service()->Initialize(); 411 service()->Initialize();
409 EXPECT_FALSE(service()->IsSyncActive()); 412 EXPECT_FALSE(service()->IsSyncActive());
413 EXPECT_TRUE(service()->IsSyncConfirmationNeeded());
410 414
411 // The last sync time shouldn't be cleared. 415 // The last sync time shouldn't be cleared.
412 // TODO(zea): figure out a way to check that the directory itself wasn't 416 // TODO(zea): figure out a way to check that the directory itself wasn't
413 // cleared. 417 // cleared.
414 EXPECT_EQ(now, sync_prefs.GetLastSyncedTime()); 418 EXPECT_EQ(now, sync_prefs.GetLastSyncedTime());
415 } 419 }
416 420
417 // Verify that the SetSetupInProgress function call updates state 421 // Verify that the SetSetupInProgress function call updates state
418 // and notifies observers. 422 // and notifies observers.
419 TEST_F(ProfileSyncServiceTest, SetupInProgress) { 423 TEST_F(ProfileSyncServiceTest, SetupInProgress) {
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 // Progress the controller to RUNNING first, which is how the service 995 // Progress the controller to RUNNING first, which is how the service
992 // determines whether a type is enabled. 996 // determines whether a type is enabled.
993 controller->StartAssociating(base::Bind(&DoNothing)); 997 controller->StartAssociating(base::Bind(&DoNothing));
994 controller->FinishStart(DataTypeController::OK_FIRST_RUN); 998 controller->FinishStart(DataTypeController::OK_FIRST_RUN);
995 service()->RegisterDataTypeController(std::move(controller)); 999 service()->RegisterDataTypeController(std::move(controller));
996 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate()); 1000 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate());
997 } 1001 }
998 1002
999 } // namespace 1003 } // namespace
1000 } // namespace browser_sync 1004 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/profile_sync_service_startup_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698