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

Unified Diff: chrome/browser/sync/sync_ui_util_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_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..23b64ce30a2046625737840dc8073311ab9c0358 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,25 @@ 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;
Andrew T Wilson (Slow) 2011/11/24 01:48:16 I wonder if this could be refactored into ProfileS
tim (not reviewing) 2011/11/24 03:59:42 Yeahh, in fact that method above is duplicated as
+}
+
} // namespace
TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- NiceMock<ProfileSyncServiceMock> service;
+ scoped_ptr<Profile> profile(MakeProfile());
+ NiceMock<ProfileSyncServiceMock> service(profile.get());
DictionaryValue strings;
// Will be released when the dictionary is destroyed
@@ -79,7 +91,8 @@ TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
TEST(SyncUIUtilTest, 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());
EXPECT_CALL(service, IsPassphraseRequired())
.WillOnce(Return(true));
@@ -95,7 +108,8 @@ TEST(SyncUIUtilTest, PassphraseGlobalError) {
TEST(SyncUIUtilTest, 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());
browser_sync::SyncBackendHost::Status status;
EXPECT_CALL(service, QueryDetailedSyncStatus())
@@ -119,6 +133,7 @@ TEST(SyncUIUtilTest, AuthStateGlobalError) {
};
for (size_t i = 0; i < sizeof(table)/sizeof(*table); ++i) {
+ SCOPED_TRACE(base::StringPrintf("iteration: %d", (int)i));
Andrew T Wilson (Slow) 2011/11/24 01:48:16 Did you mean to leave this in?
VerifySyncGlobalErrorResult(
&service, table[i].error_state, true, table[i].is_error);
VerifySyncGlobalErrorResult(

Powered by Google App Engine
This is Rietveld 408576698