Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: ash/wm/system_modal_container_layout_manager_unittest.cc

Issue 19945004: Modal window in user session not blocks user adding screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compilation for win. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/system_modal_container_layout_manager.h" 5 #include "ash/wm/system_modal_container_layout_manager.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/session_state_delegate.h" 8 #include "ash/session_state_delegate.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 // Create a modal window for the main window and verify that the main window 305 // Create a modal window for the main window and verify that the main window
306 // no longer receives mouse events. 306 // no longer receives mouse events.
307 EventTestWindow* transient_delegate = new EventTestWindow(true); 307 EventTestWindow* transient_delegate = new EventTestWindow(true);
308 aura::Window* transient = 308 aura::Window* transient =
309 transient_delegate->OpenTestWindowWithParent(main.get()); 309 transient_delegate->OpenTestWindowWithParent(main.get());
310 EXPECT_TRUE(wm::IsActiveWindow(transient)); 310 EXPECT_TRUE(wm::IsActiveWindow(transient));
311 e1.ClickLeftButton(); 311 e1.ClickLeftButton();
312 EXPECT_EQ(1, transient_delegate->mouse_presses()); 312 EXPECT_EQ(1, transient_delegate->mouse_presses());
313 313
314 // Create a window in the lock screen container and ensure that it receives 314 for (int block_reason = FIRST_BLOCK_REASON;
315 // the mouse event instead of the modal window (crbug.com/110920). 315 block_reason < NUMBER_OF_BLOCK_REASONS;
316 Shell::GetInstance()->session_state_delegate()->LockScreen(); 316 ++block_reason) {
317 EventTestWindow* lock_delegate = new EventTestWindow(false); 317 // Create a window in the lock screen container and ensure that it receives
318 scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent( 318 // the mouse event instead of the modal window (crbug.com/110920).
319 Shell::GetPrimaryRootWindowController()->GetContainer( 319 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
320 ash::internal::kShellWindowId_LockScreenContainer))); 320 EventTestWindow* lock_delegate = new EventTestWindow(false);
321 EXPECT_TRUE(wm::IsActiveWindow(lock.get())); 321 scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent(
322 e1.ClickLeftButton(); 322 Shell::GetPrimaryRootWindowController()->GetContainer(
323 EXPECT_EQ(1, lock_delegate->mouse_presses()); 323 ash::internal::kShellWindowId_LockScreenContainer)));
324 EXPECT_TRUE(wm::IsActiveWindow(lock.get()));
325 e1.ClickLeftButton();
326 EXPECT_EQ(1, lock_delegate->mouse_presses());
324 327
325 // Make sure that a modal container created by the lock screen can still 328 // Make sure that a modal container created by the lock screen can still
326 // receive mouse events. 329 // receive mouse events.
327 EventTestWindow* lock_modal_delegate = new EventTestWindow(true); 330 EventTestWindow* lock_modal_delegate = new EventTestWindow(true);
328 aura::Window* lock_modal = 331 aura::Window* lock_modal =
329 lock_modal_delegate->OpenTestWindowWithParent(lock.get()); 332 lock_modal_delegate->OpenTestWindowWithParent(lock.get());
330 EXPECT_TRUE(wm::IsActiveWindow(lock_modal)); 333 EXPECT_TRUE(wm::IsActiveWindow(lock_modal));
331 e1.ClickLeftButton(); 334 e1.ClickLeftButton();
332 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); 335 // Verify that none of the other containers received any more mouse presses.
333 336 EXPECT_EQ(1, lock_modal_delegate->mouse_presses());
334 // Verify that none of the other containers received any more mouse presses. 337 EXPECT_EQ(1, lock_delegate->mouse_presses());
335 EXPECT_EQ(1, main_delegate->mouse_presses()); 338 EXPECT_EQ(1, main_delegate->mouse_presses());
336 EXPECT_EQ(1, transient_delegate->mouse_presses()); 339 EXPECT_EQ(1, transient_delegate->mouse_presses());
337 EXPECT_EQ(1, lock_delegate->mouse_presses()); 340 UnblockUserSession();
338 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); 341 }
339
340 Shell::GetInstance()->session_state_delegate()->UnlockScreen();
341 } 342 }
342 343
343 // Makes sure we don't crash if a modal window is shown while the parent window 344 // Makes sure we don't crash if a modal window is shown while the parent window
344 // is hidden. 345 // is hidden.
345 TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) { 346 TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) {
346 // Hide the lock screen. 347 // Hide the lock screen.
347 Shell::GetPrimaryRootWindowController()->GetContainer( 348 Shell::GetPrimaryRootWindowController()->GetContainer(
348 internal::kShellWindowId_SystemModalContainer)->layer()->SetOpacity(0); 349 internal::kShellWindowId_SystemModalContainer)->layer()->SetOpacity(0);
349 350
350 // Create a modal window. 351 // Create a modal window.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 401
401 // Normal system modal window. Shows normal system modal background and not 402 // Normal system modal window. Shows normal system modal background and not
402 // locked. 403 // locked.
403 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); 404 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
404 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); 405 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
405 406
406 TestWindow::CloseTestWindow(modal_window.release()); 407 TestWindow::CloseTestWindow(modal_window.release());
407 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); 408 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
408 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); 409 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
409 410
410 // Normal system modal window while locked. Shows locked system modal 411 for (int block_reason = FIRST_BLOCK_REASON;
411 // background. 412 block_reason < NUMBER_OF_BLOCK_REASONS;
412 Shell::GetInstance()->session_state_delegate()->LockScreen(); 413 ++block_reason) {
413 scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent( 414 // Normal system modal window while blocked. Shows blocked system modal
414 Shell::GetPrimaryRootWindowController()->GetContainer( 415 // background.
415 ash::internal::kShellWindowId_LockScreenContainer), 416 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
416 false)); 417 scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent(
417 scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent( 418 Shell::GetPrimaryRootWindowController()->GetContainer(
418 lock_parent.get(), true)); 419 ash::internal::kShellWindowId_LockScreenContainer),
419 lock_parent->Show(); 420 false));
420 lock_modal_window->Show(); 421 scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent(
421 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); 422 lock_parent.get(), true));
422 EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds()); 423 lock_parent->Show();
423 TestWindow::CloseTestWindow(lock_modal_window.release()); 424 lock_modal_window->Show();
425 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
426 EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds());
427 TestWindow::CloseTestWindow(lock_modal_window.release());
424 428
425 // Normal system modal window while locked, but it belongs to the normal 429 // Normal system modal window while blocked, but it belongs to the normal
426 // window. Shouldn't show locked system modal background, but normal. 430 // window. Shouldn't show blocked system modal background, but normal.
427 scoped_ptr<aura::Window> modal_window2( 431 scoped_ptr<aura::Window> modal_window(
428 OpenTestWindowWithParent(parent.get(), true)); 432 OpenTestWindowWithParent(parent.get(), true));
429 modal_window2->Show(); 433 modal_window->Show();
430 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); 434 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
431 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); 435 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
432 TestWindow::CloseTestWindow(modal_window2.release()); 436 TestWindow::CloseTestWindow(modal_window.release());
433 437 UnblockUserSession();
434 // Here we should check the behavior of the locked system modal dialog when 438 // Here we should check the behavior of the locked system modal dialog when
435 // unlocked, but such case isn't handled very well right now. 439 // unlocked, but such case isn't handled very well right now.
436 // See crbug.com/157660 440 // See crbug.com/157660
437 // TODO(mukai): add the test case when the bug is fixed. 441 // TODO(mukai): add the test case when the bug is fixed.
442 }
438 } 443 }
439 444
440 TEST_F(SystemModalContainerLayoutManagerTest, MultiDisplays) { 445 TEST_F(SystemModalContainerLayoutManagerTest, MultiDisplays) {
441 if (!SupportsMultipleDisplays()) 446 if (!SupportsMultipleDisplays())
442 return; 447 return;
443 448
444 UpdateDisplay("500x500,500x500"); 449 UpdateDisplay("500x500,500x500");
445 450
446 scoped_ptr<aura::Window> normal(OpenToplevelTestWindow(false)); 451 scoped_ptr<aura::Window> normal(OpenToplevelTestWindow(false));
447 normal->SetBounds(gfx::Rect(100, 100, 50, 50)); 452 normal->SetBounds(gfx::Rect(100, 100, 50, 50));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 494
490 // No more modal screen. 495 // No more modal screen.
491 modal1->Hide(); 496 modal1->Hide();
492 TestWindow::CloseTestWindow(modal1.release()); 497 TestWindow::CloseTestWindow(modal1.release());
493 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); 498 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
494 EXPECT_TRUE(wm::IsActiveWindow(normal.get())); 499 EXPECT_TRUE(wm::IsActiveWindow(normal.get()));
495 } 500 }
496 501
497 } // namespace test 502 } // namespace test
498 } // namespace ash 503 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_modal_container_layout_manager.cc ('k') | chrome/browser/ui/ash/session_state_delegate_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698