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

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

Issue 2272793005: ash: Move alignment and autohide behavior from Shelf to WmShelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 4 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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/aura/wm_shelf_aura.h"
7 #include "ash/aura/wm_window_aura.h" 8 #include "ash/aura/wm_window_aura.h"
8 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
9 #include "ash/common/accelerators/accelerator_table.h" 10 #include "ash/common/accelerators/accelerator_table.h"
10 #include "ash/common/focus_cycler.h" 11 #include "ash/common/focus_cycler.h"
11 #include "ash/common/material_design/material_design_controller.h" 12 #include "ash/common/material_design/material_design_controller.h"
12 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shelf/shelf.h"
14 #include "ash/common/shelf/shelf_constants.h" 14 #include "ash/common/shelf/shelf_constants.h"
15 #include "ash/common/shelf/shelf_layout_manager_observer.h" 15 #include "ash/common/shelf/shelf_layout_manager_observer.h"
16 #include "ash/common/shelf/shelf_view.h" 16 #include "ash/common/shelf/shelf_view.h"
17 #include "ash/common/shelf/shelf_widget.h" 17 #include "ash/common/shelf/shelf_widget.h"
18 #include "ash/common/shelf/wm_shelf.h"
18 #include "ash/common/shell_window_ids.h" 19 #include "ash/common/shell_window_ids.h"
19 #include "ash/common/system/status_area_widget.h" 20 #include "ash/common/system/status_area_widget.h"
20 #include "ash/common/system/tray/system_tray.h" 21 #include "ash/common/system/tray/system_tray.h"
21 #include "ash/common/system/tray/system_tray_item.h" 22 #include "ash/common/system/tray/system_tray_item.h"
22 #include "ash/common/wm/window_state.h" 23 #include "ash/common/wm/window_state.h"
23 #include "ash/common/wm_shell.h" 24 #include "ash/common/wm_shell.h"
24 #include "ash/display/display_manager.h" 25 #include "ash/display/display_manager.h"
25 #include "ash/root_window_controller.h" 26 #include "ash/root_window_controller.h"
26 #include "ash/shell.h" 27 #include "ash/shell.h"
27 #include "ash/test/ash_test_base.h" 28 #include "ash/test/ash_test_base.h"
(...skipping 27 matching lines...) Expand all
55 #endif 56 #endif
56 57
57 namespace ash { 58 namespace ash {
58 namespace { 59 namespace {
59 60
60 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { 61 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) {
61 widget->GetNativeView()->layer()->GetAnimator()->Step( 62 widget->GetNativeView()->layer()->GetAnimator()->Step(
62 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); 63 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1));
63 } 64 }
64 65
65 Shelf* GetShelf() {
66 return Shelf::ForPrimaryDisplay();
67 }
68
69 ShelfWidget* GetShelfWidget() { 66 ShelfWidget* GetShelfWidget() {
70 return GetShelf()->shelf_widget(); 67 return test::AshTestBase::GetPrimaryShelf()->GetShelfWidgetForTesting();
71 } 68 }
72 69
73 ShelfLayoutManager* GetShelfLayoutManager() { 70 ShelfLayoutManager* GetShelfLayoutManager() {
74 return GetShelfWidget()->shelf_layout_manager(); 71 return test::AshTestBase::GetPrimaryShelf()->shelf_layout_manager();
75 } 72 }
76 73
77 // Class which waits till the shelf finishes animating to the target size and 74 // Class which waits till the shelf finishes animating to the target size and
78 // counts the number of animation steps. 75 // counts the number of animation steps.
79 class ShelfAnimationWaiter : views::WidgetObserver { 76 class ShelfAnimationWaiter : views::WidgetObserver {
80 public: 77 public:
81 explicit ShelfAnimationWaiter(const gfx::Rect& target_bounds) 78 explicit ShelfAnimationWaiter(const gfx::Rect& target_bounds)
82 : target_bounds_(target_bounds), 79 : target_bounds_(target_bounds),
83 animation_steps_(0), 80 animation_steps_(0),
84 done_waiting_(false) { 81 done_waiting_(false) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 174 }
178 175
179 // if the shelf is being dimmed test dimmer bounds as well. 176 // if the shelf is being dimmed test dimmer bounds as well.
180 if (GetShelfWidget()->GetDimsShelf()) 177 if (GetShelfWidget()->GetDimsShelf())
181 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), 178 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(),
182 GetShelfWidget()->GetDimmerBoundsForTest()); 179 GetShelfWidget()->GetDimmerBoundsForTest());
183 180
184 // Auto hidden shelf has a visible height of 0 in MD (where this inequality 181 // Auto hidden shelf has a visible height of 0 in MD (where this inequality
185 // does not apply); whereas auto hidden shelf has a visible height of 3 in 182 // does not apply); whereas auto hidden shelf has a visible height of 3 in
186 // non-MD. 183 // non-MD.
184 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf();
187 if (!ash::MaterialDesignController::IsShelfMaterial() || 185 if (!ash::MaterialDesignController::IsShelfMaterial() ||
188 GetShelf()->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) { 186 shelf->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) {
189 EXPECT_GE(shelf_bounds.height(), 187 EXPECT_GE(shelf_bounds.height(),
190 auto_hidden_shelf_widget_bounds_.height()); 188 auto_hidden_shelf_widget_bounds_.height());
191 } 189 }
192 190
193 float scroll_delta = 191 float scroll_delta =
194 GetShelfLayoutManager()->PrimaryAxisValue(scroll_.y(), scroll_.x()); 192 GetShelfLayoutManager()->PrimaryAxisValue(scroll_.y(), scroll_.x());
195 bool increasing_drag = 193 bool increasing_drag =
196 GetShelfLayoutManager()->SelectValueForShelfAlignment( 194 GetShelfLayoutManager()->SelectValueForShelfAlignment(
197 scroll_delta<0, scroll_delta> 0, scroll_delta < 0); 195 scroll_delta<0, scroll_delta> 0, scroll_delta < 0);
198 int shelf_size = GetShelfLayoutManager()->PrimaryAxisValue( 196 int shelf_size = GetShelfLayoutManager()->PrimaryAxisValue(
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); 320 WmShell::Get()->GetSessionStateDelegate()->UnlockScreen();
323 // The test session state delegate does not fire the lock state change. 321 // The test session state delegate does not fire the lock state change.
324 Shell::GetInstance()->OnLockStateChanged(false); 322 Shell::GetInstance()->OnLockStateChanged(false);
325 } 323 }
326 324
327 private: 325 private:
328 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); 326 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest);
329 }; 327 };
330 328
331 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { 329 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) {
332 Shelf* shelf = GetShelf(); 330 WmShelf* shelf = GetPrimaryShelf();
333 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 331 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
334 332
335 views::Widget* widget = CreateTestWidget(); 333 views::Widget* widget = CreateTestWidget();
336 widget->Maximize(); 334 widget->Maximize();
337 335
338 // The time delta should be large enough to prevent accidental fling creation. 336 // The time delta should be large enough to prevent accidental fling creation.
339 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100); 337 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100);
340 338
341 aura::Window* window = widget->GetNativeWindow(); 339 aura::Window* window = widget->GetNativeWindow();
342 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 340 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 679
682 // Make sure the bounds of the two widgets changed. 680 // Make sure the bounds of the two widgets changed.
683 shelf_bounds = shelf_widget->GetNativeView()->bounds(); 681 shelf_bounds = shelf_widget->GetNativeView()->bounds();
684 EXPECT_LT(shelf_bounds.y(), display.bounds().bottom()); 682 EXPECT_LT(shelf_bounds.y(), display.bounds().bottom());
685 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); 683 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds();
686 EXPECT_LT(status_bounds.y(), display.bounds().bottom()); 684 EXPECT_LT(status_bounds.y(), display.bounds().bottom());
687 } 685 }
688 686
689 // Makes sure LayoutShelf invoked while animating cleans things up. 687 // Makes sure LayoutShelf invoked while animating cleans things up.
690 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { 688 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) {
691 Shelf* shelf = GetShelf(); 689 WmShelf* shelf = GetPrimaryShelf();
692 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 690 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
693 // Force an initial layout. 691 // Force an initial layout.
694 layout_manager->LayoutShelf(); 692 layout_manager->LayoutShelf();
695 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 693 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
696 694
697 // Hide the shelf. 695 // Hide the shelf.
698 SetState(layout_manager, SHELF_HIDDEN); 696 SetState(layout_manager, SHELF_HIDDEN);
699 layout_manager->LayoutShelf(); 697 layout_manager->LayoutShelf();
700 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 698 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
701 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 699 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
(...skipping 30 matching lines...) Expand all
732 EXPECT_LE( 730 EXPECT_LE(
733 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), 731 std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()),
734 small_change); 732 small_change);
735 EXPECT_LE( 733 EXPECT_LE(
736 std::abs(initial_status_bounds.height() - current_status_bounds.height()), 734 std::abs(initial_status_bounds.height() - current_status_bounds.height()),
737 small_change); 735 small_change);
738 } 736 }
739 737
740 // Makes sure the shelf is sized when the status area changes size. 738 // Makes sure the shelf is sized when the status area changes size.
741 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { 739 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) {
742 Shelf* shelf = GetShelf(); 740 WmShelf* shelf = GetPrimaryShelf();
743 ASSERT_TRUE(shelf); 741 ASSERT_TRUE(shelf);
744 ShelfWidget* shelf_widget = GetShelfWidget(); 742 ShelfWidget* shelf_widget = GetShelfWidget();
745 ASSERT_TRUE(shelf_widget); 743 ASSERT_TRUE(shelf_widget);
746 ASSERT_TRUE(shelf_widget->status_area_widget()); 744 ASSERT_TRUE(shelf_widget->status_area_widget());
747 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); 745 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200));
748 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - 746 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() -
749 test::ShelfTestAPI(shelf).shelf_view()->width()); 747 shelf->GetShelfViewForTesting()->width());
750 } 748 }
751 749
752 // Various assertions around auto-hide. 750 // Various assertions around auto-hide.
753 TEST_F(ShelfLayoutManagerTest, AutoHide) { 751 TEST_F(ShelfLayoutManagerTest, AutoHide) {
754 ui::test::EventGenerator& generator(GetEventGenerator()); 752 ui::test::EventGenerator& generator(GetEventGenerator());
755 753
756 Shelf* shelf = GetShelf(); 754 WmShelf* shelf = GetPrimaryShelf();
757 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 755 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
758 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 756 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
759 views::Widget* widget = CreateTestWidget(); 757 views::Widget* widget = CreateTestWidget();
760 widget->Maximize(); 758 widget->Maximize();
761 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 759 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
762 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 760 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
763 761
764 // LayoutShelf() forces the animation to completion, at which point the 762 // LayoutShelf() forces the animation to completion, at which point the
765 // shelf should go off the screen. 763 // shelf should go off the screen.
766 layout_manager->LayoutShelf(); 764 layout_manager->LayoutShelf();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 // Test the behavior of the shelf when it is auto hidden and it is on the 808 // Test the behavior of the shelf when it is auto hidden and it is on the
811 // boundary between the primary and the secondary display. 809 // boundary between the primary and the secondary display.
812 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { 810 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) {
813 if (!SupportsMultipleDisplays()) 811 if (!SupportsMultipleDisplays())
814 return; 812 return;
815 813
816 UpdateDisplay("800x600,800x600"); 814 UpdateDisplay("800x600,800x600");
817 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 815 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
818 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0)); 816 test::CreateDisplayLayout(display::DisplayPlacement::RIGHT, 0));
819 // Put the primary monitor's shelf on the display boundary. 817 // Put the primary monitor's shelf on the display boundary.
820 Shelf* shelf = GetShelf(); 818 WmShelf* shelf = GetPrimaryShelf();
821 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 819 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
822 820
823 // 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
824 // visible. 822 // visible.
825 CreateTestWidget(); 823 CreateTestWidget();
826 824
827 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 825 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
828 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 826 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
829 827
830 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
893 891
894 // 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
895 // 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.
896 generator.MoveMouseTo(right_edge + 2, y); 894 generator.MoveMouseTo(right_edge + 2, y);
897 UpdateAutoHideStateNow(); 895 UpdateAutoHideStateNow();
898 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 896 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
899 } 897 }
900 898
901 // Assertions around the lock screen showing. 899 // Assertions around the lock screen showing.
902 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { 900 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) {
903 Shelf* shelf = GetShelf(); 901 WmShelf* shelf = GetPrimaryShelf();
904 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 902 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
905 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 903 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
906 views::Widget* widget = CreateTestWidget(); 904 views::Widget* widget = CreateTestWidget();
907 widget->Maximize(); 905 widget->Maximize();
908 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 906 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
909 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 907 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
910 908
911 // LayoutShelf() forces the animation to completion, at which point the 909 // LayoutShelf() forces the animation to completion, at which point the
912 // shelf should go off the screen. 910 // shelf should go off the screen.
913 layout_manager->LayoutShelf(); 911 layout_manager->LayoutShelf();
914 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 912 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
915 EXPECT_EQ(display.bounds().bottom() - kShelfAutoHideSize, 913 EXPECT_EQ(display.bounds().bottom() - kShelfAutoHideSize,
916 GetShelfWidget()->GetWindowBoundsInScreen().y()); 914 GetShelfWidget()->GetWindowBoundsInScreen().y());
917 915
918 std::unique_ptr<views::Widget> lock_widget(AshTestBase::CreateTestWidget( 916 std::unique_ptr<views::Widget> lock_widget(AshTestBase::CreateTestWidget(
919 nullptr, kShellWindowId_LockScreenContainer, gfx::Rect(200, 200))); 917 nullptr, kShellWindowId_LockScreenContainer, gfx::Rect(200, 200)));
920 lock_widget->Maximize(); 918 lock_widget->Maximize();
921 919
922 // Lock the screen. 920 // Lock the screen.
923 LockScreen(); 921 LockScreen();
924 // Showing a widget in the lock screen should force the shelf to be visibile. 922 // Showing a widget in the lock screen should force the shelf to be visibile.
925 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 923 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
926 924
927 UnlockScreen(); 925 UnlockScreen();
928 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 926 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
929 } 927 }
930 928
931 // Assertions around SetAutoHideBehavior. 929 // Assertions around SetAutoHideBehavior.
932 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { 930 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
933 Shelf* shelf = GetShelf(); 931 WmShelf* shelf = GetPrimaryShelf();
934 views::Widget* widget = CreateTestWidget(); 932 views::Widget* widget = CreateTestWidget();
935 933
936 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 934 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
937 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 935 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
938 936
939 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 937 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
940 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 938 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
941 939
942 widget->Maximize(); 940 widget->Maximize();
943 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 941 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); 1121 generator.MoveMouseTo(off_shelf.x(), off_shelf.y());
1124 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); 1122 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
1125 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); 1123 generator.MoveMouseTo(on_shelf.x(), on_shelf.y());
1126 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); 1124 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
1127 shelf_widget->ForceUndimming(true); 1125 shelf_widget->ForceUndimming(true);
1128 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); 1126 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest());
1129 } 1127 }
1130 1128
1131 // Verifies the shelf is visible when status/shelf is focused. 1129 // Verifies the shelf is visible when status/shelf is focused.
1132 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { 1130 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) {
1133 Shelf* shelf = GetShelf(); 1131 WmShelf* shelf = GetPrimaryShelf();
1134 views::Widget* widget = CreateTestWidget(); 1132 views::Widget* widget = CreateTestWidget();
1135 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1133 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1136 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1134 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1137 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1135 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1138 1136
1139 // Focus the shelf. Have to go through the focus cycler as normal focus 1137 // Focus the shelf. Have to go through the focus cycler as normal focus
1140 // requests to it do nothing. 1138 // requests to it do nothing.
1141 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 1139 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
1142 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1140 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1143 1141
1144 widget->Activate(); 1142 widget->Activate();
1145 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1143 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1146 1144
1147 // Trying to activate the status should fail, since we only allow activating 1145 // Trying to activate the status should fail, since we only allow activating
1148 // it when the user is using the keyboard (i.e. through FocusCycler). 1146 // it when the user is using the keyboard (i.e. through FocusCycler).
1149 GetShelfWidget()->status_area_widget()->Activate(); 1147 GetShelfWidget()->status_area_widget()->Activate();
1150 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1148 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1151 1149
1152 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 1150 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
1153 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1151 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1154 } 1152 }
1155 1153
1156 // Makes sure shelf will be visible when app list opens as shelf is in 1154 // Makes sure shelf will be visible when app list opens as shelf is in
1157 // SHELF_VISIBLE state,and toggling app list won't change shelf 1155 // SHELF_VISIBLE state,and toggling app list won't change shelf
1158 // visibility state. 1156 // visibility state.
1159 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { 1157 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
1160 WmShell* shell = WmShell::Get(); 1158 WmShell* shell = WmShell::Get();
1161 Shelf* shelf = GetShelf(); 1159 WmShelf* shelf = GetPrimaryShelf();
1162 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1160 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1163 layout_manager->LayoutShelf(); 1161 layout_manager->LayoutShelf();
1164 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1162 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1165 1163
1166 // Create a normal unmaximized windowm shelf should be visible. 1164 // Create a normal unmaximized windowm shelf should be visible.
1167 aura::Window* window = CreateTestWindow(); 1165 aura::Window* window = CreateTestWindow();
1168 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1166 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1169 window->Show(); 1167 window->Show();
1170 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1168 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1171 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1169 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1172 1170
1173 // Show app list and the shelf stays visible. 1171 // Show app list and the shelf stays visible.
1174 shell->ShowAppList(); 1172 shell->ShowAppList();
1175 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1173 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1176 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1174 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1177 1175
1178 // Hide app list and the shelf stays visible. 1176 // Hide app list and the shelf stays visible.
1179 shell->DismissAppList(); 1177 shell->DismissAppList();
1180 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1178 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1181 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1179 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1182 } 1180 }
1183 1181
1184 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state 1182 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state
1185 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and 1183 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and
1186 // toggling app list won't change shelf visibility state. 1184 // toggling app list won't change shelf visibility state.
1187 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 1185 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
1188 WmShell* shell = WmShell::Get(); 1186 WmShell* shell = WmShell::Get();
1189 Shelf* shelf = GetShelf(); 1187 WmShelf* shelf = GetPrimaryShelf();
1190 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1188 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1191 layout_manager->LayoutShelf(); 1189 layout_manager->LayoutShelf();
1192 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1190 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1193 1191
1194 // Create a window and show it in maximized state. 1192 // Create a window and show it in maximized state.
1195 aura::Window* window = CreateTestWindow(); 1193 aura::Window* window = CreateTestWindow();
1196 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1194 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1197 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1195 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1198 window->Show(); 1196 window->Show();
1199 wm::ActivateWindow(window); 1197 wm::ActivateWindow(window);
(...skipping 22 matching lines...) Expand all
1222 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { 1220 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) {
1223 if (!SupportsMultipleDisplays()) 1221 if (!SupportsMultipleDisplays())
1224 return; 1222 return;
1225 1223
1226 // Create two displays. 1224 // Create two displays.
1227 UpdateDisplay("0+0-200x200,+200+0-100x100"); 1225 UpdateDisplay("0+0-200x200,+200+0-100x100");
1228 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1226 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1229 EXPECT_EQ(root_windows.size(), 2U); 1227 EXPECT_EQ(root_windows.size(), 2U);
1230 1228
1231 // Get the shelves in both displays and set them to be 'AutoHide'. 1229 // Get the shelves in both displays and set them to be 'AutoHide'.
1232 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); 1230 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf_aura();
1233 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); 1231 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf_aura();
1234 EXPECT_NE(shelf_1, shelf_2); 1232 EXPECT_NE(shelf_1, shelf_2);
1235 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1233 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(),
1236 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); 1234 shelf_2->GetWindow()->GetRootWindow());
1237 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1235 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1238 shelf_1->shelf_layout_manager()->LayoutShelf(); 1236 shelf_1->shelf_layout_manager()->LayoutShelf();
1239 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1237 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1240 shelf_2->shelf_layout_manager()->LayoutShelf(); 1238 shelf_2->shelf_layout_manager()->LayoutShelf();
1241 1239
1242 // Create a window in each display and show them in maximized state. 1240 // Create a window in each display and show them in maximized state.
1243 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); 1241 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
1244 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1242 window_1->SetBounds(gfx::Rect(0, 0, 100, 100));
1245 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1243 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1246 window_1->Show(); 1244 window_1->Show();
1247 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); 1245 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]);
1248 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); 1246 window_2->SetBounds(gfx::Rect(201, 0, 100, 100));
1249 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1247 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1250 window_2->Show(); 1248 window_2->Show();
1251 1249
1252 EXPECT_EQ(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1250 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(),
1253 window_1->GetRootWindow()); 1251 WmWindowAura::Get(window_1)->GetRootWindow());
1254 EXPECT_EQ(shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1252 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(),
1255 window_2->GetRootWindow()); 1253 WmWindowAura::Get(window_2)->GetRootWindow());
1256 1254
1257 // Activate one window in one display and manually trigger the update of shelf 1255 // Activate one window in one display and manually trigger the update of shelf
1258 // visibility. 1256 // visibility.
1259 wm::ActivateWindow(window_1); 1257 wm::ActivateWindow(window_1);
1260 Shell::GetInstance()->UpdateShelfVisibility(); 1258 Shell::GetInstance()->UpdateShelfVisibility();
1261 1259
1262 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); 1260 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility());
1263 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1261 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1264 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1262 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1265 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1263 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
(...skipping 16 matching lines...) Expand all
1282 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1280 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1283 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1281 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1284 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1282 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
1285 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1283 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1286 } 1284 }
1287 1285
1288 // Makes sure the shelf will be hidden when we have a fullscreen window, and it 1286 // Makes sure the shelf will be hidden when we have a fullscreen window, and it
1289 // will unhide when we open the app list. 1287 // will unhide when we open the app list.
1290 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { 1288 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
1291 WmShell* shell = WmShell::Get(); 1289 WmShell* shell = WmShell::Get();
1292 Shelf* shelf = GetShelf(); 1290 WmShelf* shelf = GetPrimaryShelf();
1293 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1291 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1294 // For shelf to be visible, app list is not open in initial state. 1292 // For shelf to be visible, app list is not open in initial state.
1295 layout_manager->LayoutShelf(); 1293 layout_manager->LayoutShelf();
1296 1294
1297 // Create a window and make it full screen. 1295 // Create a window and make it full screen.
1298 aura::Window* window = CreateTestWindow(); 1296 aura::Window* window = CreateTestWindow();
1299 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1297 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1300 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1298 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1301 window->Show(); 1299 window->Show();
1302 wm::ActivateWindow(window); 1300 wm::ActivateWindow(window);
1303 1301
1304 // App list and shelf is not shown. 1302 // App list and shelf is not shown.
1305 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1303 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1306 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1304 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1307 1305
1308 // Show app list. 1306 // Show app list.
1309 shell->ShowAppList(); 1307 shell->ShowAppList();
1310 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1308 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1311 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1309 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1312 1310
1313 // Hide app list. 1311 // Hide app list.
1314 shell->DismissAppList(); 1312 shell->DismissAppList();
1315 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1313 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1316 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1314 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1317 } 1315 }
1318 1316
1319 // Tests the correct behavior of the shelf when there is a system modal window 1317 // Tests the correct behavior of the shelf when there is a system modal window
1320 // open when we have a single display. 1318 // open when we have a single display.
1321 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { 1319 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) {
1322 Shelf* shelf = GetShelf(); 1320 WmShelf* shelf = GetPrimaryShelf();
1323 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1321 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1324 layout_manager->LayoutShelf(); 1322 layout_manager->LayoutShelf();
1325 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1323 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1326 1324
1327 aura::Window* window = CreateTestWindow(); 1325 aura::Window* window = CreateTestWindow();
1328 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1326 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1329 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1327 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1330 window->Show(); 1328 window->Show();
1331 wm::ActivateWindow(window); 1329 wm::ActivateWindow(window);
1332 1330
(...skipping 12 matching lines...) Expand all
1345 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { 1343 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) {
1346 if (!SupportsMultipleDisplays()) 1344 if (!SupportsMultipleDisplays())
1347 return; 1345 return;
1348 1346
1349 // Create two displays. 1347 // Create two displays.
1350 UpdateDisplay("200x200,100x100"); 1348 UpdateDisplay("200x200,100x100");
1351 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1349 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1352 EXPECT_EQ(2U, root_windows.size()); 1350 EXPECT_EQ(2U, root_windows.size());
1353 1351
1354 // Get the shelves in both displays and set them to be 'AutoHide'. 1352 // Get the shelves in both displays and set them to be 'AutoHide'.
1355 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); 1353 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf_aura();
1356 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); 1354 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf_aura();
1357 EXPECT_NE(shelf_1, shelf_2); 1355 EXPECT_NE(shelf_1, shelf_2);
1358 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1356 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(),
1359 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); 1357 shelf_2->GetWindow()->GetRootWindow());
1360 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1358 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1361 shelf_1->shelf_layout_manager()->LayoutShelf(); 1359 shelf_1->shelf_layout_manager()->LayoutShelf();
1362 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1360 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1363 shelf_2->shelf_layout_manager()->LayoutShelf(); 1361 shelf_2->shelf_layout_manager()->LayoutShelf();
1364 1362
1365 // Create a window in each display and show them in maximized state. 1363 // Create a window in each display and show them in maximized state.
1366 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); 1364 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
1367 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1365 window_1->SetBounds(gfx::Rect(0, 0, 100, 100));
1368 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1366 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1369 window_1->Show(); 1367 window_1->Show();
1370 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); 1368 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]);
1371 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); 1369 window_2->SetBounds(gfx::Rect(201, 0, 100, 100));
1372 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1370 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1373 window_2->Show(); 1371 window_2->Show();
1374 1372
1375 EXPECT_EQ(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1373 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(),
1376 window_1->GetRootWindow()); 1374 WmWindowAura::Get(window_1)->GetRootWindow());
1377 EXPECT_EQ(shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1375 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(),
1378 window_2->GetRootWindow()); 1376 WmWindowAura::Get(window_2)->GetRootWindow());
1379 EXPECT_TRUE(window_1->IsVisible()); 1377 EXPECT_TRUE(window_1->IsVisible());
1380 EXPECT_TRUE(window_2->IsVisible()); 1378 EXPECT_TRUE(window_2->IsVisible());
1381 1379
1382 // Enable system modal dialog, and make sure both shelves are still hidden. 1380 // Enable system modal dialog, and make sure both shelves are still hidden.
1383 WmShell* wm_shell = WmShell::Get(); 1381 WmShell* wm_shell = WmShell::Get();
1384 wm_shell->SimulateModalWindowOpenForTesting(true); 1382 wm_shell->SimulateModalWindowOpenForTesting(true);
1385 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); 1383 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen());
1386 EXPECT_FALSE(wm::CanActivateWindow(window_1)); 1384 EXPECT_FALSE(wm::CanActivateWindow(window_1));
1387 EXPECT_FALSE(wm::CanActivateWindow(window_2)); 1385 EXPECT_FALSE(wm::CanActivateWindow(window_2));
1388 Shell::GetInstance()->UpdateShelfVisibility(); 1386 Shell::GetInstance()->UpdateShelfVisibility();
1389 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1387 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1390 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1388 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
1391 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1389 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1392 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1390 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1393 } 1391 }
1394 1392
1395 // Tests that the shelf is only hidden for a fullscreen window at the front and 1393 // Tests that the shelf is only hidden for a fullscreen window at the front and
1396 // toggles visibility when another window is activated. 1394 // toggles visibility when another window is activated.
1397 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) { 1395 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) {
1398 Shelf* shelf = GetShelf(); 1396 WmShelf* shelf = GetPrimaryShelf();
1399 1397
1400 // Create a window and make it full screen. 1398 // Create a window and make it full screen.
1401 aura::Window* window1 = CreateTestWindow(); 1399 aura::Window* window1 = CreateTestWindow();
1402 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1400 window1->SetBounds(gfx::Rect(0, 0, 100, 100));
1403 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1401 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1404 window1->Show(); 1402 window1->Show();
1405 1403
1406 aura::Window* window2 = CreateTestWindow(); 1404 aura::Window* window2 = CreateTestWindow();
1407 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); 1405 window2->SetBounds(gfx::Rect(0, 0, 100, 100));
1408 window2->Show(); 1406 window2->Show();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 EXPECT_EQ( 1445 EXPECT_EQ(
1448 SHELF_HIDDEN, 1446 SHELF_HIDDEN,
1449 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state()); 1447 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state());
1450 EXPECT_EQ( 1448 EXPECT_EQ(
1451 SHELF_VISIBLE, 1449 SHELF_VISIBLE,
1452 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); 1450 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state());
1453 } 1451 }
1454 1452
1455 // Test for Pinned mode. 1453 // Test for Pinned mode.
1456 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { 1454 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) {
1457 Shelf* shelf = GetShelf(); 1455 WmShelf* shelf = GetPrimaryShelf();
1458 1456
1459 aura::Window* window1 = CreateTestWindow(); 1457 aura::Window* window1 = CreateTestWindow();
1460 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1458 window1->SetBounds(gfx::Rect(0, 0, 100, 100));
1461 window1->Show(); 1459 window1->Show();
1462 1460
1463 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1461 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1464 1462
1465 wm::PinWindow(window1); 1463 wm::PinWindow(window1);
1466 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1464 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1467 1465
1468 WmWindowAura::Get(window1)->GetWindowState()->Restore(); 1466 WmWindowAura::Get(window1)->GetWindowState()->Restore();
1469 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1467 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1470 } 1468 }
1471 1469
1472 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). 1470 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT).
1473 TEST_F(ShelfLayoutManagerTest, SetAlignment) { 1471 TEST_F(ShelfLayoutManagerTest, SetAlignment) {
1474 Shelf* shelf = GetShelf(); 1472 WmShelf* shelf = GetPrimaryShelf();
1475 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1473 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1476 // Force an initial layout. 1474 // Force an initial layout.
1477 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1475 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1478 layout_manager->LayoutShelf(); 1476 layout_manager->LayoutShelf();
1479 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1477 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1480 1478
1481 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1479 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
1482 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen()); 1480 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen());
1483 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1481 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
1484 ASSERT_NE(-1, display.id()); 1482 ASSERT_NE(-1, display.id());
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 display.GetWorkAreaInsets().right()); 1531 display.GetWorkAreaInsets().right());
1534 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), 1532 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE),
1535 display.bounds().right() - display.work_area().right()); 1533 display.bounds().right() - display.work_area().right());
1536 } 1534 }
1537 1535
1538 TEST_F(ShelfLayoutManagerTest, GestureDrag) { 1536 TEST_F(ShelfLayoutManagerTest, GestureDrag) {
1539 // Slop is an implementation detail of gesture recognition, and complicates 1537 // Slop is an implementation detail of gesture recognition, and complicates
1540 // these tests. Ignore it. 1538 // these tests. Ignore it.
1541 ui::GestureConfiguration::GetInstance() 1539 ui::GestureConfiguration::GetInstance()
1542 ->set_max_touch_move_in_pixels_for_click(0); 1540 ->set_max_touch_move_in_pixels_for_click(0);
1543 Shelf* shelf = GetShelf(); 1541 WmShelf* shelf = GetPrimaryShelf();
1544 { 1542 {
1545 SCOPED_TRACE("BOTTOM"); 1543 SCOPED_TRACE("BOTTOM");
1546 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 1544 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
1547 RunGestureDragTests(gfx::Vector2d(0, 120)); 1545 RunGestureDragTests(gfx::Vector2d(0, 120));
1548 } 1546 }
1549 1547
1550 { 1548 {
1551 SCOPED_TRACE("LEFT"); 1549 SCOPED_TRACE("LEFT");
1552 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 1550 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
1553 RunGestureDragTests(gfx::Vector2d(-120, 0)); 1551 RunGestureDragTests(gfx::Vector2d(-120, 0));
1554 } 1552 }
1555 1553
1556 { 1554 {
1557 SCOPED_TRACE("RIGHT"); 1555 SCOPED_TRACE("RIGHT");
1558 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1556 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
1559 RunGestureDragTests(gfx::Vector2d(120, 0)); 1557 RunGestureDragTests(gfx::Vector2d(120, 0));
1560 } 1558 }
1561 } 1559 }
1562 1560
1563 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { 1561 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) {
1564 if (!SupportsMultipleDisplays()) 1562 if (!SupportsMultipleDisplays())
1565 return; 1563 return;
1566 1564
1567 UpdateDisplay("800x600,800x600"); 1565 UpdateDisplay("800x600,800x600");
1568 Shelf* shelf = GetShelf(); 1566 WmShelf* shelf = GetPrimaryShelf();
1569 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1567 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1570 layout_manager->LayoutShelf(); 1568 layout_manager->LayoutShelf();
1571 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1569 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1572 1570
1573 // Create a visible window so auto-hide behavior is enforced 1571 // Create a visible window so auto-hide behavior is enforced
1574 views::Widget* dummy = CreateTestWidget(); 1572 views::Widget* dummy = CreateTestWidget();
1575 1573
1576 // Window visible => auto hide behaves normally. 1574 // Window visible => auto hide behaves normally.
1577 layout_manager->UpdateVisibilityState(); 1575 layout_manager->UpdateVisibilityState();
1578 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1576 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 // Move back to primary display. 1610 // Move back to primary display.
1613 window2->SetBounds(gfx::Rect(50, 50, 50, 50)); 1611 window2->SetBounds(gfx::Rect(50, 50, 50, 50));
1614 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1612 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1615 } 1613 }
1616 1614
1617 // Test that the shelf animates back to its normal position upon a user 1615 // Test that the shelf animates back to its normal position upon a user
1618 // completing a gesture drag. 1616 // completing a gesture drag.
1619 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { 1617 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) {
1620 // Test the shelf animates back to its original visible bounds when it is 1618 // Test the shelf animates back to its original visible bounds when it is
1621 // dragged when there are no visible windows. 1619 // dragged when there are no visible windows.
1622 Shelf* shelf = GetShelf(); 1620 WmShelf* shelf = GetPrimaryShelf();
1623 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1621 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1624 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1622 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1625 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1623 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1626 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 1624 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
1627 { 1625 {
1628 // Enable animations so that we can make sure that they occur. 1626 // Enable animations so that we can make sure that they occur.
1629 ui::ScopedAnimationDurationScaleMode regular_animations( 1627 ui::ScopedAnimationDurationScaleMode regular_animations(
1630 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1628 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1631 1629
1632 ui::test::EventGenerator& generator(GetEventGenerator()); 1630 ui::test::EventGenerator& generator(GetEventGenerator());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 base::TimeDelta::FromMilliseconds(10), 1); 1677 base::TimeDelta::FromMilliseconds(10), 1);
1680 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1678 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1681 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1679 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1682 ShelfAnimationWaiter waiter2(auto_hidden_bounds); 1680 ShelfAnimationWaiter waiter2(auto_hidden_bounds);
1683 waiter2.WaitTillDoneAnimating(); 1681 waiter2.WaitTillDoneAnimating();
1684 EXPECT_TRUE(waiter2.WasValidAnimation()); 1682 EXPECT_TRUE(waiter2.WasValidAnimation());
1685 } 1683 }
1686 } 1684 }
1687 1685
1688 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { 1686 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) {
1689 Shelf* shelf = GetShelf(); 1687 WmShelf* shelf = GetPrimaryShelf();
1690 1688
1691 // Create a visible window so auto-hide behavior is enforced. 1689 // Create a visible window so auto-hide behavior is enforced.
1692 CreateTestWidget(); 1690 CreateTestWidget();
1693 1691
1694 // Turn on auto-hide for the shelf. 1692 // Turn on auto-hide for the shelf.
1695 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1693 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1696 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1694 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1697 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1695 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1698 1696
1699 // Show the status menu. That should make the shelf visible again. 1697 // Show the status menu. That should make the shelf visible again.
1700 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled( 1698 WmShell::Get()->accelerator_controller()->PerformActionIfEnabled(
1701 SHOW_SYSTEM_TRAY_BUBBLE); 1699 SHOW_SYSTEM_TRAY_BUBBLE);
1702 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1700 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1703 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1701 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1704 EXPECT_TRUE(GetPrimarySystemTray()->HasSystemBubble()); 1702 EXPECT_TRUE(GetPrimarySystemTray()->HasSystemBubble());
1705 } 1703 }
1706 1704
1707 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { 1705 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) {
1708 // Make sure the shelf is always visible. 1706 // Make sure the shelf is always visible.
1709 Shelf* shelf = GetShelf(); 1707 WmShelf* shelf = GetPrimaryShelf();
1710 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1708 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1711 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1709 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1712 layout_manager->LayoutShelf(); 1710 layout_manager->LayoutShelf();
1713 1711
1714 views::Widget* widget_one = CreateTestWidget(); 1712 views::Widget* widget_one = CreateTestWidget();
1715 widget_one->Maximize(); 1713 widget_one->Maximize();
1716 1714
1717 views::Widget* widget_two = CreateTestWidget(); 1715 views::Widget* widget_two = CreateTestWidget();
1718 widget_two->Maximize(); 1716 widget_two->Maximize();
1719 widget_two->Activate(); 1717 widget_two->Activate();
(...skipping 20 matching lines...) Expand all
1740 // Again both windows should be of the same size. 1738 // Again both windows should be of the same size.
1741 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), 1739 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(),
1742 widget_two->GetNativeWindow()->bounds().ToString()); 1740 widget_two->GetNativeWindow()->bounds().ToString());
1743 EXPECT_EQ(area_when_shelf_shown, 1741 EXPECT_EQ(area_when_shelf_shown,
1744 widget_one->GetNativeWindow()->bounds().size().GetArea()); 1742 widget_one->GetNativeWindow()->bounds().size().GetArea());
1745 } 1743 }
1746 1744
1747 // Confirm that the shelf is dimmed only when content is maximized and 1745 // Confirm that the shelf is dimmed only when content is maximized and
1748 // shelf is not autohidden. 1746 // shelf is not autohidden.
1749 TEST_F(ShelfLayoutManagerTest, Dimming) { 1747 TEST_F(ShelfLayoutManagerTest, Dimming) {
1750 Shelf* shelf = GetShelf(); 1748 WmShelf* shelf = GetPrimaryShelf();
1751 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1749 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1752 std::unique_ptr<aura::Window> w1(CreateTestWindow()); 1750 std::unique_ptr<aura::Window> w1(CreateTestWindow());
1753 w1->Show(); 1751 w1->Show();
1754 wm::ActivateWindow(w1.get()); 1752 wm::ActivateWindow(w1.get());
1755 1753
1756 // Normal window doesn't dim shelf. 1754 // Normal window doesn't dim shelf.
1757 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 1755 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
1758 ShelfWidget* shelf_widget = GetShelfWidget(); 1756 ShelfWidget* shelf_widget = GetShelfWidget();
1759 EXPECT_FALSE(shelf_widget->GetDimsShelf()); 1757 EXPECT_FALSE(shelf_widget->GetDimsShelf());
1760 1758
(...skipping 10 matching lines...) Expand all
1771 EXPECT_TRUE(shelf_widget->GetDimsShelf()); 1769 EXPECT_TRUE(shelf_widget->GetDimsShelf());
1772 1770
1773 // Changing shelf to autohide stops dimming. 1771 // Changing shelf to autohide stops dimming.
1774 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1772 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1775 EXPECT_FALSE(shelf_widget->GetDimsShelf()); 1773 EXPECT_FALSE(shelf_widget->GetDimsShelf());
1776 } 1774 }
1777 1775
1778 // Make sure that the shelf will not hide if the mouse is between a bubble and 1776 // Make sure that the shelf will not hide if the mouse is between a bubble and
1779 // the shelf. 1777 // the shelf.
1780 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { 1778 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) {
1781 Shelf* shelf = GetShelf(); 1779 WmShelf* shelf = GetPrimaryShelf();
1782 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1780 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1783 StatusAreaWidget* status_area_widget = 1781 StatusAreaWidget* status_area_widget =
1784 shelf->shelf_widget()->status_area_widget(); 1782 shelf->GetShelfWidgetForTesting()->status_area_widget();
1785 SystemTray* tray = GetPrimarySystemTray(); 1783 SystemTray* tray = GetPrimarySystemTray();
1786 1784
1787 // Create a visible window so auto-hide behavior is enforced. 1785 // Create a visible window so auto-hide behavior is enforced.
1788 CreateTestWidget(); 1786 CreateTestWidget();
1789 1787
1790 layout_manager->LayoutShelf(); 1788 layout_manager->LayoutShelf();
1791 ui::test::EventGenerator& generator(GetEventGenerator()); 1789 ui::test::EventGenerator& generator(GetEventGenerator());
1792 1790
1793 // Make two iterations - first without a message bubble which should make 1791 // Make two iterations - first without a message bubble which should make
1794 // the shelf disappear and then with a message bubble which should keep it 1792 // the shelf disappear and then with a message bubble which should keep it
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); 1854 EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType());
1857 w1.reset(); 1855 w1.reset();
1858 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 1856 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
1859 } 1857 }
1860 1858
1861 // Verify that the shelf doesn't have the opaque background if it's auto-hide 1859 // Verify that the shelf doesn't have the opaque background if it's auto-hide
1862 // status. 1860 // status.
1863 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { 1861 TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) {
1864 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); 1862 EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType());
1865 1863
1866 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1864 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1867 std::unique_ptr<aura::Window> w1(CreateTestWindow()); 1865 std::unique_ptr<aura::Window> w1(CreateTestWindow());
1868 w1->Show(); 1866 w1->Show();
1869 wm::ActivateWindow(w1.get()); 1867 wm::ActivateWindow(w1.get());
1870 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 1868 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
1871 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1869 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1872 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); 1870 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType());
1873 } 1871 }
1874 1872
1875 // Verify the hit bounds of the status area extend to the edge of the shelf. 1873 // Verify the hit bounds of the status area extend to the edge of the shelf.
1876 TEST_F(ShelfLayoutManagerTest, StatusAreaHitBoxCoversEdge) { 1874 TEST_F(ShelfLayoutManagerTest, StatusAreaHitBoxCoversEdge) {
1877 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); 1875 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget();
1878 ui::test::EventGenerator& generator(GetEventGenerator()); 1876 ui::test::EventGenerator& generator(GetEventGenerator());
1879 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1877 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
1880 gfx::Rect inset_display_bounds = display.bounds(); 1878 gfx::Rect inset_display_bounds = display.bounds();
1881 inset_display_bounds.Inset(0, 0, 1, 1); 1879 inset_display_bounds.Inset(0, 0, 1, 1);
1882 1880
1883 // Test bottom right pixel for bottom alignment. 1881 // Test bottom right pixel for bottom alignment.
1884 GetShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 1882 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
1885 generator.MoveMouseTo(inset_display_bounds.bottom_right()); 1883 generator.MoveMouseTo(inset_display_bounds.bottom_right());
1886 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 1884 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
1887 #if !defined(OS_WIN) 1885 #if !defined(OS_WIN)
1888 generator.ClickLeftButton(); 1886 generator.ClickLeftButton();
1889 // The bottom right pixel doesn't work on Windows; see crbug.com/633434 1887 // The bottom right pixel doesn't work on Windows; see crbug.com/633434
1890 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 1888 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
1891 #endif 1889 #endif
1892 generator.ClickLeftButton(); 1890 generator.ClickLeftButton();
1893 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 1891 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
1894 1892
1895 // Test bottom right pixel for right alignment. 1893 // Test bottom right pixel for right alignment.
1896 GetShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1894 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT);
1897 generator.MoveMouseTo(inset_display_bounds.bottom_right()); 1895 generator.MoveMouseTo(inset_display_bounds.bottom_right());
1898 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 1896 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
1899 #if !defined(OS_WIN) 1897 #if !defined(OS_WIN)
1900 generator.ClickLeftButton(); 1898 generator.ClickLeftButton();
1901 // The bottom right pixel doesn't work on Windows; see crbug.com/633434 1899 // The bottom right pixel doesn't work on Windows; see crbug.com/633434
1902 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 1900 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
1903 #endif 1901 #endif
1904 generator.ClickLeftButton(); 1902 generator.ClickLeftButton();
1905 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 1903 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
1906 1904
1907 // Test bottom left pixel for left alignment. 1905 // Test bottom left pixel for left alignment.
1908 generator.MoveMouseTo(inset_display_bounds.bottom_left()); 1906 generator.MoveMouseTo(inset_display_bounds.bottom_left());
1909 GetShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); 1907 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT);
1910 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 1908 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
1911 generator.ClickLeftButton(); 1909 generator.ClickLeftButton();
1912 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); 1910 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown());
1913 generator.ClickLeftButton(); 1911 generator.ClickLeftButton();
1914 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); 1912 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown());
1915 } 1913 }
1916 1914
1917 // Tests that when the auto-hide behaviour is changed during an animation the 1915 // Tests that when the auto-hide behaviour is changed during an animation the
1918 // target bounds are updated to reflect the new state. 1916 // target bounds are updated to reflect the new state.
1919 TEST_F(ShelfLayoutManagerTest, 1917 TEST_F(ShelfLayoutManagerTest,
1920 ShelfAutoHideToggleDuringAnimationUpdatesBounds) { 1918 ShelfAutoHideToggleDuringAnimationUpdatesBounds) {
1921 aura::Window* status_window = 1919 aura::Window* status_window =
1922 GetShelfWidget()->status_area_widget()->GetNativeView(); 1920 GetShelfWidget()->status_area_widget()->GetNativeView();
1923 gfx::Rect initial_bounds = status_window->bounds(); 1921 gfx::Rect initial_bounds = status_window->bounds();
1924 1922
1925 ui::ScopedAnimationDurationScaleMode regular_animations( 1923 ui::ScopedAnimationDurationScaleMode regular_animations(
1926 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); 1924 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
1927 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 1925 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
1928 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); 1926 gfx::Rect hide_target_bounds = status_window->GetTargetBounds();
1929 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); 1927 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y());
1930 1928
1931 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1929 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1932 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); 1930 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds();
1933 EXPECT_EQ(initial_bounds, reshow_target_bounds); 1931 EXPECT_EQ(initial_bounds, reshow_target_bounds);
1934 } 1932 }
1935 1933
1936 // Flaky crash on Windows (crbug.com/637873). 1934 // Flaky crash on Windows (crbug.com/637873).
1937 #if defined(OS_WIN) 1935 #if defined(OS_WIN)
1938 #define MAYBE_ShutdownHandlesWindowActivation \ 1936 #define MAYBE_ShutdownHandlesWindowActivation \
1939 DISABLED_ShutdownHandlesWindowActivation 1937 DISABLED_ShutdownHandlesWindowActivation
1940 #else 1938 #else
1941 #define MAYBE_ShutdownHandlesWindowActivation ShutdownHandlesWindowActivation 1939 #define MAYBE_ShutdownHandlesWindowActivation ShutdownHandlesWindowActivation
1942 #endif 1940 #endif
1943 1941
1944 // Tests that during shutdown, that window activation changes are properly 1942 // Tests that during shutdown, that window activation changes are properly
1945 // handled, and do not crash (crbug.com/458768) 1943 // handled, and do not crash (crbug.com/458768)
1946 TEST_F(ShelfLayoutManagerTest, MAYBE_ShutdownHandlesWindowActivation) { 1944 TEST_F(ShelfLayoutManagerTest, MAYBE_ShutdownHandlesWindowActivation) {
1947 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1945 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1948 1946
1949 aura::Window* window1 = CreateTestWindowInShellWithId(0); 1947 aura::Window* window1 = CreateTestWindowInShellWithId(0);
1950 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); 1948 window1->SetBounds(gfx::Rect(0, 0, 100, 100));
1951 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1949 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1952 window1->Show(); 1950 window1->Show();
1953 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0)); 1951 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0));
1954 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); 1952 window2->SetBounds(gfx::Rect(0, 0, 100, 100));
1955 window2->Show(); 1953 window2->Show();
1956 wm::ActivateWindow(window1); 1954 wm::ActivateWindow(window1);
1957 1955
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 // Open keyboard in sticky mode. 2075 // Open keyboard in sticky mode.
2078 kb_controller->ShowKeyboard(true); 2076 kb_controller->ShowKeyboard(true);
2079 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 2077 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
2080 2078
2081 // Work area should be changed. 2079 // Work area should be changed.
2082 EXPECT_NE(orig_work_area, 2080 EXPECT_NE(orig_work_area,
2083 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 2081 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2084 } 2082 }
2085 2083
2086 } // namespace ash 2084 } // namespace ash
OLDNEW
« no previous file with comments | « ash/content/keyboard_overlay/keyboard_overlay_delegate_unittest.cc ('k') | ash/shelf/shelf_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698