Index: chrome/browser/signin/account_reconcilor_unittest.cc |
diff --git a/chrome/browser/signin/account_reconcilor_unittest.cc b/chrome/browser/signin/account_reconcilor_unittest.cc |
index b9b7e7b2162ed4963690c9f9a7ce6f3a49e89a1b..d5f2dc7a848416fc1721f723af89403dabb6a20b 100644 |
--- a/chrome/browser/signin/account_reconcilor_unittest.cc |
+++ b/chrome/browser/signin/account_reconcilor_unittest.cc |
@@ -2,12 +2,9 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "base/command_line.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/run_loop.h" |
-#include "base/strings/utf_string_conversions.h" |
#include "base/time/time.h" |
-#include "chrome/browser/prefs/pref_service_syncable.h" |
#include "chrome/browser/signin/account_reconcilor_factory.h" |
#include "chrome/browser/signin/chrome_signin_client_factory.h" |
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
@@ -15,13 +12,10 @@ |
#include "chrome/browser/signin/fake_signin_manager.h" |
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
-#include "chrome/test/base/testing_browser_process.h" |
#include "chrome/test/base/testing_profile.h" |
-#include "chrome/test/base/testing_profile_manager.h" |
#include "components/signin/core/browser/account_reconcilor.h" |
#include "components/signin/core/browser/profile_oauth2_token_service.h" |
#include "components/signin/core/browser/signin_manager.h" |
-#include "components/signin/core/common/signin_switches.h" |
#include "content/public/test/test_browser_thread_bundle.h" |
#include "google_apis/gaia/gaia_urls.h" |
#include "net/url_request/test_url_fetcher_factory.h" |
@@ -42,9 +36,9 @@ |
virtual ~MockAccountReconcilor() {} |
MOCK_METHOD1(PerformMergeAction, void(const std::string& account_id)); |
- MOCK_METHOD1(PerformStartRemoveAction, void(const std::string& account_id)); |
+ MOCK_METHOD1(StartRemoveAction, void(const std::string& account_id)); |
MOCK_METHOD3( |
- PerformFinishRemoveAction, |
+ FinishRemoveAction, |
void(const std::string& account_id, |
const GoogleServiceAuthError& error, |
const std::vector<std::pair<std::string, bool> >& accounts)); |
@@ -80,7 +74,7 @@ |
virtual void SetUp() OVERRIDE; |
virtual void TearDown() OVERRIDE; |
- TestingProfile* profile() { return profile_; } |
+ TestingProfile* profile() { return profile_.get(); } |
FakeSigninManagerForTesting* signin_manager() { return signin_manager_; } |
FakeProfileOAuth2TokenService* token_service() { return token_service_; } |
@@ -105,12 +99,11 @@ |
private: |
content::TestBrowserThreadBundle bundle_; |
- TestingProfile* profile_; |
+ scoped_ptr<TestingProfile> profile_; |
FakeSigninManagerForTesting* signin_manager_; |
FakeProfileOAuth2TokenService* token_service_; |
MockAccountReconcilor* mock_reconcilor_; |
net::FakeURLFetcherFactory url_fetcher_factory_; |
- TestingProfileManager* testing_profile_manager_; |
}; |
AccountReconcilorTest::AccountReconcilorTest() |
@@ -120,26 +113,14 @@ |
url_fetcher_factory_(NULL) {} |
void AccountReconcilorTest::SetUp() { |
- CommandLine::ForCurrentProcess()->AppendSwitch( |
- switches::kNewProfileManagement); |
- |
- testing_profile_manager_ = |
- new TestingProfileManager(TestingBrowserProcess::GetGlobal()); |
- ASSERT_TRUE(testing_profile_manager_->SetUp()); |
- |
- TestingProfile::TestingFactories factories; |
- factories.push_back(std::make_pair( |
- ProfileOAuth2TokenServiceFactory::GetInstance(), |
- BuildFakeProfileOAuth2TokenService)); |
- factories.push_back(std::make_pair(SigninManagerFactory::GetInstance(), |
- FakeSigninManagerBase::Build)); |
- factories.push_back(std::make_pair(AccountReconcilorFactory::GetInstance(), |
- MockAccountReconcilor::Build)); |
- |
- profile_ = testing_profile_manager_->CreateTestingProfile("name", |
- scoped_ptr<PrefServiceSyncable>(), |
- base::UTF8ToUTF16("name"), 0, std::string(), |
- factories); |
+ TestingProfile::Builder builder; |
+ builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(), |
+ BuildFakeProfileOAuth2TokenService); |
+ builder.AddTestingFactory(SigninManagerFactory::GetInstance(), |
+ FakeSigninManagerBase::Build); |
+ builder.AddTestingFactory(AccountReconcilorFactory::GetInstance(), |
+ MockAccountReconcilor::Build); |
+ profile_ = builder.Build(); |
signin_manager_ = |
static_cast<FakeSigninManagerForTesting*>( |
@@ -151,8 +132,8 @@ |
} |
void AccountReconcilorTest::TearDown() { |
- // The |testing_profile_manager_| will handle destroying the profile. |
- delete testing_profile_manager_; |
+ // Destroy the profile before all threads are torn down. |
+ profile_.reset(); |
} |
MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() { |
@@ -194,7 +175,6 @@ |
ASSERT_TRUE(reconcilor); |
ASSERT_FALSE(reconcilor->IsRegisteredWithTokenService()); |
- signin_manager()->set_password("password"); |
signin_manager()->OnExternalSigninCompleted(kTestEmail); |
ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService()); |
@@ -206,7 +186,6 @@ |
TEST_F(AccountReconcilorTest, Reauth) { |
signin_manager()->SetAuthenticatedUsername(kTestEmail); |
- signin_manager()->set_password("password"); |
AccountReconcilor* reconcilor = |
AccountReconcilorFactory::GetForProfile(profile()); |
@@ -443,7 +422,6 @@ |
ASSERT_FALSE(reconcilor->is_reconcile_started_); |
} |
- |
TEST_F(AccountReconcilorTest, StartReconcileAddToCookie) { |
signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |