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

Unified Diff: chrome/browser/sync/profile_sync_service_startup_unittest.cc

Issue 12502017: signin: pull basic SigninManager functionality into new SigninManagerBase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deal with new enterprise_platform_keys_private_api Created 7 years, 8 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/sync/profile_sync_service_startup_unittest.cc
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index 7a46b15f7a50d9488a9ea7669eb929a8a82da26b..f6b335374d613e6a4ea56eb1e064a0984a525720 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -22,6 +22,8 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_source.h"
#include "content/public/test/test_browser_thread.h"
#include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/gaia_constants.h"
@@ -99,10 +101,21 @@ class ProfileSyncServiceStartupTest : public testing::Test {
ui_loop_.RunUntilIdle();
}
+ void Signin() {
+ sync_->signin()->SetAuthenticatedUsername("test_user");
+ profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername,
+ "test_user");
+ GoogleServiceSigninSuccessDetails details("test_user", "");
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL,
+ content::Source<Profile>(profile_.get()),
+ content::Details<const GoogleServiceSigninSuccessDetails>(&details));
+ }
+
static ProfileKeyedService* BuildService(Profile* profile) {
- SigninManager* signin = static_cast<SigninManager*>(
+ SigninManagerBase* signin = static_cast<SigninManagerBase*>(
SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
- profile, FakeSigninManager::Build));
+ profile, FakeSigninManagerBase::Build));
signin->SetAuthenticatedUsername("test_user");
return new TestProfileSyncService(
new ProfileSyncComponentsFactoryMock(),
@@ -141,7 +154,8 @@ class ProfileSyncServiceStartupTest : public testing::Test {
class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
public:
static ProfileKeyedService* BuildCrosService(Profile* profile) {
- SigninManager* signin = SigninManagerFactory::GetForProfile(profile);
+ SigninManagerBase* signin =
+ SigninManagerFactory::GetForProfile(profile);
signin->SetAuthenticatedUsername("test_user");
return new TestProfileSyncService(
new ProfileSyncComponentsFactoryMock(),
@@ -150,6 +164,7 @@ class ProfileSyncServiceStartupCrosTest : public ProfileSyncServiceStartupTest {
ProfileSyncService::AUTO_START,
true);
}
+
protected:
virtual void CreateSyncService() OVERRIDE {
sync_ = static_cast<TestProfileSyncService*>(
@@ -189,10 +204,9 @@ TEST_F(ProfileSyncServiceStartupTest, StartFirstTime) {
// Create some tokens in the token service; the service will startup when
// it is notified that tokens are available.
sync_->SetSetupInProgress(true);
- sync_->signin()
- ->StartSignIn("test_user", std::string(), std::string(), std::string());
- TokenServiceFactory::GetForProfile(profile_.get())
- ->IssueAuthTokenForTest(GaiaConstants::kSyncService, "sync_token");
+ Signin();
+ TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
+ GaiaConstants::kSyncService, "sync_token");
TokenServiceFactory::GetForProfile(profile_.get())->IssueAuthTokenForTest(
GaiaConstants::kGaiaOAuth2LoginRefreshToken, "oauth2_login_token");
sync_->SetSetupInProgress(false);
@@ -236,8 +250,7 @@ TEST_F(ProfileSyncServiceStartupTest, StartNoCredentials) {
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
sync_->SetSetupInProgress(true);
- sync_->signin()
- ->StartSignIn("test_user", std::string(), std::string(), std::string());
+ Signin();
// NOTE: Unlike StartFirstTime, this test does not issue any auth tokens.
token_service->LoadTokensFromDB();
sync_->SetSetupInProgress(false);
@@ -271,10 +284,9 @@ TEST_F(ProfileSyncServiceStartupTest, StartInvalidCredentials) {
EXPECT_CALL(*data_type_manager, Stop()).Times(1);
EXPECT_CALL(observer_, OnStateChanged()).Times(AnyNumber());
sync_->SetSetupInProgress(true);
- sync_->signin()
- ->StartSignIn("test_user", std::string(), std::string(), std::string());
- token_service->IssueAuthTokenForTest(GaiaConstants::kSyncService,
- "sync_token");
+ Signin();
+ token_service->IssueAuthTokenForTest(
+ GaiaConstants::kSyncService, "sync_token");
sync_->SetSetupInProgress(false);
MessageLoop::current()->Run();

Powered by Google App Engine
This is Rietveld 408576698