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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2864663002: cros: Merge SystemTrayDelegate::GetUserLoginStatus (Closed)
Patch Set: 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
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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_EQ(LoginStatus::USER,
391 Shell::Get()->system_tray_delegate()->GetUserLoginStatus()); 390 Shell::Get()->session_controller()->login_status());
James Cook 2017/05/05 17:51:53 How about switching some of these to their non-Log
xiyuan 2017/05/05 18:36:33 Right. Replaced LoginStatus with SessionController
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 WmWindow::Get(session_modal_widget->GetNativeWindow()))); 398 WmWindow::Get(session_modal_widget->GetNativeWindow())));
400 399
401 Shell::Get()->session_controller()->LockScreenAndFlushForTest(); 400 Shell::Get()->session_controller()->LockScreenAndFlushForTest();
402 EXPECT_EQ(LoginStatus::LOCKED, 401 EXPECT_EQ(LoginStatus::LOCKED,
403 Shell::Get()->system_tray_delegate()->GetUserLoginStatus()); 402 Shell::Get()->session_controller()->login_status());
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 WmWindow::Get(lock_modal_widget->GetNativeWindow()))); 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 WmWindow::Get(session_modal_widget->GetNativeWindow()))); 417 WmWindow::Get(session_modal_widget->GetNativeWindow())));
419 418
420 GetSessionControllerClient()->UnlockScreen(); 419 GetSessionControllerClient()->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 SessionController* session_controller = Shell::Get()->session_controller(); 426 SessionController* session_controller = Shell::Get()->session_controller();
428 SetUserLoggedIn(false); 427 SetUserLoggedIn(false);
429 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, 428 EXPECT_EQ(LoginStatus::NOT_LOGGED_IN, session_controller->login_status());
430 Shell::Get()->system_tray_delegate()->GetUserLoginStatus());
431 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers()); 429 EXPECT_EQ(0, session_controller->NumberOfLoggedInUsers());
432 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted()); 430 EXPECT_FALSE(session_controller->IsActiveUserSessionStarted());
433 431
434 RootWindowController* controller = 432 RootWindowController* controller =
435 ShellPort::Get()->GetPrimaryRootWindowController(); 433 ShellPort::Get()->GetPrimaryRootWindowController();
436 EXPECT_EQ( 434 EXPECT_EQ(
437 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 435 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
438 controller->GetSystemModalLayoutManager(NULL)); 436 controller->GetSystemModalLayoutManager(NULL));
439 437
440 aura::Window* lock_container = 438 aura::Window* lock_container =
441 controller->GetContainer(kShellWindowId_LockScreenContainer); 439 controller->GetContainer(kShellWindowId_LockScreenContainer);
442 views::Widget* login_modal_widget = 440 views::Widget* login_modal_widget =
443 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container); 441 CreateModalWidgetWithParent(gfx::Rect(300, 10, 100, 100), lock_container);
444 EXPECT_EQ( 442 EXPECT_EQ(
445 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer), 443 GetLayoutManager(controller, kShellWindowId_LockSystemModalContainer),
446 controller->GetSystemModalLayoutManager( 444 controller->GetSystemModalLayoutManager(
447 WmWindow::Get(login_modal_widget->GetNativeWindow()))); 445 WmWindow::Get(login_modal_widget->GetNativeWindow())));
448 login_modal_widget->Close(); 446 login_modal_widget->Close();
449 447
450 // Configure user session environment. 448 // Configure user session environment.
451 SetUserLoggedIn(true); 449 SetUserLoggedIn(true);
452 SetSessionStarted(true); 450 SetSessionStarted(true);
453 EXPECT_EQ(LoginStatus::USER, 451 EXPECT_EQ(LoginStatus::USER, session_controller->login_status());
James Cook 2017/05/05 17:51:53 nit: could remove this one
xiyuan 2017/05/05 18:36:33 Done.
454 Shell::Get()->system_tray_delegate()->GetUserLoginStatus());
455 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers()); 452 EXPECT_EQ(1, session_controller->NumberOfLoggedInUsers());
456 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted()); 453 EXPECT_TRUE(session_controller->IsActiveUserSessionStarted());
457 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 454 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
458 controller->GetSystemModalLayoutManager(NULL)); 455 controller->GetSystemModalLayoutManager(NULL));
459 456
460 views::Widget* session_modal_widget = 457 views::Widget* session_modal_widget =
461 CreateModalWidget(gfx::Rect(300, 10, 100, 100)); 458 CreateModalWidget(gfx::Rect(300, 10, 100, 100));
462 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer), 459 EXPECT_EQ(GetLayoutManager(controller, kShellWindowId_SystemModalContainer),
463 controller->GetSystemModalLayoutManager( 460 controller->GetSystemModalLayoutManager(
464 WmWindow::Get(session_modal_widget->GetNativeWindow()))); 461 WmWindow::Get(session_modal_widget->GetNativeWindow())));
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1234 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1238 gfx::Rect(0, 400, 800, 200)); 1235 gfx::Rect(0, 400, 800, 200));
1239 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1236 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1240 1237
1241 UpdateDisplay("600x800"); 1238 UpdateDisplay("600x800");
1242 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1239 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1243 } 1240 }
1244 1241
1245 } // namespace test 1242 } // namespace test
1246 } // namespace ash 1243 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698