diff options
Diffstat (limited to 'chrome/browser/ui')
5 files changed, 24 insertions, 18 deletions
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm index 82032a1..d57e76f 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm @@ -707,10 +707,10 @@ TEST_F(BrowserWindowControllerTest, TestSigninMenuItemAuthError) { SigninManager* signin = SigninManagerFactory::GetForProfile(profile()); signin->SetAuthenticatedUsername(username); ProfileSyncService* sync = - ProfileSyncServiceFactory::GetForProfile(profile()); + ProfileSyncServiceFactory::GetForProfile(profile()); sync->SetSyncSetupCompleted(); // Force an auth error. - FakeAuthStatusProvider provider(signin->signin_global_error()); + FakeAuthStatusProvider provider(SigninGlobalError::GetForProfile(profile())); GoogleServiceAuthError error( GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); provider.SetAuthError(error); diff --git a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc index 3f32a3d..d77a9ad 100644 --- a/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc +++ b/chrome/browser/ui/sync/one_click_signin_helper_unittest.cc @@ -224,6 +224,7 @@ class OneClickSigninHelperTest : public content::RenderViewHostTestHarness { protected: TestingProfile* profile_; + GoogleServiceAuthError no_error_; private: // The ID of the signin process the test will assume to be trusted. @@ -236,6 +237,7 @@ class OneClickSigninHelperTest : public content::RenderViewHostTestHarness { OneClickSigninHelperTest::OneClickSigninHelperTest() : profile_(NULL), + no_error_(GoogleServiceAuthError::NONE), trusted_signin_process_id_(-1) { } @@ -306,13 +308,17 @@ OneClickSigninHelperTest::CreateProfileSyncServiceMock() { ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( profile_, ProfileSyncServiceMock::BuildMockProfileSyncService)); - sync_service->Initialize(); EXPECT_CALL(*sync_service, SetSetupInProgress(true)); EXPECT_CALL(*sync_service, AddObserver(_)).Times(AtLeast(1)); EXPECT_CALL(*sync_service, FirstSetupInProgress()).WillRepeatedly( Return(false)); EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); EXPECT_CALL(*sync_service, RemoveObserver(_)).Times(AtLeast(1)); + EXPECT_CALL(*sync_service, GetAuthError()). + WillRepeatedly(::testing::ReturnRef(no_error_)); + EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(false)); + sync_service->Initialize(); + EXPECT_CALL(*sync_service, sync_initialized()).WillRepeatedly(Return(true)); return sync_service; } diff --git a/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc b/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc index d2bb889..d4c94a8 100644 --- a/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/wrench_menu_model_unittest.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ui/toolbar/wrench_menu_model.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/global_error/global_error.h" #include "chrome/browser/ui/global_error/global_error_service.h" @@ -159,8 +160,10 @@ TEST_F(WrenchMenuModelTest, Basics) { // Tests global error menu items in the wrench menu. TEST_F(WrenchMenuModelTest, GlobalError) { + // Make sure services required for tests are initialized. GlobalErrorService* service = GlobalErrorServiceFactory::GetForProfile(browser()->profile()); + ProfileOAuth2TokenServiceFactory::GetForProfile(browser()->profile()); const int command1 = 1234567; // AddGlobalError takes ownership of error1. MenuError* error1 = new MenuError(command1); diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc index a7f3410..139c0f1 100644 --- a/chrome/browser/ui/webui/sync_setup_handler.cc +++ b/chrome/browser/ui/webui/sync_setup_handler.cc @@ -984,7 +984,7 @@ void SyncSetupHandler::OpenSyncSetup() { return; } - if (signin->signin_global_error()->HasMenuItem()) { + if (SigninGlobalError::GetForProfile(GetProfile())->HasMenuItem()) { // Login has been specially requested because previously working credentials // have expired (case 3). Load the sync setup page with a spinner dialog, // and then display the gaia auth page. The user may abandon re-auth by diff --git a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc index d863800..d0c36e7 100644 --- a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc +++ b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc @@ -9,12 +9,13 @@ #include "base/command_line.h" #include "base/json/json_writer.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" #include "base/prefs/pref_service.h" #include "base/stl_util.h" #include "base/values.h" #include "chrome/browser/signin/fake_auth_status_provider.h" #include "chrome/browser/signin/fake_signin_manager.h" +#include "chrome/browser/signin/profile_oauth2_token_service.h" +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/signin_manager.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h" @@ -28,6 +29,7 @@ #include "chrome/test/base/scoped_testing_local_state.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" #include "grit/generated_resources.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" @@ -305,18 +307,21 @@ class SyncSetupHandlerTest : public testing::Test { virtual void SetUp() OVERRIDE { error_ = GoogleServiceAuthError::AuthErrorNone(); profile_.reset(ProfileSyncServiceMock::MakeSignedInTestingProfile()); + mock_pss_ = static_cast<ProfileSyncServiceMock*>( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( profile_.get(), ProfileSyncServiceMock::BuildMockProfileSyncService)); - mock_pss_->Initialize(); - + EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); ON_CALL(*mock_pss_, GetPassphraseType()).WillByDefault( Return(syncer::IMPLICIT_PASSPHRASE)); ON_CALL(*mock_pss_, GetPassphraseTime()).WillByDefault( Return(base::Time())); ON_CALL(*mock_pss_, GetExplicitPassphraseTime()).WillByDefault( Return(base::Time())); + + mock_pss_->Initialize(); + #if defined(OS_CHROMEOS) mock_signin_ = static_cast<SigninManagerBase*>( SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( @@ -357,7 +362,6 @@ class SyncSetupHandlerTest : public testing::Test { .WillRepeatedly(Return(true)); EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) .WillRepeatedly(Return(true)); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(true)); } @@ -405,11 +409,10 @@ class SyncSetupHandlerTest : public testing::Test { handler_->sync_startup_tracker_->OnStateChanged(); } + content::TestBrowserThreadBundle thread_bundle_; scoped_ptr<Profile> profile_; ProfileSyncServiceMock* mock_pss_; GoogleServiceAuthError error_; - // MessageLoop instance is required to work with OneShotTimer. - base::MessageLoop message_loop_; SigninManagerBase* mock_signin_; TestWebUI web_ui_; scoped_ptr<TestingSyncSetupHandler> handler_; @@ -424,8 +427,6 @@ TEST_F(SyncSetupHandlerTest, DisplayBasicLogin) { .WillRepeatedly(Return(false)); EXPECT_CALL(*mock_pss_, IsOAuthRefreshTokenAvailable()) .WillRepeatedly(Return(false)); - const GoogleServiceAuthError error(GoogleServiceAuthError::NONE); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error)); EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) .WillRepeatedly(Return(false)); handler_->HandleStartSignin(NULL); @@ -473,7 +474,6 @@ TEST_F(SyncSetupHandlerTest, DisplayConfigureWithBackendDisabledAndCancel) { EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) .WillRepeatedly(Return(false)); error_ = GoogleServiceAuthError::AuthErrorNone(); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); // We're simulating a user setting up sync, which would cause the backend to @@ -503,7 +503,6 @@ TEST_F(SyncSetupHandlerTest, EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) .WillRepeatedly(Return(false)); error_ = GoogleServiceAuthError::AuthErrorNone(); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); // Sync backend is stopped initially, and will start up. EXPECT_CALL(*mock_pss_, sync_initialized()) .WillRepeatedly(Return(false)); @@ -563,7 +562,6 @@ TEST_F(SyncSetupHandlerTest, EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) .WillRepeatedly(Return(false)); error_ = GoogleServiceAuthError::AuthErrorNone(); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); EXPECT_CALL(*mock_pss_, sync_initialized()) .WillOnce(Return(false)) .WillRepeatedly(Return(true)); @@ -594,7 +592,6 @@ TEST_F(SyncSetupHandlerTest, EXPECT_CALL(*mock_pss_, HasSyncSetupCompleted()) .WillRepeatedly(Return(false)); error_ = GoogleServiceAuthError::AuthErrorNone(); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); handler_->OpenSyncSetup(); @@ -907,7 +904,8 @@ TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { SetupInitializedProfileSyncService(); mock_signin_->SetAuthenticatedUsername(kTestUser); - FakeAuthStatusProvider provider(mock_signin_->signin_global_error()); + FakeAuthStatusProvider provider( + SigninGlobalError::GetForProfile(profile_.get())); provider.SetAuthError(error_); EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn()) .WillRepeatedly(Return(true)); @@ -917,7 +915,6 @@ TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) { .WillRepeatedly(Return(false)); EXPECT_CALL(*mock_pss_, IsUsingSecondaryPassphrase()) .WillRepeatedly(Return(false)); - EXPECT_CALL(*mock_pss_, GetAuthError()).WillRepeatedly(ReturnRef(error_)); EXPECT_CALL(*mock_pss_, sync_initialized()).WillRepeatedly(Return(false)); #if defined(OS_CHROMEOS) |