0

Use local state providd by AshTestBase.

This is to reduce the custom use of TestingPrefServiceSimple.

Bug: 383442863

Change-Id: I26f1a9e73e7efa500adbb2fa1b7ac1b533647b8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6195968
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1411490}
This commit is contained in:
Mitsuru Oshima
2025-01-26 23:13:29 -08:00
committed by Chromium LUCI CQ
parent 5b5206f135
commit f1bf24f98e
8 changed files with 12 additions and 28 deletions

@ -63,7 +63,7 @@ class ActiveSessionAuthControllerTest
SystemSaltGetter::Initialize();
CryptohomeMiscClient::InitializeFake();
UserDataAuthClient::InitializeFake();
auth_parts_ = AuthParts::Create(&local_state_);
auth_parts_ = AuthParts::Create(local_state());
AshTestBase::SetUp();
@ -88,9 +88,8 @@ class ActiveSessionAuthControllerTest
}
void InitializeUserManager() {
user_manager::UserManagerImpl::RegisterPrefs(local_state_.registry());
user_manager_ =
std::make_unique<user_manager::FakeUserManager>(&local_state_);
std::make_unique<user_manager::FakeUserManager>(local_state());
user_manager_->Initialize();
}
@ -204,7 +203,6 @@ class ActiveSessionAuthControllerTest
protected:
AccountId account_id_;
TestingPrefServiceSimple local_state_;
std::unique_ptr<user_manager::FakeUserManager> user_manager_;
std::unique_ptr<AuthParts> auth_parts_;
};

@ -18,7 +18,6 @@
#include "base/time/time.h"
#include "chromeos/ash/components/cryptohome/auth_factor.h"
#include "components/account_id/account_id.h"
#include "components/prefs/testing_pref_service.h"
#include "components/user_manager/fake_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#include "google_apis/gaia/gaia_id.h"
@ -53,9 +52,8 @@ class ActiveSessionAuthViewUnitTest : public AshTestBase {
widget_->SetFullscreen(true);
widget_->Show();
user_manager::UserManagerImpl::RegisterPrefs(local_state_.registry());
auto fake_user_manager =
std::make_unique<user_manager::FakeUserManager>(&local_state_);
std::make_unique<user_manager::FakeUserManager>(local_state());
AccountId account_id =
AccountId::FromUserEmailGaiaId(kTestAccount, GaiaId(kFakeGaia));
@ -117,7 +115,6 @@ class ActiveSessionAuthViewUnitTest : public AshTestBase {
AshTestBase::TearDown();
}
TestingPrefServiceSimple local_state_;
std::unique_ptr<views::Widget> widget_;
std::unique_ptr<MockActiveSessionAuthViewObserver> mock_observer_;
std::unique_ptr<AuthInputRowView::TestApi> test_api_pin_input_;

@ -12,7 +12,6 @@
#include "ash/test/ash_test_util.h"
#include "ash/test/pixel/ash_pixel_differ.h"
#include "ash/test/pixel/ash_pixel_test_init_params.h"
#include "components/prefs/testing_pref_service.h"
#include "components/user_manager/fake_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
#include "google_apis/gaia/gaia_id.h"
@ -49,9 +48,8 @@ class AuthHeaderPixelTest : public AshTestBase {
AshTestBase::SetUp();
UpdateDisplay("600x800");
user_manager::UserManagerImpl::RegisterPrefs(local_state_.registry());
auto fake_user_manager =
std::make_unique<user_manager::FakeUserManager>(&local_state_);
std::make_unique<user_manager::FakeUserManager>(local_state());
AccountId account_id =
AccountId::FromUserEmailGaiaId(kUserEmail, GaiaId(kFakeGaia));
fake_user_manager->AddGaiaUser(account_id,
@ -85,7 +83,6 @@ class AuthHeaderPixelTest : public AshTestBase {
AshTestBase::TearDown();
}
TestingPrefServiceSimple local_state_;
std::unique_ptr<views::Widget> widget_;
raw_ptr<AuthHeaderView> header_view_ = nullptr;
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_;

@ -30,7 +30,6 @@
#include "chromeos/ash/components/login/auth/public/cryptohome_key_constants.h"
#include "chromeos/ash/components/login/auth/public/key.h"
#include "chromeos/ash/components/login/auth/public/user_context.h"
#include "components/prefs/testing_pref_service.h"
#include "components/session_manager/session_manager_types.h"
#include "components/user_manager/fake_user_manager.h"
#include "components/user_manager/scoped_user_manager.h"
@ -90,9 +89,8 @@ class LocalAuthenticationRequestControllerImplPixelTest : public AshTestBase {
SetExpectedCredentialsWithDbusClient(test_account_id_, kExpectedPassword);
user_manager::UserManagerImpl::RegisterPrefs(local_state_.registry());
auto fake_user_manager =
std::make_unique<user_manager::FakeUserManager>(&local_state_);
std::make_unique<user_manager::FakeUserManager>(local_state());
fake_user_manager->AddGaiaUser(test_account_id_,
user_manager::UserType::kRegular);
scoped_user_manager_ = std::make_unique<user_manager::ScopedUserManager>(
@ -201,7 +199,6 @@ class LocalAuthenticationRequestControllerImplPixelTest : public AshTestBase {
}
base::test::ScopedFeatureList scoped_features_;
TestingPrefServiceSimple local_state_;
// Number of times the view was dismissed with close button.
int close_action_ = 0;

@ -109,10 +109,10 @@ class FirmwareUpdateStartupNotificationTest : public NoSessionAshTestBase {
void SetUp() override {
network_handler_test_helper_.RegisterPrefs(profile_prefs_.registry(),
local_state_.registry());
local_state()->registry());
network_handler_test_helper_.InitializePrefs(&profile_prefs_,
&local_state_);
local_state());
FwupdClient::InitializeFake();
dbus_client_ = FwupdClient::Get();
firmware_update_manager_ = std::make_unique<FirmwareUpdateManager>();
@ -158,7 +158,6 @@ class FirmwareUpdateStartupNotificationTest : public NoSessionAshTestBase {
raw_ptr<FwupdClient, DanglingUntriaged> dbus_client_ = nullptr;
NetworkHandlerTestHelper network_handler_test_helper_;
TestingPrefServiceSimple profile_prefs_;
TestingPrefServiceSimple local_state_;
std::unique_ptr<FirmwareUpdateManager> firmware_update_manager_;
std::unique_ptr<FirmwareUpdateNotificationController>
firmware_update_notification_controller_;

@ -13,7 +13,6 @@
#include "chromeos/ash/components/dbus/shill/shill_clients.h"
#include "chromeos/ash/components/network/network_handler.h"
#include "chromeos/ash/services/network_config/public/cpp/cros_network_config_test_helper.h"
#include "components/prefs/testing_pref_service.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
@ -43,8 +42,6 @@ class WifiToggleNotificationControllerTest : public AshTestBase {
private:
network_config::CrosNetworkConfigTestHelper network_config_helper_;
TestingPrefServiceSimple profile_prefs_;
TestingPrefServiceSimple local_state_;
};
// Verifies that toggling Wi-Fi (usually via keyboard) shows a notification.

@ -390,11 +390,11 @@ class UnifiedStatusAreaWidgetTest : public AshTestBase {
// Initializing NetworkHandler before ash is more like production.
AshTestBase::SetUp();
network_handler_test_helper_.RegisterPrefs(profile_prefs_.registry(),
local_state_.registry());
local_state()->registry());
PrefProxyConfigTrackerImpl::RegisterPrefs(profile_prefs_.registry());
network_handler_test_helper_.InitializePrefs(&profile_prefs_,
&local_state_);
local_state());
// Networking stubs may have asynchronous initialization.
base::RunLoop().RunUntilIdle();

@ -182,11 +182,11 @@ class NetworkHealthProviderTest : public AshTestBase {
network_handler_test_helper_ = std::make_unique<NetworkHandlerTestHelper>();
network_handler_test_helper_->AddDefaultProfiles();
network_handler_test_helper_->RegisterPrefs(user_prefs_.registry(),
local_state_.registry());
local_state()->registry());
PrefProxyConfigTrackerImpl::RegisterProfilePrefs(user_prefs_.registry());
PrefProxyConfigTrackerImpl::RegisterPrefs(local_state_.registry());
PrefProxyConfigTrackerImpl::RegisterPrefs(local_state()->registry());
network_handler_test_helper_->InitializePrefs(&user_prefs_, &local_state_);
network_handler_test_helper_->InitializePrefs(&user_prefs_, local_state());
ClearDevicesAndServices();
cros_network_config_ =
@ -538,7 +538,6 @@ class NetworkHealthProviderTest : public AshTestBase {
}
sync_preferences::TestingPrefServiceSyncable user_prefs_;
TestingPrefServiceSimple local_state_;
std::unique_ptr<user_manager::ScopedUserManager> scoped_user_manager_;
std::unique_ptr<NetworkHandlerTestHelper> network_handler_test_helper_;
std::unique_ptr<network_config::CrosNetworkConfig> cros_network_config_;