Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / sync_setup_handler_unittest.cc
index a3b03ea..8f4725b 100644 (file)
@@ -280,6 +280,10 @@ class SyncSetupHandlerTest : public testing::Test {
     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(),
@@ -294,9 +298,6 @@ class SyncSetupHandlerTest : public testing::Test {
 
     mock_pss_->Initialize();
 
-    mock_signin_ = static_cast<SigninManagerBase*>(
-        SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
-            profile_.get(), FakeSigninManagerBase::Build));
     handler_.reset(new TestingSyncSetupHandler(&web_ui_, profile_.get()));
   }
 
@@ -317,11 +318,7 @@ class SyncSetupHandlerTest : public testing::Test {
   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())
@@ -393,6 +390,9 @@ TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) {
       .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.
@@ -435,7 +435,6 @@ TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
   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())
@@ -464,7 +463,6 @@ TEST_F(SyncSetupHandlerTest,
   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())
@@ -520,7 +518,6 @@ TEST_F(SyncSetupHandlerTest,
   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())
@@ -549,7 +546,6 @@ TEST_F(SyncSetupHandlerTest,
   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())
@@ -580,12 +576,6 @@ TEST_F(SyncSetupHandlerTest,
 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) {