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 {
UserCloudPolicyManagerFactory::GetInstance()->RegisterTestingFactory(
base::BindRepeating(&BuildCloudPolicyManager));
TestingProfile::TestingFactories factories = {
{AccountFetcherServiceFactory::GetInstance(),
base::BindRepeating(&FakeAccountFetcherServiceBuilder::BuildForTests)},
{ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&signin::BuildTestSigninClient)}};
TestingProfile::Builder builder;
builder.SetPrefService(
std::unique_ptr<sync_preferences::PrefServiceSyncable>(
std::move(prefs)));
builder.AddTestingFactory(
AccountFetcherServiceFactory::GetInstance(),
base::BindRepeating(&FakeAccountFetcherServiceBuilder::BuildForTests));
builder.AddTestingFactory(
ChromeSigninClientFactory::GetInstance(),
base::BindRepeating(&signin::BuildTestSigninClient));
profile_ = IdentityTestEnvironmentProfileAdaptor::
CreateProfileForIdentityTestEnvironment(factories, std::move(prefs));
CreateProfileForIdentityTestEnvironment(builder);
identity_test_env_adaptor_ =
std::make_unique<IdentityTestEnvironmentProfileAdaptor>(profile_.get());
......
......@@ -36,17 +36,13 @@ std::unique_ptr<TestingProfile> IdentityTestEnvironmentProfileAdaptor::
// static
std::unique_ptr<TestingProfile>
IdentityTestEnvironmentProfileAdaptor::CreateProfileForIdentityTestEnvironment(
const TestingProfile::TestingFactories& input_factories,
std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs) {
const TestingProfile::TestingFactories& input_factories) {
TestingProfile::Builder builder;
for (auto& input_factory : input_factories) {
builder.AddTestingFactory(input_factory.first, input_factory.second);
}
if (prefs)
builder.SetPrefService(std::move(prefs));
return CreateProfileForIdentityTestEnvironment(builder);
}
......
......@@ -25,14 +25,14 @@ class IdentityTestEnvironmentProfileAdaptor {
CreateProfileForIdentityTestEnvironment();
// Like the above, but additionally configures the returned Profile with
// |input_factories| and |prefs|.
// |input_factories|.
static std::unique_ptr<TestingProfile>
CreateProfileForIdentityTestEnvironment(
const TestingProfile::TestingFactories& input_factories,
std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs = nullptr);
const TestingProfile::TestingFactories& input_factories);
// 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>
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