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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2058173002: mash: Move SystemTrayDelegate ownership to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback Created 4 years, 6 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_state_delegate.h" 9 #include "ash/common/session/session_state_delegate.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.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/window_state.h" 12 #include "ash/common/wm/window_state.h"
13 #include "ash/common/wm_shell.h"
13 #include "ash/display/display_manager.h" 14 #include "ash/display/display_manager.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
16 #include "ash/test/display_manager_test_api.h" 17 #include "ash/test/display_manager_test_api.h"
17 #include "ash/wm/system_modal_container_layout_manager.h" 18 #include "ash/wm/system_modal_container_layout_manager.h"
18 #include "ash/wm/window_properties.h" 19 #include "ash/wm/window_properties.h"
19 #include "ash/wm/window_state_aura.h" 20 #include "ash/wm/window_state_aura.h"
20 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
21 #include "base/command_line.h" 22 #include "base/command_line.h"
22 #include "ui/aura/client/focus_change_observer.h" 23 #include "ui/aura/client/focus_change_observer.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 ASSERT_EQ(lock_screen->GetNativeWindow(), 364 ASSERT_EQ(lock_screen->GetNativeWindow(),
364 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 365 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
365 ASSERT_EQ(lock_background->GetNativeWindow(), 366 ASSERT_EQ(lock_background->GetNativeWindow(),
366 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId)); 367 controller->GetRootWindow()->GetChildById(kLockBackgroundWindowId));
367 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); 368 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString());
368 } 369 }
369 370
370 TEST_F(RootWindowControllerTest, ModalContainer) { 371 TEST_F(RootWindowControllerTest, ModalContainer) {
371 UpdateDisplay("600x600"); 372 UpdateDisplay("600x600");
372 Shell* shell = Shell::GetInstance(); 373 Shell* shell = Shell::GetInstance();
374 WmShell* wm_shell = WmShell::Get();
373 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 375 RootWindowController* controller = shell->GetPrimaryRootWindowController();
374 EXPECT_EQ(LoginStatus::USER, 376 EXPECT_EQ(LoginStatus::USER,
375 shell->system_tray_delegate()->GetUserLoginStatus()); 377 wm_shell->system_tray_delegate()->GetUserLoginStatus());
376 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 378 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
377 ->layout_manager(), 379 ->layout_manager(),
378 controller->GetSystemModalLayoutManager(NULL)); 380 controller->GetSystemModalLayoutManager(NULL));
379 381
380 views::Widget* session_modal_widget = 382 views::Widget* session_modal_widget =
381 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 383 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
382 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 384 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
383 ->layout_manager(), 385 ->layout_manager(),
384 controller->GetSystemModalLayoutManager( 386 controller->GetSystemModalLayoutManager(
385 session_modal_widget->GetNativeView())); 387 session_modal_widget->GetNativeView()));
386 388
387 shell->session_state_delegate()->LockScreen(); 389 shell->session_state_delegate()->LockScreen();
388 EXPECT_EQ(LoginStatus::LOCKED, 390 EXPECT_EQ(LoginStatus::LOCKED,
389 shell->system_tray_delegate()->GetUserLoginStatus()); 391 wm_shell->system_tray_delegate()->GetUserLoginStatus());
390 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 392 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
391 ->layout_manager(), 393 ->layout_manager(),
392 controller->GetSystemModalLayoutManager(NULL)); 394 controller->GetSystemModalLayoutManager(NULL));
393 395
394 aura::Window* lock_container = 396 aura::Window* lock_container =
395 controller->GetContainer(kShellWindowId_LockScreenContainer); 397 controller->GetContainer(kShellWindowId_LockScreenContainer);
396 views::Widget* lock_modal_widget = 398 views::Widget* lock_modal_widget =
397 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 399 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
398 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 400 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
399 ->layout_manager(), 401 ->layout_manager(),
400 controller->GetSystemModalLayoutManager( 402 controller->GetSystemModalLayoutManager(
401 lock_modal_widget->GetNativeView())); 403 lock_modal_widget->GetNativeView()));
402 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 404 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
403 ->layout_manager(), 405 ->layout_manager(),
404 controller->GetSystemModalLayoutManager( 406 controller->GetSystemModalLayoutManager(
405 session_modal_widget->GetNativeView())); 407 session_modal_widget->GetNativeView()));
406 408
407 shell->session_state_delegate()->UnlockScreen(); 409 shell->session_state_delegate()->UnlockScreen();
408 } 410 }
409 411
410 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 412 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
411 UpdateDisplay("600x600"); 413 UpdateDisplay("600x600");
412 Shell* shell = Shell::GetInstance(); 414 Shell* shell = Shell::GetInstance();
415 WmShell* wm_shell = WmShell::Get();
413 416
414 // Configure login screen environment. 417 // Configure login screen environment.
415 SetUserLoggedIn(false); 418 SetUserLoggedIn(false);
416 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 419 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
417 shell->system_tray_delegate()->GetUserLoginStatus()); 420 wm_shell->system_tray_delegate()->GetUserLoginStatus());
418 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers()); 421 EXPECT_EQ(0, shell->session_state_delegate()->NumberOfLoggedInUsers());
419 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted()); 422 EXPECT_FALSE(shell->session_state_delegate()->IsActiveUserSessionStarted());
420 423
421 RootWindowController* controller = shell->GetPrimaryRootWindowController(); 424 RootWindowController* controller = shell->GetPrimaryRootWindowController();
422 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 425 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
423 ->layout_manager(), 426 ->layout_manager(),
424 controller->GetSystemModalLayoutManager(NULL)); 427 controller->GetSystemModalLayoutManager(NULL));
425 428
426 aura::Window* lock_container = 429 aura::Window* lock_container =
427 controller->GetContainer(kShellWindowId_LockScreenContainer); 430 controller->GetContainer(kShellWindowId_LockScreenContainer);
428 views::Widget* login_modal_widget = 431 views::Widget* login_modal_widget =
429 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 432 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
430 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer) 433 EXPECT_EQ(controller->GetContainer(kShellWindowId_LockSystemModalContainer)
431 ->layout_manager(), 434 ->layout_manager(),
432 controller->GetSystemModalLayoutManager( 435 controller->GetSystemModalLayoutManager(
433 login_modal_widget->GetNativeView())); 436 login_modal_widget->GetNativeView()));
434 login_modal_widget->Close(); 437 login_modal_widget->Close();
435 438
436 // Configure user session environment. 439 // Configure user session environment.
437 SetUserLoggedIn(true); 440 SetUserLoggedIn(true);
438 SetSessionStarted(true); 441 SetSessionStarted(true);
439 EXPECT_EQ(LoginStatus::USER, 442 EXPECT_EQ(LoginStatus::USER,
440 shell->system_tray_delegate()->GetUserLoginStatus()); 443 wm_shell->system_tray_delegate()->GetUserLoginStatus());
441 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers()); 444 EXPECT_EQ(1, shell->session_state_delegate()->NumberOfLoggedInUsers());
442 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted()); 445 EXPECT_TRUE(shell->session_state_delegate()->IsActiveUserSessionStarted());
443 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 446 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
444 ->layout_manager(), 447 ->layout_manager(),
445 controller->GetSystemModalLayoutManager(NULL)); 448 controller->GetSystemModalLayoutManager(NULL));
446 449
447 views::Widget* session_modal_widget = 450 views::Widget* session_modal_widget =
448 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 451 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
449 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer) 452 EXPECT_EQ(controller->GetContainer(kShellWindowId_SystemModalContainer)
450 ->layout_manager(), 453 ->layout_manager(),
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1046 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1044 gfx::Rect(0, 400, 800, 200)); 1047 gfx::Rect(0, 400, 800, 200));
1045 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1048 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1046 1049
1047 UpdateDisplay("600x800"); 1050 UpdateDisplay("600x800");
1048 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1051 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1049 } 1052 }
1050 1053
1051 } // namespace test 1054 } // namespace test
1052 } // namespace ash 1055 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698