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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2864663002: cros: Merge SystemTrayDelegate::GetUserLoginStatus (Closed)
Patch Set: update PaletteTray to exclude ARC kiosk Created 3 years, 7 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/system_tray_delegate_mus.cc ('k') | ash/session/session_controller.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/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/system/tray/system_tray_delegate.h"
15 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
16 #include "ash/test/test_session_controller_client.h" 15 #include "ash/test/test_session_controller_client.h"
17 #include "ash/wm/system_modal_container_layout_manager.h" 16 #include "ash/wm/system_modal_container_layout_manager.h"
18 #include "ash/wm/window_properties.h" 17 #include "ash/wm/window_properties.h"
19 #include "ash/wm/window_state.h" 18 #include "ash/wm/window_state.h"
20 #include "ash/wm/window_state_aura.h" 19 #include "ash/wm/window_state_aura.h"
21 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
22 #include "ash/wm_window.h" 21 #include "ash/wm_window.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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 controller->GetRootWindow()->GetChildById(kLockScreenWindowId)); 379 controller->GetRootWindow()->GetChildById(kLockScreenWindowId));
381 ASSERT_EQ(lock_wallpaper->GetNativeWindow(), 380 ASSERT_EQ(lock_wallpaper->GetNativeWindow(),
382 controller->GetRootWindow()->GetChildById(kLockWallpaperWindowId)); 381 controller->GetRootWindow()->GetChildById(kLockWallpaperWindowId));
383 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString()); 382 EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString());
384 } 383 }
385 384
386 TEST_F(RootWindowControllerTest, ModalContainer) { 385 TEST_F(RootWindowControllerTest, ModalContainer) {
387 UpdateDisplay("600x600"); 386 UpdateDisplay("600x600");
388 RootWindowController* controller = 387 RootWindowController* controller =
389 ShellPort::Get()->GetPrimaryRootWindowController(); 388 ShellPort::Get()->GetPrimaryRootWindowController();
390 EXPECT_EQ(LoginStatus::USER, 389 EXPECT_TRUE(Shell::Get()->session_controller()->IsActiveUserSessionStarted());
391 Shell::Get()->system_tray_delegate()->GetUserLoginStatus());
392 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 390 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
393 controller->GetSystemModalLayoutManager(NULL)); 391 controller->GetSystemModalLayoutManager(NULL));
394 392
395 views::Widget* session_modal_widget = 393 views::Widget* session_modal_widget =
396 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 394 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
397 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 395 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
398 controller->GetSystemModalLayoutManager( 396 controller->GetSystemModalLayoutManager(
399 WmWindow::Get(session_modal_widget->GetNativeWindow()))); 397 WmWindow::Get(session_modal_widget->GetNativeWindow())));
400 398
401 Shell::Get()->session_controller()->LockScreenAndFlushForTest(); 399 Shell::Get()->session_controller()->LockScreenAndFlushForTest();
402 EXPECT_EQ(LoginStatus::LOCKED, 400 EXPECT_TRUE(Shell::Get()->session_controller()->IsScreenLocked());
403 Shell::Get()->system_tray_delegate()->GetUserLoginStatus());
404 EXPECT_EQ( 401 EXPECT_EQ(
405 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 402 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
406 controller->GetSystemModalLayoutManager(nullptr)); 403 controller->GetSystemModalLayoutManager(nullptr));
407 404
408 aura::Window* lock_container = 405 aura::Window* lock_container =
409 controller->GetContainer(kShellWindowId_LockScreenContainer); 406 controller->GetContainer(kShellWindowId_LockScreenContainer);
410 views::Widget* lock_modal_widget = 407 views::Widget* lock_modal_widget =
411 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 408 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
412 EXPECT_EQ( 409 EXPECT_EQ(
413 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 410 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
414 controller->GetSystemModalLayoutManager( 411 controller->GetSystemModalLayoutManager(
415 WmWindow::Get(lock_modal_widget->GetNativeWindow()))); 412 WmWindow::Get(lock_modal_widget->GetNativeWindow())));
416 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 413 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
417 controller->GetSystemModalLayoutManager( 414 controller->GetSystemModalLayoutManager(
418 WmWindow::Get(session_modal_widget->GetNativeWindow()))); 415 WmWindow::Get(session_modal_widget->GetNativeWindow())));
419 416
420 GetSessionControllerClient()->UnlockScreen(); 417 GetSessionControllerClient()->UnlockScreen();
421 } 418 }
422 419
423 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) { 420 TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
424 UpdateDisplay("600x600"); 421 UpdateDisplay("600x600");
425 422
426 // Configure login screen environment. 423 // Configure login screen environment.
427 SessionController* session_controller = Shell::Get()->session_controller(); 424 SessionController* session_controller = Shell::Get()->session_controller();
428 SetUserLoggedIn(false); 425 SetUserLoggedIn(false);
429 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN,
430 Shell::Get()->system_tray_delegate()->GetUserLoginStatus());
431 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers()); 426 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers());
432 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted()); 427 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted());
433 428
434 RootWindowController* controller = 429 RootWindowController* controller =
435 ShellPort::Get()->GetPrimaryRootWindowController(); 430 ShellPort::Get()->GetPrimaryRootWindowController();
436 EXPECT_EQ( 431 EXPECT_EQ(
437 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 432 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
438 controller->GetSystemModalLayoutManager(NULL)); 433 controller->GetSystemModalLayoutManager(NULL));
439 434
440 aura::Window* lock_container = 435 aura::Window* lock_container =
441 controller->GetContainer(kShellWindowId_LockScreenContainer); 436 controller->GetContainer(kShellWindowId_LockScreenContainer);
442 views::Widget* login_modal_widget = 437 views::Widget* login_modal_widget =
443 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 438 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
444 EXPECT_EQ( 439 EXPECT_EQ(
445 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 440 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
446 controller->GetSystemModalLayoutManager( 441 controller->GetSystemModalLayoutManager(
447 WmWindow::Get(login_modal_widget->GetNativeWindow()))); 442 WmWindow::Get(login_modal_widget->GetNativeWindow())));
448 login_modal_widget->Close(); 443 login_modal_widget->Close();
449 444
450 // Configure user session environment. 445 // Configure user session environment.
451 SetUserLoggedIn(true); 446 SetUserLoggedIn(true);
452 SetSessionStarted(true); 447 SetSessionStarted(true);
453 EXPECT_EQ(LoginStatus::USER,
454 Shell::Get()->system_tray_delegate()->GetUserLoginStatus());
455 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers()); 448 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers());
456 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted()); 449 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted());
457 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 450 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
458 controller->GetSystemModalLayoutManager(NULL)); 451 controller->GetSystemModalLayoutManager(NULL));
459 452
460 views::Widget* session_modal_widget = 453 views::Widget* session_modal_widget =
461 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 454 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
462 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 455 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
463 controller->GetSystemModalLayoutManager( 456 controller->GetSystemModalLayoutManager(
464 WmWindow::Get(session_modal_widget->GetNativeWindow()))); 457 WmWindow::Get(session_modal_widget->GetNativeWindow())));
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1230 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1238 gfx::Rect(0, 400, 800, 200)); 1231 gfx::Rect(0, 400, 800, 200));
1239 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1232 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1240 1233
1241 UpdateDisplay("600x800"); 1234 UpdateDisplay("600x800");
1242 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1235 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1243 } 1236 }
1244 1237
1245 } // namespace test 1238 } // namespace test
1246 } // namespace ash 1239 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/system_tray_delegate_mus.cc ('k') | ash/session/session_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698