Index: chrome/browser/sync/profile_sync_service_startup_unittest.cc |
=================================================================== |
--- chrome/browser/sync/profile_sync_service_startup_unittest.cc (revision 58702) |
+++ chrome/browser/sync/profile_sync_service_startup_unittest.cc (working copy) |
@@ -15,6 +15,7 @@ |
#include "chrome/browser/sync/profile_sync_test_util.h" |
#include "chrome/browser/sync/test_profile_sync_service.h" |
#include "chrome/common/net/gaia/gaia_auth_consumer.h" |
+#include "chrome/common/net/gaia/gaia_constants.h" |
#include "chrome/common/notification_type.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/test/testing_profile.h" |
@@ -40,6 +41,7 @@ |
#define SKIP_MACOSX(test) test |
#endif |
+// TODO(chron): Test not using cros_user flag and use signin_ |
class ProfileSyncServiceStartupTest : public testing::Test { |
public: |
ProfileSyncServiceStartupTest() |
@@ -54,7 +56,7 @@ |
virtual void SetUp() { |
service_.reset(new TestProfileSyncService(&factory_, &profile_, |
- false, true, NULL)); |
+ "test", true, NULL)); |
service_->AddObserver(&observer_); |
service_->set_num_expected_resumes(0); |
service_->set_num_expected_pauses(0); |
@@ -99,12 +101,17 @@ |
Mock::VerifyAndClearExpectations(data_type_manager); |
// Then start things up. |
- EXPECT_CALL(*data_type_manager, Configure(_)).Times(1); |
+ EXPECT_CALL(*data_type_manager, Configure(_)).Times(2); |
EXPECT_CALL(*data_type_manager, state()). |
WillOnce(Return(DataTypeManager::CONFIGURED)); |
EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
- EXPECT_CALL(observer_, OnStateChanged()).Times(4); |
- service_->EnableForUser(NULL); |
+ EXPECT_CALL(observer_, OnStateChanged()).Times(5); |
+ |
+ // Create some tokens in the token service; the service will startup when |
+ // it is notified that tokens are available. |
+ profile_.GetTokenService()->IssueAuthTokenForTest( |
+ GaiaConstants::kSyncService, "sync_token"); |
+ |
syncable::ModelTypeSet set; |
set.insert(syncable::BOOKMARKS); |
service_->OnUserChoseDatatypes(false, set); |
@@ -119,6 +126,9 @@ |
EXPECT_CALL(observer_, OnStateChanged()).Times(3); |
+ // Pre load the tokens |
+ profile_.GetTokenService()->IssueAuthTokenForTest( |
+ GaiaConstants::kSyncService, "sync_token"); |
service_->Initialize(); |
} |
@@ -130,6 +140,8 @@ |
EXPECT_CALL(observer_, OnStateChanged()).Times(1); |
// Service should not be started by Initialize() since it's managed. |
+ profile_.GetTokenService()->IssueAuthTokenForTest( |
+ GaiaConstants::kSyncService, "sync_token"); |
service_->Initialize(); |
} |
@@ -138,6 +150,8 @@ |
EXPECT_CALL(*data_type_manager, Configure(_)).Times(1); |
EXPECT_CALL(observer_, OnStateChanged()).Times(3); |
+ profile_.GetTokenService()->IssueAuthTokenForTest( |
+ GaiaConstants::kSyncService, "sync_token"); |
service_->Initialize(); |
// The service should stop when switching to managed mode. |
@@ -164,51 +178,13 @@ |
WillOnce(DoAll(Notify(NotificationType::SYNC_CONFIGURE_START), |
NotifyWithResult(NotificationType::SYNC_CONFIGURE_DONE, |
&result))); |
- EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
EXPECT_CALL(*data_type_manager, state()). |
WillOnce(Return(DataTypeManager::STOPPED)); |
EXPECT_CALL(observer_, OnStateChanged()).Times(3); |
+ profile_.GetTokenService()->IssueAuthTokenForTest( |
+ GaiaConstants::kSyncService, "sync_token"); |
service_->Initialize(); |
EXPECT_TRUE(service_->unrecoverable_error_detected()); |
} |
- |
-class ProfileSyncServiceStartupBootstrapTest |
- : public ProfileSyncServiceStartupTest { |
- public: |
- ProfileSyncServiceStartupBootstrapTest() {} |
- virtual ~ProfileSyncServiceStartupBootstrapTest() {} |
- |
- virtual void SetUp() { |
- service_.reset(new TestProfileSyncService(&factory_, &profile_, |
- true, true, NULL)); |
- service_->AddObserver(&observer_); |
- service_->set_num_expected_resumes(0); |
- service_->set_num_expected_pauses(0); |
- service_->set_synchronous_sync_configuration(); |
- } |
-}; |
- |
-TEST_F(ProfileSyncServiceStartupBootstrapTest, SKIP_MACOSX(StartFirstTime)) { |
- DataTypeManagerMock* data_type_manager = SetUpDataTypeManager(); |
- EXPECT_CALL(*data_type_manager, Configure(_)).Times(1); |
- EXPECT_CALL(*data_type_manager, state()). |
- WillOnce(Return(DataTypeManager::CONFIGURED)); |
- EXPECT_CALL(*data_type_manager, Stop()).Times(1); |
- EXPECT_CALL(observer_, OnStateChanged()).Times(4); |
- |
- profile_.GetPrefs()->ClearPref(prefs::kSyncHasSetupCompleted); |
- |
- // Pretend the login screen worked. |
- GaiaAuthConsumer::ClientLoginResult result; |
- result.sid = "sid"; |
- result.lsid = "lsid"; |
- profile_.GetTokenService()->Initialize("test", |
- &profile_); |
- profile_.GetTokenService()->UpdateCredentials(result); |
- |
- // Will start sync even though setup hasn't been completed (since |
- // setup is bypassed when bootstrapping is enabled). |
- service_->Initialize(); |
-} |