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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2726823003: Remove WmLookup. (Closed)
Patch Set: Remove wm_lookup. 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
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 RootWindowController* controller = wm_shell->GetPrimaryRootWindowController(); 380 RootWindowController* controller = wm_shell->GetPrimaryRootWindowController();
382 EXPECT_EQ(LoginStatus::USER, 381 EXPECT_EQ(LoginStatus::USER,
383 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 382 wm_shell->system_tray_delegate()->GetUserLoginStatus());
384 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 383 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
385 controller->GetSystemModalLayoutManager(NULL)); 384 controller->GetSystemModalLayoutManager(NULL));
386 385
387 views::Widget* session_modal_widget = 386 views::Widget* session_modal_widget =
388 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 387 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
389 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 388 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
390 controller->GetSystemModalLayoutManager( 389 controller->GetSystemModalLayoutManager(
391 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 390 WmWindow::Get(session_modal_widget->GetNativeWindow())));
392 391
393 wm_shell->GetSessionStateDelegate()->LockScreen(); 392 wm_shell->GetSessionStateDelegate()->LockScreen();
394 EXPECT_EQ(LoginStatus::LOCKED, 393 EXPECT_EQ(LoginStatus::LOCKED,
395 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 394 wm_shell->system_tray_delegate()->GetUserLoginStatus());
396 EXPECT_EQ( 395 EXPECT_EQ(
397 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 396 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
398 controller->GetSystemModalLayoutManager(nullptr)); 397 controller->GetSystemModalLayoutManager(nullptr));
399 398
400 aura::Window* lock_container = 399 aura::Window* lock_container =
401 controller->GetContainer(kShellWindowId_LockScreenContainer); 400 controller->GetContainer(kShellWindowId_LockScreenContainer);
402 views::Widget* lock_modal_widget = 401 views::Widget* lock_modal_widget =
403 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 402 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
404 EXPECT_EQ( 403 EXPECT_EQ(
405 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 404 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
406 controller->GetSystemModalLayoutManager( 405 controller->GetSystemModalLayoutManager(
407 WmLookup::Get()->GetWindowForWidget(lock_modal_widget))); 406 WmWindow::Get(lock_modal_widget->GetNativeWindow())));
408 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 407 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
409 controller->GetSystemModalLayoutManager( 408 controller->GetSystemModalLayoutManager(
410 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 409 WmWindow::Get(session_modal_widget->GetNativeWindow())));
411 410
412 wm_shell->GetSessionStateDelegate()->UnlockScreen(); 411 wm_shell->GetSessionStateDelegate()->UnlockScreen();
413 } 412 }
414 413
415 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 414 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
416 UpdateDisplay("600x600"); 415 UpdateDisplay("600x600");
417 416
418 // Configure login screen environment. 417 // Configure login screen environment.
419 SessionStateDelegate* session_state_delegate = 418 SessionStateDelegate* session_state_delegate =
420 WmShell::Get()->GetSessionStateDelegate(); 419 WmShell::Get()->GetSessionStateDelegate();
421 SetUserLoggedIn(false); 420 SetUserLoggedIn(false);
422 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 421 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
423 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 422 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
424 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers()); 423 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers());
425 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted()); 424 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted());
426 425
427 RootWindowController* controller = 426 RootWindowController* controller =
428 WmShell::Get()->GetPrimaryRootWindowController(); 427 WmShell::Get()->GetPrimaryRootWindowController();
429 EXPECT_EQ( 428 EXPECT_EQ(
430 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 429 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
431 controller->GetSystemModalLayoutManager(NULL)); 430 controller->GetSystemModalLayoutManager(NULL));
432 431
433 aura::Window* lock_container = 432 aura::Window* lock_container =
434 controller->GetContainer(kShellWindowId_LockScreenContainer); 433 controller->GetContainer(kShellWindowId_LockScreenContainer);
435 views::Widget* login_modal_widget = 434 views::Widget* login_modal_widget =
436 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 435 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
437 EXPECT_EQ( 436 EXPECT_EQ(
438 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 437 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
439 controller->GetSystemModalLayoutManager( 438 controller->GetSystemModalLayoutManager(
440 WmLookup::Get()->GetWindowForWidget(login_modal_widget))); 439 WmWindow::Get(login_modal_widget->GetNativeWindow())));
441 login_modal_widget->Close(); 440 login_modal_widget->Close();
442 441
443 // Configure user session environment. 442 // Configure user session environment.
444 SetUserLoggedIn(true); 443 SetUserLoggedIn(true);
445 SetSessionStarted(true); 444 SetSessionStarted(true);
446 EXPECT_EQ(LoginStatus::USER, 445 EXPECT_EQ(LoginStatus::USER,
447 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 446 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
448 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers()); 447 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers());
449 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted()); 448 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted());
450 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 449 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
451 controller->GetSystemModalLayoutManager(NULL)); 450 controller->GetSystemModalLayoutManager(NULL));
452 451
453 views::Widget* session_modal_widget = 452 views::Widget* session_modal_widget =
454 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 453 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
455 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 454 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
456 controller->GetSystemModalLayoutManager( 455 controller->GetSystemModalLayoutManager(
457 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 456 WmWindow::Get(session_modal_widget->GetNativeWindow())));
458 } 457 }
459 458
460 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) { 459 TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) {
461 UpdateDisplay("600x600"); 460 UpdateDisplay("600x600");
462 RootWindowController* controller = 461 RootWindowController* controller =
463 WmShell::Get()->GetPrimaryRootWindowController(); 462 WmShell::Get()->GetPrimaryRootWindowController();
464 aura::Window* lock_container = 463 aura::Window* lock_container =
465 controller->GetContainer(kShellWindowId_LockScreenContainer); 464 controller->GetContainer(kShellWindowId_LockScreenContainer);
466 for (int block_reason = FIRST_BLOCK_REASON; 465 for (int block_reason = FIRST_BLOCK_REASON;
467 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { 466 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) {
468 views::Widget* session_modal_widget = 467 views::Widget* session_modal_widget =
469 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 468 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
470 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 469 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
471 controller->GetSystemModalLayoutManager( 470 controller->GetSystemModalLayoutManager(
472 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 471 WmWindow::Get(session_modal_widget->GetNativeWindow())));
473 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 472 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
474 controller->GetSystemModalLayoutManager(NULL)); 473 controller->GetSystemModalLayoutManager(NULL));
475 session_modal_widget->Close(); 474 session_modal_widget->Close();
476 475
477 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 476 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
478 477
479 EXPECT_EQ( 478 EXPECT_EQ(
480 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 479 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
481 controller->GetSystemModalLayoutManager(NULL)); 480 controller->GetSystemModalLayoutManager(NULL));
482 481
483 views::Widget* lock_modal_widget = CreateModalWidgetWithParent( 482 views::Widget* lock_modal_widget = CreateModalWidgetWithParent(
484 gfx::Rect(300, 10, 100, 100), lock_container); 483 gfx::Rect(300, 10, 100, 100), lock_container);
485 EXPECT_EQ( 484 EXPECT_EQ(
486 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 485 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
487 controller->GetSystemModalLayoutManager( 486 controller->GetSystemModalLayoutManager(
488 WmLookup::Get()->GetWindowForWidget(lock_modal_widget))); 487 WmWindow::Get(lock_modal_widget->GetNativeWindow())));
489 488
490 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 489 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100));
491 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 490 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
492 controller->GetSystemModalLayoutManager( 491 controller->GetSystemModalLayoutManager(
493 WmLookup::Get()->GetWindowForWidget(session_modal_widget))); 492 WmWindow::Get(session_modal_widget->GetNativeWindow())));
494 session_modal_widget->Close(); 493 session_modal_widget->Close();
495 494
496 lock_modal_widget->Close(); 495 lock_modal_widget->Close();
497 UnblockUserSession(); 496 UnblockUserSession();
498 } 497 }
499 } 498 }
500 499
501 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) { 500 TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) {
502 UpdateDisplay("600x600"); 501 UpdateDisplay("600x600");
503 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 502 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1230 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1232 gfx::Rect(0, 400, 800, 200)); 1231 gfx::Rect(0, 400, 800, 200));
1233 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1232 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1234 1233
1235 UpdateDisplay("600x800"); 1234 UpdateDisplay("600x800");
1236 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1235 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1237 } 1236 }
1238 1237
1239 } // namespace test 1238 } // namespace test
1240 } // namespace ash 1239 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698