Commit 67973de9 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert indirect uses of TestingFactoryFunction

TestingFactoryFunction is a simple function pointer. It is
deprecated in favor of TestingFactory which is a Callback<>.
Convert indirect uses by using base::BindRepeating() in all
invocation of SetTestingFactory/AddTestingFactory.

This converts uses in src//chrome/browser/extensions/api.

This CL was uploaded by git cl split.

R=tbarzic@chromium.org

Bug: 809610
Change-Id: Iff395f785271dc038e2e9e07f3569d91d956f27e
Reviewed-on: https://chromium-review.googlesource.com/c/1259034Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#597049}
parent 9887ccc8
......@@ -6,6 +6,7 @@
#include <memory>
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/values_test_util.h"
......@@ -66,7 +67,7 @@ class DevicePermissionsManagerTest : public testing::Test {
"}"));
HidDeviceManager::GetFactoryInstance()->SetTestingFactory(
env_->profile(), &CreateHidDeviceManager);
env_->profile(), base::BindRepeating(&CreateHidDeviceManager));
device0_ =
new MockUsbDevice(0, 0, "Test Manufacturer", "Test Product", "ABCDE");
device1_ = new MockUsbDevice(0, 0, "Test Manufacturer", "Test Product", "");
......
/// Copyright 2015 The Chromium Authors. All rights reserved.
// Copyright 2015 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 <memory>
#include <utility>
#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/extensions/extension_function_test_utils.h"
......@@ -88,11 +89,11 @@ bool ManagementApiUnitTest::RunFunction(
void ManagementApiUnitTest::SetUp() {
ExtensionServiceTestBase::SetUp();
InitializeEmptyExtensionService();
ManagementAPI::GetFactoryInstance()->SetTestingFactory(profile(),
&BuildManagementApi);
ManagementAPI::GetFactoryInstance()->SetTestingFactory(
profile(), base::BindRepeating(&BuildManagementApi));
EventRouterFactory::GetInstance()->SetTestingFactory(profile(),
&BuildEventRouter);
EventRouterFactory::GetInstance()->SetTestingFactory(
profile(), base::BindRepeating(&BuildEventRouter));
browser_window_.reset(new TestBrowserWindow());
Browser::CreateParams params(profile(), true);
......
......@@ -6,6 +6,7 @@
#include <set>
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/location.h"
......@@ -194,7 +195,8 @@ class ChromeRuntimeAPIDelegateTest : public ExtensionServiceTestWithInstall {
std::make_unique<ChromeRuntimeAPIDelegate>(browser_context());
service()->updater()->SetExtensionCacheForTesting(nullptr);
EventRouterFactory::GetInstance()->SetTestingFactory(
browser_context(), &TestEventRouterFactoryFunction);
browser_context(),
base::BindRepeating(&TestEventRouterFactoryFunction));
// Setup the ExtensionService so that extension updates won't complete
// installation until the extension is idle.
......
......@@ -7,6 +7,7 @@
#include <memory>
#include <utility>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
......@@ -227,7 +228,8 @@ void ExtensionSessionsTest::CreateTestProfileSyncService() {
browser_sync::ProfileSyncServiceMock* service =
static_cast<browser_sync::ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile, &ExtensionSessionsTest::BuildProfileSyncService));
profile, base::BindRepeating(
&ExtensionSessionsTest::BuildProfileSyncService)));
syncer::ModelTypeSet preferred_types(syncer::SESSIONS, syncer::PROXY_TABS);
GoogleServiceAuthError no_error(GoogleServiceAuthError::NONE);
......
......@@ -27,8 +27,8 @@ TEST(SignedInDevicesManager, UpdateListener) {
std::unique_ptr<TestingProfile> profile(new TestingProfile());
SigninManagerFactory::GetForProfile(profile.get())->
SetAuthenticatedAccountInfo("gaia_id", "foo");
ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile.get(),
nullptr);
ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
profile.get(), BrowserContextKeyedServiceFactory::TestingFactory());
SignedInDevicesManager manager(profile.get());
EventListenerInfo info(api::signed_in_devices::OnDeviceInfoChange::kEventName,
......
......@@ -4,6 +4,7 @@
#include <memory>
#include "base/bind.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/browser_process_impl.h"
......@@ -30,7 +31,8 @@ class SocketUnitTest : public ExtensionApiUnittest {
ExtensionApiUnittest::SetUp();
ApiResourceManager<Socket>::GetFactoryInstance()->SetTestingFactoryAndUse(
browser()->profile(), ApiResourceManagerTestFactory);
browser()->profile(),
base::BindRepeating(&ApiResourceManagerTestFactory));
}
};
......
......@@ -4,6 +4,7 @@
#include <memory>
#include "base/bind.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h"
#include "chrome/browser/browser_process_impl.h"
......@@ -38,12 +39,14 @@ class SocketsTcpServerUnitTest : public ExtensionApiUnittest {
ExtensionApiUnittest::SetUp();
ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance()
->SetTestingFactoryAndUse(browser()->profile(),
ApiResourceManagerTestFactory);
->SetTestingFactoryAndUse(
browser()->profile(),
base::BindRepeating(&ApiResourceManagerTestFactory));
ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance()
->SetTestingFactoryAndUse(browser()->profile(),
ApiResourceManagerTestServerFactory);
->SetTestingFactoryAndUse(
browser()->profile(),
base::BindRepeating(&ApiResourceManagerTestServerFactory));
}
};
......
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