| OLD | NEW |
| 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/files/file_util.h" | 5 #include "base/files/file_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/prefs/pref_service_syncable.h" | 9 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 class ProfileSyncServiceStartupTest : public testing::Test { | 81 class ProfileSyncServiceStartupTest : public testing::Test { |
| 82 public: | 82 public: |
| 83 ProfileSyncServiceStartupTest() | 83 ProfileSyncServiceStartupTest() |
| 84 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | | 84 : thread_bundle_(content::TestBrowserThreadBundle::REAL_DB_THREAD | |
| 85 content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 85 content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
| 86 content::TestBrowserThreadBundle::REAL_IO_THREAD), | 86 content::TestBrowserThreadBundle::REAL_IO_THREAD), |
| 87 profile_manager_(TestingBrowserProcess::GetGlobal()), | 87 profile_manager_(TestingBrowserProcess::GetGlobal()), |
| 88 sync_(NULL) {} | 88 sync_(NULL) {} |
| 89 | 89 |
| 90 virtual ~ProfileSyncServiceStartupTest() { | 90 ~ProfileSyncServiceStartupTest() override {} |
| 91 } | |
| 92 | 91 |
| 93 virtual void SetUp() { | 92 void SetUp() override { |
| 94 CHECK(profile_manager_.SetUp()); | 93 CHECK(profile_manager_.SetUp()); |
| 95 | 94 |
| 96 TestingProfile::TestingFactories testing_facotries; | 95 TestingProfile::TestingFactories testing_facotries; |
| 97 testing_facotries.push_back( | 96 testing_facotries.push_back( |
| 98 std::make_pair(SigninManagerFactory::GetInstance(), | 97 std::make_pair(SigninManagerFactory::GetInstance(), |
| 99 FakeSigninManagerBase::Build)); | 98 FakeSigninManagerBase::Build)); |
| 100 testing_facotries.push_back( | 99 testing_facotries.push_back( |
| 101 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), | 100 std::make_pair(ProfileOAuth2TokenServiceFactory::GetInstance(), |
| 102 BuildAutoIssuingFakeProfileOAuth2TokenService)); | 101 BuildAutoIssuingFakeProfileOAuth2TokenService)); |
| 103 testing_facotries.push_back( | 102 testing_facotries.push_back( |
| 104 std::make_pair(ProfileSyncServiceFactory::GetInstance(), | 103 std::make_pair(ProfileSyncServiceFactory::GetInstance(), |
| 105 BuildService)); | 104 BuildService)); |
| 106 | 105 |
| 107 profile_ = profile_manager_.CreateTestingProfile( | 106 profile_ = profile_manager_.CreateTestingProfile( |
| 108 "sync-startup-test", scoped_ptr<PrefServiceSyncable>(), | 107 "sync-startup-test", scoped_ptr<PrefServiceSyncable>(), |
| 109 base::UTF8ToUTF16("sync-startup-test"), 0, std::string(), | 108 base::UTF8ToUTF16("sync-startup-test"), 0, std::string(), |
| 110 testing_facotries); | 109 testing_facotries); |
| 111 } | 110 } |
| 112 | 111 |
| 113 virtual void TearDown() { | 112 void TearDown() override { sync_->RemoveObserver(&observer_); } |
| 114 sync_->RemoveObserver(&observer_); | |
| 115 } | |
| 116 | 113 |
| 117 static KeyedService* BuildService(content::BrowserContext* browser_context) { | 114 static KeyedService* BuildService(content::BrowserContext* browser_context) { |
| 118 Profile* profile = static_cast<Profile*>(browser_context); | 115 Profile* profile = static_cast<Profile*>(browser_context); |
| 119 return new TestProfileSyncServiceNoBackup( | 116 return new TestProfileSyncServiceNoBackup( |
| 120 scoped_ptr<ProfileSyncComponentsFactory>( | 117 scoped_ptr<ProfileSyncComponentsFactory>( |
| 121 new ProfileSyncComponentsFactoryMock()), | 118 new ProfileSyncComponentsFactoryMock()), |
| 122 profile, | 119 profile, |
| 123 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( | 120 make_scoped_ptr(new SupervisedUserSigninManagerWrapper( |
| 124 profile, SigninManagerFactory::GetForProfile(profile))), | 121 profile, SigninManagerFactory::GetForProfile(profile))), |
| 125 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 122 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 content::TestBrowserThreadBundle thread_bundle_; | 186 content::TestBrowserThreadBundle thread_bundle_; |
| 190 TestingProfileManager profile_manager_; | 187 TestingProfileManager profile_manager_; |
| 191 TestingProfile* profile_; | 188 TestingProfile* profile_; |
| 192 ProfileSyncService* sync_; | 189 ProfileSyncService* sync_; |
| 193 ProfileSyncServiceObserverMock observer_; | 190 ProfileSyncServiceObserverMock observer_; |
| 194 sync_driver::DataTypeStatusTable data_type_status_table_; | 191 sync_driver::DataTypeStatusTable data_type_status_table_; |
| 195 }; | 192 }; |
| 196 | 193 |
| 197 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { | 194 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { |
| 198 public: | 195 public: |
| 199 virtual void SetUp() { | 196 void SetUp() override { |
| 200 ProfileSyncServiceStartupTest::SetUp(); | 197 ProfileSyncServiceStartupTest::SetUp(); |
| 201 sync_ = static_cast<ProfileSyncService*>( | 198 sync_ = static_cast<ProfileSyncService*>( |
| 202 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 199 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 203 profile_, BuildCrosService)); | 200 profile_, BuildCrosService)); |
| 204 sync_->AddObserver(&observer_); | 201 sync_->AddObserver(&observer_); |
| 205 } | 202 } |
| 206 | 203 |
| 207 static KeyedService* BuildCrosService(content::BrowserContext* context) { | 204 static KeyedService* BuildCrosService(content::BrowserContext* context) { |
| 208 Profile* profile = static_cast<Profile*>(context); | 205 Profile* profile = static_cast<Profile*>(context); |
| 209 SigninManagerBase* signin = | 206 SigninManagerBase* signin = |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); | 567 profile_->GetPrefs()->ClearPref(sync_driver::prefs::kSyncHasSetupCompleted); |
| 571 | 568 |
| 572 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 569 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
| 573 sync_->Initialize(); | 570 sync_->Initialize(); |
| 574 | 571 |
| 575 sync_->SetSetupInProgress(true); | 572 sync_->SetSetupInProgress(true); |
| 576 IssueTestTokens(); | 573 IssueTestTokens(); |
| 577 sync_->SetSetupInProgress(false); | 574 sync_->SetSetupInProgress(false); |
| 578 EXPECT_FALSE(sync_->SyncActive()); | 575 EXPECT_FALSE(sync_->SyncActive()); |
| 579 } | 576 } |
| OLD | NEW |