Commit 3b0eebbf authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

[s13n] Migrate the IdentityTestEnvironmentProfileAdaptor clients that pass...

[s13n] Migrate the IdentityTestEnvironmentProfileAdaptor clients that pass PrefService to use Builder variant

The "build variant" is more powerful, than the one that takes a |prefs|
as parameter.

TBR=emaxx@chromium.org (chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc)

BUG=905687

Change-Id: I622446888ad8e31ef3fd0d464ac5ab25375abf3c
Reviewed-on: https://chromium-review.googlesource.com/c/1340889
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609669}
parent bce64d01
...@@ -172,13 +172,18 @@ class UserPolicySigninServiceTest : public testing::Test { ...@@ -172,13 +172,18 @@ class UserPolicySigninServiceTest : public testing::Test {
UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory( UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory(
base::BindRepeating(&BuildCloudPolicyManager)); base::BindRepeating(&BuildCloudPolicyManager));
TestingProfile::TestingFactories factories = { TestingProfile::Builder builder;
{AccountFetcherServiceFactory::GetInstance(), builder.SetPrefService(
base::BindRepeating(&FakeAccountFetcherServiceBuilder::BuildForTests)}, std::unique_ptr<sync_preferences::PrefServiceSyncable>(
{ChromeSigninClientFactory::GetInstance(), std::move(prefs)));
base::BindRepeating(&signin::BuildTestSigninClient)}}; builder.AddTestingFactory(
AccountFetcherServiceFactory::GetInstance(),
base::BindRepeating(&FakeAccountFetcherServiceBuilder::BuildForTests));
builder.AddTestingFactory(
ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&signin::BuildTestSigninClient));
profile_ = IdentityTestEnvironmentProfileAdaptor:: profile_ = IdentityTestEnvironmentProfileAdaptor::
CreateProfileForIdentityTestEnvironment(factories, std::move(prefs)); CreateProfileForIdentityTestEnvironment(builder);
identity_test_env_adaptor_ = identity_test_env_adaptor_ =
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile_.get()); std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile_.get());
......
...@@ -36,17 +36,13 @@ std::unique_ptr<TestingProfile> IdentityTestEnvironmentProfileAdaptor:: ...@@ -36,17 +36,13 @@ std::unique_ptr<TestingProfile> IdentityTestEnvironmentProfileAdaptor::
// static // static
std::unique_ptr<TestingProfile> std::unique_ptr<TestingProfile>
IdentityTestEnvironmentProfileAdaptor::CreateProfileForIdentityTestEnvironment( IdentityTestEnvironmentProfileAdaptor::CreateProfileForIdentityTestEnvironment(
const TestingProfile::TestingFactories& input_factories, const TestingProfile::TestingFactories& input_factories) {
std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs) {
TestingProfile::Builder builder; TestingProfile::Builder builder;
for (auto& input_factory : input_factories) { for (auto& input_factory : input_factories) {
builder.AddTestingFactory(input_factory.first, input_factory.second); builder.AddTestingFactory(input_factory.first, input_factory.second);
} }
if (prefs)
builder.SetPrefService(std::move(prefs));
return CreateProfileForIdentityTestEnvironment(builder); return CreateProfileForIdentityTestEnvironment(builder);
} }
......
...@@ -25,14 +25,14 @@ class IdentityTestEnvironmentProfileAdaptor { ...@@ -25,14 +25,14 @@ class IdentityTestEnvironmentProfileAdaptor {
CreateProfileForIdentityTestEnvironment(); CreateProfileForIdentityTestEnvironment();
// Like the above, but additionally configures the returned Profile with // Like the above, but additionally configures the returned Profile with
// |input_factories| and |prefs|. // |input_factories|.
static std::unique_ptr<TestingProfile> static std::unique_ptr<TestingProfile>
CreateProfileForIdentityTestEnvironment( CreateProfileForIdentityTestEnvironment(
const TestingProfile::TestingFactories& input_factories, const TestingProfile::TestingFactories& input_factories);
std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs = nullptr);
// Creates and returns a TestingProfile that has been configured with the // Creates and returns a TestingProfile that has been configured with the
// given |builder|. // given |builder| and the set of testing factories that
// IdentityTestEnvironment requires.
static std::unique_ptr<TestingProfile> static std::unique_ptr<TestingProfile>
CreateProfileForIdentityTestEnvironment(TestingProfile::Builder& builder); CreateProfileForIdentityTestEnvironment(TestingProfile::Builder& builder);
......
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