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

Unified Diff: chrome/browser/sync/sync_global_error_unittest.cc

Issue 8665011: sync: remove GetAuthenticatedUsername from ProfileSyncService/SyncBackendHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 9 years, 1 month 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
Index: chrome/browser/sync/sync_global_error_unittest.cc
diff --git a/chrome/browser/sync/sync_global_error_unittest.cc b/chrome/browser/sync/sync_global_error_unittest.cc
index 0215151f2b613049d4af817449ab91513c6db56e..c9e3ec2efb1cdfa42c7ec2d2dd545be8409c965a 100644
--- a/chrome/browser/sync/sync_global_error_unittest.cc
+++ b/chrome/browser/sync/sync_global_error_unittest.cc
@@ -6,7 +6,12 @@
#include "base/basictypes.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/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"
@@ -30,13 +35,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")));
- }
error->OnStateChanged();
@@ -67,13 +65,26 @@ void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
}
}
+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 that SyncGlobalError shows an error if a passphrase is required.
TEST(SyncGlobalErrorTest, PassphraseGlobalError) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- NiceMock<ProfileSyncServiceMock> service;
+ scoped_ptr<Profile> profile(MakeProfile());
+ NiceMock<ProfileSyncServiceMock> service(profile.get());
SyncGlobalError error(&service);
EXPECT_CALL(service, IsPassphraseRequired())
@@ -90,7 +101,8 @@ TEST(SyncGlobalErrorTest, PassphraseGlobalError) {
TEST(SyncGlobalErrorTest, AuthStateGlobalError) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- NiceMock<ProfileSyncServiceMock> service;
+ scoped_ptr<Profile> profile(MakeProfile());
+ NiceMock<ProfileSyncServiceMock> service(profile.get());
SyncGlobalError error(&service);
browser_sync::SyncBackendHost::Status status;

Powered by Google App Engine
This is Rietveld 408576698