Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4188)

Unified Diff: chrome/browser/ui/webui/sync_setup_handler_unittest.cc

Issue 162443004: sync: final pieces to sync deferred initialization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/sync_setup_handler_unittest.cc
diff --git a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
index 8f4725b8112f4a40e60cb4dc9b76fe743da9b484..b689ce239578c5551548c77f2f6e4d1e8d9f20fb 100644
--- a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
@@ -280,10 +280,11 @@ class SyncSetupHandlerTest : public testing::Test {
error_ = GoogleServiceAuthError::AuthErrorNone();
profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ profile_->GetPrefs()->SetString(
+ prefs::kGoogleServicesUsername, GetTestUser());
mock_signin_ = static_cast<SigninManagerBase*>(
SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(), FakeSigninManagerBase::Build));
-
mock_pss_ = static_cast<ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile_.get(),
@@ -319,12 +320,6 @@ class SyncSetupHandlerTest : public testing::Test {
// An initialized ProfileSyncService will have already completed sync setup
// and will have an initialized sync backend.
ASSERT_TRUE(mock_signin_->IsInitialized());
- EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
- .WillRepeatedly(Return(true));
- EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
- .WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true));
}
@@ -370,6 +365,10 @@ class SyncSetupHandlerTest : public testing::Test {
handler_->sync_startup_tracker_->OnStateChanged();
}
+ virtual std::string GetTestUser() {
+ return std::string(kTestUser);
+ }
+
content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<Profile> profile_;
ProfileSyncServiceMock* mock_pss_;
@@ -379,11 +378,15 @@ class SyncSetupHandlerTest : public testing::Test {
scoped_ptr<TestingSyncSetupHandler> handler_;
};
+class SyncSetupHandlerFirstSigninTest : public SyncSetupHandlerTest {
+ virtual std::string GetTestUser() OVERRIDE { return std::string(); }
+};
+
TEST_F(SyncSetupHandlerTest, Basic) {
}
#if !defined(OS_CHROMEOS)
-TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) {
+TEST_F(SyncSetupHandlerFirstSigninTest, DisplayBasicLogin) {
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(false));
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
@@ -427,14 +430,13 @@ TEST_F(SyncSetupHandlerTest, ShowSyncSetupWhenNotSignedIn) {
LoginUIServiceFactory::GetForProfile(
profile_.get())->current_login_ui());
}
-#endif
+#endif // !defined(OS_CHROMEOS)
// Verifies that the handler correctly handles a cancellation when
// it is displaying the spinner to the user.
TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
- profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
@@ -462,7 +464,6 @@ TEST_F(SyncSetupHandlerTest,
DisplayConfigureWithBackendDisabledAndSyncStartupCompleted) {
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
- profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
@@ -517,7 +518,6 @@ TEST_F(SyncSetupHandlerTest,
DisplayConfigureWithBackendDisabledAndCancelAfterSigninSuccess) {
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
- profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())
@@ -545,7 +545,6 @@ TEST_F(SyncSetupHandlerTest,
DisplayConfigureWithBackendDisabledAndSigninFailed) {
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
- profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, kTestUser);
EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
.WillRepeatedly(Return(true));
EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted())

Powered by Google App Engine
This is Rietveld 408576698