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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 protected: | 126 protected: |
127 DataTypeManagerMock* SetUpDataTypeManager() { | 127 DataTypeManagerMock* SetUpDataTypeManager() { |
128 DataTypeManagerMock* data_type_manager = new DataTypeManagerMock(); | 128 DataTypeManagerMock* data_type_manager = new DataTypeManagerMock(); |
129 EXPECT_CALL(*sync_->components_factory_mock(), | 129 EXPECT_CALL(*sync_->components_factory_mock(), |
130 CreateDataTypeManager(_, _, _, _, _)). | 130 CreateDataTypeManager(_, _, _, _, _)). |
131 WillOnce(Return(data_type_manager)); | 131 WillOnce(Return(data_type_manager)); |
132 return data_type_manager; | 132 return data_type_manager; |
133 } | 133 } |
134 | 134 |
135 MessageLoop ui_loop_; | 135 base::MessageLoop ui_loop_; |
136 content::TestBrowserThread ui_thread_; | 136 content::TestBrowserThread ui_thread_; |
137 content::TestBrowserThread db_thread_; | 137 content::TestBrowserThread db_thread_; |
138 content::TestBrowserThread file_thread_; | 138 content::TestBrowserThread file_thread_; |
139 content::TestBrowserThread io_thread_; | 139 content::TestBrowserThread io_thread_; |
140 scoped_ptr<TestingProfile> profile_; | 140 scoped_ptr<TestingProfile> profile_; |
141 TestProfileSyncService* sync_; | 141 TestProfileSyncService* sync_; |
142 ProfileSyncServiceObserverMock observer_; | 142 ProfileSyncServiceObserverMock observer_; |
143 }; | 143 }; |
144 | 144 |
145 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { | 145 class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 // Simulate successful signin. | 311 // Simulate successful signin. |
312 GoogleServiceSigninSuccessDetails details("test_user", std::string()); | 312 GoogleServiceSigninSuccessDetails details("test_user", std::string()); |
313 content::NotificationService::current()->Notify( | 313 content::NotificationService::current()->Notify( |
314 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, | 314 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
315 content::Source<Profile>(profile_.get()), | 315 content::Source<Profile>(profile_.get()), |
316 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); | 316 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); |
317 | 317 |
318 token_service->IssueAuthTokenForTest( | 318 token_service->IssueAuthTokenForTest( |
319 GaiaConstants::kSyncService, "sync_token"); | 319 GaiaConstants::kSyncService, "sync_token"); |
320 sync_->SetSetupInProgress(false); | 320 sync_->SetSetupInProgress(false); |
321 MessageLoop::current()->Run(); | 321 base::MessageLoop::current()->Run(); |
322 | 322 |
323 // Verify we successfully finish startup and configuration. | 323 // Verify we successfully finish startup and configuration. |
324 EXPECT_TRUE(sync_->ShouldPushChanges()); | 324 EXPECT_TRUE(sync_->ShouldPushChanges()); |
325 } | 325 } |
326 | 326 |
327 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { | 327 TEST_F(ProfileSyncServiceStartupCrosTest, StartCrosNoCredentials) { |
328 EXPECT_CALL(*sync_->components_factory_mock(), | 328 EXPECT_CALL(*sync_->components_factory_mock(), |
329 CreateDataTypeManager(_, _, _, _, _)).Times(0); | 329 CreateDataTypeManager(_, _, _, _, _)).Times(0); |
330 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); | 330 profile_->GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |
331 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 331 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 525 |
526 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); | 526 EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber()); |
527 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( | 527 TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest( |
528 GaiaConstants::kSyncService, "sync_token"); | 528 GaiaConstants::kSyncService, "sync_token"); |
529 sync_->fail_initial_download(); | 529 sync_->fail_initial_download(); |
530 | 530 |
531 sync_->Initialize(); | 531 sync_->Initialize(); |
532 EXPECT_FALSE(sync_->sync_initialized()); | 532 EXPECT_FALSE(sync_->sync_initialized()); |
533 EXPECT_FALSE(sync_->GetBackendForTest()); | 533 EXPECT_FALSE(sync_->GetBackendForTest()); |
534 } | 534 } |
OLD | NEW |