From bab45fafd8ebf52c66d5369b1d7aa2a3f98fc1fb Mon Sep 17 00:00:00 2001 From: Avery Musbach Date: Tue, 3 Sep 2019 17:13:57 +0000 Subject: [PATCH] multi user: Do not end overview mode if you cancel switching users Overview mode shall not end if you start to switch users during screen casting/sharing but then decline the confirmation dialog. Test: manual Bug: 999691 Change-Id: Id2f6138b3e67f16cc0bb932a3ed4e009f55c7cc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1779175 Reviewed-by: Ahmed Fakhry Commit-Queue: Avery Musbach Cr-Commit-Position: refs/heads/master@{#692693} --- ash/multi_user/user_switch_animator.cc | 2 ++ ash/session/session_controller_impl.cc | 4 ---- .../session_controller_impl_unittest.cc | 21 ------------------- ash/wm/desks/desks_unittests.cc | 10 +++++++++ 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/ash/multi_user/user_switch_animator.cc b/ash/multi_user/user_switch_animator.cc index e12c83107f362a..c462d6528a8103 100644 --- a/ash/multi_user/user_switch_animator.cc +++ b/ash/multi_user/user_switch_animator.cc @@ -9,6 +9,7 @@ #include "ash/shell.h" #include "ash/wallpaper/wallpaper_controller_impl.h" #include "ash/wm/mru_window_tracker.h" +#include "ash/wm/overview/overview_controller.h" #include "ash/wm/window_positioner.h" #include "base/bind.h" #include "ui/aura/client/aura_constants.h" @@ -89,6 +90,7 @@ UserSwitchAnimator::UserSwitchAnimator(MultiUserWindowManagerImpl* owner, animation_step_(ANIMATION_STEP_HIDE_OLD_USER), screen_cover_(GetScreenCover(NULL)), windows_by_account_id_() { + Shell::Get()->overview_controller()->EndOverview(); BuildUserToWindowsListMap(); AdvanceUserTransitionAnimation(); diff --git a/ash/session/session_controller_impl.cc b/ash/session/session_controller_impl.cc index 72479d8927087d..7de40e2f8ded99 100644 --- a/ash/session/session_controller_impl.cc +++ b/ash/session/session_controller_impl.cc @@ -22,7 +22,6 @@ #include "ash/system/screen_security/screen_switch_check_controller.h" #include "ash/wm/lock_state_controller.h" #include "ash/wm/mru_window_tracker.h" -#include "ash/wm/overview/overview_controller.h" #include "ash/wm/window_state.h" #include "ash/wm/window_util.h" #include "ash/wm/wm_event.h" @@ -425,9 +424,6 @@ void SessionControllerImpl::SetSessionLengthLimit(base::TimeDelta length_limit, void SessionControllerImpl::CanSwitchActiveUser( CanSwitchActiveUserCallback callback) { - // Cancel overview mode when switching user profiles. - Shell::Get()->overview_controller()->EndOverview(); - ash::Shell::Get() ->screen_switch_check_controller() ->CanSwitchAwayFromActiveUser(std::move(callback)); diff --git a/ash/session/session_controller_impl_unittest.cc b/ash/session/session_controller_impl_unittest.cc index 1f49f738c59737..ce36ef13b3d9ae 100644 --- a/ash/session/session_controller_impl_unittest.cc +++ b/ash/session/session_controller_impl_unittest.cc @@ -16,7 +16,6 @@ #include "ash/shell.h" #include "ash/system/tray/system_tray_notifier.h" #include "ash/test/ash_test_base.h" -#include "ash/wm/overview/overview_controller.h" #include "ash/wm/window_util.h" #include "base/bind.h" #include "base/callback.h" @@ -612,14 +611,6 @@ class CanSwitchUserTest : public AshTestBase { switch_callback_hit_count_++; } - // Methods needed to test with overview mode. - bool StartOverview() { - return Shell::Get()->overview_controller()->StartOverview(); - } - bool InOverviewSession() const { - return Shell::Get()->overview_controller()->InOverviewSession(); - } - // Various counter accessors. int stop_capture_callback_hit_count() const { return stop_capture_callback_hit_count_; @@ -766,18 +757,6 @@ TEST_F(CanSwitchUserTest, BothActiveAccepted) { EXPECT_EQ(1, stop_share_callback_hit_count()); } -// Test that overview mode is dismissed before switching user profile. -TEST_F(CanSwitchUserTest, OverviewModeDismissed) { - EXPECT_EQ(0, switch_callback_hit_count()); - gfx::Rect bounds(0, 0, 100, 100); - std::unique_ptr w(CreateTestWindowInShellWithBounds(bounds)); - ASSERT_TRUE(StartOverview()); - ASSERT_TRUE(InOverviewSession()); - SwitchUser(CanSwitchUserTest::NO_DIALOG); - ASSERT_FALSE(InOverviewSession()); - EXPECT_EQ(1, switch_callback_hit_count()); -} - using SessionControllerImplUnblockTest = NoSessionAshTestBase; TEST_F(SessionControllerImplUnblockTest, ActiveWindowAfterUnblocking) { diff --git a/ash/wm/desks/desks_unittests.cc b/ash/wm/desks/desks_unittests.cc index 173ac35fafe8cd..5fb53f8a89713e 100644 --- a/ash/wm/desks/desks_unittests.cc +++ b/ash/wm/desks/desks_unittests.cc @@ -37,6 +37,7 @@ #include "ash/wm/workspace_controller.h" #include "base/stl_util.h" #include "base/test/scoped_feature_list.h" +#include "components/session_manager/session_manager_types.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/client/window_parenting_client.h" #include "ui/base/ui_base_types.h" @@ -1930,6 +1931,7 @@ class DesksMultiUserTest : public NoSessionAshTestBase, MultiUserWindowManager::Create(this, GetUser1AccountId()); MultiUserWindowManagerImpl::Get()->SetAnimationSpeedForTest( MultiUserWindowManagerImpl::ANIMATION_SPEED_DISABLED); + session_controller->SetSessionState(session_manager::SessionState::ACTIVE); } void TearDown() override { @@ -2115,6 +2117,14 @@ TEST_F(DesksMultiUserTest, RemoveDesks) { EXPECT_TRUE(win6->IsVisible()); } +TEST_F(DesksMultiUserTest, SwitchingUsersEndsOverview) { + OverviewController* overview_controller = Shell::Get()->overview_controller(); + EXPECT_TRUE(overview_controller->StartOverview()); + EXPECT_TRUE(overview_controller->InOverviewSession()); + SwitchActiveUser(GetUser2AccountId()); + EXPECT_FALSE(overview_controller->InOverviewSession()); +} + } // namespace // Simulates the same behavior of event rewriting that key presses go through.