| Index: chrome/browser/ui/webui/settings/people_handler_unittest.cc
|
| diff --git a/chrome/browser/ui/webui/settings/people_handler_unittest.cc b/chrome/browser/ui/webui/settings/people_handler_unittest.cc
|
| index 7a8d1ee6521953404f968f2698165219bc6a1525..56676b98bfb5e40f306dfa643572ef0166decf0f 100644
|
| --- a/chrome/browser/ui/webui/settings/people_handler_unittest.cc
|
| +++ b/chrome/browser/ui/webui/settings/people_handler_unittest.cc
|
| @@ -25,9 +25,11 @@
|
| #include "chrome/test/base/scoped_testing_local_state.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/fake_auth_status_provider.h"
|
| #include "components/signin/core/browser/signin_manager.h"
|
| #include "components/sync_driver/sync_prefs.h"
|
| +#include "components/syncable_prefs/pref_service_syncable.h"
|
| #include "content/public/browser/web_ui.h"
|
| #include "content/public/test/test_browser_thread.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| @@ -183,21 +185,27 @@ class PeopleHandlerTest : public testing::Test {
|
| void SetUp() override {
|
| error_ = GoogleServiceAuthError::AuthErrorNone();
|
|
|
| - TestingProfile::Builder builder;
|
| - builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
|
| - BuildFakeSigninManagerBase);
|
| - profile_ = builder.Build();
|
| + profile_manager_.reset(
|
| + new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
|
| + ASSERT_TRUE(profile_manager_->SetUp());
|
| +
|
| + TestingProfile::TestingFactories testing_factories;
|
| + testing_factories.push_back(std::make_pair(
|
| + SigninManagerFactory::GetInstance(), BuildFakeSigninManagerBase));
|
| + profile_ = profile_manager_->CreateTestingProfile(
|
| + "Person 1", nullptr, base::UTF8ToUTF16("Person 1"), 0, std::string(),
|
| + testing_factories);
|
|
|
| // Sign in the user.
|
| mock_signin_ = static_cast<SigninManagerBase*>(
|
| - SigninManagerFactory::GetForProfile(profile_.get()));
|
| + SigninManagerFactory::GetForProfile(profile_));
|
| std::string username = GetTestUser();
|
| if (!username.empty())
|
| mock_signin_->SetAuthenticatedAccountInfo(username, username);
|
|
|
| mock_pss_ = static_cast<ProfileSyncServiceMock*>(
|
| ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
|
| - profile_.get(), BuildMockProfileSyncService));
|
| + profile_, BuildMockProfileSyncService));
|
| EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_));
|
| ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault(
|
| Return(syncer::IMPLICIT_PASSPHRASE));
|
| @@ -208,7 +216,7 @@ class PeopleHandlerTest : public testing::Test {
|
|
|
| mock_pss_->Initialize();
|
|
|
| - handler_.reset(new TestingPeopleHandler(&web_ui_, profile_.get()));
|
| + handler_.reset(new TestingPeopleHandler(&web_ui_, profile_));
|
| }
|
|
|
| // Setup the expectations for calls made when displaying the config page.
|
| @@ -268,7 +276,7 @@ class PeopleHandlerTest : public testing::Test {
|
| handler_->CloseSyncSetup();
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| }
|
|
|
| // It's difficult to notify sync listeners when using a ProfileSyncServiceMock
|
| @@ -284,7 +292,8 @@ class PeopleHandlerTest : public testing::Test {
|
| }
|
|
|
| content::TestBrowserThreadBundle thread_bundle_;
|
| - scoped_ptr<Profile> profile_;
|
| + scoped_ptr<TestingProfileManager> profile_manager_;
|
| + Profile* profile_;
|
| ProfileSyncServiceMock* mock_pss_;
|
| GoogleServiceAuthError error_;
|
| SigninManagerBase* mock_signin_;
|
| @@ -314,14 +323,14 @@ TEST_F(PeopleHandlerFirstSigninTest, DisplayBasicLogin) {
|
| // Sync setup hands off control to the gaia login tab.
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
|
|
| ASSERT_FALSE(handler_->is_configuring_sync());
|
|
|
| handler_->CloseSyncSetup();
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| }
|
|
|
| TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
|
| @@ -340,7 +349,7 @@ TEST_F(PeopleHandlerTest, ShowSyncSetupWhenNotSignedIn) {
|
| ASSERT_FALSE(handler_->is_configuring_sync());
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| }
|
| #endif // !defined(OS_CHROMEOS)
|
|
|
| @@ -353,7 +362,7 @@ TEST_F(PeopleHandlerTest, HandleSetupUIWhenSyncDisabled) {
|
| // Sync setup is closed when sync is disabled.
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| ASSERT_FALSE(handler_->is_configuring_sync());
|
| }
|
|
|
| @@ -377,7 +386,7 @@ TEST_F(PeopleHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) {
|
|
|
| EXPECT_EQ(handler_.get(),
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
|
|
| ExpectSpinnerAndClose();
|
| }
|
| @@ -458,7 +467,7 @@ TEST_F(PeopleHandlerTest,
|
| handler_->CloseSyncSetup();
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| }
|
|
|
| TEST_F(PeopleHandlerTest,
|
| @@ -486,7 +495,7 @@ TEST_F(PeopleHandlerTest,
|
| // On failure, the dialog will be closed.
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| }
|
|
|
| #if !defined(OS_CHROMEOS)
|
| @@ -773,7 +782,7 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
|
| SetupInitializedProfileSyncService();
|
| mock_signin_->SetAuthenticatedAccountInfo(kTestUser, kTestUser);
|
| FakeAuthStatusProvider provider(
|
| - SigninErrorControllerFactory::GetForProfile(profile_.get()));
|
| + SigninErrorControllerFactory::GetForProfile(profile_));
|
| provider.SetAuthError(kTestUser, error_);
|
| EXPECT_CALL(*mock_pss_, CanSyncStart()).WillRepeatedly(Return(true));
|
| EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable())
|
| @@ -791,7 +800,7 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
|
| // clicking on the button in the UI will sign the user out rather than
|
| // displaying a spinner. Should be no visible UI on ChromeOS in this case.
|
| EXPECT_EQ(NULL, LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
| #else
|
|
|
| // On ChromeOS, this should display the spinner while we try to startup the
|
| @@ -801,7 +810,7 @@ TEST_F(PeopleHandlerTest, ShowSigninOnAuthError) {
|
| // Sync setup is closed when re-auth is in progress.
|
| EXPECT_EQ(NULL,
|
| LoginUIServiceFactory::GetForProfile(
|
| - profile_.get())->current_login_ui());
|
| + profile_)->current_login_ui());
|
|
|
| ASSERT_FALSE(handler_->is_configuring_sync());
|
| #endif
|
| @@ -880,7 +889,7 @@ TEST_F(PeopleHandlerTest, ShowSetupSyncForAllTypesIndividually) {
|
|
|
| ExpectConfig();
|
| // Close the config overlay.
|
| - LoginUIServiceFactory::GetForProfile(profile_.get())->LoginUIClosed(
|
| + LoginUIServiceFactory::GetForProfile(profile_)->LoginUIClosed(
|
| handler_.get());
|
| const content::TestWebUI::CallData& data = *web_ui_.call_data()[0];
|
| const base::DictionaryValue* dictionary = nullptr;
|
|
|