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 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include "base/bind.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/values_test_util.h" #include "base/test/values_test_util.h"
...@@ -66,7 +67,7 @@ class DevicePermissionsManagerTest : public testing::Test { ...@@ -66,7 +67,7 @@ class DevicePermissionsManagerTest : public testing::Test {
"}")); "}"));
HidDeviceManager::GetFactoryInstance()->SetTestingFactory( HidDeviceManager::GetFactoryInstance()->SetTestingFactory(
env_->profile(), &CreateHidDeviceManager); env_->profile(), base::BindRepeating(&CreateHidDeviceManager));
device0_ = device0_ =
new MockUsbDevice(0, 0, "Test Manufacturer", "Test Product", "ABCDE"); new MockUsbDevice(0, 0, "Test Manufacturer", "Test Product", "ABCDE");
device1_ = new MockUsbDevice(0, 0, "Test Manufacturer", "Test Product", ""); 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chrome/browser/extensions/extension_function_test_utils.h" #include "chrome/browser/extensions/extension_function_test_utils.h"
...@@ -88,11 +89,11 @@ bool ManagementApiUnitTest::RunFunction( ...@@ -88,11 +89,11 @@ bool ManagementApiUnitTest::RunFunction(
void ManagementApiUnitTest::SetUp() { void ManagementApiUnitTest::SetUp() {
ExtensionServiceTestBase::SetUp(); ExtensionServiceTestBase::SetUp();
InitializeEmptyExtensionService(); InitializeEmptyExtensionService();
ManagementAPI::GetFactoryInstance()->SetTestingFactory(profile(), ManagementAPI::GetFactoryInstance()->SetTestingFactory(
&BuildManagementApi); profile(), base::BindRepeating(&BuildManagementApi));
EventRouterFactory::GetInstance()->SetTestingFactory(profile(), EventRouterFactory::GetInstance()->SetTestingFactory(
&BuildEventRouter); profile(), base::BindRepeating(&BuildEventRouter));
browser_window_.reset(new TestBrowserWindow()); browser_window_.reset(new TestBrowserWindow());
Browser::CreateParams params(profile(), true); Browser::CreateParams params(profile(), true);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <set> #include <set>
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/location.h" #include "base/location.h"
...@@ -194,7 +195,8 @@ class ChromeRuntimeAPIDelegateTest : public ExtensionServiceTestWithInstall { ...@@ -194,7 +195,8 @@ class ChromeRuntimeAPIDelegateTest : public ExtensionServiceTestWithInstall {
std::make_unique<ChromeRuntimeAPIDelegate>(browser_context()); std::make_unique<ChromeRuntimeAPIDelegate>(browser_context());
service()->updater()->SetExtensionCacheForTesting(nullptr); service()->updater()->SetExtensionCacheForTesting(nullptr);
EventRouterFactory::GetInstance()->SetTestingFactory( EventRouterFactory::GetInstance()->SetTestingFactory(
browser_context(), &TestEventRouterFactoryFunction); browser_context(),
base::BindRepeating(&TestEventRouterFactoryFunction));
// Setup the ExtensionService so that extension updates won't complete // Setup the ExtensionService so that extension updates won't complete
// installation until the extension is idle. // installation until the extension is idle.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
...@@ -227,7 +228,8 @@ void ExtensionSessionsTest::CreateTestProfileSyncService() { ...@@ -227,7 +228,8 @@ void ExtensionSessionsTest::CreateTestProfileSyncService() {
browser_sync::ProfileSyncServiceMock* service = browser_sync::ProfileSyncServiceMock* service =
static_cast<browser_sync::ProfileSyncServiceMock*>( static_cast<browser_sync::ProfileSyncServiceMock*>(
ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
profile, &ExtensionSessionsTest::BuildProfileSyncService)); profile, base::BindRepeating(
&ExtensionSessionsTest::BuildProfileSyncService)));
syncer::ModelTypeSet preferred_types(syncer::SESSIONS, syncer::PROXY_TABS); syncer::ModelTypeSet preferred_types(syncer::SESSIONS, syncer::PROXY_TABS);
GoogleServiceAuthError no_error(GoogleServiceAuthError::NONE); GoogleServiceAuthError no_error(GoogleServiceAuthError::NONE);
......
...@@ -27,8 +27,8 @@ TEST(SignedInDevicesManager, UpdateListener) { ...@@ -27,8 +27,8 @@ TEST(SignedInDevicesManager, UpdateListener) {
std::unique_ptr<TestingProfile> profile(new TestingProfile()); std::unique_ptr<TestingProfile> profile(new TestingProfile());
SigninManagerFactory::GetForProfile(profile.get())-> SigninManagerFactory::GetForProfile(profile.get())->
SetAuthenticatedAccountInfo("gaia_id", "foo"); SetAuthenticatedAccountInfo("gaia_id", "foo");
ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(profile.get(), ProfileSyncServiceFactory::GetInstance()->SetTestingFactory(
nullptr); profile.get(), BrowserContextKeyedServiceFactory::TestingFactory());
SignedInDevicesManager manager(profile.get()); SignedInDevicesManager manager(profile.get());
EventListenerInfo info(api::signed_in_devices::OnDeviceInfoChange::kEventName, EventListenerInfo info(api::signed_in_devices::OnDeviceInfoChange::kEventName,
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <memory> #include <memory>
#include "base/bind.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process_impl.h" #include "chrome/browser/browser_process_impl.h"
...@@ -30,7 +31,8 @@ class SocketUnitTest : public ExtensionApiUnittest { ...@@ -30,7 +31,8 @@ class SocketUnitTest : public ExtensionApiUnittest {
ExtensionApiUnittest::SetUp(); ExtensionApiUnittest::SetUp();
ApiResourceManager<Socket>::GetFactoryInstance()->SetTestingFactoryAndUse( ApiResourceManager<Socket>::GetFactoryInstance()->SetTestingFactoryAndUse(
browser()->profile(), ApiResourceManagerTestFactory); browser()->profile(),
base::BindRepeating(&ApiResourceManagerTestFactory));
} }
}; };
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <memory> #include <memory>
#include "base/bind.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process_impl.h" #include "chrome/browser/browser_process_impl.h"
...@@ -38,12 +39,14 @@ class SocketsTcpServerUnitTest : public ExtensionApiUnittest { ...@@ -38,12 +39,14 @@ class SocketsTcpServerUnitTest : public ExtensionApiUnittest {
ExtensionApiUnittest::SetUp(); ExtensionApiUnittest::SetUp();
ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance() ApiResourceManager<ResumableTCPSocket>::GetFactoryInstance()
->SetTestingFactoryAndUse(browser()->profile(), ->SetTestingFactoryAndUse(
ApiResourceManagerTestFactory); browser()->profile(),
base::BindRepeating(&ApiResourceManagerTestFactory));
ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance() ApiResourceManager<ResumableTCPServerSocket>::GetFactoryInstance()
->SetTestingFactoryAndUse(browser()->profile(), ->SetTestingFactoryAndUse(
ApiResourceManagerTestServerFactory); 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