| OLD | NEW |
| 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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
| 8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 11 #include "ash/display/window_tree_host_manager.h" | 11 #include "ash/display/window_tree_host_manager.h" |
| 12 #include "ash/focus_cycler.h" | 12 #include "ash/focus_cycler.h" |
| 13 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
| 14 #include "ash/session/session_state_delegate.h" | 14 #include "ash/session/session_state_delegate.h" |
| 15 #include "ash/shelf/shelf.h" | 15 #include "ash/shelf/shelf.h" |
| 16 #include "ash/shelf/shelf_layout_manager_observer.h" | 16 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 17 #include "ash/shelf/shelf_locking_manager.h" |
| 17 #include "ash/shelf/shelf_view.h" | 18 #include "ash/shelf/shelf_view.h" |
| 18 #include "ash/shelf/shelf_widget.h" | 19 #include "ash/shelf/shelf_widget.h" |
| 19 #include "ash/shell.h" | 20 #include "ash/shell.h" |
| 20 #include "ash/shell_window_ids.h" | 21 #include "ash/shell_window_ids.h" |
| 21 #include "ash/system/status_area_widget.h" | 22 #include "ash/system/status_area_widget.h" |
| 22 #include "ash/system/tray/system_tray.h" | 23 #include "ash/system/tray/system_tray.h" |
| 23 #include "ash/system/tray/system_tray_item.h" | 24 #include "ash/system/tray/system_tray_item.h" |
| 24 #include "ash/test/ash_test_base.h" | 25 #include "ash/test/ash_test_base.h" |
| 25 #include "ash/test/display_manager_test_api.h" | 26 #include "ash/test/display_manager_test_api.h" |
| 26 #include "ash/test/shelf_test_api.h" | 27 #include "ash/test/shelf_test_api.h" |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // Turn off the lock screen. | 374 // Turn off the lock screen. |
| 374 void UnlockScreen() { | 375 void UnlockScreen() { |
| 375 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 376 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
| 376 // The test session state delegate does not fire the lock state change. | 377 // The test session state delegate does not fire the lock state change. |
| 377 Shell::GetInstance()->OnLockStateChanged(false); | 378 Shell::GetInstance()->OnLockStateChanged(false); |
| 378 } | 379 } |
| 379 | 380 |
| 380 // Open the add user screen if |show| is true, otherwise end it. | 381 // Open the add user screen if |show| is true, otherwise end it. |
| 381 void ShowAddUserScreen(bool show) { | 382 void ShowAddUserScreen(bool show) { |
| 382 SetUserAddingScreenRunning(show); | 383 SetUserAddingScreenRunning(show); |
| 383 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | 384 |
| 384 manager->SessionStateChanged( | 385 const SessionStateDelegate::SessionState state = |
| 385 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY : | 386 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY |
| 386 SessionStateDelegate::SESSION_STATE_ACTIVE); | 387 : SessionStateDelegate::SESSION_STATE_ACTIVE; |
| 388 GetShelfWidget()->shelf_layout_manager()->SessionStateChanged(state); |
| 389 test::ShelfTestAPI(GetShelfWidget()->shelf()) |
| 390 .shelf_locking_manager() |
| 391 ->SessionStateChanged(state); |
| 387 } | 392 } |
| 388 | 393 |
| 389 private: | 394 private: |
| 390 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); | 395 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
| 391 }; | 396 }; |
| 392 | 397 |
| 393 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { | 398 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| 394 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 399 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 395 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 400 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 396 views::Widget* widget = new views::Widget; | 401 views::Widget* widget = new views::Widget; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 EXPECT_LT(status_bounds.y(), | 761 EXPECT_LT(status_bounds.y(), |
| 757 screen->GetPrimaryDisplay().bounds().bottom()); | 762 screen->GetPrimaryDisplay().bounds().bottom()); |
| 758 } | 763 } |
| 759 | 764 |
| 760 // Makes sure shelf alignment is correct for lock screen. | 765 // Makes sure shelf alignment is correct for lock screen. |
| 761 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) { | 766 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) { |
| 762 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | 767 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); |
| 763 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); | 768 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 764 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | 769 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); |
| 765 LockScreen(); | 770 LockScreen(); |
| 766 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); | 771 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment()); |
| 767 UnlockScreen(); | 772 UnlockScreen(); |
| 768 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | 773 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); |
| 769 } | 774 } |
| 770 | 775 |
| 771 // Makes sure shelf alignment is correct for add user screen. | 776 // Makes sure shelf alignment is correct for add user screen. |
| 772 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) { | 777 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) { |
| 773 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | 778 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); |
| 774 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); | 779 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 775 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | 780 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); |
| 776 ShowAddUserScreen(true); | 781 ShowAddUserScreen(true); |
| 777 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); | 782 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment()); |
| 778 ShowAddUserScreen(false); | 783 ShowAddUserScreen(false); |
| 779 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | 784 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); |
| 780 } | 785 } |
| 781 | 786 |
| 782 // Makes sure shelf alignment is correct for login screen. | 787 // Makes sure shelf alignment is correct for login screen. |
| 783 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) { | 788 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) { |
| 784 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | 789 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); |
| 785 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); | 790 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); |
| 786 SetUserLoggedIn(false); | 791 SetUserLoggedIn(false); |
| 787 SetSessionStarted(false); | 792 SetSessionStarted(false); |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2331 StatusAreaWidget* status_area_widget = | 2336 StatusAreaWidget* status_area_widget = |
| 2332 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); | 2337 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
| 2333 EXPECT_TRUE(status_area_widget->IsVisible()); | 2338 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 2334 // Shelf should be in the first display's area. | 2339 // Shelf should be in the first display's area. |
| 2335 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2340 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 2336 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2341 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 2337 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2342 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 2338 } | 2343 } |
| 2339 | 2344 |
| 2340 } // namespace ash | 2345 } // namespace ash |
| OLD | NEW |