summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/sync_ui_util_unittest.cc
diff options
context:
space:
mode:
authortim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 05:25:38 +0000
committertim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-02 05:25:38 +0000
commit6a108f84080257b168eea83aa41be5caaf21cdb7 (patch)
treeb26d85f65df95c77f5987ec371bfc5c13c0c5aa3 /chrome/browser/sync/sync_ui_util_unittest.cc
parent01677774d5be7581c123efe7b45a1f784cb857b1 (diff)
downloadchromium_src-6a108f84080257b168eea83aa41be5caaf21cdb7.zip
chromium_src-6a108f84080257b168eea83aa41be5caaf21cdb7.tar.gz
chromium_src-6a108f84080257b168eea83aa41be5caaf21cdb7.tar.bz2
sync: remove GetAuthenticatedUsername from ProfileSyncService/SyncBackendHost.
Removing as it's not necessary and simplifies code to make it easier to ultimately rid ProfileSyncService of cros_user, and ultimately convert it to a ProfileKeyedService. Before this change the two values only differ 1) on chrome os, where kGoogleServicesUsername doesn't seem to be set today (and in some cases we use cros_user as a crutch), and 2) when kGoogleServicesUsername is cleared, but that only happens on DisableForUser. In the future I'd imagine this value to be allowed to outlive that call as well, which would be OK. BUG=88109,93922 TEST=bits of UI that show usernames continue to show usernames Review URL: http://codereview.chromium.org/8665011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/sync_ui_util_unittest.cc')
-rw-r--r--chrome/browser/sync/sync_ui_util_unittest.cc39
1 files changed, 17 insertions, 22 deletions
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
index 6ed7d5d..2cb84c4 100644
--- a/chrome/browser/sync/sync_ui_util_unittest.cc
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -4,7 +4,9 @@
#include <set>
#include "base/basictypes.h"
+#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "content/test/test_browser_thread.h"
@@ -42,14 +44,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")));
- }
-
GoogleServiceAuthError auth_error(error_state);
EXPECT_CALL(*service, GetAuthError()).WillRepeatedly(ReturnRef(auth_error));
@@ -66,7 +60,9 @@ void VerifySyncGlobalErrorResult(NiceMock<ProfileSyncServiceMock>* service,
TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- NiceMock<ProfileSyncServiceMock> service;
+ scoped_ptr<Profile> profile(
+ ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ NiceMock<ProfileSyncServiceMock> service(profile.get());
DictionaryValue strings;
// Will be released when the dictionary is destroyed
@@ -99,7 +95,9 @@ TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
TEST(SyncUIUtilTest, PassphraseGlobalError) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- NiceMock<ProfileSyncServiceMock> service;
+ scoped_ptr<Profile> profile(
+ ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ NiceMock<ProfileSyncServiceMock> service(profile.get());
EXPECT_CALL(service, IsPassphraseRequired())
.WillOnce(Return(true));
@@ -115,7 +113,9 @@ TEST(SyncUIUtilTest, PassphraseGlobalError) {
TEST(SyncUIUtilTest, AuthStateGlobalError) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
- NiceMock<ProfileSyncServiceMock> service;
+ scoped_ptr<Profile> profile(
+ ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ NiceMock<ProfileSyncServiceMock> service(profile.get());
browser_sync::SyncBackendHost::Status status;
EXPECT_CALL(service, QueryDetailedSyncStatus())
@@ -210,8 +210,6 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
GoogleServiceAuthError::SERVICE_UNAVAILABLE);
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, GetAuthenticatedUsername())
- .Times(AtMost(1)).WillRepeatedly(Return(ASCIIToUTF16("")));
EXPECT_CALL(service, GetAuthError())
.WillOnce(ReturnRef(**auth_error));
EXPECT_CALL(service, UIShouldDepictAuthInProgress())
@@ -249,8 +247,6 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
.WillOnce(ReturnRef(**auth_error));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, GetAuthenticatedUsername())
- .WillOnce(Return(ASCIIToUTF16("example@example.com")));
EXPECT_CALL(service, UIShouldDepictAuthInProgress())
.WillOnce(Return(false));
EXPECT_CALL(service, IsPassphraseRequired())
@@ -271,8 +267,6 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
.WillOnce(ReturnRef(**auth_error));
EXPECT_CALL(service, unrecoverable_error_detected())
.WillOnce(Return(false));
- EXPECT_CALL(service, GetAuthenticatedUsername())
- .WillOnce(Return(ASCIIToUTF16("example@example.com")));
EXPECT_CALL(service, UIShouldDepictAuthInProgress())
.WillOnce(Return(false));
EXPECT_CALL(service, IsPassphraseRequired())
@@ -288,11 +282,11 @@ void GetDistinctCase(ProfileSyncServiceMock& service,
// will return a unique combination of status and link messages from
// GetStatusLabels().
TEST(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) {
- ProfileSyncServiceMock service;
-
std::set<string16> messages;
for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) {
- ProfileSyncServiceMock service;
+ scoped_ptr<Profile> profile(
+ ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ ProfileSyncServiceMock service(profile.get());
GoogleServiceAuthError* auth_error = NULL;
GetDistinctCase(service, &auth_error, idx);
string16 status_label;
@@ -316,9 +310,10 @@ TEST(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) {
// This test ensures that the html_links parameter on GetStatusLabels() is
// honored.
TEST(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) {
- ProfileSyncServiceMock service;
for (int idx = 0; idx != NUMBER_OF_STATUS_CASES; idx++) {
- ProfileSyncServiceMock service;
+ scoped_ptr<Profile> profile(
+ ProfileSyncServiceMock::MakeSignedInTestingProfile());
+ ProfileSyncServiceMock service(profile.get());
GoogleServiceAuthError* auth_error = NULL;
GetDistinctCase(service, &auth_error, idx);
string16 status_label;