| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/signin/fake_signin_manager.h" | 10 #include "chrome/browser/signin/fake_signin_manager.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 DataTypeManagerMock* SetUpDataTypeManager() { | 136 DataTypeManagerMock* SetUpDataTypeManager() { |
| 137 DataTypeManagerMock* data_type_manager = new DataTypeManagerMock(); | 137 DataTypeManagerMock* data_type_manager = new DataTypeManagerMock(); |
| 138 EXPECT_CALL(*sync_->components_factory_mock(), | 138 EXPECT_CALL(*sync_->components_factory_mock(), |
| 139 CreateDataTypeManager(_, _, _, _, _)). | 139 CreateDataTypeManager(_, _, _, _, _)). |
| 140 WillOnce(Return(data_type_manager)); | 140 WillOnce(Return(data_type_manager)); |
| 141 return data_type_manager; | 141 return data_type_manager; |
| 142 } | 142 } |
| 143 | 143 |
| 144 MessageLoop ui_loop_; | 144 base::MessageLoop ui_loop_; |
| 145 content::TestBrowserThread ui_thread_; | 145 content::TestBrowserThread ui_thread_; |
| 146 content::TestBrowserThread db_thread_; | 146 content::TestBrowserThread db_thread_; |
| 147 content::TestBrowserThread file_thread_; | 147 content::TestBrowserThread file_thread_; |
| 148 content::TestBrowserThread io_thread_; | 148 content::TestBrowserThread io_thread_; |
| 149 scoped_ptr<TestingProfile> profile_; | 149 scoped_ptr<TestingProfile> profile_; |
| 150 TestProfileSyncService* sync_; | 150 TestProfileSyncService* sync_; |
| 151 ProfileSyncServiceObserverMock observer_; | 151 ProfileSyncServiceObserverMock observer_; |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { | 154 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 EXPECT_CALL(*data_type_manager, Configure(_, _)); | 281 EXPECT_CALL(*data_type_manager, Configure(_, _)); |
| 282 EXPECT_CALL(*data_type_manager, state()). | 282 EXPECT_CALL(*data_type_manager, state()). |
| 283 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); | 283 WillRepeatedly(Return(DataTypeManager::CONFIGURED)); |
| 284 EXPECT_CALL(*data_type_manager, Stop()).Times(1); | 284 EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
| 285 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 285 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
| 286 sync_->SetSetupInProgress(true); | 286 sync_->SetSetupInProgress(true); |
| 287 Signin(); | 287 Signin(); |
| 288 token_service->IssueAuthTokenForTest( | 288 token_service->IssueAuthTokenForTest( |
| 289 GaiaConstants::kSyncService, "sync_token"); | 289 GaiaConstants::kSyncService, "sync_token"); |
| 290 sync_->SetSetupInProgress(false); | 290 sync_->SetSetupInProgress(false); |
| 291 MessageLoop::current()->Run(); | 291 base::MessageLoop::current()->Run(); |
| 292 | 292 |
| 293 // Verify we successfully finish startup and configuration. | 293 // Verify we successfully finish startup and configuration. |
| 294 EXPECT_TRUE(sync_->ShouldPushChanges()); | 294 EXPECT_TRUE(sync_->ShouldPushChanges()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { | 297 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { |
| 298 EXPECT_CALL(*sync_->components_factory_mock(), | 298 EXPECT_CALL(*sync_->components_factory_mock(), |
| 299 CreateDataTypeManager(_, _, _, _, _)).Times(0); | 299 CreateDataTypeManager(_, _, _, _, _)).Times(0); |
| 300 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); | 300 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |
| 301 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 301 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 479 |
| 480 // Preload the tokens. | 480 // Preload the tokens. |
| 481 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 481 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
| 482 GaiaConstants::kSyncService, "sync_token"); | 482 GaiaConstants::kSyncService, "sync_token"); |
| 483 sync_->fail_initial_download(); | 483 sync_->fail_initial_download(); |
| 484 | 484 |
| 485 sync_->Initialize(); | 485 sync_->Initialize(); |
| 486 EXPECT_FALSE(sync_->sync_initialized()); | 486 EXPECT_FALSE(sync_->sync_initialized()); |
| 487 EXPECT_FALSE(sync_->GetBackendForTest()); | 487 EXPECT_FALSE(sync_->GetBackendForTest()); |
| 488 } | 488 } |
| OLD | NEW |