Commit 863a437d authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

Start using IdentityTestEnvironment in ProfileSyncServiceBundle

ProfileSyncServiceBundle owns and exposes signin-related objects for
use by sync tests. These signin-related objects include ones that are
deprecated by IdentityManager and no longer used directly in the
production code being tested; however, up until now it has not been
feasible to convert this test utility to using IdentityTestEnvironment,
as doing so would have required converting the widespread usage of this
utility in one go.

We recently introduced an IdentityTestEnvironment usage mode wherein
it can be supplied with IdentityManager's dependencies from the
external client, precisely to enable incremental conversion in use cases
like this. This CL exploits this usage mode to introduce
IdentityTestEnvironment in ProfileSyncServiceBundle.h and provide an
example of its usage to eliminate a direct usage of the deprecated
classes. Once the conversion is complete, ProfileSyncServiceBundle can
then be changed to *only* hold an IdentityTestEnvironment object.

Bug: 886600, 886599
Change-Id: I205c3567fc0a9bcd6f7b613c00a247c302d71be5
Reviewed-on: https://chromium-review.googlesource.com/c/1273065
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599189}
parent c12ec9ee
...@@ -134,6 +134,7 @@ static_library("test_support") { ...@@ -134,6 +134,7 @@ static_library("test_support") {
"//google_apis", "//google_apis",
"//net:test_support", "//net:test_support",
"//services/identity/public/cpp", "//services/identity/public/cpp",
"//services/identity/public/cpp:test_support",
"//services/network:test_support", "//services/network:test_support",
"//services/network/public/cpp", "//services/network/public/cpp",
"//testing/gmock", "//testing/gmock",
......
...@@ -426,11 +426,9 @@ class ProfileSyncServiceAutofillTest ...@@ -426,11 +426,9 @@ class ProfileSyncServiceAutofillTest
} }
void StartAutofillProfileSyncService(base::OnceClosure callback) { void StartAutofillProfileSyncService(base::OnceClosure callback) {
identity::MakePrimaryAccountAvailable( profile_sync_service_bundle()
profile_sync_service_bundle()->signin_manager(), ->identity_test_env()
profile_sync_service_bundle()->auth_service(), ->MakePrimaryAccountAvailable("test_user@gmail.com");
profile_sync_service_bundle()->identity_manager(),
"test_user@gmail.com");
CreateSyncService(std::move(sync_client_owned_), std::move(callback)); CreateSyncService(std::move(sync_client_owned_), std::move(callback));
EXPECT_CALL(*profile_sync_service_bundle()->component_factory(), EXPECT_CALL(*profile_sync_service_bundle()->component_factory(),
......
...@@ -244,10 +244,10 @@ ProfileSyncServiceBundle::ProfileSyncServiceBundle() ...@@ -244,10 +244,10 @@ ProfileSyncServiceBundle::ProfileSyncServiceBundle()
gaia_cookie_manager_service_(&auth_service_, gaia_cookie_manager_service_(&auth_service_,
"profile_sync_service_bundle", "profile_sync_service_bundle",
&signin_client_), &signin_client_),
identity_manager_(&signin_manager_, identity_test_env_(&account_tracker_,
&auth_service_, &auth_service_,
&account_tracker_, &signin_manager_,
&gaia_cookie_manager_service_) { &gaia_cookie_manager_service_) {
RegisterPrefsForProfileSyncService(pref_service_.registry()); RegisterPrefsForProfileSyncService(pref_service_.registry());
auth_service_.set_auto_post_fetch_response_on_message_loop(true); auth_service_.set_auto_post_fetch_response_on_message_loop(true);
account_tracker_.Initialize(&pref_service_, base::FilePath()); account_tracker_.Initialize(&pref_service_, base::FilePath());
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "components/sync/driver/sync_api_component_factory_mock.h" #include "components/sync/driver/sync_api_component_factory_mock.h"
#include "components/sync/model/test_model_type_store_service.h" #include "components/sync/model/test_model_type_store_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h" #include "components/sync_preferences/testing_pref_service_syncable.h"
#include "services/identity/public/cpp/identity_manager.h" #include "services/identity/public/cpp/identity_test_environment.h"
#include "services/network/test/test_url_loader_factory.h" #include "services/network/test/test_url_loader_factory.h"
namespace history { namespace history {
...@@ -131,7 +131,13 @@ class ProfileSyncServiceBundle { ...@@ -131,7 +131,13 @@ class ProfileSyncServiceBundle {
FakeSigninManagerType* signin_manager() { return &signin_manager_; } FakeSigninManagerType* signin_manager() { return &signin_manager_; }
identity::IdentityManager* identity_manager() { return &identity_manager_; } identity::IdentityTestEnvironment* identity_test_env() {
return &identity_test_env_;
}
identity::IdentityManager* identity_manager() {
return identity_test_env_.identity_manager();
}
AccountTrackerService* account_tracker() { return &account_tracker_; } AccountTrackerService* account_tracker() { return &account_tracker_; }
...@@ -163,7 +169,7 @@ class ProfileSyncServiceBundle { ...@@ -163,7 +169,7 @@ class ProfileSyncServiceBundle {
FakeSigninManagerType signin_manager_; FakeSigninManagerType signin_manager_;
FakeProfileOAuth2TokenService auth_service_; FakeProfileOAuth2TokenService auth_service_;
FakeGaiaCookieManagerService gaia_cookie_manager_service_; FakeGaiaCookieManagerService gaia_cookie_manager_service_;
identity::IdentityManager identity_manager_; identity::IdentityTestEnvironment identity_test_env_;
testing::NiceMock<syncer::SyncApiComponentFactoryMock> component_factory_; testing::NiceMock<syncer::SyncApiComponentFactoryMock> component_factory_;
std::unique_ptr<invalidation::ProfileIdentityProvider> identity_provider_; std::unique_ptr<invalidation::ProfileIdentityProvider> identity_provider_;
invalidation::FakeInvalidationService fake_invalidation_service_; invalidation::FakeInvalidationService fake_invalidation_service_;
......
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