diff options
author | dzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-24 21:49:35 +0000 |
---|---|---|
committer | dzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-24 21:49:35 +0000 |
commit | a44afbbd411d54328b3b71fa67816a8505773f10 (patch) | |
tree | d54a5bca07a91b5c81a060aa6bf75918b074b55d /ash/wm/system_modal_container_layout_manager_unittest.cc | |
parent | 7b0ac436fb788c3ac0709eac560e1a8cda278668 (diff) | |
download | chromium_src-a44afbbd411d54328b3b71fa67816a8505773f10.zip chromium_src-a44afbbd411d54328b3b71fa67816a8505773f10.tar.gz chromium_src-a44afbbd411d54328b3b71fa67816a8505773f10.tar.bz2 |
Modal window in user session not blocks user adding screen.
Added IsUserSessionBlocked method indicating whether user session blocked by
some overlying UI (it can be lock/login/user adding UI).
Replaced IsScreenLocked() [|| IsActiveUserSessionStarted()] with
IsUserSessionBlocked() in several places in order to keep focus and user input
in locked container.
BUG=none
TEST=ash_unittests
R=sky
Review URL: https://chromiumcodereview.appspot.com/19945004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/wm/system_modal_container_layout_manager_unittest.cc')
-rw-r--r-- | ash/wm/system_modal_container_layout_manager_unittest.cc | 115 |
1 files changed, 60 insertions, 55 deletions
diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc index 35891ef..52643f4 100644 --- a/ash/wm/system_modal_container_layout_manager_unittest.cc +++ b/ash/wm/system_modal_container_layout_manager_unittest.cc @@ -311,33 +311,34 @@ TEST_F(SystemModalContainerLayoutManagerTest, EventFocusContainers) { e1.ClickLeftButton(); EXPECT_EQ(1, transient_delegate->mouse_presses()); - // Create a window in the lock screen container and ensure that it receives - // the mouse event instead of the modal window (crbug.com/110920). - Shell::GetInstance()->session_state_delegate()->LockScreen(); - EventTestWindow* lock_delegate = new EventTestWindow(false); - scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent( - Shell::GetPrimaryRootWindowController()->GetContainer( - ash::internal::kShellWindowId_LockScreenContainer))); - EXPECT_TRUE(wm::IsActiveWindow(lock.get())); - e1.ClickLeftButton(); - EXPECT_EQ(1, lock_delegate->mouse_presses()); - - // Make sure that a modal container created by the lock screen can still - // receive mouse events. - EventTestWindow* lock_modal_delegate = new EventTestWindow(true); - aura::Window* lock_modal = - lock_modal_delegate->OpenTestWindowWithParent(lock.get()); - EXPECT_TRUE(wm::IsActiveWindow(lock_modal)); - e1.ClickLeftButton(); - EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); - - // Verify that none of the other containers received any more mouse presses. - EXPECT_EQ(1, main_delegate->mouse_presses()); - EXPECT_EQ(1, transient_delegate->mouse_presses()); - EXPECT_EQ(1, lock_delegate->mouse_presses()); - EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); - - Shell::GetInstance()->session_state_delegate()->UnlockScreen(); + for (int block_reason = FIRST_BLOCK_REASON; + block_reason < NUMBER_OF_BLOCK_REASONS; + ++block_reason) { + // Create a window in the lock screen container and ensure that it receives + // the mouse event instead of the modal window (crbug.com/110920). + BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); + EventTestWindow* lock_delegate = new EventTestWindow(false); + scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent( + Shell::GetPrimaryRootWindowController()->GetContainer( + ash::internal::kShellWindowId_LockScreenContainer))); + EXPECT_TRUE(wm::IsActiveWindow(lock.get())); + e1.ClickLeftButton(); + EXPECT_EQ(1, lock_delegate->mouse_presses()); + + // Make sure that a modal container created by the lock screen can still + // receive mouse events. + EventTestWindow* lock_modal_delegate = new EventTestWindow(true); + aura::Window* lock_modal = + lock_modal_delegate->OpenTestWindowWithParent(lock.get()); + EXPECT_TRUE(wm::IsActiveWindow(lock_modal)); + e1.ClickLeftButton(); + // Verify that none of the other containers received any more mouse presses. + EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); + EXPECT_EQ(1, lock_delegate->mouse_presses()); + EXPECT_EQ(1, main_delegate->mouse_presses()); + EXPECT_EQ(1, transient_delegate->mouse_presses()); + UnblockUserSession(); + } } // Makes sure we don't crash if a modal window is shown while the parent window @@ -407,34 +408,38 @@ TEST_F(SystemModalContainerLayoutManagerTest, ShowNormalBackgroundOrLocked) { EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); - // Normal system modal window while locked. Shows locked system modal - // background. - Shell::GetInstance()->session_state_delegate()->LockScreen(); - scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent( - Shell::GetPrimaryRootWindowController()->GetContainer( - ash::internal::kShellWindowId_LockScreenContainer), - false)); - scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent( - lock_parent.get(), true)); - lock_parent->Show(); - lock_modal_window->Show(); - EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); - EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds()); - TestWindow::CloseTestWindow(lock_modal_window.release()); - - // Normal system modal window while locked, but it belongs to the normal - // window. Shouldn't show locked system modal background, but normal. - scoped_ptr<aura::Window> modal_window2( - OpenTestWindowWithParent(parent.get(), true)); - modal_window2->Show(); - EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); - EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); - TestWindow::CloseTestWindow(modal_window2.release()); - - // Here we should check the behavior of the locked system modal dialog when - // unlocked, but such case isn't handled very well right now. - // See crbug.com/157660 - // TODO(mukai): add the test case when the bug is fixed. + for (int block_reason = FIRST_BLOCK_REASON; + block_reason < NUMBER_OF_BLOCK_REASONS; + ++block_reason) { + // Normal system modal window while blocked. Shows blocked system modal + // background. + BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); + scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent( + Shell::GetPrimaryRootWindowController()->GetContainer( + ash::internal::kShellWindowId_LockScreenContainer), + false)); + scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent( + lock_parent.get(), true)); + lock_parent->Show(); + lock_modal_window->Show(); + EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); + EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds()); + TestWindow::CloseTestWindow(lock_modal_window.release()); + + // Normal system modal window while blocked, but it belongs to the normal + // window. Shouldn't show blocked system modal background, but normal. + scoped_ptr<aura::Window> modal_window( + OpenTestWindowWithParent(parent.get(), true)); + modal_window->Show(); + EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); + EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); + TestWindow::CloseTestWindow(modal_window.release()); + UnblockUserSession(); + // Here we should check the behavior of the locked system modal dialog when + // unlocked, but such case isn't handled very well right now. + // See crbug.com/157660 + // TODO(mukai): add the test case when the bug is fixed. + } } TEST_F(SystemModalContainerLayoutManagerTest, MultiDisplays) { |