Commit ff12033f authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Eliminate //chrome's signin_manager_builder.cc

There are no more users outside of the IdentityTestEnvironmentProfileAdaptor
class. This CL folds FakeSigninManagerForTesting into (and the helper classes)
the adaptor.

BUG=926948

Change-Id: I8d57947660eab6f217ba1f6cddf9b1baf64f1cc5
Reviewed-on: https://chromium-review.googlesource.com/c/1456516Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#630012}
parent c923379e
......@@ -5403,8 +5403,6 @@ static_library("test_support") {
"signin/fake_account_fetcher_service_builder.h",
"signin/fake_profile_oauth2_token_service_builder.cc",
"signin/fake_profile_oauth2_token_service_builder.h",
"signin/fake_signin_manager_builder.cc",
"signin/fake_signin_manager_builder.h",
"signin/gaia_cookie_manager_service_test_util.cc",
"signin/gaia_cookie_manager_service_test_util.h",
"signin/identity_test_environment_profile_adaptor.cc",
......
......@@ -263,4 +263,8 @@ specific_include_rules = {
"browser_process_impl.cc": [
"+ui/message_center/message_center.h",
],
"identity_test_environment_profile_adaptor\.cc": [
# The following is used to build FakeSigninManager instances for testing.
"+components/signin/core/browser/fake_signin_manager.h",
],
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include <utility>
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
std::unique_ptr<KeyedService> BuildFakeSigninManagerForTesting(
content::BrowserContext* context) {
std::unique_ptr<SigninManagerBase> manager;
Profile* profile = static_cast<Profile*>(context);
manager.reset(new FakeSigninManagerForTesting(profile));
manager->Initialize(nullptr);
return std::move(manager);
}
#if defined(OS_CHROMEOS)
FakeSigninManagerForTesting::FakeSigninManagerForTesting(Profile* profile)
: FakeSigninManagerBase(
ChromeSigninClientFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile)) {}
#else
FakeSigninManagerForTesting::FakeSigninManagerForTesting(Profile* profile)
: FakeSigninManager(
ChromeSigninClientFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile),
GaiaCookieManagerServiceFactory::GetForProfile(profile)) {}
#endif
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_BUILDER_H_
#define CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_BUILDER_H_
#include <memory>
#include <string>
#include "build/build_config.h"
#include "components/signin/core/browser/fake_signin_manager.h"
namespace content {
class BrowserContext;
}
class KeyedService;
class Profile;
// Helper function to be used with KeyedService::SetTestingFactory().
// In order to match the API of SigninManagerFactory::GetForProfile(), returns a
// FakeSigninManagerBase* on ChromeOS, and a FakeSigninManager* on all other
// platforms. The returned instance is initialized.
std::unique_ptr<KeyedService> BuildFakeSigninManagerForTesting(
content::BrowserContext* context);
class FakeSigninManagerForTesting
#if defined(OS_CHROMEOS)
: public FakeSigninManagerBase {
#else
: public FakeSigninManager {
#endif
public:
FakeSigninManagerForTesting(Profile* profile);
};
#endif // CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_BUILDER_H_
......@@ -9,14 +9,37 @@
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager_builder.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_test_util.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "components/signin/core/browser/fake_signin_manager.h"
namespace {
// TestingFactory that creates a FakeSigninManagerBase on ChromeOS and a
// FakeSigninManager on all other platforms.
std::unique_ptr<KeyedService> BuildFakeSigninManagerForTesting(
content::BrowserContext* context) {
Profile* profile = static_cast<Profile*>(context);
std::unique_ptr<SigninManagerBase> manager =
#if defined(OS_CHROMEOS)
std::make_unique<FakeSigninManagerBase>(
ChromeSigninClientFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile));
#else
std::make_unique<FakeSigninManager>(
ChromeSigninClientFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile),
GaiaCookieManagerServiceFactory::GetForProfile(profile));
#endif
manager->Initialize(nullptr);
return manager;
}
// Testing factory that creates a FakeAccountFetcherService.
std::unique_ptr<KeyedService> BuildFakeAccountFetcherService(
content::BrowserContext* context) {
......
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