diff options
Diffstat (limited to 'chrome/browser/sync/sync_ui_util_unittest.cc')
-rw-r--r-- | chrome/browser/sync/sync_ui_util_unittest.cc | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc index 00d0073..7246f8f 100644 --- a/chrome/browser/sync/sync_ui_util_unittest.cc +++ b/chrome/browser/sync/sync_ui_util_unittest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/sync/profile_sync_service_mock.h" #include "chrome/browser/sync/sync_ui_util.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/gmock/include/gmock/gmock-actions.h" #include "testing/gmock/include/gmock/gmock.h" @@ -66,11 +67,14 @@ void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service, } // namespace +class SyncUIUtilTest : public testing::Test { + private: + content::TestBrowserThreadBundle thread_bundle_; +}; + // Test that GetStatusLabelsForSyncGlobalError returns an error if a // passphrase is required. -TEST(SyncUIUtilTest, PassphraseGlobalError) { - base::MessageLoopForUI message_loop; - content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); +TEST_F(SyncUIUtilTest, PassphraseGlobalError) { scoped_ptr<Profile> profile( ProfileSyncServiceMock::MakeSignedInTestingProfile()); NiceMock<ProfileSyncServiceMock> service(profile.get()); @@ -88,9 +92,7 @@ TEST(SyncUIUtilTest, PassphraseGlobalError) { // Test that GetStatusLabelsForSyncGlobalError returns an error if a // passphrase is required and not for auth errors. -TEST(SyncUIUtilTest, AuthAndPassphraseGlobalError) { - base::MessageLoopForUI message_loop; - content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); +TEST_F(SyncUIUtilTest, AuthAndPassphraseGlobalError) { scoped_ptr<Profile> profile( ProfileSyncServiceMock::MakeSignedInTestingProfile()); NiceMock<ProfileSyncServiceMock> service(profile.get()); @@ -120,9 +122,7 @@ TEST(SyncUIUtilTest, AuthAndPassphraseGlobalError) { // Test that GetStatusLabelsForSyncGlobalError does not indicate errors for // auth errors (these are reported through SigninGlobalError). -TEST(SyncUIUtilTest, AuthStateGlobalError) { - base::MessageLoopForUI message_loop; - content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); +TEST_F(SyncUIUtilTest, AuthStateGlobalError) { scoped_ptr<Profile> profile( ProfileSyncServiceMock::MakeSignedInTestingProfile()); NiceMock<ProfileSyncServiceMock> service(profile.get()); @@ -319,15 +319,18 @@ void GetDistinctCase(ProfileSyncServiceMock& service, // This test ensures that a each distinctive ProfileSyncService statuses // will return a unique combination of status and link messages from // GetStatusLabels(). -TEST(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { +TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { std::set<string16> messages; for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { scoped_ptr<Profile> profile(new TestingProfile()); ProfileSyncServiceMock service(profile.get()); + GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); + EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); FakeSigninManagerForSyncUIUtilTest signin(profile.get()); signin.SetAuthenticatedUsername("test_user@test.com"); scoped_ptr<FakeAuthStatusProvider> provider( - new FakeAuthStatusProvider(signin.signin_global_error())); + new FakeAuthStatusProvider( + SigninGlobalError::GetForProfile(profile.get()))); GetDistinctCase(service, &signin, provider.get(), idx); string16 status_label; string16 link_label; @@ -348,6 +351,7 @@ TEST(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { messages.insert(combined_label); testing::Mock::VerifyAndClearExpectations(&service); testing::Mock::VerifyAndClearExpectations(&signin); + EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); provider.reset(); signin.Shutdown(); } @@ -355,15 +359,18 @@ TEST(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) { // This test ensures that the html_links parameter on GetStatusLabels() is // honored. -TEST(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) { +TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) { for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) { scoped_ptr<Profile> profile( ProfileSyncServiceMock::MakeSignedInTestingProfile()); ProfileSyncServiceMock service(profile.get()); + GoogleServiceAuthError error = GoogleServiceAuthError::AuthErrorNone(); + EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); FakeSigninManagerForSyncUIUtilTest signin(profile.get()); signin.SetAuthenticatedUsername("test_user@test.com"); scoped_ptr<FakeAuthStatusProvider> provider( - new FakeAuthStatusProvider(signin.signin_global_error())); + new FakeAuthStatusProvider( + SigninGlobalError::GetForProfile(profile.get()))); GetDistinctCase(service, &signin, provider.get(), idx); string16 status_label; string16 link_label; @@ -381,6 +388,7 @@ TEST(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) { string16::npos); testing::Mock::VerifyAndClearExpectations(&service); testing::Mock::VerifyAndClearExpectations(&signin); + EXPECT_CALL(service, GetAuthError()).WillRepeatedly(ReturnRef(error)); provider.reset(); signin.Shutdown(); } |