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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2726823003: Remove WmLookup. (Closed)
Patch Set: Clean up include and modify comment. Created 3 years, 9 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
« no previous file with comments | « ash/mus/window_manager.cc ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/session/session_controller.h" 9 #include "ash/common/session/session_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/system/tray/system_tray_delegate.h" 11 #include "ash/common/system/tray/system_tray_delegate.h"
12 #include "ash/common/wm/system_modal_container_layout_manager.h" 12 #include "ash/common/wm/system_modal_container_layout_manager.h"
13 #include "ash/common/wm/window_state.h" 13 #include "ash/common/wm/window_state.h"
14 #include "ash/common/wm_lookup.h"
15 #include "ash/common/wm_shell.h" 14 #include "ash/common/wm_shell.h"
16 #include "ash/common/wm_window.h" 15 #include "ash/common/wm_window.h"
17 #include "ash/public/cpp/shell_window_ids.h" 16 #include "ash/public/cpp/shell_window_ids.h"
18 #include "ash/shell.h" 17 #include "ash/shell.h"
19 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
20 #include "ash/wm/window_properties.h" 19 #include "ash/wm/window_properties.h"
21 #include "ash/wm/window_state_aura.h" 20 #include "ash/wm/window_state_aura.h"
22 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
23 #include "base/command_line.h" 22 #include "base/command_line.h"
24 #include "ui/aura/client/focus_change_observer.h" 23 #include "ui/aura/client/focus_change_observer.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 RootWindowController* controller = wm_shell->GetPrimaryRootWindowController(); 388 RootWindowController* controller = wm_shell->GetPrimaryRootWindowController();
390 EXPECT_EQ(LoginStatus::USER, 389 EXPECT_EQ(LoginStatus::USER,
391 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 390 wm_shell->system_tray_delegate()->GetUserLoginStatus());
392 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 391 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
393 controller->GetSystemModalLayoutManager(NULL)); 392 controller->GetSystemModalLayoutManager(NULL));
394 393
395 views::Widget* session_modal_widget = 394 views::Widget* session_modal_widget =
396 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 395 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
397 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 396 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
398 controller->GetSystemModalLayoutManager( 397 controller->GetSystemModalLayoutManager(
399 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 398 WmWindow::Get(session_modal_widget->GetNativeWindow())));
400 399
401 wm_shell->GetSessionStateDelegate()->LockScreen(); 400 wm_shell->GetSessionStateDelegate()->LockScreen();
402 EXPECT_EQ(LoginStatus::LOCKED, 401 EXPECT_EQ(LoginStatus::LOCKED,
403 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 402 wm_shell->system_tray_delegate()->GetUserLoginStatus());
404 EXPECT_EQ( 403 EXPECT_EQ(
405 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 404 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
406 controller->GetSystemModalLayoutManager(nullptr)); 405 controller->GetSystemModalLayoutManager(nullptr));
407 406
408 aura::Window* lock_container = 407 aura::Window* lock_container =
409 controller->GetContainer(kShellWindowId_LockScreenContainer); 408 controller->GetContainer(kShellWindowId_LockScreenContainer);
410 views::Widget* lock_modal_widget = 409 views::Widget* lock_modal_widget =
411 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 410 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
412 EXPECT_EQ( 411 EXPECT_EQ(
413 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 412 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
414 controller->GetSystemModalLayoutManager( 413 controller->GetSystemModalLayoutManager(
415 WmLookup::Get()->GetWindowForWidget(lock_modal_widget))); 414 WmWindow::Get(lock_modal_widget->GetNativeWindow())));
416 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 415 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
417 controller->GetSystemModalLayoutManager( 416 controller->GetSystemModalLayoutManager(
418 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 417 WmWindow::Get(session_modal_widget->GetNativeWindow())));
419 418
420 wm_shell->GetSessionStateDelegate()->UnlockScreen(); 419 wm_shell->GetSessionStateDelegate()->UnlockScreen();
421 } 420 }
422 421
423 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 422 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
424 UpdateDisplay("600x600"); 423 UpdateDisplay("600x600");
425 424
426 // Configure login screen environment. 425 // Configure login screen environment.
427 SessionStateDelegate* session_state_delegate = 426 SessionStateDelegate* session_state_delegate =
428 WmShell::Get()->GetSessionStateDelegate(); 427 WmShell::Get()->GetSessionStateDelegate();
429 SetUserLoggedIn(false); 428 SetUserLoggedIn(false);
430 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 429 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
431 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 430 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
432 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers()); 431 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers());
433 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted()); 432 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted());
434 433
435 RootWindowController* controller = 434 RootWindowController* controller =
436 WmShell::Get()->GetPrimaryRootWindowController(); 435 WmShell::Get()->GetPrimaryRootWindowController();
437 EXPECT_EQ( 436 EXPECT_EQ(
438 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 437 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
439 controller->GetSystemModalLayoutManager(NULL)); 438 controller->GetSystemModalLayoutManager(NULL));
440 439
441 aura::Window* lock_container = 440 aura::Window* lock_container =
442 controller->GetContainer(kShellWindowId_LockScreenContainer); 441 controller->GetContainer(kShellWindowId_LockScreenContainer);
443 views::Widget* login_modal_widget = 442 views::Widget* login_modal_widget =
444 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 443 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
445 EXPECT_EQ( 444 EXPECT_EQ(
446 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 445 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
447 controller->GetSystemModalLayoutManager( 446 controller->GetSystemModalLayoutManager(
448 WmLookup::Get()->GetWindowForWidget(login_modal_widget))); 447 WmWindow::Get(login_modal_widget->GetNativeWindow())));
449 login_modal_widget->Close(); 448 login_modal_widget->Close();
450 449
451 // Configure user session environment. 450 // Configure user session environment.
452 SetUserLoggedIn(true); 451 SetUserLoggedIn(true);
453 SetSessionStarted(true); 452 SetSessionStarted(true);
454 EXPECT_EQ(LoginStatus::USER, 453 EXPECT_EQ(LoginStatus::USER,
455 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 454 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
456 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers()); 455 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers());
457 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted()); 456 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted());
458 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 457 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
459 controller->GetSystemModalLayoutManager(NULL)); 458 controller->GetSystemModalLayoutManager(NULL));
460 459
461 views::Widget* session_modal_widget = 460 views::Widget* session_modal_widget =
462 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 461 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
463 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 462 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
464 controller->GetSystemModalLayoutManager( 463 controller->GetSystemModalLayoutManager(
465 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 464 WmWindow::Get(session_modal_widget->GetNativeWindow())));
466 } 465 }
467 466
468 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { 467 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) {
469 UpdateDisplay("600x600"); 468 UpdateDisplay("600x600");
470 RootWindowController* controller = 469 RootWindowController* controller =
471 WmShell::Get()->GetPrimaryRootWindowController(); 470 WmShell::Get()->GetPrimaryRootWindowController();
472 aura::Window* lock_container = 471 aura::Window* lock_container =
473 controller->GetContainer(kShellWindowId_LockScreenContainer); 472 controller->GetContainer(kShellWindowId_LockScreenContainer);
474 for (int block_reason = FIRST_BLOCK_REASON; 473 for (int block_reason = FIRST_BLOCK_REASON;
475 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { 474 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) {
476 views::Widget* session_modal_widget = 475 views::Widget* session_modal_widget =
477 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 476 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
478 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 477 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
479 controller->GetSystemModalLayoutManager( 478 controller->GetSystemModalLayoutManager(
480 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 479 WmWindow::Get(session_modal_widget->GetNativeWindow())));
481 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 480 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
482 controller->GetSystemModalLayoutManager(NULL)); 481 controller->GetSystemModalLayoutManager(NULL));
483 session_modal_widget->Close(); 482 session_modal_widget->Close();
484 483
485 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 484 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
486 485
487 EXPECT_EQ( 486 EXPECT_EQ(
488 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 487 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
489 controller->GetSystemModalLayoutManager(NULL)); 488 controller->GetSystemModalLayoutManager(NULL));
490 489
491 views::Widget* lock_modal_widget = CreateModalWidgetWithParent( 490 views::Widget* lock_modal_widget = CreateModalWidgetWithParent(
492 gfx::Rect(300, 10, 100, 100), lock_container); 491 gfx::Rect(300, 10, 100, 100), lock_container);
493 EXPECT_EQ( 492 EXPECT_EQ(
494 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 493 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
495 controller->GetSystemModalLayoutManager( 494 controller->GetSystemModalLayoutManager(
496 WmLookup::Get()->GetWindowForWidget(lock_modal_widget))); 495 WmWindow::Get(lock_modal_widget->GetNativeWindow())));
497 496
498 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 497 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100));
499 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 498 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
500 controller->GetSystemModalLayoutManager( 499 controller->GetSystemModalLayoutManager(
501 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 500 WmWindow::Get(session_modal_widget->GetNativeWindow())));
502 session_modal_widget->Close(); 501 session_modal_widget->Close();
503 502
504 lock_modal_widget->Close(); 503 lock_modal_widget->Close();
505 UnblockUserSession(); 504 UnblockUserSession();
506 } 505 }
507 } 506 }
508 507
509 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { 508 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) {
510 UpdateDisplay("600x600"); 509 UpdateDisplay("600x600");
511 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 510 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1238 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1240 gfx::Rect(0, 400, 800, 200)); 1239 gfx::Rect(0, 400, 800, 200));
1241 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1240 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1242 1241
1243 UpdateDisplay("600x800"); 1242 UpdateDisplay("600x800");
1244 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1243 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1245 } 1244 }
1246 1245
1247 } // namespace test 1246 } // namespace test
1248 } // namespace ash 1247 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/window_manager.cc ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698