Deprecate CreateUserSessions
* Replace them with SimulateUserLogin * I couldn't replace one for start_session in AshTestHelper because SimulateUserLogin calls StabilizeUI, which shouldn't be called at this point. I'll work on it in a follow up CL. * Remove unnecessary CreateUserSessions. This was actually causing incorrect state transition. * Created default email constexpr value for eacy transition. I also found many SimulateUserLogin usage juset use some random email. * DetachedableBaseNotificationController was initialised before SystemNotificationController even though it has dependency. Unit test was testing "locked -> login_primary" transition, but not "locked -> active", and it was passing incorrectly. Bug: 383441831 Test: All tests should still pass. Change-Id: Iccca14f65ed50a938842ace202f1f263d224c2bd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6089266 Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Commit-Queue: Mitsuru Oshima <oshima@chromium.org> Cr-Commit-Position: refs/heads/main@{#1396256}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
cf22866740
commit
e06dd8a7f4
ash
ambient
detachable_base
focus
metrics
login_unlock_throughput_recorder_unittest.ccunlock_throughput_recorder_unittest.ccuser_metrics_recorder_unittest.cc
root_window_controller_unittest.ccsession
shelf
home_button_unittest.cchome_to_overview_nudge_controller_unittest.cclogin_shelf_view_unittest.ccshelf_widget_unittest.ccshelf_window_watcher_unittest.cc
shell.ccshell.hsystem
accessibility
nearby_share
network
overview
power
session
unified
test
chrome/browser
ash
ui
ash
assistant
quick_answers
components/exo
@ -2043,7 +2043,7 @@ TEST_F(AmbientControllerForManagedScreensaverLoginScreenTest,
|
||||
ASSERT_TRUE(GetContainerView());
|
||||
|
||||
// Simulate user session start (e.g. user login)
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// Confirm that ambient mode is not shown if disabled. (disabled by default)
|
||||
FastForwardByLockScreenInactivityTimeout();
|
||||
@ -2093,7 +2093,7 @@ TEST_F(AmbientControllerForManagedScreensaverLoginScreenTest,
|
||||
EXPECT_FALSE(ambient_controller()->ShouldShowAmbientUi());
|
||||
|
||||
// Simulate login
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_FALSE(ambient_controller()->ShouldShowAmbientUi());
|
||||
|
||||
SetAmbientModeManagedScreensaverEnabled(true);
|
||||
@ -2126,7 +2126,7 @@ TEST_F(AmbientControllerForManagedScreensaverLoginScreenTest,
|
||||
EXPECT_FALSE(ambient_controller()->ShouldShowAmbientUi());
|
||||
|
||||
// Simulate login
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_FALSE(ambient_controller()->ShouldShowAmbientUi());
|
||||
|
||||
SetAmbientModeManagedScreensaverEnabled(true);
|
||||
|
@ -77,7 +77,7 @@ class DetachableBaseNotificationControllerTest : public NoSessionAshTestBase {
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest,
|
||||
ShowPairingNotificationIfSessionNotBlocked) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// The first detachable base used by the user - no notification expected.
|
||||
detachable_base_handler()->PairChallengeSucceeded({0x01, 0x01});
|
||||
@ -98,7 +98,7 @@ TEST_F(DetachableBaseNotificationControllerTest,
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest,
|
||||
ShowNotificationOnNonAuthenticatedBases) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
detachable_base_handler()->PairChallengeFailed();
|
||||
EXPECT_TRUE(IsBaseChangedNotificationVisible());
|
||||
@ -106,7 +106,7 @@ TEST_F(DetachableBaseNotificationControllerTest,
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest,
|
||||
UpdateNotificationOnUserSwitch) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// The first detachable base used by the user - no notification expected.
|
||||
detachable_base_handler()->PairChallengeSucceeded({0x01, 0x01});
|
||||
@ -127,7 +127,7 @@ TEST_F(DetachableBaseNotificationControllerTest,
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest,
|
||||
NonAuthenticatedBaseNotificationOnUserSwitch) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
detachable_base_handler()->PairChallengeFailed();
|
||||
EXPECT_TRUE(IsBaseChangedNotificationVisible());
|
||||
@ -185,12 +185,12 @@ TEST_F(DetachableBaseNotificationControllerTest,
|
||||
detachable_base_handler()->PairChallengeFailed();
|
||||
EXPECT_FALSE(IsBaseChangedNotificationVisible());
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_TRUE(IsBaseChangedNotificationVisible());
|
||||
}
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest, NoNotificationOnLockScreen) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
// The first detachable base used by the user - no notification expected.
|
||||
detachable_base_handler()->PairChallengeSucceeded({0x01, 0x01});
|
||||
|
||||
@ -205,7 +205,7 @@ TEST_F(DetachableBaseNotificationControllerTest, NoNotificationOnLockScreen) {
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest,
|
||||
NoNotificationAfterLockScreenIfSetAsUsed) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
// The first detachable base used by the user - no notification expected.
|
||||
detachable_base_handler()->PairChallengeSucceeded({0x01, 0x01});
|
||||
BlockUserSession(UserSessionBlockReason::BLOCKED_BY_LOCK_SCREEN);
|
||||
@ -225,16 +225,17 @@ TEST_F(DetachableBaseNotificationControllerTest,
|
||||
// about the base.
|
||||
TEST_F(DetachableBaseNotificationControllerTest,
|
||||
NonAuthenticatedBaseNotificationNotShownOnLock) {
|
||||
BlockUserSession(UserSessionBlockReason::BLOCKED_BY_LOCK_SCREEN);
|
||||
ASSERT_TRUE(IsInSessionState(session_manager::SessionState::LOGIN_PRIMARY));
|
||||
detachable_base_handler()->PairChallengeFailed();
|
||||
EXPECT_FALSE(IsBaseChangedNotificationVisible());
|
||||
|
||||
UnblockUserSession();
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
EXPECT_TRUE(IsBaseChangedNotificationVisible());
|
||||
}
|
||||
|
||||
TEST_F(DetachableBaseNotificationControllerTest, NotificationOnUpdateRequired) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
detachable_base_handler()->BaseFirmwareUpdateNeeded();
|
||||
EXPECT_TRUE(IsBaseRequiresUpdateNotificationVisible());
|
||||
@ -253,7 +254,7 @@ TEST_F(DetachableBaseNotificationControllerTest,
|
||||
EXPECT_FALSE(IsBaseRequiresUpdateNotificationVisible());
|
||||
|
||||
// Login, expect the notification to be shown.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_TRUE(IsBaseRequiresUpdateNotificationVisible());
|
||||
|
||||
// The notification should be removed when the base gets detached.
|
||||
|
@ -38,7 +38,10 @@ class LockScreenSessionControllerClient : public TestSessionControllerClient {
|
||||
TestPrefServiceProvider* prefs_provider)
|
||||
: TestSessionControllerClient(controller, prefs_provider) {
|
||||
InitializeAndSetClient();
|
||||
CreatePredefinedUserSessions(1);
|
||||
|
||||
Reset();
|
||||
AddUserSession("user0@tray");
|
||||
SetSessionState(session_manager::SessionState::ACTIVE);
|
||||
}
|
||||
|
||||
LockScreenSessionControllerClient(const LockScreenSessionControllerClient&) =
|
||||
|
@ -201,7 +201,7 @@ class LoginUnlockThroughputRecorderTestBase : public LoginTestBase {
|
||||
}
|
||||
|
||||
void LoginOwner() {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE,
|
||||
LoginState::LOGGED_IN_USER_REGULAR);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class UnlockThroughputRecorderTest : public LoginTestBase,
|
||||
|
||||
protected:
|
||||
void LoginOwner() {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
LoginState::Get()->SetLoggedInState(LoginState::LOGGED_IN_ACTIVE,
|
||||
LoginState::LOGGED_IN_USER_REGULAR);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ TEST_F(UserMetricsRecorderTest, VerifyIsUserInActiveDesktopEnvironmentValues) {
|
||||
EXPECT_FALSE(test_api().IsUserInActiveDesktopEnvironment());
|
||||
|
||||
// Environment is active after login.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ASSERT_TRUE(session->IsActiveUserSessionStarted());
|
||||
EXPECT_TRUE(test_api().IsUserInActiveDesktopEnvironment());
|
||||
|
||||
@ -97,7 +97,7 @@ TEST_F(UserMetricsRecorderTest,
|
||||
// recorded when a user is active in a desktop environment.
|
||||
TEST_F(UserMetricsRecorderTest,
|
||||
VerifyStatsRecordedWhenUserInActiveDesktopEnvironment) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ASSERT_TRUE(test_api().IsUserInActiveDesktopEnvironment());
|
||||
test_api().RecordPeriodicMetrics();
|
||||
|
||||
@ -109,7 +109,7 @@ TEST_F(UserMetricsRecorderTest,
|
||||
// Verify the shelf item counts recorded by the
|
||||
// UserMetricsRecorder::RecordPeriodicMetrics() method.
|
||||
TEST_F(UserMetricsRecorderTest, ValuesRecordedByRecordShelfItemCounts) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// Make sure the shelf model is empty at first.
|
||||
ShelfModel* shelf_model = ShelfModel::Get();
|
||||
|
@ -444,7 +444,7 @@ TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
|
||||
login_modal_widget->Close();
|
||||
|
||||
// Configure user session environment.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers());
|
||||
EXPECT_TRUE(session_controller->IsActiveUserSessionStarted());
|
||||
EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
|
||||
|
@ -117,25 +117,6 @@ void TestSessionControllerClient::SetIsDemoSession() {
|
||||
controller_->SetSessionInfo(session_info_);
|
||||
}
|
||||
|
||||
void TestSessionControllerClient::CreatePredefinedUserSessions(int count) {
|
||||
DCHECK_GT(count, 0);
|
||||
|
||||
// Resets the controller's state.
|
||||
Reset();
|
||||
|
||||
// Adds user sessions with numbered emails if more are needed.
|
||||
for (int numbered_user_index = 0; numbered_user_index < count;
|
||||
++numbered_user_index) {
|
||||
AddUserSession(base::StringPrintf("user%d@tray", numbered_user_index));
|
||||
}
|
||||
|
||||
// Sets the first user as active.
|
||||
SwitchActiveUser(controller_->GetUserSession(0)->user_info.account_id);
|
||||
|
||||
// Updates session state after adding user sessions.
|
||||
SetSessionState(session_manager::SessionState::ACTIVE);
|
||||
}
|
||||
|
||||
void TestSessionControllerClient::AddUserSession(
|
||||
const std::string& display_email,
|
||||
user_manager::UserType user_type,
|
||||
@ -349,6 +330,12 @@ std::optional<int> TestSessionControllerClient::GetExistingUsersCount() const {
|
||||
return existing_users_count_;
|
||||
}
|
||||
|
||||
int TestSessionControllerClient::NumberOfLoggedInUsers() const {
|
||||
// This should be migrated to GetExistingUserCount when
|
||||
// TestSessionControllerImpl is removed.
|
||||
return controller_->NumberOfLoggedInUsers();
|
||||
}
|
||||
|
||||
void TestSessionControllerClient::DoSwitchUser(const AccountId& account_id,
|
||||
bool switch_user) {
|
||||
if (!switch_user)
|
||||
|
@ -80,12 +80,6 @@ class TestSessionControllerClient : public SessionControllerClient {
|
||||
void SetIsRunningInAppMode(bool app_mode);
|
||||
void SetIsDemoSession();
|
||||
|
||||
// Creates the |count| pre-defined user sessions. The users are named by
|
||||
// numbers using "user%d@tray" template. The first user is set as active user
|
||||
// to be consistent with crash-and-restore scenario. Note that existing user
|
||||
// sessions prior this call will be removed without sending out notifications.
|
||||
void CreatePredefinedUserSessions(int count);
|
||||
|
||||
// Adds a user session from a given display email. If |provide_pref_service|
|
||||
// is true, eagerly inject a PrefService for this user. |is_new_profile|
|
||||
// indicates whether the user has a newly created profile on the device.
|
||||
@ -174,6 +168,8 @@ class TestSessionControllerClient : public SessionControllerClient {
|
||||
default_provide_pref_service_ = default_provide_pref_service;
|
||||
}
|
||||
|
||||
int NumberOfLoggedInUsers() const;
|
||||
|
||||
private:
|
||||
void DoSwitchUser(const AccountId& account_id, bool switch_user);
|
||||
|
||||
|
@ -1002,7 +1002,9 @@ TEST_F(HomeButtonAnimationTest, NonAnimatedLayoutDuringAnimation) {
|
||||
|
||||
TEST_P(HomeButtonTest, LongPressGesture) {
|
||||
// Simulate two users with primary user as active.
|
||||
CreateUserSessions(2);
|
||||
auto primary = SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SwitchActiveUser(primary);
|
||||
|
||||
// Enable the Assistant in system settings.
|
||||
prefs()->SetBoolean(assistant::prefs::kAssistantEnabled, true);
|
||||
@ -1033,7 +1035,9 @@ TEST_P(HomeButtonTest, LongPressGesture) {
|
||||
|
||||
TEST_P(HomeButtonTest, LongPressGestureInTabletMode) {
|
||||
// Simulate two users with primary user as active.
|
||||
CreateUserSessions(2);
|
||||
auto primary = SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SwitchActiveUser(primary);
|
||||
|
||||
// Enable the Assistant in system settings.
|
||||
prefs()->SetBoolean(assistant::prefs::kAssistantEnabled, true);
|
||||
@ -1109,7 +1113,9 @@ TEST_P(HomeButtonTest, LongPressGestureWithSecondaryUser) {
|
||||
|
||||
TEST_P(HomeButtonTest, LongPressGestureWithSettingsDisabled) {
|
||||
// Simulate two user with primary user as active.
|
||||
CreateUserSessions(2);
|
||||
auto primary = SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SwitchActiveUser(primary);
|
||||
|
||||
// Simulate a user who has already completed setup flow, but disabled the
|
||||
// Assistant in settings.
|
||||
|
@ -48,7 +48,8 @@ class WidgetCloseObserver {
|
||||
base::WeakPtr<views::Widget> widget_;
|
||||
};
|
||||
|
||||
class HomeToOverviewNudgeControllerWithNudgesDisabledTest : public AshTestBase {
|
||||
class HomeToOverviewNudgeControllerWithNudgesDisabledTest
|
||||
: public NoSessionAshTestBase {
|
||||
public:
|
||||
HomeToOverviewNudgeControllerWithNudgesDisabledTest() {
|
||||
scoped_feature_list_.InitAndDisableFeature(
|
||||
@ -67,7 +68,7 @@ class HomeToOverviewNudgeControllerWithNudgesDisabledTest : public AshTestBase {
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
};
|
||||
|
||||
class HomeToOverviewNudgeControllerTest : public AshTestBase {
|
||||
class HomeToOverviewNudgeControllerTest : public NoSessionAshTestBase {
|
||||
public:
|
||||
HomeToOverviewNudgeControllerTest() {
|
||||
scoped_feature_list_.InitAndEnableFeature(
|
||||
@ -82,7 +83,7 @@ class HomeToOverviewNudgeControllerTest : public AshTestBase {
|
||||
|
||||
// AshTestBase:
|
||||
void SetUp() override {
|
||||
AshTestBase::SetUp();
|
||||
NoSessionAshTestBase::SetUp();
|
||||
GetSessionControllerClient()->SetSessionState(
|
||||
session_manager::SessionState::LOGIN_PRIMARY);
|
||||
test_clock_.Advance(base::Hours(2));
|
||||
@ -90,7 +91,7 @@ class HomeToOverviewNudgeControllerTest : public AshTestBase {
|
||||
}
|
||||
void TearDown() override {
|
||||
contextual_tooltip::ClearClockOverrideForTesting();
|
||||
AshTestBase::TearDown();
|
||||
NoSessionAshTestBase::TearDown();
|
||||
}
|
||||
|
||||
HomeToOverviewNudgeController* GetNudgeController() {
|
||||
@ -186,7 +187,7 @@ TEST_F(HomeToOverviewNudgeControllerWithNudgesDisabledTest,
|
||||
->shelf_layout_manager()
|
||||
->home_to_overview_nudge_controller_for_testing());
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
std::unique_ptr<aura::Window> window_1 =
|
||||
CreateTestWindow(gfx::Rect(0, 0, 400, 400));
|
||||
@ -205,7 +206,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoNudgeBeforeLogin) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
EXPECT_FALSE(GetNudgeController());
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_TRUE(GetNudgeController());
|
||||
}
|
||||
|
||||
@ -214,7 +215,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoNudgeBeforeLogin) {
|
||||
// subsequent shows, the nudge should be hidden after a timeout.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, ShownOnHomeScreen) {
|
||||
base::HistogramTester histogram_tester;
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// The nudge should not be shown in clamshell.
|
||||
EXPECT_FALSE(GetNudgeController());
|
||||
@ -286,7 +287,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, ShownOnHomeScreen) {
|
||||
// Tests that the nudge eventually stops showing.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, ShownLimitedNumberOfTimes) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
|
||||
@ -317,7 +318,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, ShownLimitedNumberOfTimes) {
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, HiddenOnTabletModeExit) {
|
||||
base::HistogramTester histogram_tester;
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -335,7 +336,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, HiddenOnTabletModeExit) {
|
||||
// Tests that the nudge show is canceled when tablet mode exits.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, ShowCanceledOnTabletModeExit) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -354,7 +355,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, ShowCanceledOnTabletModeExit) {
|
||||
TEST_F(HomeToOverviewNudgeControllerTest,
|
||||
ShowAnimationCanceledOnTabletModeExit) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -378,7 +379,7 @@ TEST_F(HomeToOverviewNudgeControllerTest,
|
||||
// Tests that the nudge is hidden when the screen is locked.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, HiddenOnScreenLock) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -404,7 +405,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, HiddenOnScreenLock) {
|
||||
// show timer runs.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, InAppShelfShownBeforeShowTimer) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -433,7 +434,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, InAppShelfShownBeforeShowTimer) {
|
||||
// animation to show the nudge.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, NudgeHiddenDuringShowAnimation) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -484,7 +485,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NudgeHiddenDuringShowAnimation) {
|
||||
// Tests that there is no crash if the nudge widget gets closed unexpectedly.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, NoCrashIfNudgeWidgetGetsClosed) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -504,7 +505,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoCrashIfNudgeWidgetGetsClosed) {
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeClosesTheNudge) {
|
||||
base::HistogramTester histogram_tester;
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -529,7 +530,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeClosesTheNudge) {
|
||||
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeDuringShowAnimation) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList extra_windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -583,7 +584,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, TapOnTheNudgeDuringShowAnimation) {
|
||||
// times.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, NoNudgeAfterSuccessfulGestures) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
EXPECT_FALSE(GetNudgeController()->nudge_for_testing());
|
||||
@ -648,7 +649,7 @@ TEST_F(HomeToOverviewNudgeControllerTest, NoNudgeAfterSuccessfulGestures) {
|
||||
// widget works - i.e. that home still transitions to overview.
|
||||
TEST_F(HomeToOverviewNudgeControllerTest, HomeToOverviewGestureFromNudge) {
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
EXPECT_FALSE(GetNudgeController()->nudge_for_testing());
|
||||
@ -691,7 +692,7 @@ TEST_F(HomeToOverviewNudgeControllerTest,
|
||||
NudgeBoundsUpdatedOnDisplayBoundsChange) {
|
||||
UpdateDisplay("768x1200");
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
@ -719,7 +720,7 @@ TEST_P(HomeToOverviewNudgeControllerTestWithA11yPrefs,
|
||||
// Enters tablet mode and sets up two minimized windows. This will create the
|
||||
// show nudge timer.
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
ASSERT_TRUE(GetNudgeController());
|
||||
EXPECT_TRUE(GetNudgeController()->HasShowTimerForTesting());
|
||||
@ -741,15 +742,13 @@ TEST_P(HomeToOverviewNudgeControllerTestWithA11yPrefs,
|
||||
DisableNudgesForShelfControls) {
|
||||
SCOPED_TRACE(testing::Message() << "Pref=" << GetParam());
|
||||
// Enabling accessibility shelf controls should disable the nudge.
|
||||
Shell::Get()
|
||||
->session_controller()
|
||||
->GetLastActiveUserPrefService()
|
||||
->SetBoolean(GetParam(), true);
|
||||
Shell::Get()->session_controller()->GetActivePrefService()->SetBoolean(
|
||||
GetParam(), true);
|
||||
|
||||
// Enters tablet mode and sets up two minimized windows. This should not
|
||||
// trigger the nudge show timer because shelf controls are on.
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
CreateUserSessions(1);
|
||||
SimulateNewUserFirstLogin("test@gmail.com");
|
||||
ScopedWindowList windows = CreateAndMinimizeWindows(2);
|
||||
|
||||
EXPECT_FALSE(GetNudgeController());
|
||||
|
@ -228,7 +228,7 @@ TEST_F(LoginShelfViewTest,
|
||||
ShouldUpdateUiAfterShutdownPolicyChangeAtLockScreen) {
|
||||
EXPECT_TRUE(ShowsShelfButtons({}));
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -252,7 +252,7 @@ TEST_F(LoginShelfViewTest, ShouldUpdateUiBasedOnShutdownPolicyInActiveSession) {
|
||||
// The initial state of |reboot_on_shutdown| is false.
|
||||
EXPECT_TRUE(ShowsShelfButtons({}));
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifyShutdownPolicyChanged(true /*reboot_on_shutdown*/);
|
||||
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
@ -270,7 +270,7 @@ TEST_F(LoginShelfViewTest, ShouldNotShowAppsButtonAfterSessionStarted) {
|
||||
EXPECT_TRUE(
|
||||
login_shelf_view_->GetViewByID(LoginShelfView::kApps)->GetVisible());
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_FALSE(
|
||||
login_shelf_view_->GetViewByID(LoginShelfView::kApps)->GetVisible());
|
||||
}
|
||||
@ -470,7 +470,7 @@ TEST_F(LoginShelfViewTest, ClickShutdownButton) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewTest, ClickShutdownButtonOnLockScreen) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
ShutdownAndConfirm();
|
||||
EXPECT_TRUE(Shell::Get()->lock_state_controller()->ShutdownRequested());
|
||||
@ -480,13 +480,13 @@ TEST_F(LoginShelfViewTest, ClickShutdownButtonOnLockScreen) {
|
||||
// session that starts with side shelf. See https://crbug.com/1050192.
|
||||
TEST_F(LoginShelfViewTest,
|
||||
ClickShutdownButtonOnLockScreenWithVerticalInSessionShelf) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetShelfAlignmentPref(
|
||||
Shell::Get()->session_controller()->GetPrimaryUserPrefService(),
|
||||
GetPrimaryDisplay().id(), ShelfAlignment::kLeft);
|
||||
ClearLogin();
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
|
||||
ShutdownAndConfirm();
|
||||
@ -495,7 +495,7 @@ TEST_F(LoginShelfViewTest,
|
||||
|
||||
TEST_F(LoginShelfViewTest, ClickRestartButton) {
|
||||
// The Restart button is not available in OOBE session state.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
|
||||
NotifyShutdownPolicyChanged(true /*reboot_on_shutdown*/);
|
||||
@ -507,7 +507,7 @@ TEST_F(LoginShelfViewTest, ClickRestartButton) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewTest, ClickSignOutButton) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_EQ(session_manager::SessionState::ACTIVE,
|
||||
Shell::Get()->session_controller()->GetSessionState());
|
||||
|
||||
@ -520,7 +520,7 @@ TEST_F(LoginShelfViewTest, ClickSignOutButton) {
|
||||
TEST_F(LoginShelfViewTest, ClickCancelButton) {
|
||||
auto client = std::make_unique<MockLoginScreenClient>();
|
||||
EXPECT_CALL(*client, CancelAddUser());
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOGIN_SECONDARY);
|
||||
Click(LoginShelfView::kCancel);
|
||||
}
|
||||
@ -544,7 +544,7 @@ TEST_F(LoginShelfViewTest, ClickEnterpriseEnrollmentButton) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewTest, TabGoesFromShelfToStatusAreaAndBackToShelf) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -584,7 +584,7 @@ TEST_F(LoginShelfViewTest, TabGoesFromShelfToStatusAreaAndBackToShelf) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewTest, LoginShelfButtonTooltipText) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -638,7 +638,7 @@ TEST_F(LoginShelfViewTest, LoginShelfButtonTooltipText) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewTest, LoginShelfButtonTooltipTextAccessibility) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -837,7 +837,7 @@ TEST_F(LoginShelfViewTest, ParentAccessButtonVisibility) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewTest, ParentAccessButtonVisibilityChangeOnLockScreen) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -949,7 +949,7 @@ TEST_F(LoginShelfViewTest, MouseWheelOnLoginShelf) {
|
||||
test_mouse_wheel_noop(location);
|
||||
}
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
|
||||
for (const auto& location : kLocations) {
|
||||
@ -1045,7 +1045,7 @@ TEST_F(LoginShelfViewTest, AccessiblePreviousAndNextFocus) {
|
||||
|
||||
// Simulate the lock screen scenario to verify the previous focus is updated.
|
||||
Shell::Get()->login_screen_controller()->ShowLockScreen();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
|
||||
data = ui::AXNodeData();
|
||||
@ -1199,7 +1199,7 @@ class LoginShelfViewWithShutdownConfirmationTest : public LoginShelfViewTest {
|
||||
// shutdown button on the lockscreen
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
ShouldShowAfterShutdownButtonLockSession) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -1242,7 +1242,7 @@ TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
// cancel button on the shutdown confirmation bubble and could be shown again.
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
ShouldCloseAfterCancelButton) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -1283,7 +1283,7 @@ TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
// down.
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
ShouldCloseAndShutdownAfterConfirmButton) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -1311,7 +1311,7 @@ TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
|
||||
// Checks that shutdown confirmation bubble disappears after inactive.
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest, ShouldCloseAfterInactive) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -1341,7 +1341,7 @@ TEST_F(LoginShelfViewWithShutdownConfirmationTest, ShouldCloseAfterInactive) {
|
||||
// Checks that shutdown confirmation was first cancelled, then confirmed
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
ShouldCloseAndShutdownAfterCancelAndConfirmButton) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -1444,7 +1444,7 @@ TEST_F(LoginShelfViewWithShutdownConfirmationTest, DisplayOff) {
|
||||
}
|
||||
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest, ClickRestartButton) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
EXPECT_TRUE(
|
||||
ShowsShelfButtons({LoginShelfView::kShutdown, LoginShelfView::kSignOut}));
|
||||
@ -1460,7 +1460,7 @@ TEST_F(LoginShelfViewWithShutdownConfirmationTest, ClickRestartButton) {
|
||||
|
||||
TEST_F(LoginShelfViewWithShutdownConfirmationTest,
|
||||
ShelfShutdownConfirmationBubbleAccessibleProperties) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
NotifySessionStateChanged(SessionState::LOCKED);
|
||||
Click(LoginShelfView::kShutdown);
|
||||
auto* confirmation_bubble =
|
||||
|
@ -401,7 +401,7 @@ TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) {
|
||||
ASSERT_TRUE(shelf_widget2);
|
||||
|
||||
// Simulate login.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
const int total_width1 =
|
||||
screen_util::GetDisplayBoundsWithShelf(shelf_widget1->GetNativeWindow())
|
||||
@ -967,7 +967,7 @@ class ShelfWidgetAfterLoginTest : public AshTestBase {
|
||||
ShelfVisibilityState expected_shelf_visibility_state,
|
||||
ShelfAutoHideState expected_shelf_auto_hide_state) {
|
||||
// Simulate login.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// Simulate shelf settings being applied from profile prefs.
|
||||
Shelf* shelf = GetPrimaryShelf();
|
||||
@ -1001,7 +1001,7 @@ TEST_F(ShelfWidgetAfterLoginTest, InitialValues) {
|
||||
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
|
||||
|
||||
// Simulate login.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// Ensure settings are correct after login.
|
||||
EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
|
||||
|
@ -332,7 +332,7 @@ TEST_F(ShelfWindowWatcherSessionStartTest, PreExistingWindow) {
|
||||
EXPECT_EQ(0, model->item_count());
|
||||
|
||||
// Start the test user session; ShelfWindowWatcher will find the open window.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_EQ(1, model->item_count());
|
||||
}
|
||||
|
||||
|
25
ash/shell.cc
25
ash/shell.cc
@ -994,6 +994,13 @@ Shell::~Shell() {
|
||||
// notification.
|
||||
focus_mode_controller_.reset();
|
||||
|
||||
// DetachableBaseNotificationController depends on DetachableBaseHandler, and
|
||||
// has to be destructed before it.
|
||||
detachable_base_notification_controller_.reset();
|
||||
// DetachableBaseHandler depends on the PrefService and must be destructed
|
||||
// before it.
|
||||
detachable_base_handler_.reset();
|
||||
|
||||
system_notification_controller_.reset();
|
||||
// Should be destroyed after Shelf and |system_notification_controller_|.
|
||||
system_tray_model_.reset();
|
||||
@ -1164,12 +1171,6 @@ Shell::~Shell() {
|
||||
// TouchDevicesController depends on the PrefService and must be destructed
|
||||
// before it.
|
||||
touch_devices_controller_ = nullptr;
|
||||
// DetachableBaseNotificationController depends on DetachableBaseHandler, and
|
||||
// has to be destructed before it.
|
||||
detachable_base_notification_controller_.reset();
|
||||
// DetachableBaseHandler depends on the PrefService and must be destructed
|
||||
// before it.
|
||||
detachable_base_handler_.reset();
|
||||
|
||||
diagnostics_log_controller_.reset();
|
||||
|
||||
@ -1276,11 +1277,6 @@ void Shell::Init(
|
||||
// These controllers call Shell::Get() in their constructors, so they cannot
|
||||
// be in the member initialization list.
|
||||
touch_devices_controller_ = std::make_unique<TouchDevicesController>();
|
||||
detachable_base_handler_ =
|
||||
std::make_unique<DetachableBaseHandler>(local_state_);
|
||||
detachable_base_notification_controller_ =
|
||||
std::make_unique<DetachableBaseNotificationController>(
|
||||
detachable_base_handler_.get());
|
||||
display_speaker_controller_ = std::make_unique<DisplaySpeakerController>();
|
||||
policy_recommendation_restorer_ =
|
||||
std::make_unique<PolicyRecommendationRestorer>();
|
||||
@ -1725,6 +1721,13 @@ void Shell::Init(
|
||||
system_notification_controller_ =
|
||||
std::make_unique<SystemNotificationController>();
|
||||
|
||||
// They listen to session controller after notification controller.
|
||||
detachable_base_handler_ =
|
||||
std::make_unique<DetachableBaseHandler>(local_state_);
|
||||
detachable_base_notification_controller_ =
|
||||
std::make_unique<DetachableBaseNotificationController>(
|
||||
detachable_base_handler_.get());
|
||||
|
||||
// WmModeController should be created before initializing the window tree
|
||||
// hosts, since the latter will initialize the shelf on each display, which
|
||||
// hosts the WM mode tray button.
|
||||
|
@ -1063,9 +1063,6 @@ class ASH_EXPORT Shell : public SessionObserver,
|
||||
std::unique_ptr<DesksController> desks_controller_;
|
||||
std::unique_ptr<SavedDeskController> saved_desk_controller_;
|
||||
std::unique_ptr<SavedDeskDelegate> saved_desk_delegate_;
|
||||
std::unique_ptr<DetachableBaseHandler> detachable_base_handler_;
|
||||
std::unique_ptr<DetachableBaseNotificationController>
|
||||
detachable_base_notification_controller_;
|
||||
std::unique_ptr<diagnostics::DiagnosticsLogController>
|
||||
diagnostics_log_controller_;
|
||||
std::unique_ptr<DisplayHighlightController> display_highlight_controller_;
|
||||
@ -1150,6 +1147,9 @@ class ASH_EXPORT Shell : public SessionObserver,
|
||||
std::unique_ptr<AcceleratorTracker> accelerator_tracker_;
|
||||
std::unique_ptr<ShutdownControllerImpl> shutdown_controller_;
|
||||
std::unique_ptr<SystemNotificationController> system_notification_controller_;
|
||||
std::unique_ptr<DetachableBaseHandler> detachable_base_handler_;
|
||||
std::unique_ptr<DetachableBaseNotificationController>
|
||||
detachable_base_notification_controller_;
|
||||
std::unique_ptr<SystemNudgePauseManagerImpl> system_nudge_pause_manager_;
|
||||
std::unique_ptr<SystemTrayModel> system_tray_model_;
|
||||
std::unique_ptr<SystemTrayNotifier> system_tray_notifier_;
|
||||
|
@ -95,7 +95,7 @@ TEST_F(AccessibilityFeaturePodControllerTest, ButtonVisibilityNotLoggedIn) {
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityFeaturePodControllerTest, ButtonVisibilityLoggedIn) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
GetPrimaryUnifiedSystemTray()->ShowBubble();
|
||||
auto* tile = views::AsViewClass<FeatureTile>(
|
||||
GetPrimaryUnifiedSystemTray()->bubble()->GetBubbleView()->GetViewByID(
|
||||
|
@ -97,14 +97,14 @@ TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisibilityNotLoggedIn) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisibilityLoggedIn) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpButton();
|
||||
// If logged in, it should be visible.
|
||||
EXPECT_TRUE(IsButtonVisible());
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisibilityLocked) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
BlockUserSession(UserSessionBlockReason::BLOCKED_BY_LOCK_SCREEN);
|
||||
|
||||
// Showing the lock screen closes the system tray bubble, so re-show it before
|
||||
@ -117,7 +117,7 @@ TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisibilityLocked) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisibilityLoginScreen) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
BlockUserSession(UserSessionBlockReason::BLOCKED_BY_LOGIN_SCREEN);
|
||||
SetUpButton();
|
||||
// If the login screen is showing (e.g. multi-user signin), it should not be
|
||||
@ -126,7 +126,7 @@ TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisibilityLoginScreen) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisiblilityHiddenByDelegate) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->set_is_pod_button_visible(false);
|
||||
SetUpButton();
|
||||
// If NearbyShareDelegate::IsPodButtonVisible() returns false, it should
|
||||
@ -136,7 +136,7 @@ TEST_F(NearbyShareFeaturePodControllerTest, ButtonVisiblilityHiddenByDelegate) {
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
ButtonToggledByHighVisibilityEnabledEvent) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpButton();
|
||||
ASSERT_FALSE(IsButtonToggled());
|
||||
nearby_share_controller_->HighVisibilityEnabledChanged(true);
|
||||
@ -146,7 +146,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, ButtonPressTogglesHighVisibility) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpButton();
|
||||
test_delegate_->method_calls().clear();
|
||||
|
||||
@ -164,7 +164,7 @@ TEST_F(NearbyShareFeaturePodControllerTest, ButtonPressTogglesHighVisibility) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, IconUMATracking) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpButton();
|
||||
|
||||
std::string histogram_prefix;
|
||||
@ -193,7 +193,7 @@ TEST_F(NearbyShareFeaturePodControllerTest, IconUMATracking) {
|
||||
}
|
||||
|
||||
TEST_F(NearbyShareFeaturePodControllerTest, ButtonEnabledStateVisibility) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->set_is_enabled(false);
|
||||
SetUpButton();
|
||||
// If NearbyShareDelegate::IsEnabled() returns false, the button should
|
||||
@ -204,7 +204,7 @@ TEST_F(NearbyShareFeaturePodControllerTest, ButtonEnabledStateVisibility) {
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOnYourDevicesVisibility) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
// Default visibility is Your devices.
|
||||
SetUpButton();
|
||||
EXPECT_TRUE(IsButtonToggled());
|
||||
@ -213,7 +213,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOnContactsVisibility) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->set_visibility(
|
||||
::nearby_share::mojom::Visibility::kAllContacts);
|
||||
SetUpButton();
|
||||
@ -223,7 +223,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOnSelectedContactsVisibility) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->set_visibility(
|
||||
::nearby_share::mojom::Visibility::kSelectedContacts);
|
||||
SetUpButton();
|
||||
@ -233,7 +233,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOnHiddenVisibility) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->set_visibility(::nearby_share::mojom::Visibility::kNoOne);
|
||||
SetUpButton();
|
||||
EXPECT_TRUE(IsButtonToggled());
|
||||
@ -242,7 +242,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOn_HighVisibilityEnabled) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->set_is_high_visibility_on(true);
|
||||
SetUpButton();
|
||||
EXPECT_TRUE(IsButtonToggled());
|
||||
@ -251,7 +251,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOn_QuickShareEnabled) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->SetEnabled(true);
|
||||
SetUpButton();
|
||||
EXPECT_TRUE(IsButtonToggled());
|
||||
@ -260,7 +260,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_ButtonToggledOff_QuickShareDisabled) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->SetEnabled(false);
|
||||
SetUpButton();
|
||||
EXPECT_FALSE(IsButtonToggled());
|
||||
@ -269,7 +269,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_IconTogglesButtonOn_QuickShareOn_OnPress) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->SetEnabled(false);
|
||||
SetUpButton();
|
||||
EXPECT_FALSE(IsButtonToggled());
|
||||
@ -282,7 +282,7 @@ TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
TEST_F(NearbyShareFeaturePodControllerTest,
|
||||
QuickShareV2_IconTogglesButtonOff_QuickShareOff_OnPress) {
|
||||
EnableQuickShareV2();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
test_delegate_->SetEnabled(true);
|
||||
SetUpButton();
|
||||
EXPECT_TRUE(IsButtonToggled());
|
||||
|
@ -243,7 +243,7 @@ TEST_F(NetworkListNetworkItemViewTest, HasCorrectCellularSublabel) {
|
||||
IDS_ASH_STATUS_TRAY_NETWORK_STATUS_ACTIVATE_AFTER_DEVICE_SETUP),
|
||||
network_list_network_item_view()->sub_text_label()->GetText());
|
||||
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Label for unactivated eSIM networks.
|
||||
@ -456,7 +456,7 @@ TEST_F(NetworkListNetworkItemViewTest, HasExpectedA11yText) {
|
||||
base::UTF8ToUTF16(kCellularName)),
|
||||
network_list_network_item_view()->GetViewAccessibility().GetCachedName());
|
||||
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Contact carrier A11Y label is shown when a eSIM network is connected but
|
||||
@ -593,7 +593,7 @@ TEST_F(NetworkListNetworkItemViewTest, HasExpectedDescriptionForCellular) {
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_ASH_STATUS_TRAY_NETWORK_STATUS_ACTIVATE_AFTER_DEVICE_SETUP));
|
||||
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
// Cellular is not activated and is an eSIM network.
|
||||
|
@ -296,7 +296,7 @@ TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) {
|
||||
ClearLogin();
|
||||
Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN);
|
||||
EXPECT_FALSE(GetTray()->GetVisible());
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER);
|
||||
EXPECT_TRUE(GetTray()->GetVisible());
|
||||
SetUserAddingScreenRunning(true);
|
||||
|
@ -836,7 +836,7 @@ TEST_F(PowerButtonControllerTest, MenuItemsToLoginAndLockedStatus) {
|
||||
// Should have sign out, lock screen and feedback items if user is logged in
|
||||
// and screen is unlocked.
|
||||
ClearLogin();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
OpenPowerButtonMenu();
|
||||
EXPECT_FALSE(GetLockedState());
|
||||
EXPECT_TRUE(power_button_test_api_->MenuHasSignOutItem());
|
||||
@ -1034,7 +1034,7 @@ TEST_F(PowerButtonControllerTest, MenuNavigation) {
|
||||
TapToDismissPowerButtonMenu();
|
||||
|
||||
ClearLogin();
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
OpenPowerButtonMenu();
|
||||
ASSERT_TRUE(power_button_test_api_->MenuHasSignOutItem());
|
||||
ASSERT_TRUE(power_button_test_api_->MenuHasLockScreenItem());
|
||||
|
@ -109,7 +109,7 @@ void PowerButtonTestBase::Initialize(
|
||||
if (status == LoginStatus::NOT_LOGGED_IN)
|
||||
ClearLogin();
|
||||
else
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
if (status == LoginStatus::GUEST)
|
||||
SetCanLockScreen(false);
|
||||
|
@ -221,7 +221,7 @@ TEST_F(LastWindowClosedTest, RegularSession) {
|
||||
EXPECT_FALSE(controller->dialog_for_testing());
|
||||
|
||||
// Dialog is not visible after login.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_FALSE(controller->dialog_for_testing());
|
||||
|
||||
// Creating and closing a window does not show the dialog because this is not
|
||||
|
@ -183,7 +183,7 @@ TEST_F(SessionLimitNotificationControllerLoginTest,
|
||||
EXPECT_FALSE(GetNotification());
|
||||
|
||||
// Notification is shown after login.
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_TRUE(GetNotification());
|
||||
|
||||
RemoveNotification();
|
||||
@ -196,7 +196,7 @@ TEST_F(SessionLimitNotificationControllerLoginTest,
|
||||
|
||||
// Notification should be absent.
|
||||
UpdateSessionLengthLimitInMin(kNotificationThresholdInMinutes + 10);
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
EXPECT_FALSE(GetNotification());
|
||||
|
||||
RemoveNotification();
|
||||
|
@ -65,7 +65,7 @@ TEST_F(PowerButtonPixelTest, DISABLED_NoSession) {
|
||||
|
||||
// TODO(crbug.com/1451244): Re-enable this test.
|
||||
TEST_F(PowerButtonPixelTest, DISABLED_LoginSession) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
"check_button",
|
||||
@ -79,7 +79,7 @@ TEST_F(PowerButtonPixelTest, DISABLED_LoginSession) {
|
||||
|
||||
// TODO(crbug.com/1451244): Re-enable this test.
|
||||
TEST_F(PowerButtonPixelTest, DISABLED_LockScreenSession) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
|
||||
|
||||
EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen(
|
||||
|
@ -148,7 +148,7 @@ class PowerButtonTest : public NoSessionAshTestBase {
|
||||
// `PowerButton` should be with the correct view id and have the UMA tracking
|
||||
// with the correct catalog name.
|
||||
TEST_F(PowerButtonTest, PowerButtonHasCorrectViewIdAndUma) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// No metrics logged before clicking on any buttons.
|
||||
histogram_tester_.ExpectTotalCount("Ash.QuickSettings.Button.Activated",
|
||||
@ -170,7 +170,9 @@ TEST_F(PowerButtonTest, PowerButtonHasCorrectViewIdAndUma) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, LockMenuButtonRecordsUma) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
// TOOD(crbug.com/383442863): Move this to SimulateUserLogin.
|
||||
GetSessionControllerClient()->SetCanLockScreen(true);
|
||||
SimulatePowerButtonPress();
|
||||
|
||||
LeftClickOn(GetLockButton());
|
||||
@ -184,7 +186,7 @@ TEST_F(PowerButtonTest, LockMenuButtonRecordsUma) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, SignOutMenuButtonRecordsUma) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulatePowerButtonPress();
|
||||
|
||||
LeftClickOn(GetSignOutButton());
|
||||
@ -199,7 +201,7 @@ TEST_F(PowerButtonTest, SignOutMenuButtonRecordsUma) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, RestartMenuButtonRecordsUma) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulatePowerButtonPress();
|
||||
|
||||
LeftClickOn(GetRestartButton());
|
||||
@ -214,7 +216,7 @@ TEST_F(PowerButtonTest, RestartMenuButtonRecordsUma) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, PowerOffMenuButtonRecordsUma) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulatePowerButtonPress();
|
||||
|
||||
LeftClickOn(GetPowerOffButton());
|
||||
@ -228,7 +230,7 @@ TEST_F(PowerButtonTest, PowerOffMenuButtonRecordsUma) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, EmailMenuButtonRecordsUma) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulatePowerButtonPress();
|
||||
|
||||
LeftClickOn(GetEmailButton());
|
||||
@ -269,7 +271,9 @@ TEST_F(PowerButtonTest, ButtonStatesNotLoggedIn) {
|
||||
|
||||
// All buttons are shown after login.
|
||||
TEST_F(PowerButtonTest, ButtonStatesLoggedIn) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
// TOOD(crbug.com/383442863): Move this to SimulateUserLogin.
|
||||
GetSessionControllerClient()->SetCanLockScreen(true);
|
||||
|
||||
EXPECT_TRUE(GetPowerButton()->GetVisible());
|
||||
|
||||
@ -297,7 +301,7 @@ TEST_F(PowerButtonTest, ButtonStatesLoggedIn) {
|
||||
|
||||
// The lock button are hidden at the lock screen.
|
||||
TEST_F(PowerButtonTest, ButtonStatesLockScreen) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
|
||||
|
||||
// Changes in lock state close the system tray bubble, so re-show it.
|
||||
@ -331,7 +335,7 @@ TEST_F(PowerButtonTest, ButtonStatesLockScreen) {
|
||||
|
||||
// The lock button is hidden when adding a second multiprofile user.
|
||||
TEST_F(PowerButtonTest, ButtonStatesAddingUser) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUserAddingScreenRunning(true);
|
||||
|
||||
EXPECT_TRUE(GetPowerButton()->GetVisible());
|
||||
@ -450,7 +454,7 @@ TEST_F(PowerButtonTest, UserItemButtonTooltipText) {
|
||||
// Power button's rounded radii should change correctly when switching between
|
||||
// active/inactive.
|
||||
TEST_F(PowerButtonTest, ButtonRoundedRadii) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// Sets a LTR locale.
|
||||
base::i18n::SetICUDefaultLocale("en_US");
|
||||
@ -483,7 +487,7 @@ TEST_F(PowerButtonTest, ButtonRoundedRadii) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, DeviceRebootOnShutdownPolicyHidesPowerOffButton) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
// Simulate DeviceRebootOnShutdownPolicy is enabled.
|
||||
Shell::Get()->shutdown_controller()->SetRebootOnShutdown(true);
|
||||
|
||||
@ -494,7 +498,7 @@ TEST_F(PowerButtonTest, DeviceRebootOnShutdownPolicyHidesPowerOffButton) {
|
||||
}
|
||||
|
||||
TEST_F(PowerButtonTest, ChevronFlipsWhenMenuIsShowing) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
EXPECT_TRUE(GetPowerButton()->GetVisible());
|
||||
EXPECT_FALSE(IsMenuShowing());
|
||||
|
@ -81,7 +81,9 @@ class QuickSettingsFooterTest : public NoSessionAshTestBase {
|
||||
// Tests that all buttons are with the correct view id, catalog name and UMA
|
||||
// tracking.
|
||||
TEST_F(QuickSettingsFooterTest, ButtonNamesAndUMA) {
|
||||
CreateUserSessions(2);
|
||||
auto primary = SimulateUserLogin(kDefaultUserEmail);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SwitchActiveUser(primary);
|
||||
SetUpView();
|
||||
|
||||
// The number of view id should be the number of catalog name -1, since
|
||||
@ -141,7 +143,7 @@ TEST_F(QuickSettingsFooterTest, ButtonStatesNotLoggedIn) {
|
||||
|
||||
// All buttons are shown after login.
|
||||
TEST_F(QuickSettingsFooterTest, ButtonStatesLoggedIn) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpView();
|
||||
|
||||
EXPECT_FALSE(GetSignOutButton());
|
||||
@ -180,7 +182,7 @@ TEST_F(QuickSettingsFooterTest, ButtonStatesLockScreen) {
|
||||
// Settings button and lock button are hidden when adding a second
|
||||
// multiprofile user.
|
||||
TEST_F(QuickSettingsFooterTest, ButtonStatesAddingUser) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUserAddingScreenRunning(true);
|
||||
SetUpView();
|
||||
|
||||
@ -233,7 +235,7 @@ TEST_F(QuickSettingsFooterTest, ButtonStatesPublicAccount) {
|
||||
|
||||
TEST_F(QuickSettingsFooterTest, SignOutShowsWithMultipleAccounts) {
|
||||
GetSessionControllerClient()->set_existing_users_count(2);
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpView();
|
||||
|
||||
ASSERT_TRUE(GetSignOutButton());
|
||||
@ -252,7 +254,7 @@ TEST_F(QuickSettingsFooterTest, SignOutButtonRecordsUmaAndSignsOut) {
|
||||
}
|
||||
|
||||
GetSessionControllerClient()->set_existing_users_count(2);
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpView();
|
||||
|
||||
base::HistogramTester histogram_tester;
|
||||
@ -285,7 +287,7 @@ TEST_F(QuickSettingsFooterTest, DisableSettingsIconPolicy) {
|
||||
|
||||
// Tests different battery states.
|
||||
TEST_F(QuickSettingsFooterTest, BatteryButtonState) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpView();
|
||||
|
||||
const bool use_smart_charging_ui =
|
||||
@ -313,7 +315,7 @@ TEST_F(QuickSettingsFooterTest, ButtonLayoutNotLoggedIn) {
|
||||
|
||||
// Try to layout buttons after login.
|
||||
TEST_F(QuickSettingsFooterTest, ButtonLayoutLoggedIn) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpView();
|
||||
LayoutFooter();
|
||||
}
|
||||
@ -327,7 +329,7 @@ TEST_F(QuickSettingsFooterTest, ButtonLayoutLockScreen) {
|
||||
|
||||
// Try to layout buttons when adding a second multiprofile user.
|
||||
TEST_F(QuickSettingsFooterTest, ButtonLayoutAddingUser) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUserAddingScreenRunning(true);
|
||||
SetUpView();
|
||||
LayoutFooter();
|
||||
|
@ -78,14 +78,14 @@ TEST_F(QuietModeFeaturePodControllerTest, ButtonVisibilityNotLoggedIn) {
|
||||
}
|
||||
|
||||
TEST_F(QuietModeFeaturePodControllerTest, ButtonVisibilityLoggedIn) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpButton();
|
||||
// If logged in, it should be visible.
|
||||
EXPECT_TRUE(IsButtonVisible());
|
||||
}
|
||||
|
||||
TEST_F(QuietModeFeaturePodControllerTest, ButtonVisibilityLocked) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
BlockUserSession(UserSessionBlockReason::BLOCKED_BY_LOCK_SCREEN);
|
||||
SetUpButton();
|
||||
// If locked, it should not be visible.
|
||||
@ -93,7 +93,7 @@ TEST_F(QuietModeFeaturePodControllerTest, ButtonVisibilityLocked) {
|
||||
}
|
||||
|
||||
TEST_F(QuietModeFeaturePodControllerTest, IconUMATracking) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
SetUpButton();
|
||||
message_center::MessageCenter::Get()->SetQuietMode(false);
|
||||
|
||||
@ -135,7 +135,7 @@ TEST_F(QuietModeFeaturePodControllerTest, IconUMATracking) {
|
||||
}
|
||||
|
||||
TEST_F(QuietModeFeaturePodControllerTest, ToggledState) {
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
|
||||
// Do not disturb is initially off, button is not toggled.
|
||||
SetUpButton();
|
||||
|
@ -427,13 +427,11 @@ AmbientAshTestHelper* AshTestBase::GetAmbientAshTestHelper() {
|
||||
return ash_test_helper_->ambient_ash_test_helper();
|
||||
}
|
||||
|
||||
void AshTestBase::CreateUserSessions(int n) {
|
||||
GetSessionControllerClient()->CreatePredefinedUserSessions(n);
|
||||
}
|
||||
|
||||
void AshTestBase::SimulateUserLogin(const std::string& user_email,
|
||||
user_manager::UserType user_type) {
|
||||
SimulateUserLogin(AccountId::FromUserEmail(user_email), user_type);
|
||||
AccountId AshTestBase::SimulateUserLogin(const std::string& user_email,
|
||||
user_manager::UserType user_type) {
|
||||
auto account_id = AccountId::FromUserEmail(user_email);
|
||||
SimulateUserLogin(account_id, user_type);
|
||||
return account_id;
|
||||
}
|
||||
|
||||
void AshTestBase::SimulateUserLogin(const AccountId& account_id,
|
||||
@ -441,10 +439,13 @@ void AshTestBase::SimulateUserLogin(const AccountId& account_id,
|
||||
ash_test_helper_->SimulateUserLogin(account_id, user_type);
|
||||
}
|
||||
|
||||
void AshTestBase::SimulateNewUserFirstLogin(const std::string& user_email) {
|
||||
ash_test_helper_->SimulateUserLogin(AccountId::FromUserEmail(user_email),
|
||||
AccountId AshTestBase::SimulateNewUserFirstLogin(
|
||||
const std::string& user_email) {
|
||||
auto account_id = AccountId::FromUserEmail(user_email);
|
||||
ash_test_helper_->SimulateUserLogin(account_id,
|
||||
user_manager::UserType::kRegular,
|
||||
/*is_new_profile=*/true);
|
||||
return account_id;
|
||||
}
|
||||
|
||||
void AshTestBase::SimulateGuestLogin() {
|
||||
@ -460,6 +461,14 @@ void AshTestBase::SimulateKioskMode(user_manager::UserType user_type) {
|
||||
SimulateUserLogin(AccountId::FromUserEmail(kKioskUserEmail), user_type);
|
||||
}
|
||||
|
||||
void AshTestBase::SwitchActiveUser(const AccountId& account_id) {
|
||||
Shell::Get()->session_controller()->SwitchActiveUser(account_id);
|
||||
}
|
||||
|
||||
bool AshTestBase::IsInSessionState(session_manager::SessionState state) const {
|
||||
return Shell::Get()->session_controller()->GetSessionState() == state;
|
||||
}
|
||||
|
||||
void AshTestBase::SetAccessibilityPanelHeight(int panel_height) {
|
||||
Shell::GetPrimaryRootWindowController()
|
||||
->GetAccessibilityPanelLayoutManagerForTest()
|
||||
@ -488,7 +497,6 @@ void AshTestBase::SetUserAddingScreenRunning(bool user_adding_screen_running) {
|
||||
void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) {
|
||||
switch (block_reason) {
|
||||
case BLOCKED_BY_LOCK_SCREEN:
|
||||
CreateUserSessions(1);
|
||||
GetSessionControllerClient()->LockScreen();
|
||||
break;
|
||||
case BLOCKED_BY_LOGIN_SCREEN:
|
||||
@ -503,7 +511,6 @@ void AshTestBase::BlockUserSession(UserSessionBlockReason block_reason) {
|
||||
}
|
||||
|
||||
void AshTestBase::UnblockUserSession() {
|
||||
CreateUserSessions(1);
|
||||
GetSessionControllerClient()->UnlockScreen();
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,8 @@ class TestSystemTrayClient;
|
||||
class UnifiedSystemTray;
|
||||
class WorkAreaInsets;
|
||||
|
||||
inline constexpr std::string kDefaultUserEmail = "user0@tray";
|
||||
|
||||
// Base class for most tests in //ash. Constructs ash::Shell and all its
|
||||
// dependencies. Provides a user login session (use NoSessionAshTestBase for
|
||||
// tests that start at the login screen or need unusual user types). Sets
|
||||
@ -310,18 +312,15 @@ class AshTestBase : public testing::Test {
|
||||
|
||||
AmbientAshTestHelper* GetAmbientAshTestHelper();
|
||||
|
||||
// Emulates an ash session that have |session_count| user sessions running.
|
||||
// Note that existing user sessions will be cleared.
|
||||
void CreateUserSessions(int session_count);
|
||||
|
||||
// Simulates a user sign-in. It creates a new user session, adds it to
|
||||
// existing user sessions and makes it the active user session.
|
||||
// Simulates a user sign-in, and returns an AccountId used to sign in. It
|
||||
// creates a new user session, adds it to existing user sessions and makes it
|
||||
// the active user session.
|
||||
//
|
||||
// For convenience |user_email| is used to create an |AccountId|. For testing
|
||||
// behavior where |AccountId|s are compared, prefer the method of the same
|
||||
// name that takes an |AccountId| created with a valid storage key instead.
|
||||
// See the documentation for|AccountId::GetUserEmail| for discussion.
|
||||
void SimulateUserLogin(
|
||||
AccountId SimulateUserLogin(
|
||||
const std::string& user_email,
|
||||
user_manager::UserType user_type = user_manager::UserType::kRegular);
|
||||
|
||||
@ -332,7 +331,7 @@ class AshTestBase : public testing::Test {
|
||||
user_manager::UserType user_type = user_manager::UserType::kRegular);
|
||||
|
||||
// Simular to SimulateUserLogin but for a newly created user first ever login.
|
||||
void SimulateNewUserFirstLogin(const std::string& user_email);
|
||||
AccountId SimulateNewUserFirstLogin(const std::string& user_email);
|
||||
|
||||
// Similar to SimulateUserLogin but for a guest user.
|
||||
void SimulateGuestLogin();
|
||||
@ -340,6 +339,12 @@ class AshTestBase : public testing::Test {
|
||||
// Simulates kiosk mode. |user_type| must correlate to a kiosk type user.
|
||||
void SimulateKioskMode(user_manager::UserType user_type);
|
||||
|
||||
// Switches the active user to `account_id`;
|
||||
void SwitchActiveUser(const AccountId& account_id);
|
||||
|
||||
// Returns true if the session is in `state`.
|
||||
bool IsInSessionState(session_manager::SessionState state) const;
|
||||
|
||||
// Simulates setting height of the accessibility panel.
|
||||
// Note: Accessibility panel widget needs to be setup first.
|
||||
void SetAccessibilityPanelHeight(int panel_height);
|
||||
@ -358,6 +363,7 @@ class AshTestBase : public testing::Test {
|
||||
|
||||
// Methods to emulate blocking and unblocking user session with given
|
||||
// |block_reason|.
|
||||
// TODO(crbug.com/383770001): Deprecate these methods.
|
||||
void BlockUserSession(UserSessionBlockReason block_reason);
|
||||
void UnblockUserSession();
|
||||
|
||||
|
@ -398,9 +398,6 @@ void AshTestHelper::SetUp(InitParams init_params) {
|
||||
session_controller_client_ = std::make_unique<TestSessionControllerClient>(
|
||||
shell->session_controller(), prefs_provider_.get());
|
||||
session_controller_client_->InitializeAndSetClient();
|
||||
if (init_params.start_session) {
|
||||
session_controller_client_->CreatePredefinedUserSessions(1);
|
||||
}
|
||||
|
||||
// Requires the AppListController the Shell creates.
|
||||
app_list_test_helper_ = std::make_unique<AppListTestHelper>();
|
||||
@ -408,6 +405,21 @@ void AshTestHelper::SetUp(InitParams init_params) {
|
||||
Shell::GetPrimaryRootWindow()->Show();
|
||||
Shell::GetPrimaryRootWindow()->GetHost()->Show();
|
||||
|
||||
// Sign-in after UI is shown.
|
||||
if (init_params.start_session) {
|
||||
// TODO(crbug.com/383441831): Remove Reset();
|
||||
session_controller_client_->Reset();
|
||||
|
||||
auto account_id = AccountId::FromUserEmail("user0@tray");
|
||||
// TODO((crbug.com/383441831): Use SimulateUserLogin.
|
||||
session_controller_client_->AddUserSession(
|
||||
account_id, account_id.GetUserEmail(),
|
||||
user_manager::UserType::kRegular);
|
||||
session_controller_client_->SwitchActiveUser(account_id);
|
||||
session_controller_client_->SetSessionState(
|
||||
session_manager::SessionState::ACTIVE);
|
||||
}
|
||||
|
||||
// Don't change the display size due to host size resize.
|
||||
display::test::DisplayManagerTestApi(shell->display_manager())
|
||||
.DisableChangeDisplayUponHostResize();
|
||||
|
@ -148,7 +148,7 @@ class MahiManagerImplTest : public NoSessionAshTestBase {
|
||||
mahi_manager_impl_ = std::make_unique<MahiManagerImpl>();
|
||||
mahi_manager_impl_->mahi_provider_ = CreateMahiProvider();
|
||||
|
||||
CreateUserSessions(1);
|
||||
SimulateUserLogin(kDefaultUserEmail);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
@ -34,7 +34,9 @@
|
||||
class AssistantBrowserDelegateImplTest : public ChromeAshTestBase {
|
||||
public:
|
||||
AssistantBrowserDelegateImplTest()
|
||||
: fake_user_manager_(std::make_unique<ash::FakeChromeUserManager>()) {}
|
||||
: fake_user_manager_(std::make_unique<ash::FakeChromeUserManager>()) {
|
||||
set_start_session(false);
|
||||
}
|
||||
~AssistantBrowserDelegateImplTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
@ -46,7 +48,6 @@ class AssistantBrowserDelegateImplTest : public ChromeAshTestBase {
|
||||
auto* user = fake_user_manager_->AddUser(account_id);
|
||||
fake_user_manager_->LoginUser(account_id);
|
||||
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
SimulateUserLogin(account_id);
|
||||
|
||||
ash::ProfileHelper::Get()->SetUserToProfileMappingForTesting(
|
||||
|
@ -20,7 +20,9 @@
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
ChromeQuickAnswersTestBase::ChromeQuickAnswersTestBase() = default;
|
||||
ChromeQuickAnswersTestBase::ChromeQuickAnswersTestBase() {
|
||||
set_start_session(false);
|
||||
}
|
||||
|
||||
ChromeQuickAnswersTestBase::~ChromeQuickAnswersTestBase() = default;
|
||||
|
||||
@ -38,11 +40,11 @@ void ChromeQuickAnswersTestBase::SetUp() {
|
||||
GetFakeUserManager()->AddUser(account_id);
|
||||
GetFakeUserManager()->LoginUser(account_id);
|
||||
|
||||
SimulateUserLogin(account_id);
|
||||
|
||||
SetUpInitialPrefValues();
|
||||
quick_answers_controller_ =
|
||||
CreateQuickAnswersControllerImpl(read_write_cards_ui_controller_);
|
||||
|
||||
CreateUserSessions(/*session_count=*/1);
|
||||
}
|
||||
|
||||
void ChromeQuickAnswersTestBase::TearDown() {
|
||||
|
@ -1183,7 +1183,9 @@ TEST_F(KeyboardTest, KeyRepeatSettingsUpdateAtRuntime) {
|
||||
|
||||
TEST_F(KeyboardTest, KeyRepeatSettingsIgnoredForNonActiveUser) {
|
||||
// Simulate two users, with the first user as active.
|
||||
CreateUserSessions(2);
|
||||
auto active_account_id = SimulateUserLogin("user0@gmail.com");
|
||||
auto inactive_account_id = SimulateUserLogin("user1@gmail.com");
|
||||
SwitchActiveUser(active_account_id);
|
||||
|
||||
// Key repeat settings should be sent exactly once, for the default values.
|
||||
auto delegate = std::make_unique<NiceMockKeyboardDelegate>();
|
||||
@ -1198,7 +1200,7 @@ TEST_F(KeyboardTest, KeyRepeatSettingsIgnoredForNonActiveUser) {
|
||||
EXPECT_CALL(*delegate_ptr,
|
||||
OnKeyRepeatSettingsChanged(testing::_, testing::_, testing::_))
|
||||
.Times(0);
|
||||
const std::string email = "user1@tray";
|
||||
const auto email = inactive_account_id.GetUserEmail();
|
||||
SetUserPref(email, ash::prefs::kXkbAutoRepeatEnabled, base::Value(true));
|
||||
SetUserPref(email, ash::prefs::kXkbAutoRepeatDelay, base::Value(1000));
|
||||
SetUserPref(email, ash::prefs::kXkbAutoRepeatInterval, base::Value(1000));
|
||||
@ -1207,10 +1209,12 @@ TEST_F(KeyboardTest, KeyRepeatSettingsIgnoredForNonActiveUser) {
|
||||
|
||||
TEST_F(KeyboardTest, KeyRepeatSettingsUpdateOnProfileChange) {
|
||||
// Simulate two users, with the first user as active.
|
||||
CreateUserSessions(2);
|
||||
auto active_account_id = SimulateUserLogin("user0@gmail.com");
|
||||
auto inactive_account_id = SimulateUserLogin("user1@gmail.com");
|
||||
SwitchActiveUser(active_account_id);
|
||||
|
||||
// Second user has different preferences.
|
||||
std::string email = "user1@tray";
|
||||
std::string email = inactive_account_id.GetUserEmail();
|
||||
SetUserPref(email, ash::prefs::kXkbAutoRepeatEnabled, base::Value(true));
|
||||
SetUserPref(email, ash::prefs::kXkbAutoRepeatDelay, base::Value(1000));
|
||||
SetUserPref(email, ash::prefs::kXkbAutoRepeatInterval, base::Value(1000));
|
||||
|
Reference in New Issue
Block a user