OLD | NEW |
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/shell.h" | 9 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "ui/aura/root_window.h" | 15 #include "ui/aura/root_window.h" |
16 #include "ui/aura/test/event_generator.h" | 16 #include "ui/aura/test/event_generator.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
19 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Create a window in the lock screen container and ensure that it receives |
315 // the mouse event instead of the modal window (crbug.com/110920). | 315 // the mouse event instead of the modal window (crbug.com/110920). |
316 Shell::GetInstance()->delegate()->LockScreen(); | 316 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
317 EventTestWindow* lock_delegate = new EventTestWindow(false); | 317 EventTestWindow* lock_delegate = new EventTestWindow(false); |
318 scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent( | 318 scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent( |
319 Shell::GetPrimaryRootWindowController()->GetContainer( | 319 Shell::GetPrimaryRootWindowController()->GetContainer( |
320 ash::internal::kShellWindowId_LockScreenContainer))); | 320 ash::internal::kShellWindowId_LockScreenContainer))); |
321 EXPECT_TRUE(wm::IsActiveWindow(lock.get())); | 321 EXPECT_TRUE(wm::IsActiveWindow(lock.get())); |
322 e1.ClickLeftButton(); | 322 e1.ClickLeftButton(); |
323 EXPECT_EQ(1, lock_delegate->mouse_presses()); | 323 EXPECT_EQ(1, lock_delegate->mouse_presses()); |
324 | 324 |
325 // Make sure that a modal container created by the lock screen can still | 325 // Make sure that a modal container created by the lock screen can still |
326 // receive mouse events. | 326 // receive mouse events. |
327 EventTestWindow* lock_modal_delegate = new EventTestWindow(true); | 327 EventTestWindow* lock_modal_delegate = new EventTestWindow(true); |
328 aura::Window* lock_modal = | 328 aura::Window* lock_modal = |
329 lock_modal_delegate->OpenTestWindowWithParent(lock.get()); | 329 lock_modal_delegate->OpenTestWindowWithParent(lock.get()); |
330 EXPECT_TRUE(wm::IsActiveWindow(lock_modal)); | 330 EXPECT_TRUE(wm::IsActiveWindow(lock_modal)); |
331 e1.ClickLeftButton(); | 331 e1.ClickLeftButton(); |
332 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); | 332 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); |
333 | 333 |
334 // Verify that none of the other containers received any more mouse presses. | 334 // Verify that none of the other containers received any more mouse presses. |
335 EXPECT_EQ(1, main_delegate->mouse_presses()); | 335 EXPECT_EQ(1, main_delegate->mouse_presses()); |
336 EXPECT_EQ(1, transient_delegate->mouse_presses()); | 336 EXPECT_EQ(1, transient_delegate->mouse_presses()); |
337 EXPECT_EQ(1, lock_delegate->mouse_presses()); | 337 EXPECT_EQ(1, lock_delegate->mouse_presses()); |
338 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); | 338 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); |
339 | 339 |
340 Shell::GetInstance()->delegate()->UnlockScreen(); | 340 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
341 } | 341 } |
342 | 342 |
343 // Makes sure we don't crash if a modal window is shown while the parent window | 343 // Makes sure we don't crash if a modal window is shown while the parent window |
344 // is hidden. | 344 // is hidden. |
345 TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) { | 345 TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) { |
346 // Hide the lock screen. | 346 // Hide the lock screen. |
347 Shell::GetPrimaryRootWindowController()->GetContainer( | 347 Shell::GetPrimaryRootWindowController()->GetContainer( |
348 internal::kShellWindowId_SystemModalContainer)->layer()->SetOpacity(0); | 348 internal::kShellWindowId_SystemModalContainer)->layer()->SetOpacity(0); |
349 | 349 |
350 // Create a modal window. | 350 // Create a modal window. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // locked. | 402 // locked. |
403 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); | 403 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); |
404 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); | 404 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); |
405 | 405 |
406 TestWindow::CloseTestWindow(modal_window.release()); | 406 TestWindow::CloseTestWindow(modal_window.release()); |
407 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); | 407 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); |
408 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); | 408 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); |
409 | 409 |
410 // Normal system modal window while locked. Shows locked system modal | 410 // Normal system modal window while locked. Shows locked system modal |
411 // background. | 411 // background. |
412 Shell::GetInstance()->delegate()->LockScreen(); | 412 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
413 scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent( | 413 scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent( |
414 Shell::GetPrimaryRootWindowController()->GetContainer( | 414 Shell::GetPrimaryRootWindowController()->GetContainer( |
415 ash::internal::kShellWindowId_LockScreenContainer), | 415 ash::internal::kShellWindowId_LockScreenContainer), |
416 false)); | 416 false)); |
417 scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent( | 417 scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent( |
418 lock_parent.get(), true)); | 418 lock_parent.get(), true)); |
419 lock_parent->Show(); | 419 lock_parent->Show(); |
420 lock_modal_window->Show(); | 420 lock_modal_window->Show(); |
421 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); | 421 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); |
422 EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds()); | 422 EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds()); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 | 493 |
494 // No more modal screen. | 494 // No more modal screen. |
495 modal1->Hide(); | 495 modal1->Hide(); |
496 TestWindow::CloseTestWindow(modal1.release()); | 496 TestWindow::CloseTestWindow(modal1.release()); |
497 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); | 497 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); |
498 EXPECT_TRUE(wm::IsActiveWindow(normal.get())); | 498 EXPECT_TRUE(wm::IsActiveWindow(normal.get())); |
499 } | 499 } |
500 | 500 |
501 } // namespace test | 501 } // namespace test |
502 } // namespace ash | 502 } // namespace ash |
OLD | NEW |