error_ = GoogleServiceAuthError::AuthErrorNone();
profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ mock_signin_ = static_cast<SigninManagerBase*>(
+ SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile_.get(), FakeSigninManagerBase::Build));
+
mock_pss_ = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(),
mock_pss_->Initialize();
- mock_signin_ = static_cast<SigninManagerBase*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), FakeSigninManagerBase::Build));
handler_.reset(new TestingSyncSetupHandler(&web_ui_, profile_.get()));
}
void SetupInitializedProfileSyncService() {
// An initialized ProfileSyncService will have already completed sync setup
// and will have an initialized sync backend.
- if (!mock_signin_->IsInitialized()) {
- profile_->GetPrefs()->SetString(
- prefs::kGoogleServicesUsername, kTestUser);
- mock_signin_->Initialize(profile_.get(), NULL);
- }
+ ASSERT_TRUE(mock_signin_->IsInitialized());
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(false));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
.WillRepeatedly(Return(false));
+ // Ensure that the user is not signed in before calling |HandleStartSignin()|.
+ SigninManager* manager = static_cast<SigninManager*>(mock_signin_);
+ manager->SignOut();
handler_->HandleStartSignin(NULL);
// Sync setup hands off control to the gaia login tab.
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
- mock_signin_->Initialize(profile_.get(), NULL);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
- mock_signin_->Initialize(profile_.get(), NULL);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
- mock_signin_->Initialize(profile_.get(), NULL);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
- mock_signin_->Initialize(profile_.get(), NULL);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
class SyncSetupHandlerNonCrosTest : public SyncSetupHandlerTest {
public:
SyncSetupHandlerNonCrosTest() {}
- virtual void SetUp() OVERRIDE {
- SyncSetupHandlerTest::SetUp();
- mock_signin_ = static_cast<SigninManagerBase*>(
- SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile_.get(), FakeSigninManagerBase::Build));
- }
};
TEST_F(SyncSetupHandlerNonCrosTest, HandleGaiaAuthFailure) {