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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2899253002: chromeos: Rename ash::WmShelf to Shelf (Closed)
Patch Set: cleanup 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/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/focus_cycler.h" 9 #include "ash/focus_cycler.h"
10 #include "ash/public/cpp/config.h" 10 #include "ash/public/cpp/config.h"
11 #include "ash/public/cpp/shell_window_ids.h" 11 #include "ash/public/cpp/shell_window_ids.h"
12 #include "ash/root_window_controller.h" 12 #include "ash/root_window_controller.h"
13 #include "ash/session/session_controller.h" 13 #include "ash/session/session_controller.h"
14 #include "ash/shelf/shelf.h"
14 #include "ash/shelf/shelf_constants.h" 15 #include "ash/shelf/shelf_constants.h"
15 #include "ash/shelf/shelf_layout_manager_observer.h" 16 #include "ash/shelf/shelf_layout_manager_observer.h"
16 #include "ash/shelf/shelf_view.h" 17 #include "ash/shelf/shelf_view.h"
17 #include "ash/shelf/shelf_widget.h" 18 #include "ash/shelf/shelf_widget.h"
18 #include "ash/shelf/wm_shelf.h"
19 #include "ash/shell.h" 19 #include "ash/shell.h"
20 #include "ash/shell_port.h" 20 #include "ash/shell_port.h"
21 #include "ash/system/status_area_widget.h" 21 #include "ash/system/status_area_widget.h"
22 #include "ash/system/tray/system_tray.h" 22 #include "ash/system/tray/system_tray.h"
23 #include "ash/system/tray/system_tray_item.h" 23 #include "ash/system/tray/system_tray_item.h"
24 #include "ash/test/ash_test_base.h" 24 #include "ash/test/ash_test_base.h"
25 #include "ash/test/test_app_list_view_presenter_impl.h" 25 #include "ash/test/test_app_list_view_presenter_impl.h"
26 #include "ash/test/test_system_tray_item.h" 26 #include "ash/test/test_system_tray_item.h"
27 #include "ash/wm/lock_state_controller.h" 27 #include "ash/wm/lock_state_controller.h"
28 #include "ash/wm/window_state.h" 28 #include "ash/wm/window_state.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return; 149 return;
150 } 150 }
151 151
152 // The state of the shelf at the end of the gesture is tested separately. 152 // The state of the shelf at the end of the gesture is tested separately.
153 if (type == ui::ET_GESTURE_SCROLL_END) 153 if (type == ui::ET_GESTURE_SCROLL_END)
154 return; 154 return;
155 155
156 if (type == ui::ET_GESTURE_SCROLL_UPDATE) 156 if (type == ui::ET_GESTURE_SCROLL_UPDATE)
157 scroll_.Add(delta); 157 scroll_.Add(delta);
158 158
159 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf(); 159 Shelf* shelf = test::AshTestBase::GetPrimaryShelf();
160 gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 160 gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
161 if (shelf->IsHorizontalAlignment()) { 161 if (shelf->IsHorizontalAlignment()) {
162 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.bottom(), 162 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.bottom(),
163 shelf_bounds.bottom()); 163 shelf_bounds.bottom());
164 EXPECT_EQ(shelf_widget_bounds_.bottom(), shelf_bounds.bottom()); 164 EXPECT_EQ(shelf_widget_bounds_.bottom(), shelf_bounds.bottom());
165 } else if (SHELF_ALIGNMENT_RIGHT == shelf->alignment()) { 165 } else if (SHELF_ALIGNMENT_RIGHT == shelf->alignment()) {
166 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right()); 166 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right());
167 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right()); 167 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right());
168 } else if (SHELF_ALIGNMENT_LEFT == shelf->alignment()) { 168 } else if (SHELF_ALIGNMENT_LEFT == shelf->alignment()) {
169 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x()); 169 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x());
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 306
307 int64_t GetPrimaryDisplayId() { 307 int64_t GetPrimaryDisplayId() {
308 return display::Screen::GetScreen()->GetPrimaryDisplay().id(); 308 return display::Screen::GetScreen()->GetPrimaryDisplay().id();
309 } 309 }
310 310
311 private: 311 private:
312 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); 312 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest);
313 }; 313 };
314 314
315 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { 315 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
316 WmShelf* shelf = GetPrimaryShelf(); 316 Shelf* shelf = GetPrimaryShelf();
317 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 317 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
318 318
319 views::Widget* widget = CreateTestWidget(); 319 views::Widget* widget = CreateTestWidget();
320 widget->Maximize(); 320 widget->Maximize();
321 321
322 // The time delta should be large enough to prevent accidental fling creation. 322 // The time delta should be large enough to prevent accidental fling creation.
323 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100); 323 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100);
324 324
325 aura::Window* window = widget->GetNativeWindow(); 325 aura::Window* window = widget->GetNativeWindow();
326 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 326 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 672
673 // Make sure the bounds of the two widgets changed. 673 // Make sure the bounds of the two widgets changed.
674 shelf_bounds = shelf_widget->GetNativeView()->bounds(); 674 shelf_bounds = shelf_widget->GetNativeView()->bounds();
675 EXPECT_LT(shelf_bounds.y(), display.bounds().bottom()); 675 EXPECT_LT(shelf_bounds.y(), display.bounds().bottom());
676 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); 676 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds();
677 EXPECT_LT(status_bounds.y(), display.bounds().bottom()); 677 EXPECT_LT(status_bounds.y(), display.bounds().bottom());
678 } 678 }
679 679
680 // Makes sure LayoutShelf invoked while animating cleans things up. 680 // Makes sure LayoutShelf invoked while animating cleans things up.
681 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 681 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
682 WmShelf* shelf = GetPrimaryShelf(); 682 Shelf* shelf = GetPrimaryShelf();
683 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 683 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
684 // Force an initial layout. 684 // Force an initial layout.
685 layout_manager->LayoutShelf(); 685 layout_manager->LayoutShelf();
686 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 686 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
687 687
688 // Hide the shelf. 688 // Hide the shelf.
689 SetState(layout_manager, SHELF_HIDDEN); 689 SetState(layout_manager, SHELF_HIDDEN);
690 layout_manager->LayoutShelf(); 690 layout_manager->LayoutShelf();
691 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 691 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
692 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 692 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
(...skipping 30 matching lines...) Expand all
723 EXPECT_LE( 723 EXPECT_LE(
724 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), 724 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()),
725 small_change); 725 small_change);
726 EXPECT_LE( 726 EXPECT_LE(
727 std::abs(initial_status_bounds.height() - current_status_bounds.height()), 727 std::abs(initial_status_bounds.height() - current_status_bounds.height()),
728 small_change); 728 small_change);
729 } 729 }
730 730
731 // Makes sure the shelf is sized when the status area changes size. 731 // Makes sure the shelf is sized when the status area changes size.
732 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { 732 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) {
733 WmShelf* shelf = GetPrimaryShelf(); 733 Shelf* shelf = GetPrimaryShelf();
734 ASSERT_TRUE(shelf); 734 ASSERT_TRUE(shelf);
735 ShelfWidget* shelf_widget = GetShelfWidget(); 735 ShelfWidget* shelf_widget = GetShelfWidget();
736 ASSERT_TRUE(shelf_widget); 736 ASSERT_TRUE(shelf_widget);
737 ASSERT_TRUE(shelf_widget->status_area_widget()); 737 ASSERT_TRUE(shelf_widget->status_area_widget());
738 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); 738 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200));
739 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - 739 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() -
740 shelf->GetShelfViewForTesting()->width()); 740 shelf->GetShelfViewForTesting()->width());
741 } 741 }
742 742
743 // Various assertions around auto-hide. 743 // Various assertions around auto-hide.
744 TEST_F(ShelfLayoutManagerTest, AutoHide) { 744 TEST_F(ShelfLayoutManagerTest, AutoHide) {
745 // TODO: investigate failure in mash, http://crbug.com/695686. 745 // TODO: investigate failure in mash, http://crbug.com/695686.
746 if (Shell::GetAshConfig() == Config::MASH) 746 if (Shell::GetAshConfig() == Config::MASH)
747 return; 747 return;
748 748
749 ui::test::EventGenerator& generator(GetEventGenerator()); 749 ui::test::EventGenerator& generator(GetEventGenerator());
750 750
751 WmShelf* shelf = GetPrimaryShelf(); 751 Shelf* shelf = GetPrimaryShelf();
752 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 752 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
753 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 753 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
754 views::Widget* widget = CreateTestWidget(); 754 views::Widget* widget = CreateTestWidget();
755 widget->Maximize(); 755 widget->Maximize();
756 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 756 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
757 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 757 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
758 758
759 // LayoutShelf() forces the animation to completion, at which point the 759 // LayoutShelf() forces the animation to completion, at which point the
760 // shelf should go off the screen. 760 // shelf should go off the screen.
761 layout_manager->LayoutShelf(); 761 layout_manager->LayoutShelf();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 if (Shell::GetAshConfig() == Config::MASH) 808 if (Shell::GetAshConfig() == Config::MASH)
809 return; 809 return;
810 810
811 UpdateDisplay("800x600,800x600"); 811 UpdateDisplay("800x600,800x600");
812 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash. 812 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash.
813 // http://crbug.com/698043. 813 // http://crbug.com/698043.
814 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays( 814 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays(
815 display::test::CreateDisplayLayout(display_manager(), 815 display::test::CreateDisplayLayout(display_manager(),
816 display::DisplayPlacement::RIGHT, 0)); 816 display::DisplayPlacement::RIGHT, 0));
817 // Put the primary monitor's shelf on the display boundary. 817 // Put the primary monitor's shelf on the display boundary.
818 WmShelf* shelf = GetPrimaryShelf(); 818 Shelf* shelf = GetPrimaryShelf();
819 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 819 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
820 820
821 // Create a window because the shelf is always shown when no windows are 821 // Create a window because the shelf is always shown when no windows are
822 // visible. 822 // visible.
823 CreateTestWidget(); 823 CreateTestWidget();
824 824
825 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 825 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
826 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 826 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
827 827
828 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 828 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 891
892 // Moving to the left edge of the secondary display without first crossing 892 // Moving to the left edge of the secondary display without first crossing
893 // the primary display's right aligned shelf first should not show the shelf. 893 // the primary display's right aligned shelf first should not show the shelf.
894 generator.MoveMouseTo(right_edge + 2, y); 894 generator.MoveMouseTo(right_edge + 2, y);
895 UpdateAutoHideStateNow(); 895 UpdateAutoHideStateNow();
896 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 896 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
897 } 897 }
898 898
899 // Assertions around the login screen. 899 // Assertions around the login screen.
900 TEST_F(ShelfLayoutManagerTest, VisibleWhenLoginScreenShowing) { 900 TEST_F(ShelfLayoutManagerTest, VisibleWhenLoginScreenShowing) {
901 WmShelf* shelf = GetPrimaryShelf(); 901 Shelf* shelf = GetPrimaryShelf();
902 902
903 mojom::SessionInfoPtr info = mojom::SessionInfo::New(); 903 mojom::SessionInfoPtr info = mojom::SessionInfo::New();
904 info->state = session_manager::SessionState::LOGIN_PRIMARY; 904 info->state = session_manager::SessionState::LOGIN_PRIMARY;
905 ash::Shell::Get()->session_controller()->SetSessionInfo(std::move(info)); 905 ash::Shell::Get()->session_controller()->SetSessionInfo(std::move(info));
906 906
907 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 907 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
908 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 908 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
909 } 909 }
910 910
911 // Assertions around the lock screen showing. 911 // Assertions around the lock screen showing.
912 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { 912 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
913 WmShelf* shelf = GetPrimaryShelf(); 913 Shelf* shelf = GetPrimaryShelf();
914 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 914 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
915 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 915 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
916 views::Widget* widget = CreateTestWidget(); 916 views::Widget* widget = CreateTestWidget();
917 widget->Maximize(); 917 widget->Maximize();
918 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 918 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
919 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 919 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
920 920
921 // LayoutShelf() forces the animation to completion, at which point the 921 // LayoutShelf() forces the animation to completion, at which point the
922 // shelf should go off the screen. 922 // shelf should go off the screen.
923 layout_manager->LayoutShelf(); 923 layout_manager->LayoutShelf();
(...skipping 11 matching lines...) Expand all
935 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 935 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
936 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 936 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
937 937
938 UnlockScreen(); 938 UnlockScreen();
939 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 939 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
940 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 940 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
941 } 941 }
942 942
943 // Assertions around SetAutoHideBehavior. 943 // Assertions around SetAutoHideBehavior.
944 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { 944 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
945 WmShelf* shelf = GetPrimaryShelf(); 945 Shelf* shelf = GetPrimaryShelf();
946 views::Widget* widget = CreateTestWidget(); 946 views::Widget* widget = CreateTestWidget();
947 947
948 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 948 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
949 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 949 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
950 950
951 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 951 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
952 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 952 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
953 953
954 widget->Maximize(); 954 widget->Maximize();
955 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 955 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
(...skipping 14 matching lines...) Expand all
970 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); 970 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible());
971 StepWidgetLayerAnimatorToEnd(shelf_widget); 971 StepWidgetLayerAnimatorToEnd(shelf_widget);
972 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); 972 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
973 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 973 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
974 EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(), 974 EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(),
975 widget->GetWorkAreaBoundsInScreen().bottom()); 975 widget->GetWorkAreaBoundsInScreen().bottom());
976 } 976 }
977 977
978 // Verifies the shelf is visible when status/shelf is focused. 978 // Verifies the shelf is visible when status/shelf is focused.
979 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { 979 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) {
980 WmShelf* shelf = GetPrimaryShelf(); 980 Shelf* shelf = GetPrimaryShelf();
981 views::Widget* widget = CreateTestWidget(); 981 views::Widget* widget = CreateTestWidget();
982 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 982 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
983 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 983 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
984 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 984 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
985 985
986 // Focus the shelf. Have to go through the focus cycler as normal focus 986 // Focus the shelf. Have to go through the focus cycler as normal focus
987 // requests to it do nothing. 987 // requests to it do nothing.
988 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 988 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
989 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 989 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
990 990
991 widget->Activate(); 991 widget->Activate();
992 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 992 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
993 993
994 // Trying to activate the status should fail, since we only allow activating 994 // Trying to activate the status should fail, since we only allow activating
995 // it when the user is using the keyboard (i.e. through FocusCycler). 995 // it when the user is using the keyboard (i.e. through FocusCycler).
996 GetShelfWidget()->status_area_widget()->Activate(); 996 GetShelfWidget()->status_area_widget()->Activate();
997 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 997 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
998 998
999 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 999 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
1000 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1000 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1001 } 1001 }
1002 1002
1003 // Ensure a SHELF_VISIBLE shelf stays visible when the app list is shown. 1003 // Ensure a SHELF_VISIBLE shelf stays visible when the app list is shown.
1004 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { 1004 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
1005 WmShelf* shelf = GetPrimaryShelf(); 1005 Shelf* shelf = GetPrimaryShelf();
1006 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1006 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1007 1007
1008 // The tested behavior relies on the app list presenter implementation. 1008 // The tested behavior relies on the app list presenter implementation.
1009 test::TestAppListViewPresenterImpl app_list_presenter_impl; 1009 test::TestAppListViewPresenterImpl app_list_presenter_impl;
1010 1010
1011 // Create a normal unmaximized window; the shelf should be visible. 1011 // Create a normal unmaximized window; the shelf should be visible.
1012 aura::Window* window = CreateTestWindow(); 1012 aura::Window* window = CreateTestWindow();
1013 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1013 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1014 window->Show(); 1014 window->Show();
1015 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); 1015 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility());
(...skipping 10 matching lines...) Expand all
1026 1026
1027 // Hide the app list and the shelf stays visible. 1027 // Hide the app list and the shelf stays visible.
1028 app_list_presenter_impl.Dismiss(); 1028 app_list_presenter_impl.Dismiss();
1029 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); 1029 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility());
1030 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1030 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1031 } 1031 }
1032 1032
1033 // Ensure a SHELF_AUTO_HIDE shelf is shown temporarily (SHELF_AUTO_HIDE_SHOWN) 1033 // Ensure a SHELF_AUTO_HIDE shelf is shown temporarily (SHELF_AUTO_HIDE_SHOWN)
1034 // when the app list is shown, but the visibility state doesn't change. 1034 // when the app list is shown, but the visibility state doesn't change.
1035 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 1035 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
1036 WmShelf* shelf = GetPrimaryShelf(); 1036 Shelf* shelf = GetPrimaryShelf();
1037 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1037 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1038 1038
1039 // The tested behavior relies on the app list presenter implementation. 1039 // The tested behavior relies on the app list presenter implementation.
1040 test::TestAppListViewPresenterImpl app_list_presenter_impl; 1040 test::TestAppListViewPresenterImpl app_list_presenter_impl;
1041 1041
1042 // Create a normal unmaximized window; the shelf should be hidden. 1042 // Create a normal unmaximized window; the shelf should be hidden.
1043 aura::Window* window = CreateTestWindow(); 1043 aura::Window* window = CreateTestWindow();
1044 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1044 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1045 window->Show(); 1045 window->Show();
1046 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); 1046 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility());
(...skipping 23 matching lines...) Expand all
1070 // Makes sure that when we have dual displays, with one or both shelves are set 1070 // Makes sure that when we have dual displays, with one or both shelves are set
1071 // to AutoHide, viewing the AppList on one of them doesn't unhide the other 1071 // to AutoHide, viewing the AppList on one of them doesn't unhide the other
1072 // hidden shelf. 1072 // hidden shelf.
1073 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { 1073 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) {
1074 // Create two displays. 1074 // Create two displays.
1075 UpdateDisplay("0+0-200x200,+200+0-100x100"); 1075 UpdateDisplay("0+0-200x200,+200+0-100x100");
1076 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1076 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1077 EXPECT_EQ(root_windows.size(), 2U); 1077 EXPECT_EQ(root_windows.size(), 2U);
1078 1078
1079 // Get the shelves in both displays and set them to be 'AutoHide'. 1079 // Get the shelves in both displays and set them to be 'AutoHide'.
1080 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf(); 1080 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->shelf();
1081 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf(); 1081 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->shelf();
1082 EXPECT_NE(shelf_1, shelf_2); 1082 EXPECT_NE(shelf_1, shelf_2);
1083 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), 1083 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(),
1084 shelf_2->GetWindow()->GetRootWindow()); 1084 shelf_2->GetWindow()->GetRootWindow());
1085 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1085 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1086 shelf_1->shelf_layout_manager()->LayoutShelf(); 1086 shelf_1->shelf_layout_manager()->LayoutShelf();
1087 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1087 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1088 shelf_2->shelf_layout_manager()->LayoutShelf(); 1088 shelf_2->shelf_layout_manager()->LayoutShelf();
1089 1089
1090 // Create a window in each display and show them in maximized state. 1090 // Create a window in each display and show them in maximized state.
1091 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); 1091 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); 1134 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility());
1135 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1135 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1136 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1136 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1137 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1137 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
1138 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1138 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1139 } 1139 }
1140 1140
1141 // Ensure a SHELF_HIDDEN shelf (for a fullscreen window) is shown temporarily 1141 // Ensure a SHELF_HIDDEN shelf (for a fullscreen window) is shown temporarily
1142 // when the app list is shown, and hidden again when the app list is dismissed. 1142 // when the app list is shown, and hidden again when the app list is dismissed.
1143 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { 1143 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
1144 WmShelf* shelf = GetPrimaryShelf(); 1144 Shelf* shelf = GetPrimaryShelf();
1145 1145
1146 // The tested behavior relies on the app list presenter implementation. 1146 // The tested behavior relies on the app list presenter implementation.
1147 test::TestAppListViewPresenterImpl app_list_presenter_impl; 1147 test::TestAppListViewPresenterImpl app_list_presenter_impl;
1148 1148
1149 // Create a window and make it full screen; the shelf should be hidden. 1149 // Create a window and make it full screen; the shelf should be hidden.
1150 aura::Window* window = CreateTestWindow(); 1150 aura::Window* window = CreateTestWindow();
1151 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1151 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1152 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1152 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1153 window->Show(); 1153 window->Show();
1154 wm::ActivateWindow(window); 1154 wm::ActivateWindow(window);
(...skipping 11 matching lines...) Expand all
1166 1166
1167 // Hide the app list and the shelf should be hidden again. 1167 // Hide the app list and the shelf should be hidden again.
1168 app_list_presenter_impl.Dismiss(); 1168 app_list_presenter_impl.Dismiss();
1169 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); 1169 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility());
1170 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1170 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1171 } 1171 }
1172 1172
1173 // Tests the correct behavior of the shelf when there is a system modal window 1173 // Tests the correct behavior of the shelf when there is a system modal window
1174 // open when we have a single display. 1174 // open when we have a single display.
1175 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { 1175 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) {
1176 WmShelf* shelf = GetPrimaryShelf(); 1176 Shelf* shelf = GetPrimaryShelf();
1177 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1177 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1178 layout_manager->LayoutShelf(); 1178 layout_manager->LayoutShelf();
1179 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1179 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1180 1180
1181 aura::Window* window = CreateTestWindow(); 1181 aura::Window* window = CreateTestWindow();
1182 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1182 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1183 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1183 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1184 window->Show(); 1184 window->Show();
1185 wm::ActivateWindow(window); 1185 wm::ActivateWindow(window);
1186 1186
1187 // Enable system modal dialog, and make sure shelf is still hidden. 1187 // Enable system modal dialog, and make sure shelf is still hidden.
1188 ShellPort::Get()->SimulateModalWindowOpenForTesting(true); 1188 ShellPort::Get()->SimulateModalWindowOpenForTesting(true);
1189 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); 1189 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen());
1190 EXPECT_FALSE(wm::CanActivateWindow(window)); 1190 EXPECT_FALSE(wm::CanActivateWindow(window));
1191 Shell::Get()->UpdateShelfVisibility(); 1191 Shell::Get()->UpdateShelfVisibility();
1192 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1192 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1193 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1193 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1194 } 1194 }
1195 1195
1196 // Tests the correct behavior of the shelf when there is a system modal window 1196 // Tests the correct behavior of the shelf when there is a system modal window
1197 // open when we have dual display. 1197 // open when we have dual display.
1198 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { 1198 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) {
1199 // Create two displays. 1199 // Create two displays.
1200 UpdateDisplay("200x200,100x100"); 1200 UpdateDisplay("200x200,100x100");
1201 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1201 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1202 EXPECT_EQ(2U, root_windows.size()); 1202 EXPECT_EQ(2U, root_windows.size());
1203 1203
1204 // Get the shelves in both displays and set them to be 'AutoHide'. 1204 // Get the shelves in both displays and set them to be 'AutoHide'.
1205 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf(); 1205 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->shelf();
1206 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf(); 1206 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->shelf();
1207 EXPECT_NE(shelf_1, shelf_2); 1207 EXPECT_NE(shelf_1, shelf_2);
1208 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), 1208 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(),
1209 shelf_2->GetWindow()->GetRootWindow()); 1209 shelf_2->GetWindow()->GetRootWindow());
1210 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1210 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1211 shelf_1->shelf_layout_manager()->LayoutShelf(); 1211 shelf_1->shelf_layout_manager()->LayoutShelf();
1212 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1212 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1213 shelf_2->shelf_layout_manager()->LayoutShelf(); 1213 shelf_2->shelf_layout_manager()->LayoutShelf();
1214 1214
1215 // Create a window in each display and show them in maximized state. 1215 // Create a window in each display and show them in maximized state.
1216 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); 1216 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
(...skipping 20 matching lines...) Expand all
1237 Shell::Get()->UpdateShelfVisibility(); 1237 Shell::Get()->UpdateShelfVisibility();
1238 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1238 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1239 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1239 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
1240 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1240 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1241 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1241 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1242 } 1242 }
1243 1243
1244 // Tests that the shelf is only hidden for a fullscreen window at the front and 1244 // Tests that the shelf is only hidden for a fullscreen window at the front and
1245 // toggles visibility when another window is activated. 1245 // toggles visibility when another window is activated.
1246 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) { 1246 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) {
1247 WmShelf* shelf = GetPrimaryShelf(); 1247 Shelf* shelf = GetPrimaryShelf();
1248 1248
1249 // Create a window and make it full screen. 1249 // Create a window and make it full screen.
1250 aura::Window* window1 = CreateTestWindow(); 1250 aura::Window* window1 = CreateTestWindow();
1251 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1251 window1->SetBounds(gfx::Rect(0, 0, 100, 100));
1252 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1252 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1253 window1->Show(); 1253 window1->Show();
1254 1254
1255 aura::Window* window2 = CreateTestWindow(); 1255 aura::Window* window2 = CreateTestWindow();
1256 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); 1256 window2->SetBounds(gfx::Rect(0, 0, 100, 100));
1257 window2->Show(); 1257 window2->Show();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 SHELF_VISIBLE, 1297 SHELF_VISIBLE,
1298 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); 1298 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state());
1299 } 1299 }
1300 1300
1301 // Test for Pinned mode. 1301 // Test for Pinned mode.
1302 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { 1302 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) {
1303 // TODO: investigate failure in mash, http://crbug.com/695686. 1303 // TODO: investigate failure in mash, http://crbug.com/695686.
1304 if (Shell::GetAshConfig() == Config::MASH) 1304 if (Shell::GetAshConfig() == Config::MASH)
1305 return; 1305 return;
1306 1306
1307 WmShelf* shelf = GetPrimaryShelf(); 1307 Shelf* shelf = GetPrimaryShelf();
1308 1308
1309 aura::Window* window1 = CreateTestWindow(); 1309 aura::Window* window1 = CreateTestWindow();
1310 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1310 window1->SetBounds(gfx::Rect(0, 0, 100, 100));
1311 window1->Show(); 1311 window1->Show();
1312 1312
1313 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1313 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1314 1314
1315 wm::PinWindow(window1, /* trusted */ false); 1315 wm::PinWindow(window1, /* trusted */ false);
1316 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1316 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1317 1317
1318 WmWindow::Get(window1)->GetWindowState()->Restore(); 1318 WmWindow::Get(window1)->GetWindowState()->Restore();
1319 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1319 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1320 } 1320 }
1321 1321
1322 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). 1322 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT).
1323 TEST_F(ShelfLayoutManagerTest, SetAlignment) { 1323 TEST_F(ShelfLayoutManagerTest, SetAlignment) {
1324 WmShelf* shelf = GetPrimaryShelf(); 1324 Shelf* shelf = GetPrimaryShelf();
1325 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1325 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1326 // Force an initial layout. 1326 // Force an initial layout.
1327 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1327 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1328 layout_manager->LayoutShelf(); 1328 layout_manager->LayoutShelf();
1329 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1329 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1330 1330
1331 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1331 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
1332 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen()); 1332 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen());
1333 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1333 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
1334 ASSERT_NE(-1, display.id()); 1334 ASSERT_NE(-1, display.id());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1388
1389 TEST_F(ShelfLayoutManagerTest, GestureDrag) { 1389 TEST_F(ShelfLayoutManagerTest, GestureDrag) {
1390 // TODO: investigate failure in mash, http://crbug.com/695686. 1390 // TODO: investigate failure in mash, http://crbug.com/695686.
1391 if (Shell::GetAshConfig() == Config::MASH) 1391 if (Shell::GetAshConfig() == Config::MASH)
1392 return; 1392 return;
1393 1393
1394 // Slop is an implementation detail of gesture recognition, and complicates 1394 // Slop is an implementation detail of gesture recognition, and complicates
1395 // these tests. Ignore it. 1395 // these tests. Ignore it.
1396 ui::GestureConfiguration::GetInstance() 1396 ui::GestureConfiguration::GetInstance()
1397 ->set_max_touch_move_in_pixels_for_click(0); 1397 ->set_max_touch_move_in_pixels_for_click(0);
1398 WmShelf* shelf = GetPrimaryShelf(); 1398 Shelf* shelf = GetPrimaryShelf();
1399 { 1399 {
1400 SCOPED_TRACE("BOTTOM"); 1400 SCOPED_TRACE("BOTTOM");
1401 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 1401 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
1402 RunGestureDragTests(gfx::Vector2d(0, 120)); 1402 RunGestureDragTests(gfx::Vector2d(0, 120));
1403 } 1403 }
1404 1404
1405 { 1405 {
1406 SCOPED_TRACE("LEFT"); 1406 SCOPED_TRACE("LEFT");
1407 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1407 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
1408 RunGestureDragTests(gfx::Vector2d(-120, 0)); 1408 RunGestureDragTests(gfx::Vector2d(-120, 0));
1409 } 1409 }
1410 1410
1411 { 1411 {
1412 SCOPED_TRACE("RIGHT"); 1412 SCOPED_TRACE("RIGHT");
1413 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1413 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
1414 RunGestureDragTests(gfx::Vector2d(120, 0)); 1414 RunGestureDragTests(gfx::Vector2d(120, 0));
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { 1418 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) {
1419 UpdateDisplay("800x600,800x600"); 1419 UpdateDisplay("800x600,800x600");
1420 WmShelf* shelf = GetPrimaryShelf(); 1420 Shelf* shelf = GetPrimaryShelf();
1421 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1421 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1422 layout_manager->LayoutShelf(); 1422 layout_manager->LayoutShelf();
1423 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1423 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1424 1424
1425 // Create a visible window so auto-hide behavior is enforced 1425 // Create a visible window so auto-hide behavior is enforced
1426 views::Widget* dummy = CreateTestWidget(); 1426 views::Widget* dummy = CreateTestWidget();
1427 1427
1428 // Window visible => auto hide behaves normally. 1428 // Window visible => auto hide behaves normally.
1429 layout_manager->UpdateVisibilityState(); 1429 layout_manager->UpdateVisibilityState();
1430 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1430 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 // Move back to primary display. 1464 // Move back to primary display.
1465 window2->SetBounds(gfx::Rect(50, 50, 50, 50)); 1465 window2->SetBounds(gfx::Rect(50, 50, 50, 50));
1466 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1466 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1467 } 1467 }
1468 1468
1469 // Test that the shelf animates back to its normal position upon a user 1469 // Test that the shelf animates back to its normal position upon a user
1470 // completing a gesture drag. 1470 // completing a gesture drag.
1471 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { 1471 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
1472 // Test the shelf animates back to its original visible bounds when it is 1472 // Test the shelf animates back to its original visible bounds when it is
1473 // dragged when there are no visible windows. 1473 // dragged when there are no visible windows.
1474 WmShelf* shelf = GetPrimaryShelf(); 1474 Shelf* shelf = GetPrimaryShelf();
1475 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1475 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1476 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1476 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1477 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1477 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1478 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 1478 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
1479 { 1479 {
1480 // Enable animations so that we can make sure that they occur. 1480 // Enable animations so that we can make sure that they occur.
1481 ui::ScopedAnimationDurationScaleMode regular_animations( 1481 ui::ScopedAnimationDurationScaleMode regular_animations(
1482 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1482 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1483 1483
1484 ui::test::EventGenerator& generator(GetEventGenerator()); 1484 ui::test::EventGenerator& generator(GetEventGenerator());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 base::TimeDelta::FromMilliseconds(10), 1); 1531 base::TimeDelta::FromMilliseconds(10), 1);
1532 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1532 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1533 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1533 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1534 ShelfAnimationWaiter waiter2(auto_hidden_bounds); 1534 ShelfAnimationWaiter waiter2(auto_hidden_bounds);
1535 waiter2.WaitTillDoneAnimating(); 1535 waiter2.WaitTillDoneAnimating();
1536 EXPECT_TRUE(waiter2.WasValidAnimation()); 1536 EXPECT_TRUE(waiter2.WasValidAnimation());
1537 } 1537 }
1538 } 1538 }
1539 1539
1540 TEST_F(ShelfLayoutManagerTest, AutohideShelfForAutohideWhenActiveWindow) { 1540 TEST_F(ShelfLayoutManagerTest, AutohideShelfForAutohideWhenActiveWindow) {
1541 WmShelf* shelf = GetPrimaryShelf(); 1541 Shelf* shelf = GetPrimaryShelf();
1542 1542
1543 views::Widget* widget_one = CreateTestWidget(); 1543 views::Widget* widget_one = CreateTestWidget();
1544 views::Widget* widget_two = CreateTestWidget(); 1544 views::Widget* widget_two = CreateTestWidget();
1545 aura::Window* window_two = widget_two->GetNativeWindow(); 1545 aura::Window* window_two = widget_two->GetNativeWindow();
1546 1546
1547 // Turn on hide_shelf_when_active behavior for window two - shelf should 1547 // Turn on hide_shelf_when_active behavior for window two - shelf should
1548 // still be visible when window two is made active since it is not yet 1548 // still be visible when window two is made active since it is not yet
1549 // maximized. 1549 // maximized.
1550 widget_one->Activate(); 1550 widget_one->Activate();
1551 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1551 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
(...skipping 20 matching lines...) Expand all
1572 ->set_autohide_shelf_when_maximized_or_fullscreen(false); 1572 ->set_autohide_shelf_when_maximized_or_fullscreen(false);
1573 widget_two->Activate(); 1573 widget_two->Activate();
1574 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1574 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1575 } 1575 }
1576 1576
1577 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { 1577 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) {
1578 // TODO: investigate failure in mash, http://crbug.com/695686. 1578 // TODO: investigate failure in mash, http://crbug.com/695686.
1579 if (Shell::GetAshConfig() == Config::MASH) 1579 if (Shell::GetAshConfig() == Config::MASH)
1580 return; 1580 return;
1581 1581
1582 WmShelf* shelf = GetPrimaryShelf(); 1582 Shelf* shelf = GetPrimaryShelf();
1583 1583
1584 // Create a visible window so auto-hide behavior is enforced. 1584 // Create a visible window so auto-hide behavior is enforced.
1585 CreateTestWidget(); 1585 CreateTestWidget();
1586 1586
1587 // Turn on auto-hide for the shelf. 1587 // Turn on auto-hide for the shelf.
1588 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1588 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1589 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1589 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1590 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1590 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1591 1591
1592 // Show the status menu. That should make the shelf visible again. 1592 // Show the status menu. That should make the shelf visible again.
1593 Shell::Get()->accelerator_controller()->PerformActionIfEnabled( 1593 Shell::Get()->accelerator_controller()->PerformActionIfEnabled(
1594 SHOW_SYSTEM_TRAY_BUBBLE); 1594 SHOW_SYSTEM_TRAY_BUBBLE);
1595 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1595 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1596 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1596 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1597 EXPECT_TRUE(GetPrimarySystemTray()->HasSystemBubble()); 1597 EXPECT_TRUE(GetPrimarySystemTray()->HasSystemBubble());
1598 } 1598 }
1599 1599
1600 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { 1600 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) {
1601 // Make sure the shelf is always visible. 1601 // Make sure the shelf is always visible.
1602 WmShelf* shelf = GetPrimaryShelf(); 1602 Shelf* shelf = GetPrimaryShelf();
1603 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1603 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1604 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1604 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1605 layout_manager->LayoutShelf(); 1605 layout_manager->LayoutShelf();
1606 1606
1607 views::Widget* widget_one = CreateTestWidget(); 1607 views::Widget* widget_one = CreateTestWidget();
1608 widget_one->Maximize(); 1608 widget_one->Maximize();
1609 1609
1610 views::Widget* widget_two = CreateTestWidget(); 1610 views::Widget* widget_two = CreateTestWidget();
1611 widget_two->Maximize(); 1611 widget_two->Maximize();
1612 widget_two->Activate(); 1612 widget_two->Activate();
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1888 // Open keyboard in sticky mode. 1888 // Open keyboard in sticky mode.
1889 kb_controller->ShowKeyboard(true); 1889 kb_controller->ShowKeyboard(true);
1890 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 1890 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
1891 1891
1892 // Work area should be changed. 1892 // Work area should be changed.
1893 EXPECT_NE(orig_work_area, 1893 EXPECT_NE(orig_work_area,
1894 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1894 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1895 } 1895 }
1896 1896
1897 } // namespace ash 1897 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698