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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/public/cpp/config.h" | 9 #include "ash/public/cpp/config.h" |
10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
11 #include "ash/session/session_controller.h" | 11 #include "ash/session/session_controller.h" |
12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
13 #include "ash/shell_port.h" | 13 #include "ash/shell_port.h" |
14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/test_session_controller_client.h" | 15 #include "ash/test/test_session_controller_client.h" |
16 #include "ash/wm/system_modal_container_layout_manager.h" | 16 #include "ash/wm/system_modal_container_layout_manager.h" |
17 #include "ash/wm/window_properties.h" | 17 #include "ash/wm/window_properties.h" |
18 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
19 #include "ash/wm/window_state_aura.h" | 19 #include "ash/wm/window_state_aura.h" |
20 #include "ash/wm/window_util.h" | 20 #include "ash/wm/window_util.h" |
21 #include "ash/wm_window.h" | |
22 #include "base/command_line.h" | 21 #include "base/command_line.h" |
23 #include "ui/aura/client/focus_change_observer.h" | 22 #include "ui/aura/client/focus_change_observer.h" |
24 #include "ui/aura/client/focus_client.h" | 23 #include "ui/aura/client/focus_client.h" |
25 #include "ui/aura/client/window_parenting_client.h" | 24 #include "ui/aura/client/window_parenting_client.h" |
26 #include "ui/aura/env.h" | 25 #include "ui/aura/env.h" |
27 #include "ui/aura/test/test_window_delegate.h" | 26 #include "ui/aura/test/test_window_delegate.h" |
28 #include "ui/aura/test/test_windows.h" | 27 #include "ui/aura/test/test_windows.h" |
29 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
30 #include "ui/aura/window_event_dispatcher.h" | 29 #include "ui/aura/window_event_dispatcher.h" |
31 #include "ui/aura/window_tracker.h" | 30 #include "ui/aura/window_tracker.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 aura::Window* lost_focus) override { | 87 aura::Window* lost_focus) override { |
89 if (window_ == lost_focus) | 88 if (window_ == lost_focus) |
90 delete window_; | 89 delete window_; |
91 } | 90 } |
92 | 91 |
93 aura::Window* window_; | 92 aura::Window* window_; |
94 | 93 |
95 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); | 94 DISALLOW_COPY_AND_ASSIGN(DeleteOnBlurDelegate); |
96 }; | 95 }; |
97 | 96 |
98 WmLayoutManager* GetLayoutManager(RootWindowController* controller, int id) { | 97 aura::LayoutManager* GetLayoutManager(RootWindowController* controller, |
99 return WmWindow::Get(controller->GetContainer(id))->GetLayoutManager(); | 98 int id) { |
| 99 return controller->GetContainer(id)->layout_manager(); |
100 } | 100 } |
101 | 101 |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 namespace test { | 104 namespace test { |
105 | 105 |
106 class RootWindowControllerTest : public AshTestBase { | 106 class RootWindowControllerTest : public AshTestBase { |
107 public: | 107 public: |
108 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { | 108 views::Widget* CreateTestWidget(const gfx::Rect& bounds) { |
109 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( | 109 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 RootWindowController* controller = | 387 RootWindowController* controller = |
388 ShellPort::Get()->GetPrimaryRootWindowController(); | 388 ShellPort::Get()->GetPrimaryRootWindowController(); |
389 EXPECT_TRUE(Shell::Get()->session_controller()->IsActiveUserSessionStarted()); | 389 EXPECT_TRUE(Shell::Get()->session_controller()->IsActiveUserSessionStarted()); |
390 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 390 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
391 controller->GetSystemModalLayoutManager(NULL)); | 391 controller->GetSystemModalLayoutManager(NULL)); |
392 | 392 |
393 views::Widget* session_modal_widget = | 393 views::Widget* session_modal_widget = |
394 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 394 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
395 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 395 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
396 controller->GetSystemModalLayoutManager( | 396 controller->GetSystemModalLayoutManager( |
397 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 397 session_modal_widget->GetNativeWindow())); |
398 | 398 |
399 Shell::Get()->session_controller()->LockScreenAndFlushForTest(); | 399 Shell::Get()->session_controller()->LockScreenAndFlushForTest(); |
400 EXPECT_TRUE(Shell::Get()->session_controller()->IsScreenLocked()); | 400 EXPECT_TRUE(Shell::Get()->session_controller()->IsScreenLocked()); |
401 EXPECT_EQ( | 401 EXPECT_EQ( |
402 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 402 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
403 controller->GetSystemModalLayoutManager(nullptr)); | 403 controller->GetSystemModalLayoutManager(nullptr)); |
404 | 404 |
405 aura::Window* lock_container = | 405 aura::Window* lock_container = |
406 controller->GetContainer(kShellWindowId_LockScreenContainer); | 406 controller->GetContainer(kShellWindowId_LockScreenContainer); |
407 views::Widget* lock_modal_widget = | 407 views::Widget* lock_modal_widget = |
408 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); | 408 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); |
409 EXPECT_EQ( | 409 EXPECT_EQ( |
410 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 410 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
411 controller->GetSystemModalLayoutManager( | 411 controller->GetSystemModalLayoutManager( |
412 WmWindow::Get(lock_modal_widget->GetNativeWindow()))); | 412 lock_modal_widget->GetNativeWindow())); |
413 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 413 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
414 controller->GetSystemModalLayoutManager( | 414 controller->GetSystemModalLayoutManager( |
415 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 415 session_modal_widget->GetNativeWindow())); |
416 | 416 |
417 GetSessionControllerClient()->UnlockScreen(); | 417 GetSessionControllerClient()->UnlockScreen(); |
418 } | 418 } |
419 | 419 |
420 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { | 420 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { |
421 UpdateDisplay("600x600"); | 421 UpdateDisplay("600x600"); |
422 | 422 |
423 // Configure login screen environment. | 423 // Configure login screen environment. |
424 SessionController* session_controller = Shell::Get()->session_controller(); | 424 SessionController* session_controller = Shell::Get()->session_controller(); |
425 SetUserLoggedIn(false); | 425 SetUserLoggedIn(false); |
426 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers()); | 426 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers()); |
427 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted()); | 427 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted()); |
428 | 428 |
429 RootWindowController* controller = | 429 RootWindowController* controller = |
430 ShellPort::Get()->GetPrimaryRootWindowController(); | 430 ShellPort::Get()->GetPrimaryRootWindowController(); |
431 EXPECT_EQ( | 431 EXPECT_EQ( |
432 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 432 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
433 controller->GetSystemModalLayoutManager(NULL)); | 433 controller->GetSystemModalLayoutManager(NULL)); |
434 | 434 |
435 aura::Window* lock_container = | 435 aura::Window* lock_container = |
436 controller->GetContainer(kShellWindowId_LockScreenContainer); | 436 controller->GetContainer(kShellWindowId_LockScreenContainer); |
437 views::Widget* login_modal_widget = | 437 views::Widget* login_modal_widget = |
438 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); | 438 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); |
439 EXPECT_EQ( | 439 EXPECT_EQ( |
440 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 440 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
441 controller->GetSystemModalLayoutManager( | 441 controller->GetSystemModalLayoutManager( |
442 WmWindow::Get(login_modal_widget->GetNativeWindow()))); | 442 login_modal_widget->GetNativeWindow())); |
443 login_modal_widget->Close(); | 443 login_modal_widget->Close(); |
444 | 444 |
445 // Configure user session environment. | 445 // Configure user session environment. |
446 SetUserLoggedIn(true); | 446 SetUserLoggedIn(true); |
447 SetSessionStarted(true); | 447 SetSessionStarted(true); |
448 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers()); | 448 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers()); |
449 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted()); | 449 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted()); |
450 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 450 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
451 controller->GetSystemModalLayoutManager(NULL)); | 451 controller->GetSystemModalLayoutManager(NULL)); |
452 | 452 |
453 views::Widget* session_modal_widget = | 453 views::Widget* session_modal_widget = |
454 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 454 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
455 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 455 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
456 controller->GetSystemModalLayoutManager( | 456 controller->GetSystemModalLayoutManager( |
457 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 457 session_modal_widget->GetNativeWindow())); |
458 } | 458 } |
459 | 459 |
460 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { | 460 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { |
461 UpdateDisplay("600x600"); | 461 UpdateDisplay("600x600"); |
462 RootWindowController* controller = | 462 RootWindowController* controller = |
463 ShellPort::Get()->GetPrimaryRootWindowController(); | 463 ShellPort::Get()->GetPrimaryRootWindowController(); |
464 aura::Window* lock_container = | 464 aura::Window* lock_container = |
465 controller->GetContainer(kShellWindowId_LockScreenContainer); | 465 controller->GetContainer(kShellWindowId_LockScreenContainer); |
466 for (int block_reason = FIRST_BLOCK_REASON; | 466 for (int block_reason = FIRST_BLOCK_REASON; |
467 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { | 467 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { |
468 views::Widget* session_modal_widget = | 468 views::Widget* session_modal_widget = |
469 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 469 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
470 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 470 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
471 controller->GetSystemModalLayoutManager( | 471 controller->GetSystemModalLayoutManager( |
472 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 472 session_modal_widget->GetNativeWindow())); |
473 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 473 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
474 controller->GetSystemModalLayoutManager(NULL)); | 474 controller->GetSystemModalLayoutManager(NULL)); |
475 session_modal_widget->Close(); | 475 session_modal_widget->Close(); |
476 | 476 |
477 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); | 477 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); |
478 | 478 |
479 EXPECT_EQ( | 479 EXPECT_EQ( |
480 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 480 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
481 controller->GetSystemModalLayoutManager(NULL)); | 481 controller->GetSystemModalLayoutManager(NULL)); |
482 | 482 |
483 views::Widget* lock_modal_widget = CreateModalWidgetWithParent( | 483 views::Widget* lock_modal_widget = CreateModalWidgetWithParent( |
484 gfx::Rect(300, 10, 100, 100), lock_container); | 484 gfx::Rect(300, 10, 100, 100), lock_container); |
485 EXPECT_EQ( | 485 EXPECT_EQ( |
486 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), | 486 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), |
487 controller->GetSystemModalLayoutManager( | 487 controller->GetSystemModalLayoutManager( |
488 WmWindow::Get(lock_modal_widget->GetNativeWindow()))); | 488 lock_modal_widget->GetNativeWindow())); |
489 | 489 |
490 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); | 490 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); |
491 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), | 491 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), |
492 controller->GetSystemModalLayoutManager( | 492 controller->GetSystemModalLayoutManager( |
493 WmWindow::Get(session_modal_widget->GetNativeWindow()))); | 493 session_modal_widget->GetNativeWindow())); |
494 session_modal_widget->Close(); | 494 session_modal_widget->Close(); |
495 | 495 |
496 lock_modal_widget->Close(); | 496 lock_modal_widget->Close(); |
497 UnblockUserSession(); | 497 UnblockUserSession(); |
498 } | 498 } |
499 } | 499 } |
500 | 500 |
501 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { | 501 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { |
502 UpdateDisplay("600x600"); | 502 UpdateDisplay("600x600"); |
503 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 503 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1230 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1230 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
1231 gfx::Rect(0, 400, 800, 200)); | 1231 gfx::Rect(0, 400, 800, 200)); |
1232 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1232 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
1233 | 1233 |
1234 UpdateDisplay("600x800"); | 1234 UpdateDisplay("600x800"); |
1235 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1235 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
1236 } | 1236 } |
1237 | 1237 |
1238 } // namespace test | 1238 } // namespace test |
1239 } // namespace ash | 1239 } // namespace ash |
OLD | NEW |