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

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

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 11 matching lines...) Expand all
22 #include "ui/views/widget/widget_delegate.h" 22 #include "ui/views/widget/widget_delegate.h"
23 #include "ui/wm/core/window_util.h" 23 #include "ui/wm/core/window_util.h"
24 24
25 namespace ash { 25 namespace ash {
26 namespace test { 26 namespace test {
27 27
28 namespace { 28 namespace {
29 29
30 aura::Window* GetModalContainer() { 30 aura::Window* GetModalContainer() {
31 return Shell::GetPrimaryRootWindowController()->GetContainer( 31 return Shell::GetPrimaryRootWindowController()->GetContainer(
32 ash::internal::kShellWindowId_SystemModalContainer); 32 ash::kShellWindowId_SystemModalContainer);
33 } 33 }
34 34
35 bool AllRootWindowsHaveModalBackgroundsForContainer(int container_id) { 35 bool AllRootWindowsHaveModalBackgroundsForContainer(int container_id) {
36 std::vector<aura::Window*> containers = 36 std::vector<aura::Window*> containers =
37 Shell::GetContainersFromAllRootWindows(container_id, NULL); 37 Shell::GetContainersFromAllRootWindows(container_id, NULL);
38 bool has_modal_screen = !containers.empty(); 38 bool has_modal_screen = !containers.empty();
39 for (std::vector<aura::Window*>::iterator iter = containers.begin(); 39 for (std::vector<aura::Window*>::iterator iter = containers.begin();
40 iter != containers.end(); ++iter) { 40 iter != containers.end(); ++iter) {
41 has_modal_screen &= 41 has_modal_screen &= static_cast<SystemModalContainerLayoutManager*>(
42 static_cast<internal::SystemModalContainerLayoutManager*>( 42 (*iter)->layout_manager())->has_modal_background();
43 (*iter)->layout_manager())->has_modal_background();
44 } 43 }
45 return has_modal_screen; 44 return has_modal_screen;
46 } 45 }
47 46
48 bool AllRootWindowsHaveLockedModalBackgrounds() { 47 bool AllRootWindowsHaveLockedModalBackgrounds() {
49 return AllRootWindowsHaveModalBackgroundsForContainer( 48 return AllRootWindowsHaveModalBackgroundsForContainer(
50 internal::kShellWindowId_LockSystemModalContainer); 49 kShellWindowId_LockSystemModalContainer);
51 } 50 }
52 51
53 bool AllRootWindowsHaveModalBackgrounds() { 52 bool AllRootWindowsHaveModalBackgrounds() {
54 return AllRootWindowsHaveModalBackgroundsForContainer( 53 return AllRootWindowsHaveModalBackgroundsForContainer(
55 internal::kShellWindowId_SystemModalContainer); 54 kShellWindowId_SystemModalContainer);
56 } 55 }
57 56
58 class TestWindow : public views::WidgetDelegateView { 57 class TestWindow : public views::WidgetDelegateView {
59 public: 58 public:
60 explicit TestWindow(bool modal) : modal_(modal) {} 59 explicit TestWindow(bool modal) : modal_(modal) {}
61 virtual ~TestWindow() {} 60 virtual ~TestWindow() {}
62 61
63 // The window needs be closed from widget in order for 62 // The window needs be closed from widget in order for
64 // aura::client::kModalKey property to be reset. 63 // aura::client::kModalKey property to be reset.
65 static void CloseTestWindow(aura::Window* window) { 64 static void CloseTestWindow(aura::Window* window) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 305
307 for (int block_reason = FIRST_BLOCK_REASON; 306 for (int block_reason = FIRST_BLOCK_REASON;
308 block_reason < NUMBER_OF_BLOCK_REASONS; 307 block_reason < NUMBER_OF_BLOCK_REASONS;
309 ++block_reason) { 308 ++block_reason) {
310 // Create a window in the lock screen container and ensure that it receives 309 // Create a window in the lock screen container and ensure that it receives
311 // the mouse event instead of the modal window (crbug.com/110920). 310 // the mouse event instead of the modal window (crbug.com/110920).
312 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 311 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
313 EventTestWindow* lock_delegate = new EventTestWindow(false); 312 EventTestWindow* lock_delegate = new EventTestWindow(false);
314 scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent( 313 scoped_ptr<aura::Window> lock(lock_delegate->OpenTestWindowWithParent(
315 Shell::GetPrimaryRootWindowController()->GetContainer( 314 Shell::GetPrimaryRootWindowController()->GetContainer(
316 ash::internal::kShellWindowId_LockScreenContainer))); 315 ash::kShellWindowId_LockScreenContainer)));
317 EXPECT_TRUE(wm::IsActiveWindow(lock.get())); 316 EXPECT_TRUE(wm::IsActiveWindow(lock.get()));
318 e1.ClickLeftButton(); 317 e1.ClickLeftButton();
319 EXPECT_EQ(1, lock_delegate->mouse_presses()); 318 EXPECT_EQ(1, lock_delegate->mouse_presses());
320 319
321 // Make sure that a modal container created by the lock screen can still 320 // Make sure that a modal container created by the lock screen can still
322 // receive mouse events. 321 // receive mouse events.
323 EventTestWindow* lock_modal_delegate = new EventTestWindow(true); 322 EventTestWindow* lock_modal_delegate = new EventTestWindow(true);
324 aura::Window* lock_modal = 323 aura::Window* lock_modal =
325 lock_modal_delegate->OpenTestWindowWithParent(lock.get()); 324 lock_modal_delegate->OpenTestWindowWithParent(lock.get());
326 EXPECT_TRUE(wm::IsActiveWindow(lock_modal)); 325 EXPECT_TRUE(wm::IsActiveWindow(lock_modal));
327 e1.ClickLeftButton(); 326 e1.ClickLeftButton();
328 // Verify that none of the other containers received any more mouse presses. 327 // Verify that none of the other containers received any more mouse presses.
329 EXPECT_EQ(1, lock_modal_delegate->mouse_presses()); 328 EXPECT_EQ(1, lock_modal_delegate->mouse_presses());
330 EXPECT_EQ(1, lock_delegate->mouse_presses()); 329 EXPECT_EQ(1, lock_delegate->mouse_presses());
331 EXPECT_EQ(1, main_delegate->mouse_presses()); 330 EXPECT_EQ(1, main_delegate->mouse_presses());
332 EXPECT_EQ(1, transient_delegate->mouse_presses()); 331 EXPECT_EQ(1, transient_delegate->mouse_presses());
333 UnblockUserSession(); 332 UnblockUserSession();
334 } 333 }
335 } 334 }
336 335
337 // Makes sure we don't crash if a modal window is shown while the parent window 336 // Makes sure we don't crash if a modal window is shown while the parent window
338 // is hidden. 337 // is hidden.
339 TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) { 338 TEST_F(SystemModalContainerLayoutManagerTest, ShowModalWhileHidden) {
340 // Hide the lock screen. 339 // Hide the lock screen.
341 Shell::GetPrimaryRootWindowController()->GetContainer( 340 Shell::GetPrimaryRootWindowController()
342 internal::kShellWindowId_SystemModalContainer)->layer()->SetOpacity(0); 341 ->GetContainer(kShellWindowId_SystemModalContainer)
342 ->layer()
343 ->SetOpacity(0);
343 344
344 // Create a modal window. 345 // Create a modal window.
345 scoped_ptr<aura::Window> parent(OpenToplevelTestWindow(false)); 346 scoped_ptr<aura::Window> parent(OpenToplevelTestWindow(false));
346 scoped_ptr<aura::Window> modal_window( 347 scoped_ptr<aura::Window> modal_window(
347 OpenTestWindowWithParent(parent.get(), true)); 348 OpenTestWindowWithParent(parent.get(), true));
348 parent->Show(); 349 parent->Show();
349 modal_window->Show(); 350 modal_window->Show();
350 } 351 }
351 352
352 // Verifies we generate a capture lost when showing a modal window. 353 // Verifies we generate a capture lost when showing a modal window.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds()); 403 EXPECT_FALSE(AllRootWindowsHaveLockedModalBackgrounds());
403 404
404 for (int block_reason = FIRST_BLOCK_REASON; 405 for (int block_reason = FIRST_BLOCK_REASON;
405 block_reason < NUMBER_OF_BLOCK_REASONS; 406 block_reason < NUMBER_OF_BLOCK_REASONS;
406 ++block_reason) { 407 ++block_reason) {
407 // Normal system modal window while blocked. Shows blocked system modal 408 // Normal system modal window while blocked. Shows blocked system modal
408 // background. 409 // background.
409 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 410 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
410 scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent( 411 scoped_ptr<aura::Window> lock_parent(OpenTestWindowWithParent(
411 Shell::GetPrimaryRootWindowController()->GetContainer( 412 Shell::GetPrimaryRootWindowController()->GetContainer(
412 ash::internal::kShellWindowId_LockScreenContainer), 413 ash::kShellWindowId_LockScreenContainer),
413 false)); 414 false));
414 scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent( 415 scoped_ptr<aura::Window> lock_modal_window(OpenTestWindowWithParent(
415 lock_parent.get(), true)); 416 lock_parent.get(), true));
416 lock_parent->Show(); 417 lock_parent->Show();
417 lock_modal_window->Show(); 418 lock_modal_window->Show();
418 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); 419 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
419 EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds()); 420 EXPECT_TRUE(AllRootWindowsHaveLockedModalBackgrounds());
420 TestWindow::CloseTestWindow(lock_modal_window.release()); 421 TestWindow::CloseTestWindow(lock_modal_window.release());
421 422
422 // Normal system modal window while blocked, but it belongs to the normal 423 // Normal system modal window while blocked, but it belongs to the normal
(...skipping 17 matching lines...) Expand all
440 return; 441 return;
441 442
442 UpdateDisplay("500x500,500x500"); 443 UpdateDisplay("500x500,500x500");
443 444
444 scoped_ptr<aura::Window> normal(OpenToplevelTestWindow(false)); 445 scoped_ptr<aura::Window> normal(OpenToplevelTestWindow(false));
445 normal->SetBounds(gfx::Rect(100, 100, 50, 50)); 446 normal->SetBounds(gfx::Rect(100, 100, 50, 50));
446 447
447 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 448 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
448 EXPECT_EQ(2U, root_windows.size()); 449 EXPECT_EQ(2U, root_windows.size());
449 aura::Window* container1 = Shell::GetContainer( 450 aura::Window* container1 = Shell::GetContainer(
450 root_windows[0], ash::internal::kShellWindowId_SystemModalContainer); 451 root_windows[0], ash::kShellWindowId_SystemModalContainer);
451 aura::Window* container2 = Shell::GetContainer( 452 aura::Window* container2 = Shell::GetContainer(
452 root_windows[1], ash::internal::kShellWindowId_SystemModalContainer); 453 root_windows[1], ash::kShellWindowId_SystemModalContainer);
453 454
454 scoped_ptr<aura::Window> modal1( 455 scoped_ptr<aura::Window> modal1(
455 OpenTestWindowWithParent(container1, true)); 456 OpenTestWindowWithParent(container1, true));
456 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds()); 457 EXPECT_TRUE(AllRootWindowsHaveModalBackgrounds());
457 EXPECT_TRUE(wm::IsActiveWindow(modal1.get())); 458 EXPECT_TRUE(wm::IsActiveWindow(modal1.get()));
458 459
459 scoped_ptr<aura::Window> modal11( 460 scoped_ptr<aura::Window> modal11(
460 OpenTestWindowWithParent(container1, true)); 461 OpenTestWindowWithParent(container1, true));
461 EXPECT_TRUE(wm::IsActiveWindow(modal11.get())); 462 EXPECT_TRUE(wm::IsActiveWindow(modal11.get()));
462 463
(...skipping 24 matching lines...) Expand all
487 488
488 // No more modal screen. 489 // No more modal screen.
489 modal1->Hide(); 490 modal1->Hide();
490 TestWindow::CloseTestWindow(modal1.release()); 491 TestWindow::CloseTestWindow(modal1.release());
491 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds()); 492 EXPECT_FALSE(AllRootWindowsHaveModalBackgrounds());
492 EXPECT_TRUE(wm::IsActiveWindow(normal.get())); 493 EXPECT_TRUE(wm::IsActiveWindow(normal.get()));
493 } 494 }
494 495
495 } // namespace test 496 } // namespace test
496 } // namespace ash 497 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/system_modal_container_layout_manager.cc ('k') | ash/wm/toplevel_window_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698