| Index: chrome/browser/sync/sync_ui_util_unittest.cc
|
| diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
|
| index b392ed6de6650152211a6fcb22035280a4e535e5..191e2a1f763a19b0d02190a57b18dbbfa66553ee 100644
|
| --- a/chrome/browser/sync/sync_ui_util_unittest.cc
|
| +++ b/chrome/browser/sync/sync_ui_util_unittest.cc
|
| @@ -3,9 +3,15 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/basictypes.h"
|
| +#include "base/stringprintf.h"
|
| #include "base/utf_string_conversions.h"
|
| +#include "chrome/browser/prefs/pref_service_mock_builder.h"
|
| +#include "chrome/browser/prefs/testing_pref_store.h"
|
| #include "chrome/browser/sync/profile_sync_service_mock.h"
|
| +#include "chrome/browser/sync/signin_manager.h"
|
| #include "chrome/browser/sync/sync_ui_util.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "chrome/test/base/testing_profile.h"
|
| #include "content/test/test_browser_thread.h"
|
| #include "testing/gmock/include/gmock/gmock-actions.h"
|
| #include "testing/gmock/include/gmock/gmock.h"
|
| @@ -28,13 +34,6 @@ void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
|
|
|
| EXPECT_CALL(*service, HasSyncSetupCompleted())
|
| .WillRepeatedly(Return(is_signed_in));
|
| - if (error_state == GoogleServiceAuthError::SERVICE_UNAVAILABLE) {
|
| - EXPECT_CALL(*service, GetAuthenticatedUsername())
|
| - .WillRepeatedly(Return(UTF8ToUTF16("")));
|
| - } else {
|
| - EXPECT_CALL(*service, GetAuthenticatedUsername())
|
| - .WillRepeatedly(Return(UTF8ToUTF16("foo")));
|
| - }
|
|
|
| string16 label1, label2, label3;
|
| sync_ui_util::GetStatusLabelsForSyncGlobalError(
|
| @@ -44,12 +43,24 @@ void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
|
| EXPECT_EQ(label3.empty(), !is_error);
|
| }
|
|
|
| +Profile* MakeProfile() {
|
| + TestingProfile* profile = new TestingProfile();
|
| + TestingPrefStore* user_prefs = new TestingPrefStore();
|
| + PrefService* prefs = PrefServiceMockBuilder()
|
| + .WithUserPrefs(user_prefs)
|
| + .Create();
|
| + profile->SetPrefService(prefs);
|
| + SigninManager::RegisterUserPrefs(prefs);
|
| + user_prefs->SetString(prefs::kGoogleServicesUsername, "foo");
|
| + return profile;
|
| +}
|
| +
|
| } // namespace
|
|
|
| TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
|
| MessageLoopForUI message_loop;
|
| content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
|
| - NiceMock<ProfileSyncServiceMock> service;
|
| + NiceMock<ProfileSyncServiceMock> service(MakeProfile());
|
| DictionaryValue strings;
|
|
|
| // Will be released when the dictionary is destroyed
|
| @@ -79,7 +90,7 @@ TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
|
| TEST(SyncUIUtilTest, PassphraseGlobalError) {
|
| MessageLoopForUI message_loop;
|
| content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
|
| - NiceMock<ProfileSyncServiceMock> service;
|
| + NiceMock<ProfileSyncServiceMock> service(MakeProfile());
|
|
|
| EXPECT_CALL(service, IsPassphraseRequired())
|
| .WillOnce(Return(true));
|
| @@ -95,7 +106,7 @@ TEST(SyncUIUtilTest, PassphraseGlobalError) {
|
| TEST(SyncUIUtilTest, AuthStateGlobalError) {
|
| MessageLoopForUI message_loop;
|
| content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
|
| - NiceMock<ProfileSyncServiceMock> service;
|
| + NiceMock<ProfileSyncServiceMock> service(MakeProfile());
|
|
|
| browser_sync::SyncBackendHost::Status status;
|
| EXPECT_CALL(service, QueryDetailedSyncStatus())
|
| @@ -119,6 +130,7 @@ TEST(SyncUIUtilTest, AuthStateGlobalError) {
|
| };
|
|
|
| for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
|
| + SCOPED_TRACE(base::StringPrintf("iteration: %d", (int)i));
|
| VerifySyncGlobalErrorResult(
|
| &service, table[i].error_state, true, table[i].is_error);
|
| VerifySyncGlobalErrorResult(
|
|
|