[cr141] ScopedTestingLocalState deleted

The local state is always valid, and should be retrieved from
`TestingBrowserProcess::GetGlobal()->GetTestingLocalState()`.

Chromium changes:
https://chromium.googlesource.com/chromium/src/+/68994f1d5aaecfdb064cdb62384538c16a5c7472

commit 68994f1d5aaecfdb064cdb62384538c16a5c7472
Author: Jun Ishiguro <junis@google.com>
Date:   Wed Aug 6 22:16:21 2025 -0700

    Remove ScopedTestingLocalState usage (part 6)

    This CL removes usages of ScopedTestingLocalState, which has been
    deprecated.

    This CL was made by Gemini CLI.

    Bug: 422039036
    Change-Id: I143e5bff8b52c15fb530e1c9719a05eb08758df2
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6805174
    Commit-Queue: Jun Ishiguro <junis@google.com>
    Reviewed-by: Georg Neis <neis@chromium.org>
    Cr-Commit-Position: refs/heads/main@{#1498019}
This commit is contained in:
Claudio DeSouza
2025-09-22 14:59:27 -04:00
committed by Max Karolinskiy
parent 421db7320a
commit 792819e173
28 changed files with 66 additions and 124 deletions
@@ -15,10 +15,10 @@
#include "brave/components/ai_chat/core/common/mojom/ai_chat.mojom-shared.h"
#include "chrome/browser/ui/chrome_select_file_policy.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/file_system_chooser_test_helpers.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
@@ -71,15 +71,15 @@ class UploadFileHelperTest : public content::RenderViewHostTestHarness {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
auto* profile = Profile::FromBrowserContext(browser_context());
testing_local_state_ = std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal());
#if BUILDFLAG(IS_ANDROID)
testing_local_state_->Get()->registry()->RegisterBooleanPref(
prefs::kAllowFileSelectionDialogs, true);
TestingBrowserProcess::GetGlobal()
->GetTestingLocalState()
->registry()
->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true);
#endif
// To fulfill ChromeSelectFilePolicy::CanOpenSelectFileDialog()
testing_local_state_->Get()->SetBoolean(prefs::kAllowFileSelectionDialogs,
true);
TestingBrowserProcess::GetGlobal()->GetTestingLocalState()->SetBoolean(
prefs::kAllowFileSelectionDialogs, true);
file_helper_ = std::make_unique<UploadFileHelper>(web_contents(), profile);
}
@@ -108,7 +108,6 @@ class UploadFileHelperTest : public content::RenderViewHostTestHarness {
protected:
base::ScopedTempDir temp_dir_;
std::unique_ptr<ScopedTestingLocalState> testing_local_state_;
std::unique_ptr<UploadFileHelper> file_helper_;
// Must persist throughout TearDown().
content::SelectFileDialogParams dialog_params_;
@@ -11,9 +11,9 @@
#include "brave/components/skus/common/skus_utils.h"
#include "build/build_config.h"
#include "chrome/browser/chrome_content_browser_client.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "extensions/buildflags/buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -81,14 +81,14 @@ TEST_F(BraveContentBrowserClientTest, GetOriginsRequiringDedicatedProcess) {
TEST_F(BraveContentBrowserClientTest, IsWindowsRecallDisabled) {
BraveContentBrowserClient client;
ScopedTestingLocalState testing_local_state(
TestingBrowserProcess::GetGlobal());
#if BUILDFLAG(IS_WIN)
base::test::ScopedOSInfoOverride win_version(
base::test::ScopedOSInfoOverride::Type::kWin11Home);
// Pref is registered.
EXPECT_TRUE(testing_local_state.Get()->FindPreference(
windows_recall::prefs::kWindowsRecallDisabled));
EXPECT_TRUE(
TestingBrowserProcess::GetGlobal()
->GetTestingLocalState()
->FindPreference(windows_recall::prefs::kWindowsRecallDisabled));
// Disabled by default on Win11 or newer.
EXPECT_TRUE(client.IsWindowsRecallDisabled());
#else
@@ -7,7 +7,6 @@
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
@@ -36,8 +35,7 @@ namespace brave_shields {
class BraveShieldsUtilProfilesTest : public testing::Test {
public:
BraveShieldsUtilProfilesTest()
: local_state_(TestingBrowserProcess::GetGlobal()) {}
BraveShieldsUtilProfilesTest() = default;
~BraveShieldsUtilProfilesTest() override = default;
TestingProfile* regular_profile() { return &profile_; }
@@ -84,7 +82,6 @@ class BraveShieldsUtilProfilesTest : public testing::Test {
private:
content::BrowserTaskEnvironment task_environment_;
TestingProfile profile_;
ScopedTestingLocalState local_state_;
};
TEST_F(BraveShieldsUtilProfilesTest, SetBraveShieldsEnabled) {
@@ -21,9 +21,9 @@
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "net/dns/public/secure_dns_mode.h"
@@ -45,7 +45,7 @@ class BraveVpnDnsObserverServiceUnitTest : public testing::Test {
BraveVpnDnsObserverFactory::GetInstance()->RegisterProfilePrefs(
profile_pref_service_.registry());
stub_resolver_config_reader_ = std::make_unique<StubResolverConfigReader>(
scoped_testing_local_state_.Get());
TestingBrowserProcess::GetGlobal()->GetTestingLocalState());
SystemNetworkContextManager::set_stub_resolver_config_reader_for_testing(
stub_resolver_config_reader_.get());
CreateDnsObserverService();
@@ -73,7 +73,9 @@ class BraveVpnDnsObserverServiceUnitTest : public testing::Test {
SystemNetworkContextManager::GetStubResolverConfigReader();
config_reader->OverrideParentalControlsForTesting(value);
}
PrefService* local_state() { return scoped_testing_local_state_.Get(); }
PrefService* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
PrefService* pref_service() { return &profile_pref_service_; }
void FireBraveVPNStateChange(mojom::ConnectionState state) {
@@ -138,7 +140,7 @@ class BraveVpnDnsObserverServiceUnitTest : public testing::Test {
}
void SetManagedMode(const std::string& value) {
scoped_testing_local_state_.Get()->SetManagedPref(
TestingBrowserProcess::GetGlobal()->GetTestingLocalState()->SetManagedPref(
::prefs::kDnsOverHttpsMode, base::Value(value));
}
@@ -147,8 +149,6 @@ class BraveVpnDnsObserverServiceUnitTest : public testing::Test {
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<BraveVpnDnsObserverService> dns_observer_service_;
sync_preferences::TestingPrefServiceSyncable profile_pref_service_;
ScopedTestingLocalState scoped_testing_local_state_{
TestingBrowserProcess::GetGlobal()};
std::unique_ptr<StubResolverConfigReader> stub_resolver_config_reader_;
};
@@ -10,8 +10,8 @@
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "brave/components/brave_vpn/common/brave_vpn_utils.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/prefs/testing_pref_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -23,7 +23,8 @@ class BraveVpnWireguardObserverServiceUnitTest : public testing::Test {
BraveVpnWireguardObserverServiceUnitTest() {}
void SetUp() override {
EnableWireguardIfPossible(scoped_testing_local_state_.Get());
EnableWireguardIfPossible(
TestingBrowserProcess::GetGlobal()->GetTestingLocalState());
CreateWireguardObserverService();
}
@@ -56,8 +57,6 @@ class BraveVpnWireguardObserverServiceUnitTest : public testing::Test {
private:
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState scoped_testing_local_state_{
TestingBrowserProcess::GetGlobal()};
std::unique_ptr<BraveVpnWireguardObserverService> wireguard_observer_service_;
};
@@ -8,10 +8,10 @@
#include "base/memory/raw_ptr.h"
#include "brave/components/tor/buildflags/buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/prefs/testing_pref_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/test/browser_task_environment.h"
@@ -44,7 +44,6 @@ class DecentralizedDnsNavigationThrottleTest : public testing::Test {
void SetUp() override {
ASSERT_TRUE(profile_manager_.SetUp());
profile_ = profile_manager_.CreateTestingProfile(kTestProfileName);
local_state_ = TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
web_contents_ =
content::WebContentsTester::CreateTestWebContents(profile_, nullptr);
}
@@ -52,7 +51,9 @@ class DecentralizedDnsNavigationThrottleTest : public testing::Test {
void TearDown() override { web_contents_.reset(); }
PrefService* user_prefs() { return user_prefs::UserPrefs::Get(profile_); }
PrefService* local_state() { return local_state_; }
PrefService* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
content::WebContents* web_contents() { return web_contents_.get(); }
// Helper that creates simple test guest profile.
@@ -71,7 +72,6 @@ class DecentralizedDnsNavigationThrottleTest : public testing::Test {
TestingProfileManager profile_manager_;
std::unique_ptr<content::WebContents> web_contents_;
std::string locale_;
raw_ptr<TestingPrefServiceSimple> local_state_ = nullptr;
raw_ptr<TestingProfile> profile_ = nullptr;
};
@@ -132,8 +132,7 @@ class DecentralizedDnsNavigationThrottleSubframeTest
public:
DecentralizedDnsNavigationThrottleSubframeTest()
: content::RenderViewHostTestHarness(
base::test::TaskEnvironment::TimeSource::MOCK_TIME),
local_state_(TestingBrowserProcess::GetGlobal()) {}
base::test::TaskEnvironment::TimeSource::MOCK_TIME) {}
~DecentralizedDnsNavigationThrottleSubframeTest() override = default;
void SetUp() override {
@@ -151,7 +150,9 @@ class DecentralizedDnsNavigationThrottleSubframeTest
}
PrefService* user_prefs() { return &prefs_; }
PrefService* local_state() { return local_state_.Get(); }
PrefService* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
content::RenderFrameHost* subframe() { return subframe_; }
std::string locale() { return kLocale; }
@@ -159,7 +160,6 @@ class DecentralizedDnsNavigationThrottleSubframeTest
raw_ptr<content::RenderFrameHost> subframe_;
sync_preferences::TestingPrefServiceSyncable prefs_;
ScopedTestingLocalState local_state_;
};
TEST_F(DecentralizedDnsNavigationThrottleSubframeTest, Subframe) {
@@ -8,7 +8,6 @@
#include "base/test/task_environment.h"
#include "brave/components/decentralized_dns/core/constants.h"
#include "brave/components/decentralized_dns/core/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,14 +16,15 @@ namespace decentralized_dns {
class UtilsUnitTest : public testing::Test {
public:
UtilsUnitTest() : local_state_(TestingBrowserProcess::GetGlobal()) {}
UtilsUnitTest() = default;
~UtilsUnitTest() override = default;
PrefService* local_state() { return local_state_.Get(); }
PrefService* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
private:
base::test::TaskEnvironment task_environment_;
ScopedTestingLocalState local_state_;
};
TEST_F(UtilsUnitTest, IsUnstoppableDomainsTLD) {
@@ -7,7 +7,6 @@
#include "brave/browser/metrics/buildflags/buildflags.h"
#include "brave/browser/metrics/metrics_reporting_util.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_service.h"
@@ -15,10 +14,6 @@
TEST(MetricsUtilTest, CrashReportPermissionAskDialogTest) {
#if BUILDFLAG(ENABLE_CRASH_DIALOG)
std::unique_ptr<ScopedTestingLocalState> local_state =
std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal());
g_browser_process->local_state()->SetBoolean(
metrics::prefs::kMetricsReportingEnabled, false);
EXPECT_TRUE(ShouldShowCrashReportPermissionAskDialog());
@@ -12,7 +12,6 @@
#include "brave/components/constants/pref_names.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_registry_simple.h"
@@ -26,8 +25,6 @@ namespace misc_metrics {
class ThemeMetricsTest : public testing::Test {
public:
void SetUp() override {
local_state_ = std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal());
theme_service_ = ThemeServiceFactory::GetForProfile(&profile_);
dark_mode::SetUseSystemDarkModeEnabledForTest(true);
theme_metrics_ = std::make_unique<ThemeMetrics>(theme_service_);
@@ -35,7 +32,6 @@ class ThemeMetricsTest : public testing::Test {
protected:
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<ScopedTestingLocalState> local_state_;
TestingProfile profile_;
raw_ptr<ThemeService> theme_service_;
std::unique_ptr<ThemeMetrics> theme_metrics_;
@@ -22,8 +22,8 @@
#include "brave/test/base/testing_brave_browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "net/base/net_errors.h"
#include "net/dns/mock_host_resolver.h"
@@ -89,12 +89,9 @@ void FakeAdBlockSubscriptionDownloadManagerGetter(
class BraveAdBlockTPNetworkDelegateHelperTest : public testing::Test {
protected:
void SetUp() override {
local_state_ = std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal());
brave_component_updater_delegate_ =
std::make_unique<TestingBraveComponentUpdaterDelegate>(
local_state_->Get());
TestingBrowserProcess::GetGlobal()->GetTestingLocalState());
base::FilePath user_data_dir;
DCHECK(base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
@@ -113,8 +110,8 @@ class BraveAdBlockTPNetworkDelegateHelperTest : public testing::Test {
host_resolver_.get(), net::NetLog::Get());
brave::SetAdblockCnameHostResolverForTesting(resolver_wrapper_.get());
stub_resolver_config_reader_ =
std::make_unique<StubResolverConfigReader>(local_state_->Get());
stub_resolver_config_reader_ = std::make_unique<StubResolverConfigReader>(
TestingBrowserProcess::GetGlobal()->GetTestingLocalState());
SystemNetworkContextManager::set_stub_resolver_config_reader_for_testing(
stub_resolver_config_reader_.get());
}
@@ -146,8 +143,6 @@ class BraveAdBlockTPNetworkDelegateHelperTest : public testing::Test {
return rc == net::ERR_IO_PENDING;
}
std::unique_ptr<ScopedTestingLocalState> local_state_;
std::unique_ptr<TestingBraveComponentUpdaterDelegate>
brave_component_updater_delegate_;
@@ -27,7 +27,6 @@
#include "brave/components/decentralized_dns/core/pref_names.h"
#include "brave/components/decentralized_dns/core/utils.h"
#include "build/build_config.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/testing_pref_service.h"
@@ -47,9 +46,7 @@ namespace decentralized_dns {
class DecentralizedDnsNetworkDelegateHelperTest : public testing::Test {
public:
DecentralizedDnsNetworkDelegateHelperTest()
: local_state_(std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal())) {}
DecentralizedDnsNetworkDelegateHelperTest() = default;
~DecentralizedDnsNetworkDelegateHelperTest() override = default;
@@ -70,12 +67,13 @@ class DecentralizedDnsNetworkDelegateHelperTest : public testing::Test {
void TearDown() override {
json_rpc_service_ = nullptr;
profile_.reset();
local_state_.reset();
}
content::BrowserContext* browser_context() { return profile_.get(); }
TestingProfile* profile() { return profile_.get(); }
PrefService* local_state() { return local_state_->Get(); }
PrefService* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
network::TestURLLoaderFactory& test_url_loader_factory() {
return test_url_loader_factory_;
}
@@ -84,7 +82,6 @@ class DecentralizedDnsNetworkDelegateHelperTest : public testing::Test {
private:
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<ScopedTestingLocalState> local_state_;
network::TestURLLoaderFactory test_url_loader_factory_;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory_;
raw_ptr<brave_wallet::JsonRpcService> json_rpc_service_ = nullptr;
@@ -14,8 +14,7 @@
#include "components/sync_preferences/testing_pref_service_syncable.h"
namespace playlist {
PlaylistUnitTestBase::PlaylistUnitTestBase()
: scoped_testing_local_state_(TestingBrowserProcess::GetGlobal()) {}
PlaylistUnitTestBase::PlaylistUnitTestBase() = default;
PlaylistUnitTestBase::~PlaylistUnitTestBase() = default;
@@ -10,7 +10,6 @@
#include "base/test/scoped_feature_list.h"
#include "brave/components/playlist/common/features.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/test_renderer_host.h"
@@ -31,7 +30,6 @@ class PlaylistUnitTestBase : public content::RenderViewHostTestHarness {
// content::RenderViewHostTestHarness:
std::unique_ptr<content::BrowserContext> CreateBrowserContext() override;
ScopedTestingLocalState scoped_testing_local_state_;
base::test::ScopedFeatureList feature_list_{features::kPlaylist};
};
} // namespace playlist
@@ -1,7 +1,7 @@
// Copyright 2021 The Brave Authors. All rights reserved.
// Copyright (c) 2021 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
// You can obtain one at https://mozilla.org/MPL/2.0/.
#include "brave/browser/profiles/brave_profile_manager.h"
@@ -19,7 +19,6 @@
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -71,8 +70,7 @@ class TestingBraveProfileManager : public BraveProfileManagerWithoutInit {
class BraveProfileManagerTest : public testing::Test {
public:
BraveProfileManagerTest()
: local_state_(TestingBrowserProcess::GetGlobal()) {}
BraveProfileManagerTest() = default;
void SetUp() override {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
@@ -95,7 +93,6 @@ class BraveProfileManagerTest : public testing::Test {
private:
base::ScopedTempDir temp_dir_;
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState local_state_;
};
TEST_F(BraveProfileManagerTest, EnableMediaRouterOnRestartDefaultValue) {
@@ -15,7 +15,6 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -80,8 +79,7 @@ class BraveRenderViewContextMenuMock : public BraveRenderViewContextMenu {
class BraveRenderViewContextMenuTest : public testing::Test {
protected:
BraveRenderViewContextMenuTest()
: testing_local_state_(TestingBrowserProcess::GetGlobal()) {}
BraveRenderViewContextMenuTest() = default;
content::WebContents* GetWebContents() { return web_contents_.get(); }
// Returns a test context menu.
@@ -148,7 +146,6 @@ class BraveRenderViewContextMenuTest : public testing::Test {
private:
content::BrowserTaskEnvironment browser_task_environment;
ScopedTestingLocalState testing_local_state_;
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<custom_handlers::ProtocolHandlerRegistry> registry_;
std::unique_ptr<Browser> browser_;
+3 -8
View File
@@ -15,10 +15,10 @@
#include "chrome/browser/sync/chrome_sync_client.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/prefs/testing_pref_service.h"
#include "components/search_engines/search_engines_pref_names.h"
#include "components/sync/test/test_sync_service.h"
#include "components/sync_preferences/pref_service_mock_factory.h"
@@ -78,8 +78,6 @@ class BraveSyncClientTest : public testing::Test {
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<Profile> profile_;
base::ScopedTempDir temp_dir_;
std::unique_ptr<ScopedTestingLocalState> local_state_;
};
// We need this because otherwise we'll get crash on uninitialized
@@ -88,16 +86,13 @@ class BraveSyncClientTest : public testing::Test {
// CreateAdBlockSubscriptionDownloadClient() =>
// g_brave_browser_process->ad_block_service()
void BraveSyncClientTest::SetupAdblockServiceForBraveBrowserProcess() {
local_state_ = std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal());
base::FilePath user_data_dir;
DCHECK(base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
auto adblock_service = std::make_unique<brave_shields::AdBlockService>(
local_state_->Get(), "en", nullptr,
TestingBrowserProcess::GetGlobal()->GetTestingLocalState(), "en", nullptr,
base::SingleThreadTaskRunner::GetCurrentDefault(),
std::make_unique<brave_shields::AdBlockSubscriptionServiceManager>(
local_state_->Get(),
TestingBrowserProcess::GetGlobal()->GetTestingLocalState(),
base::SingleThreadTaskRunner::GetCurrentDefault(),
base::BindOnce(&FakeAdBlockSubscriptionDownloadManagerGetter),
user_data_dir));
@@ -22,9 +22,9 @@
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -430,21 +430,21 @@ TEST_F(AcceleratorServiceUnitTest, PolicyFiltering) {
class AcceleratorServiceUnitTestWithLocalState : public testing::Test {
public:
AcceleratorServiceUnitTestWithLocalState()
: testing_local_state_(TestingBrowserProcess::GetGlobal()) {
AcceleratorServiceUnitTestWithLocalState() {
features_.InitAndEnableFeature(commands::features::kBraveCommands);
}
~AcceleratorServiceUnitTestWithLocalState() override = default;
TestingProfile& profile() { return profile_; }
PrefService* local_state() { return testing_local_state_.Get(); }
PrefService* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
private:
content::BrowserTaskEnvironment task_environment_;
TestingProfile profile_;
base::test::ScopedFeatureList features_;
ScopedTestingLocalState testing_local_state_;
};
TEST_F(AcceleratorServiceUnitTestWithLocalState, PolicyFiltering) {
@@ -19,7 +19,6 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -92,8 +91,6 @@ class BraveBookmarkSubMenuModelUnitTest : public testing::Test {
protected:
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState scoped_testing_local_state_{
TestingBrowserProcess::GetGlobal()};
TestSimpleMenuDelegate delegate_;
std::unique_ptr<Browser> browser_;
std::unique_ptr<TestBrowserWindow> test_window_;
@@ -14,9 +14,9 @@
#include "brave/components/brave_vpn/common/pref_names.h"
#include "brave/grit/brave_generated_resources.h"
#include "chrome/browser/browser_process.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/testing_pref_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
@@ -30,16 +30,15 @@ class BraveVPNMenuModelUnitTest : public testing::Test {
PrefService* prefs() { return &prefs_; }
void SetUp() override {
local_state_ = std::make_unique<ScopedTestingLocalState>(
TestingBrowserProcess::GetGlobal());
brave_vpn::RegisterProfilePrefs(prefs_.registry());
}
TestingPrefServiceSimple* local_state() { return local_state_->Get(); }
TestingPrefServiceSimple* local_state() {
return TestingBrowserProcess::GetGlobal()->GetTestingLocalState();
}
private:
sync_preferences::TestingPrefServiceSyncable prefs_;
std::unique_ptr<ScopedTestingLocalState> local_state_;
};
#if BUILDFLAG(IS_WIN)
@@ -20,10 +20,10 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/testing_pref_service.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/test/browser_task_environment.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
@@ -34,8 +34,7 @@ namespace brave_vpn {
class BraveVpnButtonUnitTest : public testing::Test {
public:
BraveVpnButtonUnitTest()
: testing_local_state_(TestingBrowserProcess::GetGlobal()) {}
BraveVpnButtonUnitTest() = default;
BraveVpnButtonUnitTest(const BraveVpnButtonUnitTest&) = delete;
BraveVpnButtonUnitTest& operator=(const BraveVpnButtonUnitTest&) = delete;
@@ -67,7 +66,8 @@ class BraveVpnButtonUnitTest : public testing::Test {
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_);
auto manager = std::make_unique<BraveVPNConnectionManager>(
shared_url_loader_factory_, testing_local_state_.Get(),
shared_url_loader_factory_,
TestingBrowserProcess::GetGlobal()->GetTestingLocalState(),
base::NullCallback());
manager->SetConnectionAPIImplForTesting(
std::make_unique<ConnectionAPIImplSim>(manager.get(),
@@ -122,7 +122,6 @@ class BraveVpnButtonUnitTest : public testing::Test {
ChromeLayoutProvider layout_provider_;
network::TestURLLoaderFactory url_loader_factory_;
scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory_;
ScopedTestingLocalState testing_local_state_;
std::unique_ptr<Browser> browser_;
std::unique_ptr<TestBrowserWindow> test_window_;
std::unique_ptr<TestingProfile> profile_;
@@ -12,7 +12,6 @@
#include "brave/browser/ui/webui/brave_browser_command/brave_browser_command_handler.h"
#include "brave/components/brave_education/education_urls.h"
#include "brave/components/brave_vpn/common/buildflags/buildflags.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/browser_task_environment.h"
@@ -79,7 +78,6 @@ class BraveEducationPageHandlerTest : public testing::Test {
private:
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState local_state_{TestingBrowserProcess::GetGlobal()};
mojo::Remote<brave_browser_command::mojom::BraveBrowserCommandHandler>
remote_;
std::unique_ptr<Profile> profile_;
@@ -11,7 +11,6 @@
#include "brave/browser/themes/brave_dark_mode_utils.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
@@ -65,7 +64,6 @@ class BraveCustomizeColorSchemeModeHandlerUnitTest : public testing::Test {
}
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState local_state_{TestingBrowserProcess::GetGlobal()};
TestingProfile testing_profile_;
testing::NiceMock<MockClient> mock_client_;
@@ -28,7 +28,6 @@
#include "brave/components/brave_wallet/common/common_utils.h"
#include "brave/components/brave_wallet/common/test_utils.h"
#include "brave/components/brave_wallet/common/value_conversion_utils.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/scoped_user_pref_update.h"
@@ -65,8 +64,7 @@ void UpdateCustomNetworks(PrefService* prefs,
class TestBraveWalletHandler : public BraveWalletHandler {
public:
TestBraveWalletHandler()
: local_state_(TestingBrowserProcess::GetGlobal()),
shared_url_loader_factory_(
: shared_url_loader_factory_(
base::MakeRefCounted<network::WeakWrapperSharedURLLoaderFactory>(
&url_loader_factory_)) {
TestingProfile::Builder builder;
@@ -148,7 +146,6 @@ class TestBraveWalletHandler : public BraveWalletHandler {
}
private:
ScopedTestingLocalState local_state_;
content::BrowserTaskEnvironment browser_task_environment_;
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<content::WebContents> web_contents_;
@@ -14,7 +14,6 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_service.h"
@@ -94,8 +93,6 @@ class WebDiscoveryCTATest : public testing::Test {
base::SimpleTestClock test_clock_;
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState scoped_testing_local_state_{
TestingBrowserProcess::GetGlobal()};
content::RenderViewHostTestEnabler render_view_host_test_enabler_;
std::unique_ptr<TemplateURLServiceTestUtil> test_util_;
std::unique_ptr<content::WebContents> web_contents_;
@@ -11,7 +11,6 @@
#include "brave/components/permissions/permission_widevine_utils.h"
#include "chrome/browser/download/download_permission_request.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/permissions/permission_prompt.h"
@@ -7,7 +7,6 @@
#include <memory>
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/browser_task_environment.h"
@@ -18,8 +17,6 @@ class ExternalProtocolHandlerTest : public testing::Test {
void SetUp() override { profile_ = std::make_unique<TestingProfile>(); }
content::BrowserTaskEnvironment task_environment_;
ScopedTestingLocalState scoped_testing_local_state_{
TestingBrowserProcess::GetGlobal()};
std::unique_ptr<TestingProfile> profile_;
};
+1 -2
View File
@@ -18,8 +18,7 @@ specific_include_rules = {
"!chrome/browser/content_settings/cookie_settings_factory.h",
"!chrome/browser/content_settings/host_content_settings_map_factory.h",
"!chrome/browser/profiles/profile.h",
"!chrome/test/base/scoped_testing_local_state.h",
"!chrome/test/base/testing_browser_process.h",
"!chrome/test/base/testing_profile.h",
],
}
}
@@ -19,7 +19,6 @@
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/content_settings/core/browser/cookie_settings.h"
@@ -44,7 +43,7 @@ using brave_shields::features::kBraveDomainBlock;
class BraveShieldsUtilTest : public testing::Test {
public:
BraveShieldsUtilTest() : local_state_(TestingBrowserProcess::GetGlobal()) {}
BraveShieldsUtilTest() = default;
BraveShieldsUtilTest(const BraveShieldsUtilTest&) = delete;
BraveShieldsUtilTest& operator=(const BraveShieldsUtilTest&) = delete;
~BraveShieldsUtilTest() override = default;
@@ -83,7 +82,6 @@ class BraveShieldsUtilTest : public testing::Test {
base::ScopedTempDir temp_dir_;
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<TestingProfile> profile_;
ScopedTestingLocalState local_state_;
};
class BraveShieldsUtilDomainBlockFeatureTest : public BraveShieldsUtilTest {