Commit 867be2f7 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert SyncUIUtilTest to use IdentityTestEnvironment

Instead of creating a TestingProfile with custom factories, create
fake for the required services and pass them directly to the code
that is tested.

This makes the tests simpler (as they do not have to create a full
TestingProfile but only need to create the necessary services). It
required adding an overload of sync_ui_util::GetStatusLabels() that
received the services instead of accessing them via their factories.

Bug: 984487
Change-Id: Ia596fb46b9915e240bfce2ef2e4ee888c99e16c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715297
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680488}
parent b96a52ad
......@@ -217,27 +217,36 @@ MessageType GetStatusLabelsImpl(
} // namespace
MessageType GetStatusLabels(Profile* profile,
MessageType GetStatusLabels(syncer::SyncService* sync_service,
signin::IdentityManager* identity_manager,
bool is_user_signout_allowed,
base::string16* status_label,
base::string16* link_label,
ActionType* action_type) {
DCHECK(profile);
syncer::SyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile);
if (!service) {
if (!sync_service) {
// This can happen if Sync is disabled via the command line.
return PRE_SYNCED;
}
const bool is_user_signout_allowed =
signin_util::IsUserSignoutAllowedForProfile(profile);
CoreAccountInfo account_info = service->GetAuthenticatedAccountInfo();
DCHECK(identity_manager);
CoreAccountInfo account_info = sync_service->GetAuthenticatedAccountInfo();
GoogleServiceAuthError auth_error =
IdentityManagerFactory::GetForProfile(profile)
->GetErrorStateOfRefreshTokenForAccount(account_info.account_id);
return GetStatusLabelsImpl(service, is_user_signout_allowed, auth_error,
identity_manager->GetErrorStateOfRefreshTokenForAccount(
account_info.account_id);
return GetStatusLabelsImpl(sync_service, is_user_signout_allowed, auth_error,
status_label, link_label, action_type);
}
MessageType GetStatusLabels(Profile* profile,
base::string16* status_label,
base::string16* link_label,
ActionType* action_type) {
DCHECK(profile);
return GetStatusLabels(ProfileSyncServiceFactory::GetForProfile(profile),
IdentityManagerFactory::GetForProfile(profile),
signin_util::IsUserSignoutAllowedForProfile(profile),
status_label, link_label, action_type);
}
MessageType GetStatus(Profile* profile) {
return GetStatusLabels(profile, /*status_label=*/nullptr,
/*link_label=*/nullptr, /*action_type=*/nullptr);
......
......@@ -10,6 +10,10 @@
class Profile;
namespace signin {
class IdentityManager;
} // namespace signin
namespace syncer {
class SyncService;
} // namespace syncer
......@@ -46,7 +50,20 @@ enum AvatarSyncErrorType {
};
// Returns the high-level sync status, and populates status and link label
// strings for the current sync status by querying |profile|.
// strings for the current sync status by querying |sync_service| and
// |identity_manager|. Any of |status_label|, |link_label|, and |action_type|
// may be null if the caller isn't interested in it.
MessageType GetStatusLabels(syncer::SyncService* sync_service,
signin::IdentityManager* identity_manager,
bool is_user_signout_allowed,
base::string16* status_label,
base::string16* link_label,
ActionType* action_type);
// Returns the high-level sync status, and populates status and link label
// strings for the current sync status by querying |profile|. This is a
// convenience version of GetStatusLabels that use the |sync_service| and
// |identity_manager| associated to |profile| via their respective factories.
// Any of |status_label|, |link_label|, and |action_type| may be null if the
// caller isn't interested in it.
MessageType GetStatusLabels(Profile* profile,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment