OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
11 #include "ash/focus_cycler.h" | 11 #include "ash/focus_cycler.h" |
12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
13 #include "ash/session/session_state_delegate.h" | 13 #include "ash/session/session_state_delegate.h" |
14 #include "ash/shelf/shelf.h" | 14 #include "ash/shelf/shelf.h" |
15 #include "ash/shelf/shelf_layout_manager_observer.h" | 15 #include "ash/shelf/shelf_layout_manager_observer.h" |
16 #include "ash/shelf/shelf_view.h" | 16 #include "ash/shelf/shelf_view.h" |
17 #include "ash/shelf/shelf_widget.h" | 17 #include "ash/shelf/shelf_widget.h" |
18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
19 #include "ash/shell_window_ids.h" | 19 #include "ash/shell_window_ids.h" |
20 #include "ash/system/status_area_widget.h" | 20 #include "ash/system/status_area_widget.h" |
21 #include "ash/system/tray/system_tray.h" | 21 #include "ash/system/tray/system_tray.h" |
22 #include "ash/system/tray/system_tray_item.h" | 22 #include "ash/system/tray/system_tray_item.h" |
23 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
24 #include "ash/test/shelf_test_api.h" | 24 #include "ash/test/shelf_test_api.h" |
25 #include "ash/wm/window_state.h" | 25 #include "ash/wm/window_state.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "base/command_line.h" | 27 #include "base/command_line.h" |
28 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
29 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
30 #include "ui/aura/test/event_generator.h" | |
31 #include "ui/aura/window.h" | 30 #include "ui/aura/window.h" |
32 #include "ui/aura/window_event_dispatcher.h" | 31 #include "ui/aura/window_event_dispatcher.h" |
33 #include "ui/compositor/layer.h" | 32 #include "ui/compositor/layer.h" |
34 #include "ui/compositor/layer_animator.h" | 33 #include "ui/compositor/layer_animator.h" |
35 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 34 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
36 #include "ui/events/gestures/gesture_configuration.h" | 35 #include "ui/events/gestures/gesture_configuration.h" |
| 36 #include "ui/events/test/event_generator.h" |
37 #include "ui/gfx/display.h" | 37 #include "ui/gfx/display.h" |
38 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
39 #include "ui/views/controls/label.h" | 39 #include "ui/views/controls/label.h" |
40 #include "ui/views/layout/fill_layout.h" | 40 #include "ui/views/layout/fill_layout.h" |
41 #include "ui/views/view.h" | 41 #include "ui/views/view.h" |
42 #include "ui/views/widget/widget.h" | 42 #include "ui/views/widget/widget.h" |
43 | 43 |
44 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
45 #include "base/win/windows_version.h" | 45 #include "base/win/windows_version.h" |
46 #endif | 46 #endif |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 401 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
402 shelf->LayoutShelf(); | 402 shelf->LayoutShelf(); |
403 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 403 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
404 | 404 |
405 gfx::Rect bounds_noshelf = window->bounds(); | 405 gfx::Rect bounds_noshelf = window->bounds(); |
406 gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); | 406 gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); |
407 | 407 |
408 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 408 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
409 shelf->LayoutShelf(); | 409 shelf->LayoutShelf(); |
410 | 410 |
411 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 411 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
412 const int kNumScrollSteps = 4; | 412 const int kNumScrollSteps = 4; |
413 ShelfDragCallback handler(shelf_hidden, shelf_shown); | 413 ShelfDragCallback handler(shelf_hidden, shelf_shown); |
414 | 414 |
415 // Swipe up on the shelf. This should not change any state. | 415 // Swipe up on the shelf. This should not change any state. |
416 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 416 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
417 gfx::Point end = start + delta; | 417 gfx::Point end = start + delta; |
418 | 418 |
419 // Swipe down on the shelf to hide it. | 419 // Swipe down on the shelf to hide it. |
420 generator.GestureScrollSequenceWithCallback( | 420 generator.GestureScrollSequenceWithCallback( |
421 start, | 421 start, |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 #if defined(OS_WIN) | 821 #if defined(OS_WIN) |
822 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 822 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
823 #define MAYBE_AutoHide DISABLED_AutoHide | 823 #define MAYBE_AutoHide DISABLED_AutoHide |
824 #else | 824 #else |
825 #define MAYBE_AutoHide AutoHide | 825 #define MAYBE_AutoHide AutoHide |
826 #endif | 826 #endif |
827 | 827 |
828 // Various assertions around auto-hide. | 828 // Various assertions around auto-hide. |
829 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { | 829 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { |
830 aura::Window* root = Shell::GetPrimaryRootWindow(); | 830 aura::Window* root = Shell::GetPrimaryRootWindow(); |
831 aura::test::EventGenerator generator(root, root); | 831 ui::test::EventGenerator generator(root, root); |
832 generator.MoveMouseTo(0, 0); | 832 generator.MoveMouseTo(0, 0); |
833 | 833 |
834 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 834 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
835 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 835 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
836 views::Widget* widget = new views::Widget; | 836 views::Widget* widget = new views::Widget; |
837 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 837 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
838 params.bounds = gfx::Rect(0, 0, 200, 200); | 838 params.bounds = gfx::Rect(0, 0, 200, 200); |
839 params.context = CurrentContext(); | 839 params.context = CurrentContext(); |
840 // Widget is now owned by the parent window. | 840 // Widget is now owned by the parent window. |
841 widget->Init(params); | 841 widget->Init(params); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 ASSERT_EQ(root_windows[0], | 912 ASSERT_EQ(root_windows[0], |
913 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); | 913 GetShelfWidget()->GetNativeWindow()->GetRootWindow()); |
914 | 914 |
915 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 915 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
916 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 916 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
917 | 917 |
918 int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; | 918 int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; |
919 int y = root_windows[0]->GetBoundsInScreen().y(); | 919 int y = root_windows[0]->GetBoundsInScreen().y(); |
920 | 920 |
921 // Start off the mouse nowhere near the shelf; the shelf should be hidden. | 921 // Start off the mouse nowhere near the shelf; the shelf should be hidden. |
922 aura::test::EventGenerator& generator(GetEventGenerator()); | 922 ui::test::EventGenerator& generator(GetEventGenerator()); |
923 generator.MoveMouseTo(right_edge - 50, y); | 923 generator.MoveMouseTo(right_edge - 50, y); |
924 UpdateAutoHideStateNow(); | 924 UpdateAutoHideStateNow(); |
925 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 925 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
926 | 926 |
927 // Moving the mouse over the light bar (but not to the edge of the screen) | 927 // Moving the mouse over the light bar (but not to the edge of the screen) |
928 // should show the shelf. | 928 // should show the shelf. |
929 generator.MoveMouseTo(right_edge - 1, y); | 929 generator.MoveMouseTo(right_edge - 1, y); |
930 UpdateAutoHideStateNow(); | 930 UpdateAutoHideStateNow(); |
931 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 931 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
932 EXPECT_EQ(right_edge - 1, Shell::GetScreen()->GetCursorScreenPoint().x()); | 932 EXPECT_EQ(right_edge - 1, Shell::GetScreen()->GetCursorScreenPoint().x()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 // the primary display's right aligned shelf first should not show the shelf. | 980 // the primary display's right aligned shelf first should not show the shelf. |
981 generator.MoveMouseTo(right_edge + 2, y); | 981 generator.MoveMouseTo(right_edge + 2, y); |
982 UpdateAutoHideStateNow(); | 982 UpdateAutoHideStateNow(); |
983 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); | 983 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
984 } | 984 } |
985 | 985 |
986 // Assertions around the lock screen showing. | 986 // Assertions around the lock screen showing. |
987 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { | 987 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
988 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 988 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
989 // it isn't over the shelf. | 989 // it isn't over the shelf. |
990 aura::test::EventGenerator generator( | 990 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
991 Shell::GetPrimaryRootWindow(), gfx::Point()); | 991 gfx::Point()); |
992 generator.MoveMouseTo(0, 0); | 992 generator.MoveMouseTo(0, 0); |
993 | 993 |
994 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 994 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
995 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 995 shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
996 views::Widget* widget = new views::Widget; | 996 views::Widget* widget = new views::Widget; |
997 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 997 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
998 params.bounds = gfx::Rect(0, 0, 200, 200); | 998 params.bounds = gfx::Rect(0, 0, 200, 200); |
999 params.context = CurrentContext(); | 999 params.context = CurrentContext(); |
1000 // Widget is now owned by the parent window. | 1000 // Widget is now owned by the parent window. |
1001 widget->Init(params); | 1001 widget->Init(params); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 | 1033 |
1034 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 1034 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
1035 shelf->UpdateVisibilityState(); | 1035 shelf->UpdateVisibilityState(); |
1036 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1036 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
1037 } | 1037 } |
1038 | 1038 |
1039 // Assertions around SetAutoHideBehavior. | 1039 // Assertions around SetAutoHideBehavior. |
1040 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { | 1040 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
1041 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1041 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
1042 // it isn't over the shelf. | 1042 // it isn't over the shelf. |
1043 aura::test::EventGenerator generator( | 1043 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1044 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1044 gfx::Point()); |
1045 generator.MoveMouseTo(0, 0); | 1045 generator.MoveMouseTo(0, 0); |
1046 | 1046 |
1047 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1047 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1048 views::Widget* widget = new views::Widget; | 1048 views::Widget* widget = new views::Widget; |
1049 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1049 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
1050 params.bounds = gfx::Rect(0, 0, 200, 200); | 1050 params.bounds = gfx::Rect(0, 0, 200, 200); |
1051 params.context = CurrentContext(); | 1051 params.context = CurrentContext(); |
1052 // Widget is now owned by the parent window. | 1052 // Widget is now owned by the parent window. |
1053 widget->Init(params); | 1053 widget->Init(params); |
1054 widget->Show(); | 1054 widget->Show(); |
(...skipping 23 matching lines...) Expand all Loading... |
1078 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1078 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
1079 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( | 1079 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
1080 window).work_area().bottom(), | 1080 window).work_area().bottom(), |
1081 widget->GetWorkAreaBoundsInScreen().bottom()); | 1081 widget->GetWorkAreaBoundsInScreen().bottom()); |
1082 } | 1082 } |
1083 | 1083 |
1084 // Basic assertions around the dimming of the shelf. | 1084 // Basic assertions around the dimming of the shelf. |
1085 TEST_F(ShelfLayoutManagerTest, TestDimmingBehavior) { | 1085 TEST_F(ShelfLayoutManagerTest, TestDimmingBehavior) { |
1086 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1086 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
1087 // it isn't over the shelf. | 1087 // it isn't over the shelf. |
1088 aura::test::EventGenerator generator( | 1088 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1089 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1089 gfx::Point()); |
1090 generator.MoveMouseTo(0, 0); | 1090 generator.MoveMouseTo(0, 0); |
1091 | 1091 |
1092 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1092 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1093 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); | 1093 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); |
1094 | 1094 |
1095 views::Widget* widget = new views::Widget; | 1095 views::Widget* widget = new views::Widget; |
1096 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1096 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
1097 params.bounds = gfx::Rect(0, 0, 200, 200); | 1097 params.bounds = gfx::Rect(0, 0, 200, 200); |
1098 params.context = CurrentContext(); | 1098 params.context = CurrentContext(); |
1099 // Widget is now owned by the parent window. | 1099 // Widget is now owned by the parent window. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 | 1152 |
1153 // After restore, the dimming object should be deleted again. | 1153 // After restore, the dimming object should be deleted again. |
1154 widget->Restore(); | 1154 widget->Restore(); |
1155 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1155 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
1156 } | 1156 } |
1157 | 1157 |
1158 // Assertions around the dimming of the shelf in conjunction with menus. | 1158 // Assertions around the dimming of the shelf in conjunction with menus. |
1159 TEST_F(ShelfLayoutManagerTest, TestDimmingBehaviorWithMenus) { | 1159 TEST_F(ShelfLayoutManagerTest, TestDimmingBehaviorWithMenus) { |
1160 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1160 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
1161 // it isn't over the shelf. | 1161 // it isn't over the shelf. |
1162 aura::test::EventGenerator generator( | 1162 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1163 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1163 gfx::Point()); |
1164 generator.MoveMouseTo(0, 0); | 1164 generator.MoveMouseTo(0, 0); |
1165 | 1165 |
1166 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1166 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1167 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); | 1167 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); |
1168 | 1168 |
1169 views::Widget* widget = new views::Widget; | 1169 views::Widget* widget = new views::Widget; |
1170 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1170 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
1171 params.bounds = gfx::Rect(0, 0, 200, 200); | 1171 params.bounds = gfx::Rect(0, 0, 200, 200); |
1172 params.context = CurrentContext(); | 1172 params.context = CurrentContext(); |
1173 // Widget is now owned by the parent window. | 1173 // Widget is now owned by the parent window. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1222 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
1223 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1223 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
1224 shelf->shelf_widget()->ForceUndimming(true); | 1224 shelf->shelf_widget()->ForceUndimming(true); |
1225 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1225 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
1226 } | 1226 } |
1227 | 1227 |
1228 // Verifies the shelf is visible when status/shelf is focused. | 1228 // Verifies the shelf is visible when status/shelf is focused. |
1229 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { | 1229 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { |
1230 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1230 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
1231 // it isn't over the shelf. | 1231 // it isn't over the shelf. |
1232 aura::test::EventGenerator generator( | 1232 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1233 Shell::GetPrimaryRootWindow(), gfx::Point()); | 1233 gfx::Point()); |
1234 generator.MoveMouseTo(0, 0); | 1234 generator.MoveMouseTo(0, 0); |
1235 | 1235 |
1236 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1236 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1237 views::Widget* widget = new views::Widget; | 1237 views::Widget* widget = new views::Widget; |
1238 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1238 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
1239 params.bounds = gfx::Rect(0, 0, 200, 200); | 1239 params.bounds = gfx::Rect(0, 0, 200, 200); |
1240 params.context = CurrentContext(); | 1240 params.context = CurrentContext(); |
1241 // Widget is now owned by the parent window. | 1241 // Widget is now owned by the parent window. |
1242 widget->Init(params); | 1242 widget->Init(params); |
1243 widget->Show(); | 1243 widget->Show(); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1525 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1526 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1526 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1527 views::Widget* widget = new views::Widget; | 1527 views::Widget* widget = new views::Widget; |
1528 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1528 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
1529 params.bounds = gfx::Rect(0, 0, 200, 200); | 1529 params.bounds = gfx::Rect(0, 0, 200, 200); |
1530 params.context = CurrentContext(); | 1530 params.context = CurrentContext(); |
1531 widget->Init(params); | 1531 widget->Init(params); |
1532 widget->Show(); | 1532 widget->Show(); |
1533 widget->Maximize(); | 1533 widget->Maximize(); |
1534 | 1534 |
1535 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1535 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1536 | 1536 |
1537 aura::Window* window = widget->GetNativeWindow(); | 1537 aura::Window* window = widget->GetNativeWindow(); |
1538 shelf->LayoutShelf(); | 1538 shelf->LayoutShelf(); |
1539 | 1539 |
1540 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); | 1540 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); |
1541 gfx::Rect bounds_shelf = window->bounds(); | 1541 gfx::Rect bounds_shelf = window->bounds(); |
1542 | 1542 |
1543 // Edge swipe when SHELF_VISIBLE should not change visibility state. | 1543 // Edge swipe when SHELF_VISIBLE should not change visibility state. |
1544 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1544 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
1545 generator.GestureEdgeSwipe(); | 1545 generator.GestureEdgeSwipe(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 views::Widget* widget = new views::Widget; | 1577 views::Widget* widget = new views::Widget; |
1578 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1578 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
1579 params.bounds = gfx::Rect(0, 0, 200, 200); | 1579 params.bounds = gfx::Rect(0, 0, 200, 200); |
1580 params.context = CurrentContext(); | 1580 params.context = CurrentContext(); |
1581 widget->Init(params); | 1581 widget->Init(params); |
1582 widget->Show(); | 1582 widget->Show(); |
1583 aura::Window* window = widget->GetNativeWindow(); | 1583 aura::Window* window = widget->GetNativeWindow(); |
1584 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | 1584 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); |
1585 widget->SetFullscreen(true); | 1585 widget->SetFullscreen(true); |
1586 | 1586 |
1587 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1587 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1588 | 1588 |
1589 // The maximize mode gets started. | 1589 // The maximize mode gets started. |
1590 shelf->OnMaximizeModeStarted(); | 1590 shelf->OnMaximizeModeStarted(); |
1591 shelf->LayoutShelf(); | 1591 shelf->LayoutShelf(); |
1592 shelf->UpdateVisibilityState(); | 1592 shelf->UpdateVisibilityState(); |
1593 | 1593 |
1594 // Edge swipe in fullscreen + AUTO_HIDE_HIDDEN should show the shelf and | 1594 // Edge swipe in fullscreen + AUTO_HIDE_HIDDEN should show the shelf and |
1595 // remain fullscreen. | 1595 // remain fullscreen. |
1596 EXPECT_TRUE(widget->IsFullscreen()); | 1596 EXPECT_TRUE(widget->IsFullscreen()); |
1597 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1597 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1696 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1697 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1697 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1698 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1698 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
1699 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1699 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
1700 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1700 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
1701 { | 1701 { |
1702 // Enable animations so that we can make sure that they occur. | 1702 // Enable animations so that we can make sure that they occur. |
1703 ui::ScopedAnimationDurationScaleMode regular_animations( | 1703 ui::ScopedAnimationDurationScaleMode regular_animations( |
1704 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 1704 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
1705 | 1705 |
1706 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1706 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1707 gfx::Rect shelf_bounds_in_screen = | 1707 gfx::Rect shelf_bounds_in_screen = |
1708 GetShelfWidget()->GetWindowBoundsInScreen(); | 1708 GetShelfWidget()->GetWindowBoundsInScreen(); |
1709 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); | 1709 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); |
1710 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); | 1710 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); |
1711 generator.GestureScrollSequence(start, end, | 1711 generator.GestureScrollSequence(start, end, |
1712 base::TimeDelta::FromMilliseconds(10), 5); | 1712 base::TimeDelta::FromMilliseconds(10), 5); |
1713 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | 1713 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
1714 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); | 1714 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
1715 | 1715 |
1716 ShelfAnimationWaiter waiter(visible_bounds); | 1716 ShelfAnimationWaiter waiter(visible_bounds); |
(...skipping 11 matching lines...) Expand all Loading... |
1728 gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1728 gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
1729 | 1729 |
1730 { | 1730 { |
1731 // Enable the animations so that we can make sure they do occur. | 1731 // Enable the animations so that we can make sure they do occur. |
1732 ui::ScopedAnimationDurationScaleMode regular_animations( | 1732 ui::ScopedAnimationDurationScaleMode regular_animations( |
1733 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 1733 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
1734 | 1734 |
1735 gfx::Point start = | 1735 gfx::Point start = |
1736 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 1736 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
1737 gfx::Point end(start.x(), start.y() - 100); | 1737 gfx::Point end(start.x(), start.y() - 100); |
1738 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1738 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1739 | 1739 |
1740 // Test that the shelf animates to the visible bounds after a swipe up on | 1740 // Test that the shelf animates to the visible bounds after a swipe up on |
1741 // the auto hidden shelf. | 1741 // the auto hidden shelf. |
1742 generator.GestureScrollSequence(start, end, | 1742 generator.GestureScrollSequence(start, end, |
1743 base::TimeDelta::FromMilliseconds(10), 1); | 1743 base::TimeDelta::FromMilliseconds(10), 1); |
1744 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1744 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
1745 ShelfAnimationWaiter waiter1(visible_bounds); | 1745 ShelfAnimationWaiter waiter1(visible_bounds); |
1746 waiter1.WaitTillDoneAnimating(); | 1746 waiter1.WaitTillDoneAnimating(); |
1747 EXPECT_TRUE(waiter1.WasValidAnimation()); | 1747 EXPECT_TRUE(waiter1.WasValidAnimation()); |
1748 | 1748 |
(...skipping 13 matching lines...) Expand all Loading... |
1762 TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { | 1762 TEST_F(ShelfLayoutManagerTest, GestureRevealsTrayBubble) { |
1763 if (!SupportsHostWindowResize()) | 1763 if (!SupportsHostWindowResize()) |
1764 return; | 1764 return; |
1765 | 1765 |
1766 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1766 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1767 shelf->LayoutShelf(); | 1767 shelf->LayoutShelf(); |
1768 | 1768 |
1769 // Create a visible window so auto-hide behavior is enforced. | 1769 // Create a visible window so auto-hide behavior is enforced. |
1770 CreateTestWidget(); | 1770 CreateTestWidget(); |
1771 | 1771 |
1772 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1772 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1773 SystemTray* tray = GetSystemTray(); | 1773 SystemTray* tray = GetSystemTray(); |
1774 | 1774 |
1775 // First, make sure the shelf is visible. | 1775 // First, make sure the shelf is visible. |
1776 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1776 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1777 EXPECT_FALSE(tray->HasSystemBubble()); | 1777 EXPECT_FALSE(tray->HasSystemBubble()); |
1778 | 1778 |
1779 // Now, drag up on the tray to show the bubble. | 1779 // Now, drag up on the tray to show the bubble. |
1780 gfx::Point start = GetShelfWidget()->status_area_widget()-> | 1780 gfx::Point start = GetShelfWidget()->status_area_widget()-> |
1781 GetWindowBoundsInScreen().CenterPoint(); | 1781 GetWindowBoundsInScreen().CenterPoint(); |
1782 gfx::Point end(start.x(), start.y() - 100); | 1782 gfx::Point end(start.x(), start.y() - 100); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { | 1903 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { |
1904 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1904 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1905 StatusAreaWidget* status_area_widget = | 1905 StatusAreaWidget* status_area_widget = |
1906 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); | 1906 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
1907 SystemTray* tray = GetSystemTray(); | 1907 SystemTray* tray = GetSystemTray(); |
1908 | 1908 |
1909 // Create a visible window so auto-hide behavior is enforced. | 1909 // Create a visible window so auto-hide behavior is enforced. |
1910 CreateTestWidget(); | 1910 CreateTestWidget(); |
1911 | 1911 |
1912 shelf->LayoutShelf(); | 1912 shelf->LayoutShelf(); |
1913 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1913 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1914 | 1914 |
1915 // Make two iterations - first without a message bubble which should make | 1915 // Make two iterations - first without a message bubble which should make |
1916 // the shelf disappear and then with a message bubble which should keep it | 1916 // the shelf disappear and then with a message bubble which should keep it |
1917 // visible. | 1917 // visible. |
1918 for (int i = 0; i < 2; i++) { | 1918 for (int i = 0; i < 2; i++) { |
1919 // Make sure the shelf is visible and position the mouse over it. Then | 1919 // Make sure the shelf is visible and position the mouse over it. Then |
1920 // allow auto hide. | 1920 // allow auto hide. |
1921 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1921 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1922 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1922 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
1923 gfx::Point center = | 1923 gfx::Point center = |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 #else | 1999 #else |
2000 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge | 2000 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge |
2001 #endif | 2001 #endif |
2002 | 2002 |
2003 // Verify the hit bounds of the status area extend to the edge of the shelf. | 2003 // Verify the hit bounds of the status area extend to the edge of the shelf. |
2004 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { | 2004 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { |
2005 UpdateDisplay("400x400"); | 2005 UpdateDisplay("400x400"); |
2006 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 2006 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
2007 StatusAreaWidget* status_area_widget = | 2007 StatusAreaWidget* status_area_widget = |
2008 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); | 2008 Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
2009 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 2009 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
2010 generator.MoveMouseTo(399,399); | 2010 generator.MoveMouseTo(399,399); |
2011 | 2011 |
2012 // Test bottom right pixel for bottom alignment. | 2012 // Test bottom right pixel for bottom alignment. |
2013 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2013 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2014 generator.ClickLeftButton(); | 2014 generator.ClickLeftButton(); |
2015 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2015 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
2016 generator.ClickLeftButton(); | 2016 generator.ClickLeftButton(); |
2017 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2017 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2018 | 2018 |
2019 // Test bottom right pixel for right alignment. | 2019 // Test bottom right pixel for right alignment. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2071 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 2071 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
2072 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); | 2072 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
2073 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); | 2073 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
2074 | 2074 |
2075 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2075 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
2076 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); | 2076 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
2077 EXPECT_EQ(initial_bounds, reshow_target_bounds); | 2077 EXPECT_EQ(initial_bounds, reshow_target_bounds); |
2078 } | 2078 } |
2079 | 2079 |
2080 } // namespace ash | 2080 } // namespace ash |
OLD | NEW |