Do not create SessionManager in ScopedConfigTestHelper.
This is a step to fix the creation of SessionManager/ProfileManager and profile object. Note that this CL doesn't fix all and there are still tests that needs to be fixed. Make sure the componentns that depend on SessionManager are created after SessionManager creation. Bug: 403142627 Change-Id: I1d37694e47bc8449b9506fda958949f1ca13b5d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6382192 Reviewed-by: Hidehiko Abe <hidehiko@chromium.org> Commit-Queue: Mitsuru Oshima <oshima@chromium.org> Cr-Commit-Position: refs/heads/main@{#1438160}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
91439dff04
commit
b2828d69d4
@ -5509,6 +5509,7 @@ static_library("test_support") {
|
||||
"//components/exo/wayland:ui_controls_protocol_stub",
|
||||
"//components/manta/proto",
|
||||
"//components/prefs:test_support",
|
||||
"//components/session_manager/core",
|
||||
"//components/user_education/common",
|
||||
"//components/user_manager:user_manager",
|
||||
"//components/viz/test:test_support",
|
||||
|
1
ash/DEPS
1
ash/DEPS
@ -194,5 +194,6 @@ specific_include_rules = {
|
||||
# Allowed to access user_manager in test code to set up testing environment
|
||||
# close to the production.
|
||||
"+components/user_manager",
|
||||
"+components/session_manager/core",
|
||||
]
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "chromeos/ash/services/bluetooth_config/fake_discovery_session_manager.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/in_process_instance.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
#include "chromeos/ash/services/quick_pair/quick_pair_process_manager_impl.h"
|
||||
#include "components/prefs/pref_registry.h"
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/fake_bluetooth_device_status_notifier.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
|
||||
namespace ash {
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
#include "chromeos/constants/chromeos_features.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
@ -145,8 +146,8 @@ class BluetoothFeaturePodControllerTest
|
||||
}
|
||||
|
||||
void LockScreen() {
|
||||
bluetooth_config_test_helper()->session_manager()->SessionStarted();
|
||||
bluetooth_config_test_helper()->session_manager()->SetSessionState(
|
||||
session_manager::SessionManager::Get()->SessionStarted();
|
||||
session_manager::SessionManager::Get()->SetSessionState(
|
||||
session_manager::SessionState::LOCKED);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/run_loop.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/fake_adapter_state_controller.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom-shared.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
|
@ -4,7 +4,7 @@ include_rules = [
|
||||
"+chromeos/ash/components/test",
|
||||
"+components/viz/test",
|
||||
"+mojo/core/embedder",
|
||||
"+third_party/googletest/src/googletest/include/gtest/gtest.h",
|
||||
"+third_party/googletest/src/googletest/include/gtest/gtest.h",
|
||||
]
|
||||
|
||||
specific_include_rules = {
|
||||
@ -12,5 +12,6 @@ specific_include_rules = {
|
||||
"+ash/host",
|
||||
"+chromeos/ash/components/fwupd",
|
||||
"+chromeos/ash/components/login/login_state",
|
||||
"+components/session_manager/core",
|
||||
],
|
||||
}
|
||||
|
@ -296,8 +296,14 @@ class AshTestBase : public testing::Test {
|
||||
init_params_->create_quick_pair_mediator = create_quick_pair_mediator;
|
||||
}
|
||||
|
||||
void set_create_session_manager(bool create_session_manager) {
|
||||
CHECK(init_params_)
|
||||
<< "create_session_manager must set before calling SetUp()";
|
||||
init_params_->create_session_manager = create_session_manager;
|
||||
}
|
||||
|
||||
void set_shell_delegate(std::unique_ptr<ShellDelegate> shell_delegate) {
|
||||
CHECK(init_params_) << "shell_delegate mustset before calling SetUp()";
|
||||
CHECK(init_params_) << "shell_delegate must set before calling SetUp()";
|
||||
CHECK(!init_params_->delegate);
|
||||
init_params_->delegate = std::move(shell_delegate);
|
||||
}
|
||||
|
@ -54,9 +54,11 @@
|
||||
#include "chromeos/ash/components/fwupd/fake_fwupd_download_client.h"
|
||||
#include "chromeos/ash/components/login/login_state/login_state.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/in_process_instance.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
#include "chromeos/ash/services/hotspot_config/public/cpp/cros_hotspot_config_test_helper.h"
|
||||
#include "chromeos/dbus/power/power_policy_controller.h"
|
||||
#include "chromeos/ui/frame/multitask_menu/multitask_menu_nudge_controller.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "device/bluetooth/bluetooth_adapter_factory.h"
|
||||
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
|
||||
#include "device/bluetooth/floss/floss_dbus_manager.h"
|
||||
@ -251,6 +253,9 @@ void AshTestHelper::TearDown() {
|
||||
input_method::InputMethodManager::Shutdown();
|
||||
input_method_manager_ = nullptr;
|
||||
}
|
||||
|
||||
scoped_bluetooth_config_test_helper_.reset();
|
||||
session_manager_.reset();
|
||||
}
|
||||
|
||||
aura::Window* AshTestHelper::GetContext() {
|
||||
@ -290,6 +295,14 @@ void AshTestHelper::SetUp(InitParams init_params) {
|
||||
create_quick_pair_mediator_ = init_params.create_quick_pair_mediator;
|
||||
destroy_screen_ = init_params.destroy_screen;
|
||||
|
||||
// SessionManager
|
||||
if (init_params.create_session_manager) {
|
||||
session_manager_ = std::make_unique<session_manager::SessionManager>();
|
||||
}
|
||||
|
||||
scoped_bluetooth_config_test_helper_ =
|
||||
std::make_unique<bluetooth_config::ScopedBluetoothConfigTestHelper>();
|
||||
|
||||
if (create_global_cras_audio_handler_) {
|
||||
// Create `CrasAudioHandler` for testing since `g_browser_process` is not
|
||||
// created in `AshTestBase` tests.
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "base/test/scoped_command_line.h"
|
||||
#include "base/types/pass_key.h"
|
||||
#include "chromeos/ash/components/system/fake_statistics_provider.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
#include "chromeos/ash/services/federated/public/cpp/fake_service_connection.h"
|
||||
#include "chromeos/ash/services/federated/public/cpp/service_connection.h"
|
||||
#include "ui/aura/test/aura_test_helper.h"
|
||||
@ -42,6 +41,10 @@ namespace display {
|
||||
class Display;
|
||||
} // namespace display
|
||||
|
||||
namespace session_manager {
|
||||
class SessionManager;
|
||||
} // namespace session_manager
|
||||
|
||||
namespace ui {
|
||||
class ContextFactory;
|
||||
} // namespace ui
|
||||
@ -62,6 +65,10 @@ class TestNewWindowDelegate;
|
||||
class TestWallpaperControllerClient;
|
||||
class AshTestBase;
|
||||
|
||||
namespace bluetooth_config {
|
||||
class ScopedBluetoothConfigTestHelper;
|
||||
} // namespace bluetooth_config
|
||||
|
||||
namespace floating_workspace {
|
||||
class FloatingWorkspaceServiceTest;
|
||||
} // namespace floating_workspace
|
||||
@ -103,6 +110,9 @@ class AshTestHelper : public aura::test::AuraTestHelper {
|
||||
// True to auto create prefs services.
|
||||
bool auto_create_prefs_services = true;
|
||||
|
||||
// True to create session manager.
|
||||
bool create_session_manager = true;
|
||||
|
||||
// Whether or not to destroy the screen in the destructor.
|
||||
bool destroy_screen = true;
|
||||
};
|
||||
@ -179,7 +189,7 @@ class AshTestHelper : public aura::test::AuraTestHelper {
|
||||
|
||||
bluetooth_config::ScopedBluetoothConfigTestHelper*
|
||||
bluetooth_config_test_helper() {
|
||||
return &scoped_bluetooth_config_test_helper_;
|
||||
return scoped_bluetooth_config_test_helper_.get();
|
||||
}
|
||||
|
||||
SavedDeskTestHelper* saved_desk_test_helper() {
|
||||
@ -214,6 +224,8 @@ class AshTestHelper : public aura::test::AuraTestHelper {
|
||||
class FlossDBusManagerInitializer;
|
||||
class PowerPolicyControllerInitializer;
|
||||
|
||||
std::unique_ptr<session_manager::SessionManager> session_manager_;
|
||||
|
||||
// Must be constructed so that `base::SystemMonitor::Get()` returns a valid
|
||||
// instance.
|
||||
std::unique_ptr<base::SystemMonitor> system_monitor_;
|
||||
@ -251,7 +263,7 @@ class AshTestHelper : public aura::test::AuraTestHelper {
|
||||
std::unique_ptr<hotspot_config::CrosHotspotConfigTestHelper>
|
||||
cros_hotspot_config_test_helper_;
|
||||
|
||||
bluetooth_config::ScopedBluetoothConfigTestHelper
|
||||
std::unique_ptr<bluetooth_config::ScopedBluetoothConfigTestHelper>
|
||||
scoped_bluetooth_config_test_helper_;
|
||||
|
||||
// InputMethodManager is not owned by this class. It is stored in a
|
||||
|
@ -46,11 +46,9 @@ class ArcProvisionNotificationServiceTest : public BrowserWithTestWindowTest {
|
||||
ArcProvisionNotificationServiceTest& operator=(
|
||||
const ArcProvisionNotificationServiceTest&) = delete;
|
||||
|
||||
void SetUp() override {
|
||||
SetUpInternal(/*should_create_session_manager=*/true);
|
||||
}
|
||||
void SetUp() override { SetUpInternal(); }
|
||||
|
||||
void SetUpInternal(bool should_create_session_manager) {
|
||||
void SetUpInternal() {
|
||||
ash::ConciergeClient::InitializeFake(/*fake_cicerone_client=*/nullptr);
|
||||
|
||||
SetArcAvailableCommandLineForTesting(
|
||||
@ -62,15 +60,12 @@ class ArcProvisionNotificationServiceTest : public BrowserWithTestWindowTest {
|
||||
CreateTestArcSessionManager(std::make_unique<ArcSessionRunner>(
|
||||
base::BindRepeating(FakeArcSession::Create)));
|
||||
|
||||
if (should_create_session_manager) {
|
||||
// SessionManager is created by
|
||||
// |AshTestHelper::bluetooth_config_test_helper()|.
|
||||
session_manager_ = session_manager::SessionManager::Get();
|
||||
}
|
||||
|
||||
// This creates |profile()|, so it has to come after the arc managers.
|
||||
BrowserWithTestWindowTest::SetUp();
|
||||
|
||||
// SessionManager is created in `BrowserWithTestWIndowTest::SetUp()`.
|
||||
session_manager_ = session_manager::SessionManager::Get();
|
||||
|
||||
arc_service_manager_->set_browser_context(profile());
|
||||
display_service_ =
|
||||
std::make_unique<NotificationDisplayServiceTester>(profile());
|
||||
@ -89,6 +84,7 @@ class ArcProvisionNotificationServiceTest : public BrowserWithTestWindowTest {
|
||||
arc_session_manager_->Shutdown();
|
||||
display_service_.reset();
|
||||
arc_service_manager_->set_browser_context(nullptr);
|
||||
session_manager_ = nullptr;
|
||||
BrowserWithTestWindowTest::TearDown();
|
||||
arc_session_manager_.reset();
|
||||
arc_service_manager_.reset();
|
||||
@ -325,8 +321,7 @@ class ArcProvisionNotificationServiceOobeTest
|
||||
void SetUp() override {
|
||||
// SessionManager is created in FakeLoginDisplayHost. We should not create
|
||||
// another one here.
|
||||
ArcProvisionNotificationServiceTest::SetUpInternal(
|
||||
/*should_create_session_manager=*/false);
|
||||
ArcProvisionNotificationServiceTest::SetUpInternal();
|
||||
|
||||
CreateLoginDisplayHost();
|
||||
}
|
||||
|
@ -37,19 +37,18 @@ LoginScreenExtensionsLifetimeManager::LoginScreenExtensionsLifetimeManager(
|
||||
extension_system_(
|
||||
extensions::ExtensionSystem::Get(signin_original_profile_)),
|
||||
extensions_process_manager_(
|
||||
extensions::ProcessManager::Get(signin_original_profile_)),
|
||||
session_manager_(session_manager::SessionManager::Get()) {
|
||||
extensions::ProcessManager::Get(signin_original_profile_)) {
|
||||
DCHECK(signin_original_profile_);
|
||||
DCHECK(extension_system_);
|
||||
DCHECK(extensions_process_manager_);
|
||||
DCHECK(session_manager_);
|
||||
DCHECK(session_manager::SessionManager::Get());
|
||||
|
||||
auto* const extension_registry =
|
||||
extensions::ExtensionRegistry::Get(signin_original_profile_);
|
||||
DCHECK(extension_registry);
|
||||
extension_registry_observation_.Observe(extension_registry);
|
||||
|
||||
session_manager_observation_.Observe(session_manager_);
|
||||
session_manager_observation_.Observe(session_manager::SessionManager::Get());
|
||||
|
||||
ProfileManager* const profile_manager = g_browser_process->profile_manager();
|
||||
DCHECK(profile_manager);
|
||||
@ -118,7 +117,7 @@ bool LoginScreenExtensionsLifetimeManager::
|
||||
// transition states between the login screen and the user session, since the
|
||||
// user may still see some pieces of the login screen that rely on these
|
||||
// extensions.
|
||||
return session_manager_->session_state() !=
|
||||
return session_manager::SessionManager::Get()->session_state() !=
|
||||
session_manager::SessionState::ACTIVE;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,6 @@ class LoginScreenExtensionsLifetimeManager final
|
||||
raw_ptr<Profile> const signin_original_profile_;
|
||||
raw_ptr<extensions::ExtensionSystem> const extension_system_;
|
||||
raw_ptr<extensions::ProcessManager> const extensions_process_manager_;
|
||||
raw_ptr<session_manager::SessionManager> const session_manager_;
|
||||
|
||||
base::ScopedObservation<extensions::ExtensionRegistry,
|
||||
extensions::ExtensionRegistryObserver>
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ash/test/ash_test_helper.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/test/power_monitor_test.h"
|
||||
@ -26,6 +25,8 @@
|
||||
#include "components/pref_registry/pref_registry_syncable.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/prefs/testing_pref_service.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "components/session_manager/session_manager_types.h"
|
||||
#include "components/user_manager/known_user.h"
|
||||
#include "components/user_manager/scoped_user_manager.h"
|
||||
#include "components/user_manager/test_helper.h"
|
||||
@ -90,8 +91,7 @@ class OfflineSigninLimiterTest : public testing::Test {
|
||||
|
||||
ScopedTestingLocalState local_state_{TestingBrowserProcess::GetGlobal()};
|
||||
std::unique_ptr<user_manager::KnownUser> known_user_;
|
||||
// `AshTestHelper` makes sure that `SessionManager` is set up in these tests.
|
||||
ash::AshTestHelper ash_test_helper_;
|
||||
std::unique_ptr<session_manager::SessionManager> session_manager_;
|
||||
};
|
||||
|
||||
OfflineSigninLimiterTest::OfflineSigninLimiterTest() = default;
|
||||
@ -120,6 +120,7 @@ void OfflineSigninLimiterTest::CreateLimiter() {
|
||||
}
|
||||
|
||||
void OfflineSigninLimiterTest::SetUp() {
|
||||
session_manager_ = std::make_unique<session_manager::SessionManager>();
|
||||
fake_user_manager_.Reset(std::make_unique<ash::FakeChromeUserManager>());
|
||||
profile_ = std::make_unique<TestingProfile>();
|
||||
known_user_ = std::make_unique<user_manager::KnownUser>(local_state_.Get());
|
||||
@ -128,6 +129,7 @@ void OfflineSigninLimiterTest::SetUp() {
|
||||
void OfflineSigninLimiterTest::TearDown() {
|
||||
DestroyLimiter();
|
||||
profile_.reset();
|
||||
session_manager_.reset();
|
||||
}
|
||||
|
||||
FakeChromeUserManager* OfflineSigninLimiterTest::GetFakeChromeUserManager() {
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "chromeos/ash/components/system/fake_statistics_provider.h"
|
||||
#include "chromeos/ash/services/network_config/public/cpp/cros_network_config_test_helper.h"
|
||||
#include "components/prefs/testing_pref_service.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "components/sync_preferences/testing_pref_service_syncable.h"
|
||||
#include "components/user_manager/fake_user_manager.h"
|
||||
#include "components/user_manager/scoped_user_manager.h"
|
||||
@ -179,6 +180,7 @@ class WizardControllerTestBase : public ::testing::Test {
|
||||
WizardControllerTestBase() = default;
|
||||
|
||||
void SetUp() override {
|
||||
session_manager_ = std::make_unique<session_manager::SessionManager>();
|
||||
profile_manager_ = std::make_unique<TestingProfileManager>(
|
||||
TestingBrowserProcess::GetGlobal());
|
||||
network_handler_test_helper_ = std::make_unique<NetworkHandlerTestHelper>();
|
||||
@ -186,6 +188,7 @@ class WizardControllerTestBase : public ::testing::Test {
|
||||
AshTestHelper::InitParams params;
|
||||
params.start_session = false;
|
||||
params.local_state = profile_manager_->local_state()->Get();
|
||||
params.create_session_manager = false;
|
||||
test_context_factories_ = std::make_unique<ui::TestContextFactories>(
|
||||
/*enable_pixel_output=*/false);
|
||||
ash_test_helper_ = std::make_unique<AshTestHelper>(
|
||||
@ -251,6 +254,7 @@ class WizardControllerTestBase : public ::testing::Test {
|
||||
TestingBrowserProcess::GetGlobal()->platform_part()->StartTearDown();
|
||||
profile_ = nullptr;
|
||||
profile_manager_.reset();
|
||||
session_manager_.reset();
|
||||
}
|
||||
|
||||
void FakeInstallAttributesForDemoMode() {
|
||||
@ -269,6 +273,7 @@ class WizardControllerTestBase : public ::testing::Test {
|
||||
|
||||
user_manager::TypedScopedUserManager<user_manager::FakeUserManager>
|
||||
fake_user_manager_{std::make_unique<user_manager::FakeUserManager>()};
|
||||
std::unique_ptr<session_manager::SessionManager> session_manager_;
|
||||
std::unique_ptr<TestingProfileManager> profile_manager_;
|
||||
raw_ptr<Profile> profile_ = nullptr;
|
||||
std::unique_ptr<ui::TestContextFactories> test_context_factories_;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "chrome/browser/extensions/extension_api_unittest.h"
|
||||
#include "chrome/common/chrome_constants.h"
|
||||
#include "chrome/test/base/testing_profile.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "components/session_manager/session_manager_types.h"
|
||||
#include "extensions/browser/api_test_utils.h"
|
||||
#include "extensions/common/extension.h"
|
||||
|
@ -47,7 +47,7 @@ class NetworkPortalNotificationControllerTest
|
||||
|
||||
void SetUp() override {
|
||||
BrowserWithTestWindowTest::SetUp();
|
||||
|
||||
controller_ = std::make_unique<NetworkPortalNotificationController>();
|
||||
TestingBrowserProcess::GetGlobal()->SetSystemNotificationHelper(
|
||||
std::make_unique<SystemNotificationHelper>());
|
||||
display_service_ = std::make_unique<NotificationDisplayServiceTester>(
|
||||
@ -61,13 +61,14 @@ class NetworkPortalNotificationControllerTest
|
||||
|
||||
void TearDown() override {
|
||||
NetworkPortalSigninController::Shutdown();
|
||||
controller_.reset();
|
||||
BrowserWithTestWindowTest::TearDown();
|
||||
}
|
||||
|
||||
protected:
|
||||
void PortalStateChanged(const NetworkState* network,
|
||||
NetworkState::PortalState portal_state) {
|
||||
controller_.PortalStateChanged(network, portal_state);
|
||||
controller_->PortalStateChanged(network, portal_state);
|
||||
}
|
||||
|
||||
bool HasNotification() {
|
||||
@ -75,7 +76,7 @@ class NetworkPortalNotificationControllerTest
|
||||
}
|
||||
|
||||
std::unique_ptr<NotificationDisplayServiceTester> display_service_;
|
||||
NetworkPortalNotificationController controller_;
|
||||
std::unique_ptr<NetworkPortalNotificationController> controller_;
|
||||
};
|
||||
|
||||
TEST_F(NetworkPortalNotificationControllerTest, NetworkStateChangedPortal) {
|
||||
|
@ -86,13 +86,14 @@ class ProjectorSodaInstallationControllerTest : public ChromeAshTestBase {
|
||||
|
||||
// ChromeAshTestBase:
|
||||
void SetUp() override {
|
||||
ChromeAshTestBase::SetUp();
|
||||
|
||||
testing_profile_manager_ = std::make_unique<TestingProfileManager>(
|
||||
TestingBrowserProcess::GetGlobal());
|
||||
ASSERT_TRUE(testing_profile_manager_->SetUp());
|
||||
testing_profile_ = ProfileManager::GetPrimaryUserProfile();
|
||||
|
||||
ChromeAshTestBase::SetUp();
|
||||
|
||||
testing_profile_ = ProfileManager::GetPrimaryUserProfile();
|
||||
soda_installer_ = std::make_unique<MockSodaInstaller>();
|
||||
ON_CALL(*soda_installer(), GetAvailableLanguages)
|
||||
.WillByDefault(
|
||||
@ -126,8 +127,10 @@ class ProjectorSodaInstallationControllerTest : public ChromeAshTestBase {
|
||||
mock_app_client_.reset();
|
||||
mock_client_.reset();
|
||||
soda_installer_.reset();
|
||||
testing_profile_ = nullptr;
|
||||
|
||||
ChromeAshTestBase::TearDown();
|
||||
|
||||
// ProfileManager is destroyed in OnHelperWillBeDestroyed()
|
||||
// invoked in ChromeAshTestBase::TearDown().
|
||||
EXPECT_FALSE(testing_profile_manager_.get());
|
||||
|
@ -88,6 +88,7 @@ include_rules = [
|
||||
"+components/safe_browsing/buildflags.h",
|
||||
"+components/safe_browsing/core/browser/db",
|
||||
"+components/sampling_profiler",
|
||||
"+components/session_manager/core",
|
||||
"+components/sharing_message",
|
||||
"+components/search",
|
||||
"+components/search_engines",
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "chromeos/ash/components/dbus/cros_disks/cros_disks_client.h"
|
||||
#include "chromeos/ash/components/disks/disk_mount_manager.h"
|
||||
#include "chromeos/ash/components/disks/fake_disk_mount_manager.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "components/user_manager/fake_user_manager.h"
|
||||
#include "components/user_manager/scoped_user_manager.h"
|
||||
#include "components/user_manager/test_helper.h"
|
||||
@ -65,6 +66,10 @@ void BrowserWithTestWindowTest::SetUp() {
|
||||
testing::Test::SetUp();
|
||||
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kNoFirstRun);
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
session_manager_ = std::make_unique<session_manager::SessionManager>();
|
||||
#endif
|
||||
|
||||
if (!profile_manager_) {
|
||||
SetUpProfileManager();
|
||||
}
|
||||
@ -83,6 +88,7 @@ void BrowserWithTestWindowTest::SetUp() {
|
||||
ash::AshTestHelper::InitParams ash_init;
|
||||
ash_init.local_state = g_browser_process->local_state();
|
||||
ash_init.start_session = false;
|
||||
ash_init.create_session_manager = false;
|
||||
|
||||
// Do not auto create user pref service. PrefService will be created by
|
||||
// TestingProfile.
|
||||
@ -166,6 +172,7 @@ void BrowserWithTestWindowTest::TearDown() {
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
test_views_delegate_.reset();
|
||||
user_manager_.Reset();
|
||||
session_manager_.reset();
|
||||
ash::disks::DiskMountManager::Shutdown();
|
||||
ash::CrosDisksClient::Shutdown();
|
||||
#elif defined(TOOLKIT_VIEWS)
|
||||
|
@ -57,6 +57,10 @@ class NavigationController;
|
||||
namespace crosapi {
|
||||
class CrosapiManager;
|
||||
}
|
||||
|
||||
namespace session_manager {
|
||||
class SessionManager;
|
||||
}
|
||||
#endif
|
||||
|
||||
class TestingProfileManager;
|
||||
@ -302,6 +306,7 @@ class BrowserWithTestWindowTest : public testing::Test, public ProfileObserver {
|
||||
std::unique_ptr<Browser> browser_;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
std::unique_ptr<session_manager::SessionManager> session_manager_;
|
||||
ash::AshTestHelper ash_test_helper_;
|
||||
std::unique_ptr<views::TestViewsDelegate> test_views_delegate_ =
|
||||
std::make_unique<ChromeTestViewsDelegate<ash::AshTestViewsDelegate>>();
|
||||
|
@ -64,6 +64,7 @@ source_set("unit_tests") {
|
||||
"//chromeos/ash/services/bluetooth_config",
|
||||
"//chromeos/ash/services/bluetooth_config:test_support",
|
||||
"//chromeos/ash/services/bluetooth_config/public/mojom",
|
||||
"//components/session_manager/core",
|
||||
"//device/bluetooth:mocks",
|
||||
"//mojo/public/cpp/bindings",
|
||||
"//services/device/public/cpp/hid:hid",
|
||||
|
@ -10,5 +10,6 @@ specific_include_rules = {
|
||||
".*unittest\\.cc": [
|
||||
# Allows fake implementations.
|
||||
"+chromeos/ash/services/bluetooth_config",
|
||||
"+components/session_manager/core",
|
||||
]
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "chromeos/ash/services/bluetooth_config/fake_discovery_session_manager.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/public/mojom/cros_bluetooth_config.mojom.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/scoped_bluetooth_config_test_helper.h"
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace ash::hid_detection {
|
||||
@ -74,6 +75,9 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
|
||||
// testing::Test:
|
||||
void SetUp() override {
|
||||
session_manager_ = std::make_unique<session_manager::SessionManager>();
|
||||
scoped_bluetooth_config_test_helper_ =
|
||||
std::make_unique<bluetooth_config::ScopedBluetoothConfigTestHelper>();
|
||||
bluetooth_hid_detector_ = std::make_unique<BluetoothHidDetectorImpl>();
|
||||
}
|
||||
|
||||
@ -82,6 +86,9 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
// destroyed.
|
||||
if (IsDiscoverySessionActive())
|
||||
StopBluetoothHidDetection(/*is_using_bluetooth=*/false);
|
||||
bluetooth_hid_detector_.reset();
|
||||
scoped_bluetooth_config_test_helper_.reset();
|
||||
session_manager_.reset();
|
||||
}
|
||||
|
||||
FakeBluetoothHidDetectorDelegate* StartBluetoothHidDetection(
|
||||
@ -111,25 +118,25 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
// the Bluetooth adapter and persists that state which is restored when HID
|
||||
// detection finishes.
|
||||
void SimulateBluetoothToggledByUi(bool enabled) {
|
||||
scoped_bluetooth_config_test_helper_.fake_bluetooth_power_controller()
|
||||
scoped_bluetooth_config_test_helper_->fake_bluetooth_power_controller()
|
||||
->SetBluetoothEnabledState(enabled);
|
||||
}
|
||||
|
||||
// Sets the state of the Bluetooth adapter without any persistence. This
|
||||
// simulates the adapter changing without any user interaction.
|
||||
void SetAdapterState(BluetoothSystemState system_state) {
|
||||
scoped_bluetooth_config_test_helper_.fake_adapter_state_controller()
|
||||
scoped_bluetooth_config_test_helper_->fake_adapter_state_controller()
|
||||
->SetSystemState(system_state);
|
||||
}
|
||||
|
||||
BluetoothSystemState GetAdapterState() {
|
||||
return scoped_bluetooth_config_test_helper_.fake_adapter_state_controller()
|
||||
return scoped_bluetooth_config_test_helper_->fake_adapter_state_controller()
|
||||
->GetAdapterState();
|
||||
}
|
||||
|
||||
bool IsDiscoverySessionActive() {
|
||||
return scoped_bluetooth_config_test_helper_
|
||||
.fake_discovery_session_manager()
|
||||
->fake_discovery_session_manager()
|
||||
->IsDiscoverySessionActive();
|
||||
}
|
||||
|
||||
@ -140,7 +147,7 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
paired_device->device_properties = BluetoothDeviceProperties::New();
|
||||
std::vector<PairedBluetoothDevicePropertiesPtr> paired_devices;
|
||||
paired_devices.push_back(mojo::Clone(paired_device));
|
||||
scoped_bluetooth_config_test_helper_.fake_device_cache()->SetPairedDevices(
|
||||
scoped_bluetooth_config_test_helper_->fake_device_cache()->SetPairedDevices(
|
||||
std::move(paired_devices));
|
||||
base::RunLoop().RunUntilIdle();
|
||||
}
|
||||
@ -183,7 +190,7 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
std::vector<raw_ptr<FakeDevicePairingHandler, VectorExperimental>>
|
||||
GetDevicePairingHandlers() {
|
||||
return scoped_bluetooth_config_test_helper_
|
||||
.fake_discovery_session_manager()
|
||||
->fake_discovery_session_manager()
|
||||
->device_pairing_handlers();
|
||||
}
|
||||
|
||||
@ -254,7 +261,7 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
for (auto& device : unpaired_devices_) {
|
||||
unpaired_devices.push_back(device.Clone());
|
||||
}
|
||||
scoped_bluetooth_config_test_helper_.fake_discovered_devices_provider()
|
||||
scoped_bluetooth_config_test_helper_->fake_discovered_devices_provider()
|
||||
->SetDiscoveredDevices(std::move(unpaired_devices));
|
||||
}
|
||||
|
||||
@ -278,9 +285,11 @@ class BluetoothHidDetectorImplTest : public testing::Test {
|
||||
// detection is stopped in TearDown().
|
||||
std::vector<std::unique_ptr<FakeBluetoothHidDetectorDelegate>> delegates_;
|
||||
|
||||
bluetooth_config::ScopedBluetoothConfigTestHelper
|
||||
std::unique_ptr<bluetooth_config::ScopedBluetoothConfigTestHelper>
|
||||
scoped_bluetooth_config_test_helper_;
|
||||
|
||||
std::unique_ptr<session_manager::SessionManager> session_manager_;
|
||||
|
||||
std::unique_ptr<hid_detection::BluetoothHidDetectorImpl>
|
||||
bluetooth_hid_detector_;
|
||||
};
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "chromeos/ash/services/bluetooth_config/initializer.h"
|
||||
|
||||
#include "components/session_manager/core/session_manager.h"
|
||||
|
||||
namespace ash::bluetooth_config {
|
||||
|
||||
class FakeAdapterStateController;
|
||||
@ -63,10 +61,6 @@ class ScopedBluetoothConfigTestHelper : public Initializer {
|
||||
return fake_device_operation_handler_;
|
||||
}
|
||||
|
||||
session_manager::SessionManager* session_manager() {
|
||||
return &session_manager_;
|
||||
}
|
||||
|
||||
private:
|
||||
// Initializer:
|
||||
std::unique_ptr<AdapterStateController> CreateAdapterStateController(
|
||||
@ -111,7 +105,6 @@ class ScopedBluetoothConfigTestHelper : public Initializer {
|
||||
fake_discovery_session_manager_;
|
||||
raw_ptr<FakeDeviceOperationHandler, DanglingUntriaged>
|
||||
fake_device_operation_handler_;
|
||||
session_manager::SessionManager session_manager_;
|
||||
};
|
||||
|
||||
} // namespace ash::bluetooth_config
|
||||
|
Reference in New Issue
Block a user