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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2336653002: Ports SystemModalContainerLayoutManager to ash/common (Closed)
Patch Set: merge again Created 4 years, 3 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/root_window_controller.cc ('k') | ash/shell.h » ('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/aura/wm_window_aura.h"
9 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
14 #include "ash/common/wm/system_modal_container_layout_manager.h"
13 #include "ash/common/wm/window_state.h" 15 #include "ash/common/wm/window_state.h"
16 #include "ash/common/wm_lookup.h"
17 #include "ash/common/wm_root_window_controller.h"
14 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
19 #include "ash/common/wm_window.h"
15 #include "ash/display/display_manager.h" 20 #include "ash/display/display_manager.h"
16 #include "ash/shell.h" 21 #include "ash/shell.h"
17 #include "ash/test/ash_md_test_base.h" 22 #include "ash/test/ash_md_test_base.h"
18 #include "ash/test/ash_test_base.h" 23 #include "ash/test/ash_test_base.h"
19 #include "ash/test/display_manager_test_api.h" 24 #include "ash/test/display_manager_test_api.h"
20 #include "ash/wm/system_modal_container_layout_manager.h"
21 #include "ash/wm/window_properties.h" 25 #include "ash/wm/window_properties.h"
22 #include "ash/wm/window_state_aura.h" 26 #include "ash/wm/window_state_aura.h"
23 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
24 #include "base/command_line.h" 28 #include "base/command_line.h"
25 #include "ui/aura/client/focus_change_observer.h" 29 #include "ui/aura/client/focus_change_observer.h"
26 #include "ui/aura/client/focus_client.h" 30 #include "ui/aura/client/focus_client.h"
27 #include "ui/aura/client/window_tree_client.h" 31 #include "ui/aura/client/window_tree_client.h"
28 #include "ui/aura/env.h" 32 #include "ui/aura/env.h"
29 #include "ui/aura/test/test_window_delegate.h" 33 #include "ui/aura/test/test_window_delegate.h"
30 #include "ui/aura/test/test_windows.h" 34 #include "ui/aura/test/test_windows.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 ASSERT_EQ(lock_screen->GetNativeWindow(), 374 ASSERT_EQ(lock_screen->GetNativeWindow(),
371 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 375 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
372 ASSERT_EQ(lock_wallpaper->GetNativeWindow(), 376 ASSERT_EQ(lock_wallpaper->GetNativeWindow(),
373 controller->GetRootWindow()->GetChildById(kLockWallpaperWindowId)); 377 controller->GetRootWindow()->GetChildById(kLockWallpaperWindowId));
374 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); 378 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString());
375 } 379 }
376 380
377 TEST_P(RootWindowControllerTest, ModalContainer) { 381 TEST_P(RootWindowControllerTest, ModalContainer) {
378 UpdateDisplay("600x600"); 382 UpdateDisplay("600x600");
379 WmShell* wm_shell = WmShell::Get(); 383 WmShell* wm_shell = WmShell::Get();
380 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 384 WmRootWindowController* controller =
385 wm_shell->GetPrimaryRootWindowController();
381 EXPECT_EQ(LoginStatus::USER, 386 EXPECT_EQ(LoginStatus::USER,
382 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 387 wm_shell->system_tray_delegate()->GetUserLoginStatus());
383 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 388 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
384 ->layout_manager(), 389 ->GetLayoutManager(),
385 controller->GetSystemModalLayoutManager(NULL)); 390 controller->GetSystemModalLayoutManager(NULL));
386 391
387 views::Widget* session_modal_widget = 392 views::Widget* session_modal_widget =
388 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 393 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
389 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 394 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
390 ->layout_manager(), 395 ->GetLayoutManager(),
391 controller->GetSystemModalLayoutManager( 396 controller->GetSystemModalLayoutManager(
392 session_modal_widget->GetNativeView())); 397 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
393 398
394 wm_shell->GetSessionStateDelegate()->LockScreen(); 399 wm_shell->GetSessionStateDelegate()->LockScreen();
395 EXPECT_EQ(LoginStatus::LOCKED, 400 EXPECT_EQ(LoginStatus::LOCKED,
396 wm_shell->system_tray_delegate()->GetUserLoginStatus()); 401 wm_shell->system_tray_delegate()->GetUserLoginStatus());
397 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 402 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
398 ->layout_manager(), 403 ->GetLayoutManager(),
399 controller->GetSystemModalLayoutManager(NULL)); 404 controller->GetSystemModalLayoutManager(NULL));
400 405
401 aura::Window* lock_container = 406 aura::Window* lock_container = WmWindowAura::GetAuraWindow(
402 controller->GetContainer(kShellWindowId_LockScreenContainer); 407 controller->GetContainer(kShellWindowId_LockScreenContainer));
403 views::Widget* lock_modal_widget = 408 views::Widget* lock_modal_widget =
404 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 409 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
405 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 410 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
406 ->layout_manager(), 411 ->GetLayoutManager(),
407 controller->GetSystemModalLayoutManager( 412 controller->GetSystemModalLayoutManager(
408 lock_modal_widget->GetNativeView())); 413 WmLookup::Get()->GetWindowForWidget(lock_modal_widget)));
409 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 414 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
410 ->layout_manager(), 415 ->GetLayoutManager(),
411 controller->GetSystemModalLayoutManager( 416 controller->GetSystemModalLayoutManager(
412 session_modal_widget->GetNativeView())); 417 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
413 418
414 wm_shell->GetSessionStateDelegate()->UnlockScreen(); 419 wm_shell->GetSessionStateDelegate()->UnlockScreen();
415 } 420 }
416 421
417 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 422 TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
418 UpdateDisplay("600x600"); 423 UpdateDisplay("600x600");
419 424
420 // Configure login screen environment. 425 // Configure login screen environment.
421 SessionStateDelegate* session_state_delegate = 426 SessionStateDelegate* session_state_delegate =
422 WmShell::Get()->GetSessionStateDelegate(); 427 WmShell::Get()->GetSessionStateDelegate();
423 SetUserLoggedIn(false); 428 SetUserLoggedIn(false);
424 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 429 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
425 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 430 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
426 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers()); 431 EXPECT_EQ(0, session_state_delegate->NumberOfLoggedInUsers());
427 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted()); 432 EXPECT_FALSE(session_state_delegate->IsActiveUserSessionStarted());
428 433
429 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 434 WmRootWindowController* controller =
435 WmShell::Get()->GetPrimaryRootWindowController();
430 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 436 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
431 ->layout_manager(), 437 ->GetLayoutManager(),
432 controller->GetSystemModalLayoutManager(NULL)); 438 controller->GetSystemModalLayoutManager(NULL));
433 439
434 aura::Window* lock_container = 440 aura::Window* lock_container = WmWindowAura::GetAuraWindow(
435 controller->GetContainer(kShellWindowId_LockScreenContainer); 441 controller->GetContainer(kShellWindowId_LockScreenContainer));
436 views::Widget* login_modal_widget = 442 views::Widget* login_modal_widget =
437 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 443 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
438 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 444 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
439 ->layout_manager(), 445 ->GetLayoutManager(),
440 controller->GetSystemModalLayoutManager( 446 controller->GetSystemModalLayoutManager(
441 login_modal_widget->GetNativeView())); 447 WmLookup::Get()->GetWindowForWidget(login_modal_widget)));
442 login_modal_widget->Close(); 448 login_modal_widget->Close();
443 449
444 // Configure user session environment. 450 // Configure user session environment.
445 SetUserLoggedIn(true); 451 SetUserLoggedIn(true);
446 SetSessionStarted(true); 452 SetSessionStarted(true);
447 EXPECT_EQ(LoginStatus::USER, 453 EXPECT_EQ(LoginStatus::USER,
448 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus()); 454 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus());
449 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers()); 455 EXPECT_EQ(1, session_state_delegate->NumberOfLoggedInUsers());
450 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted()); 456 EXPECT_TRUE(session_state_delegate->IsActiveUserSessionStarted());
451 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 457 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
452 ->layout_manager(), 458 ->GetLayoutManager(),
453 controller->GetSystemModalLayoutManager(NULL)); 459 controller->GetSystemModalLayoutManager(NULL));
454 460
455 views::Widget* session_modal_widget = 461 views::Widget* session_modal_widget =
456 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 462 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
457 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 463 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
458 ->layout_manager(), 464 ->GetLayoutManager(),
459 controller->GetSystemModalLayoutManager( 465 controller->GetSystemModalLayoutManager(
460 session_modal_widget->GetNativeView())); 466 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
461 } 467 }
462 468
463 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) { 469 TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) {
464 UpdateDisplay("600x600"); 470 UpdateDisplay("600x600");
465 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 471 WmRootWindowController* controller =
466 aura::Window* lock_container = 472 WmShell::Get()->GetPrimaryRootWindowController();
467 controller->GetContainer(kShellWindowId_LockScreenContainer); 473 aura::Window* lock_container = WmWindowAura::GetAuraWindow(
474 controller->GetContainer(kShellWindowId_LockScreenContainer));
468 for (int block_reason = FIRST_BLOCK_REASON; 475 for (int block_reason = FIRST_BLOCK_REASON;
469 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) { 476 block_reason < NUMBER_OF_BLOCK_REASONS; ++block_reason) {
470 views::Widget* session_modal_widget = 477 views::Widget* session_modal_widget =
471 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 478 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
472 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 479 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
473 ->layout_manager(), 480 ->GetLayoutManager(),
474 controller->GetSystemModalLayoutManager( 481 controller->GetSystemModalLayoutManager(
475 session_modal_widget->GetNativeView())); 482 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
476 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 483 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
477 ->layout_manager(), 484 ->GetLayoutManager(),
478 controller->GetSystemModalLayoutManager(NULL)); 485 controller->GetSystemModalLayoutManager(NULL));
479 session_modal_widget->Close(); 486 session_modal_widget->Close();
480 487
481 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason)); 488 BlockUserSession(static_cast<UserSessionBlockReason>(block_reason));
482 489
483 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 490 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
484 ->layout_manager(), 491 ->GetLayoutManager(),
485 controller->GetSystemModalLayoutManager(NULL)); 492 controller->GetSystemModalLayoutManager(NULL));
486 493
487 views::Widget* lock_modal_widget = CreateModalWidgetWithParent( 494 views::Widget* lock_modal_widget = CreateModalWidgetWithParent(
488 gfx::Rect(300, 10, 100, 100), lock_container); 495 gfx::Rect(300, 10, 100, 100), lock_container);
489 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 496 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
490 ->layout_manager(), 497 ->GetLayoutManager(),
491 controller->GetSystemModalLayoutManager( 498 controller->GetSystemModalLayoutManager(
492 lock_modal_widget->GetNativeView())); 499 WmLookup::Get()->GetWindowForWidget(lock_modal_widget)));
493 500
494 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 501 session_modal_widget = CreateModalWidget(gfx::Rect(300, 10, 100, 100));
495 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 502 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
496 ->layout_manager(), 503 ->GetLayoutManager(),
497 controller->GetSystemModalLayoutManager( 504 controller->GetSystemModalLayoutManager(
498 session_modal_widget->GetNativeView())); 505 WmLookup::Get()->GetWindowForWidget(session_modal_widget)));
499 session_modal_widget->Close(); 506 session_modal_widget->Close();
500 507
501 lock_modal_widget->Close(); 508 lock_modal_widget->Close();
502 UnblockUserSession(); 509 UnblockUserSession();
503 } 510 }
504 } 511 }
505 512
506 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) { 513 TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) {
507 UpdateDisplay("600x600"); 514 UpdateDisplay("600x600");
508 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 515 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1049 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1043 gfx::Rect(0, 400, 800, 200)); 1050 gfx::Rect(0, 400, 800, 200));
1044 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1051 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1045 1052
1046 UpdateDisplay("600x800"); 1053 UpdateDisplay("600x800");
1047 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1054 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1048 } 1055 }
1049 1056
1050 } // namespace test 1057 } // namespace test
1051 } // namespace ash 1058 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698