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

Unified Diff: chrome/browser/signin/account_reconcilor_unittest.cc

Issue 276463002: non-new-profile-management creates a "no-op" style account_reconcilor, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 6 years, 7 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
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/signin/test_signin_client_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d5f2dc7a848416fc1721f723af89403dabb6a20b..26bdac96f60c15fe2d5926664cb46da48ace2bd0 100644
--- a/chrome/browser/signin/account_reconcilor_unittest.cc
+++ b/chrome/browser/signin/account_reconcilor_unittest.cc
@@ -2,9 +2,12 @@
// 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"
@@ -12,10 +15,15 @@
#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/browser/signin/test_signin_client_builder.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/browser/test_signin_client.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"
@@ -36,9 +44,9 @@ class MockAccountReconcilor : public testing::StrictMock<AccountReconcilor> {
virtual ~MockAccountReconcilor() {}
MOCK_METHOD1(PerformMergeAction, void(const std::string& account_id));
- MOCK_METHOD1(StartRemoveAction, void(const std::string& account_id));
+ MOCK_METHOD1(PerformStartRemoveAction, void(const std::string& account_id));
MOCK_METHOD3(
- FinishRemoveAction,
+ PerformFinishRemoveAction,
void(const std::string& account_id,
const GoogleServiceAuthError& error,
const std::vector<std::pair<std::string, bool> >& accounts));
@@ -72,9 +80,8 @@ class AccountReconcilorTest : public testing::Test {
public:
AccountReconcilorTest();
virtual void SetUp() OVERRIDE;
- virtual void TearDown() OVERRIDE;
- TestingProfile* profile() { return profile_.get(); }
+ TestingProfile* profile() { return profile_; }
FakeSigninManagerForTesting* signin_manager() { return signin_manager_; }
FakeProfileOAuth2TokenService* token_service() { return token_service_; }
@@ -99,11 +106,12 @@ class AccountReconcilorTest : public testing::Test {
private:
content::TestBrowserThreadBundle bundle_;
- scoped_ptr<TestingProfile> profile_;
+ TestingProfile* profile_;
FakeSigninManagerForTesting* signin_manager_;
FakeProfileOAuth2TokenService* token_service_;
MockAccountReconcilor* mock_reconcilor_;
net::FakeURLFetcherFactory url_fetcher_factory_;
+ scoped_ptr<TestingProfileManager> testing_profile_manager_;
};
AccountReconcilorTest::AccountReconcilorTest()
@@ -113,14 +121,28 @@ AccountReconcilorTest::AccountReconcilorTest()
url_fetcher_factory_(NULL) {}
void AccountReconcilorTest::SetUp() {
- TestingProfile::Builder builder;
- builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
- BuildFakeProfileOAuth2TokenService);
- builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
- FakeSigninManagerBase::Build);
- builder.AddTestingFactory(AccountReconcilorFactory::GetInstance(),
- MockAccountReconcilor::Build);
- profile_ = builder.Build();
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kNewProfileManagement);
+
+ testing_profile_manager_.reset(
+ new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
+ ASSERT_TRUE(testing_profile_manager_.get()->SetUp());
+
+ TestingProfile::TestingFactories factories;
+ factories.push_back(std::make_pair(ChromeSigninClientFactory::GetInstance(),
+ signin::BuildTestSigninClient));
+ 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_.get()->CreateTestingProfile("name",
+ scoped_ptr<PrefServiceSyncable>(),
+ base::UTF8ToUTF16("name"), 0, std::string(),
+ factories);
signin_manager_ =
static_cast<FakeSigninManagerForTesting*>(
@@ -131,11 +153,6 @@ void AccountReconcilorTest::SetUp() {
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()));
}
-void AccountReconcilorTest::TearDown() {
- // Destroy the profile before all threads are torn down.
- profile_.reset();
-}
-
MockAccountReconcilor* AccountReconcilorTest::GetMockReconcilor() {
if (!mock_reconcilor_) {
mock_reconcilor_ =
@@ -169,12 +186,17 @@ TEST_F(AccountReconcilorTest, Basic) {
#if !defined(OS_CHROMEOS)
+// This method requires the use of the |TestSigninClient| to be created from the
+// |ChromeSigninClientFactory| because it overrides the |GoogleSigninSucceeded|
+// method with an empty implementation. On MacOS, the normal implementation
+// causes the try_bots to time out.
TEST_F(AccountReconcilorTest, SigninManagerRegistration) {
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
ASSERT_TRUE(reconcilor);
ASSERT_FALSE(reconcilor->IsRegisteredWithTokenService());
+ signin_manager()->set_password("password");
signin_manager()->OnExternalSigninCompleted(kTestEmail);
ASSERT_TRUE(reconcilor->IsRegisteredWithTokenService());
@@ -184,8 +206,13 @@ TEST_F(AccountReconcilorTest, SigninManagerRegistration) {
ASSERT_FALSE(reconcilor->IsRegisteredWithTokenService());
}
+// This method requires the use of the |TestSigninClient| to be created from the
+// |ChromeSigninClientFactory| because it overrides the |GoogleSigninSucceeded|
+// method with an empty implementation. On MacOS, the normal implementation
+// causes the try_bots to time out.
TEST_F(AccountReconcilorTest, Reauth) {
signin_manager()->SetAuthenticatedUsername(kTestEmail);
+ signin_manager()->set_password("password");
AccountReconcilor* reconcilor =
AccountReconcilorFactory::GetForProfile(profile());
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/signin/test_signin_client_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698