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" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 Shell::GetInstance()->OnLockStateChanged(true); | 372 Shell::GetInstance()->OnLockStateChanged(true); |
373 } | 373 } |
374 | 374 |
375 // Turn off the lock screen. | 375 // Turn off the lock screen. |
376 void UnlockScreen() { | 376 void UnlockScreen() { |
377 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 377 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
378 // The test session state delegate does not fire the lock state change. | 378 // The test session state delegate does not fire the lock state change. |
379 Shell::GetInstance()->OnLockStateChanged(false); | 379 Shell::GetInstance()->OnLockStateChanged(false); |
380 } | 380 } |
381 | 381 |
382 // Open the add user screen if |show| is true, otherwise end it. | |
383 void ShowAddUserScreen(bool show) { | |
384 SetUserAddingScreenRunning(show); | |
385 | |
386 const SessionStateDelegate::SessionState state = | |
387 show ? SessionStateDelegate::SESSION_STATE_LOGIN_SECONDARY | |
388 : SessionStateDelegate::SESSION_STATE_ACTIVE; | |
389 GetShelfWidget()->shelf_layout_manager()->SessionStateChanged(state); | |
390 test::ShelfTestAPI(GetShelfWidget()->shelf()) | |
391 .shelf_locking_manager() | |
392 ->SessionStateChanged(state); | |
393 } | |
394 | |
395 private: | 382 private: |
396 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); | 383 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
397 }; | 384 }; |
398 | 385 |
399 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { | 386 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
400 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 387 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
401 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 388 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
402 views::Widget* widget = new views::Widget; | 389 views::Widget* widget = new views::Widget; |
403 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 390 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
404 params.bounds = gfx::Rect(0, 0, 200, 200); | 391 params.bounds = gfx::Rect(0, 0, 200, 200); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 743 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
757 | 744 |
758 // Make sure the bounds of the two widgets changed. | 745 // Make sure the bounds of the two widgets changed. |
759 shelf_bounds = shelf->GetNativeView()->bounds(); | 746 shelf_bounds = shelf->GetNativeView()->bounds(); |
760 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); | 747 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
761 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); | 748 status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); |
762 EXPECT_LT(status_bounds.y(), | 749 EXPECT_LT(status_bounds.y(), |
763 screen->GetPrimaryDisplay().bounds().bottom()); | 750 screen->GetPrimaryDisplay().bounds().bottom()); |
764 } | 751 } |
765 | 752 |
766 // Makes sure shelf alignment is correct for lock screen. | |
767 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLockScreen) { | |
768 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | |
769 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); | |
770 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | |
771 LockScreen(); | |
772 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment()); | |
773 UnlockScreen(); | |
774 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | |
775 } | |
776 | |
777 // Makes sure shelf alignment is correct for add user screen. | |
778 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithAddUserScreen) { | |
779 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | |
780 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); | |
781 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | |
782 ShowAddUserScreen(true); | |
783 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM_LOCKED, manager->GetAlignment()); | |
784 ShowAddUserScreen(false); | |
785 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | |
786 } | |
787 | |
788 // Makes sure shelf alignment is correct for login screen. | |
789 TEST_F(ShelfLayoutManagerTest, SideAlignmentInteractionWithLoginScreen) { | |
790 ShelfLayoutManager* manager = GetShelfWidget()->shelf_layout_manager(); | |
791 ASSERT_EQ(SHELF_ALIGNMENT_BOTTOM, manager->GetAlignment()); | |
792 SetUserLoggedIn(false); | |
793 SetSessionStarted(false); | |
794 | |
795 // The test session state delegate does not fire state changes. | |
796 SetSessionStarting(); | |
797 manager->SessionStateChanged( | |
798 Shell::GetInstance()->session_state_delegate()->GetSessionState()); | |
799 | |
800 // Login sets alignment preferences before the session completes startup. | |
801 manager->SetAlignment(SHELF_ALIGNMENT_LEFT); | |
802 SetUserLoggedIn(true); | |
803 SetSessionStarted(true); | |
804 | |
805 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, manager->GetAlignment()); | |
806 // Ensure that the shelf has been notified. | |
807 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetShelfWidget()->shelf()->alignment()); | |
808 } | |
809 | |
810 // Makes sure LayoutShelf invoked while animating cleans things up. | 753 // Makes sure LayoutShelf invoked while animating cleans things up. |
811 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 754 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
812 ShelfWidget* shelf = GetShelfWidget(); | 755 ShelfWidget* shelf = GetShelfWidget(); |
813 // Force an initial layout. | 756 // Force an initial layout. |
814 shelf->shelf_layout_manager()->LayoutShelf(); | 757 shelf->shelf_layout_manager()->LayoutShelf(); |
815 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); | 758 EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); |
816 | 759 |
817 // Hide the shelf. | 760 // Hide the shelf. |
818 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); | 761 SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); |
819 shelf->shelf_layout_manager()->LayoutShelf(); | 762 shelf->shelf_layout_manager()->LayoutShelf(); |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2337 StatusAreaWidget* status_area_widget = | 2280 StatusAreaWidget* status_area_widget = |
2338 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); | 2281 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
2339 EXPECT_TRUE(status_area_widget->IsVisible()); | 2282 EXPECT_TRUE(status_area_widget->IsVisible()); |
2340 // Shelf should be in the first display's area. | 2283 // Shelf should be in the first display's area. |
2341 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2284 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
2342 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2285 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
2343 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2286 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
2344 } | 2287 } |
2345 | 2288 |
2346 } // namespace ash | 2289 } // namespace ash |
OLD | NEW |