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/focus_cycler.h" | 9 #include "ash/focus_cycler.h" |
10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
12 #include "ash/session/session_controller.h" | 12 #include "ash/session/session_controller.h" |
13 #include "ash/shelf/shelf_constants.h" | 13 #include "ash/shelf/shelf_constants.h" |
14 #include "ash/shelf/shelf_layout_manager_observer.h" | 14 #include "ash/shelf/shelf_layout_manager_observer.h" |
15 #include "ash/shelf/shelf_view.h" | 15 #include "ash/shelf/shelf_view.h" |
16 #include "ash/shelf/shelf_widget.h" | 16 #include "ash/shelf/shelf_widget.h" |
17 #include "ash/shelf/wm_shelf.h" | 17 #include "ash/shelf/wm_shelf.h" |
18 #include "ash/shell.h" | 18 #include "ash/shell.h" |
| 19 #include "ash/shell_port.h" |
19 #include "ash/system/status_area_widget.h" | 20 #include "ash/system/status_area_widget.h" |
20 #include "ash/system/tray/system_tray.h" | 21 #include "ash/system/tray/system_tray.h" |
21 #include "ash/system/tray/system_tray_item.h" | 22 #include "ash/system/tray/system_tray_item.h" |
22 #include "ash/test/ash_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
23 #include "ash/test/test_app_list_view_presenter_impl.h" | 24 #include "ash/test/test_app_list_view_presenter_impl.h" |
24 #include "ash/test/test_system_tray_item.h" | 25 #include "ash/test/test_system_tray_item.h" |
25 #include "ash/wm/lock_state_controller.h" | 26 #include "ash/wm/lock_state_controller.h" |
26 #include "ash/wm/window_state.h" | 27 #include "ash/wm/window_state.h" |
27 #include "ash/wm/window_state_aura.h" | 28 #include "ash/wm/window_state_aura.h" |
28 #include "ash/wm/window_util.h" | 29 #include "ash/wm/window_util.h" |
29 #include "ash/wm_shell.h" | |
30 #include "ash/wm_window.h" | 30 #include "ash/wm_window.h" |
31 #include "base/command_line.h" | 31 #include "base/command_line.h" |
32 #include "base/memory/ptr_util.h" | 32 #include "base/memory/ptr_util.h" |
33 #include "base/run_loop.h" | 33 #include "base/run_loop.h" |
34 #include "ui/aura/client/aura_constants.h" | 34 #include "ui/aura/client/aura_constants.h" |
35 #include "ui/aura/client/window_parenting_client.h" | 35 #include "ui/aura/client/window_parenting_client.h" |
36 #include "ui/aura/window.h" | 36 #include "ui/aura/window.h" |
37 #include "ui/aura/window_event_dispatcher.h" | 37 #include "ui/aura/window_event_dispatcher.h" |
38 #include "ui/base/ui_base_switches.h" | 38 #include "ui/base/ui_base_switches.h" |
39 #include "ui/compositor/layer.h" | 39 #include "ui/compositor/layer.h" |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 ASSERT_TRUE(shelf_widget); | 678 ASSERT_TRUE(shelf_widget); |
679 ASSERT_TRUE(shelf_widget->status_area_widget()); | 679 ASSERT_TRUE(shelf_widget->status_area_widget()); |
680 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); | 680 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); |
681 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - | 681 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - |
682 shelf->GetShelfViewForTesting()->width()); | 682 shelf->GetShelfViewForTesting()->width()); |
683 } | 683 } |
684 | 684 |
685 // Various assertions around auto-hide. | 685 // Various assertions around auto-hide. |
686 TEST_F(ShelfLayoutManagerTest, AutoHide) { | 686 TEST_F(ShelfLayoutManagerTest, AutoHide) { |
687 // TODO: investigate failure in mash, http://crbug.com/695686. | 687 // TODO: investigate failure in mash, http://crbug.com/695686. |
688 if (WmShell::Get()->IsRunningInMash()) | 688 if (ShellPort::Get()->IsRunningInMash()) |
689 return; | 689 return; |
690 | 690 |
691 ui::test::EventGenerator& generator(GetEventGenerator()); | 691 ui::test::EventGenerator& generator(GetEventGenerator()); |
692 | 692 |
693 WmShelf* shelf = GetPrimaryShelf(); | 693 WmShelf* shelf = GetPrimaryShelf(); |
694 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 694 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
695 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 695 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
696 views::Widget* widget = CreateTestWidget(); | 696 views::Widget* widget = CreateTestWidget(); |
697 widget->Maximize(); | 697 widget->Maximize(); |
698 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 698 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 generator.PressLeftButton(); | 741 generator.PressLeftButton(); |
742 generator.MoveMouseTo(1, display_bottom - 1); | 742 generator.MoveMouseTo(1, display_bottom - 1); |
743 UpdateAutoHideStateNow(); | 743 UpdateAutoHideStateNow(); |
744 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 744 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
745 } | 745 } |
746 | 746 |
747 // Test the behavior of the shelf when it is auto hidden and it is on the | 747 // Test the behavior of the shelf when it is auto hidden and it is on the |
748 // boundary between the primary and the secondary display. | 748 // boundary between the primary and the secondary display. |
749 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { | 749 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { |
750 // TODO: investigate failure in mash, http://crbug.com/695686. | 750 // TODO: investigate failure in mash, http://crbug.com/695686. |
751 if (WmShell::Get()->IsRunningInMash()) | 751 if (ShellPort::Get()->IsRunningInMash()) |
752 return; | 752 return; |
753 | 753 |
754 UpdateDisplay("800x600,800x600"); | 754 UpdateDisplay("800x600,800x600"); |
755 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash. | 755 // TODO: SetLayoutForCurrentDisplays() needs to ported to mash. |
756 // http://crbug.com/698043. | 756 // http://crbug.com/698043. |
757 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays( | 757 Shell::Get()->display_manager()->SetLayoutForCurrentDisplays( |
758 display::test::CreateDisplayLayout(display_manager(), | 758 display::test::CreateDisplayLayout(display_manager(), |
759 display::DisplayPlacement::RIGHT, 0)); | 759 display::DisplayPlacement::RIGHT, 0)); |
760 // Put the primary monitor's shelf on the display boundary. | 760 // Put the primary monitor's shelf on the display boundary. |
761 WmShelf* shelf = GetPrimaryShelf(); | 761 WmShelf* shelf = GetPrimaryShelf(); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 test::TestAppListViewPresenterImpl app_list_presenter_impl; | 952 test::TestAppListViewPresenterImpl app_list_presenter_impl; |
953 | 953 |
954 // Create a normal unmaximized window; the shelf should be visible. | 954 // Create a normal unmaximized window; the shelf should be visible. |
955 aura::Window* window = CreateTestWindow(); | 955 aura::Window* window = CreateTestWindow(); |
956 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 956 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
957 window->Show(); | 957 window->Show(); |
958 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 958 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
959 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 959 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
960 | 960 |
961 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. | 961 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. |
962 if (WmShell::Get()->IsRunningInMash()) | 962 if (ShellPort::Get()->IsRunningInMash()) |
963 return; | 963 return; |
964 | 964 |
965 // Show the app list and the shelf stays visible. | 965 // Show the app list and the shelf stays visible. |
966 app_list_presenter_impl.Show(GetPrimaryDisplayId()); | 966 app_list_presenter_impl.Show(GetPrimaryDisplayId()); |
967 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); | 967 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); |
968 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 968 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
969 | 969 |
970 // Hide the app list and the shelf stays visible. | 970 // Hide the app list and the shelf stays visible. |
971 app_list_presenter_impl.Dismiss(); | 971 app_list_presenter_impl.Dismiss(); |
972 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 972 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
(...skipping 11 matching lines...) Expand all Loading... |
984 | 984 |
985 // Create a normal unmaximized window; the shelf should be hidden. | 985 // Create a normal unmaximized window; the shelf should be hidden. |
986 aura::Window* window = CreateTestWindow(); | 986 aura::Window* window = CreateTestWindow(); |
987 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 987 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
988 window->Show(); | 988 window->Show(); |
989 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 989 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
990 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 990 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
991 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 991 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
992 | 992 |
993 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. | 993 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. |
994 if (WmShell::Get()->IsRunningInMash()) | 994 if (ShellPort::Get()->IsRunningInMash()) |
995 return; | 995 return; |
996 | 996 |
997 // Show the app list and the shelf should be temporarily visible. | 997 // Show the app list and the shelf should be temporarily visible. |
998 app_list_presenter_impl.Show(GetPrimaryDisplayId()); | 998 app_list_presenter_impl.Show(GetPrimaryDisplayId()); |
999 // The shelf's auto hide state won't be changed until the timer fires, so | 999 // The shelf's auto hide state won't be changed until the timer fires, so |
1000 // force it to update now. | 1000 // force it to update now. |
1001 GetShelfLayoutManager()->UpdateVisibilityState(); | 1001 GetShelfLayoutManager()->UpdateVisibilityState(); |
1002 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); | 1002 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); |
1003 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1003 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
1004 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 1004 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 test::TestAppListViewPresenterImpl app_list_presenter_impl; | 1052 test::TestAppListViewPresenterImpl app_list_presenter_impl; |
1053 | 1053 |
1054 Shell::Get()->UpdateShelfVisibility(); | 1054 Shell::Get()->UpdateShelfVisibility(); |
1055 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 1055 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
1056 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1056 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
1057 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | 1057 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); |
1058 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | 1058 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); |
1059 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | 1059 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); |
1060 | 1060 |
1061 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. | 1061 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. |
1062 if (WmShell::Get()->IsRunningInMash()) | 1062 if (ShellPort::Get()->IsRunningInMash()) |
1063 return; | 1063 return; |
1064 | 1064 |
1065 // Show the app list; only the shelf on the same display should be shown. | 1065 // Show the app list; only the shelf on the same display should be shown. |
1066 app_list_presenter_impl.Show(GetPrimaryDisplayId()); | 1066 app_list_presenter_impl.Show(GetPrimaryDisplayId()); |
1067 Shell::Get()->UpdateShelfVisibility(); | 1067 Shell::Get()->UpdateShelfVisibility(); |
1068 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); | 1068 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); |
1069 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1069 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
1070 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_1->GetAutoHideState()); | 1070 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_1->GetAutoHideState()); |
1071 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | 1071 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); |
1072 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | 1072 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); |
(...skipping 19 matching lines...) Expand all Loading... |
1092 // Create a window and make it full screen; the shelf should be hidden. | 1092 // Create a window and make it full screen; the shelf should be hidden. |
1093 aura::Window* window = CreateTestWindow(); | 1093 aura::Window* window = CreateTestWindow(); |
1094 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1094 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1095 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 1095 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
1096 window->Show(); | 1096 window->Show(); |
1097 wm::ActivateWindow(window); | 1097 wm::ActivateWindow(window); |
1098 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 1098 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
1099 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 1099 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
1100 | 1100 |
1101 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. | 1101 // TODO: fails in mash because of AppListPresenter. http://crbug.com/696028. |
1102 if (WmShell::Get()->IsRunningInMash()) | 1102 if (ShellPort::Get()->IsRunningInMash()) |
1103 return; | 1103 return; |
1104 | 1104 |
1105 // Show the app list and the shelf should be temporarily visible. | 1105 // Show the app list and the shelf should be temporarily visible. |
1106 app_list_presenter_impl.Show(GetPrimaryDisplayId()); | 1106 app_list_presenter_impl.Show(GetPrimaryDisplayId()); |
1107 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); | 1107 EXPECT_TRUE(app_list_presenter_impl.GetTargetVisibility()); |
1108 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1108 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1109 | 1109 |
1110 // Hide the app list and the shelf should be hidden again. | 1110 // Hide the app list and the shelf should be hidden again. |
1111 app_list_presenter_impl.Dismiss(); | 1111 app_list_presenter_impl.Dismiss(); |
1112 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 1112 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
1113 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 1113 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
1114 } | 1114 } |
1115 | 1115 |
1116 // Tests the correct behavior of the shelf when there is a system modal window | 1116 // Tests the correct behavior of the shelf when there is a system modal window |
1117 // open when we have a single display. | 1117 // open when we have a single display. |
1118 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { | 1118 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowSingleDisplay) { |
1119 WmShelf* shelf = GetPrimaryShelf(); | 1119 WmShelf* shelf = GetPrimaryShelf(); |
1120 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1120 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
1121 layout_manager->LayoutShelf(); | 1121 layout_manager->LayoutShelf(); |
1122 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1122 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1123 | 1123 |
1124 aura::Window* window = CreateTestWindow(); | 1124 aura::Window* window = CreateTestWindow(); |
1125 window->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1125 window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1126 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1126 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1127 window->Show(); | 1127 window->Show(); |
1128 wm::ActivateWindow(window); | 1128 wm::ActivateWindow(window); |
1129 | 1129 |
1130 // Enable system modal dialog, and make sure shelf is still hidden. | 1130 // Enable system modal dialog, and make sure shelf is still hidden. |
1131 WmShell* wm_shell = WmShell::Get(); | 1131 ShellPort::Get()->SimulateModalWindowOpenForTesting(true); |
1132 wm_shell->SimulateModalWindowOpenForTesting(true); | 1132 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); |
1133 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); | |
1134 EXPECT_FALSE(wm::CanActivateWindow(window)); | 1133 EXPECT_FALSE(wm::CanActivateWindow(window)); |
1135 Shell::Get()->UpdateShelfVisibility(); | 1134 Shell::Get()->UpdateShelfVisibility(); |
1136 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1135 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
1137 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1136 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
1138 } | 1137 } |
1139 | 1138 |
1140 // Tests the correct behavior of the shelf when there is a system modal window | 1139 // Tests the correct behavior of the shelf when there is a system modal window |
1141 // open when we have dual display. | 1140 // open when we have dual display. |
1142 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { | 1141 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { |
1143 // Create two displays. | 1142 // Create two displays. |
(...skipping 23 matching lines...) Expand all Loading... |
1167 window_2->Show(); | 1166 window_2->Show(); |
1168 | 1167 |
1169 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), | 1168 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), |
1170 WmWindow::Get(window_1)->GetRootWindow()); | 1169 WmWindow::Get(window_1)->GetRootWindow()); |
1171 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), | 1170 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), |
1172 WmWindow::Get(window_2)->GetRootWindow()); | 1171 WmWindow::Get(window_2)->GetRootWindow()); |
1173 EXPECT_TRUE(window_1->IsVisible()); | 1172 EXPECT_TRUE(window_1->IsVisible()); |
1174 EXPECT_TRUE(window_2->IsVisible()); | 1173 EXPECT_TRUE(window_2->IsVisible()); |
1175 | 1174 |
1176 // Enable system modal dialog, and make sure both shelves are still hidden. | 1175 // Enable system modal dialog, and make sure both shelves are still hidden. |
1177 WmShell* wm_shell = WmShell::Get(); | 1176 ShellPort::Get()->SimulateModalWindowOpenForTesting(true); |
1178 wm_shell->SimulateModalWindowOpenForTesting(true); | 1177 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); |
1179 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); | |
1180 EXPECT_FALSE(wm::CanActivateWindow(window_1)); | 1178 EXPECT_FALSE(wm::CanActivateWindow(window_1)); |
1181 EXPECT_FALSE(wm::CanActivateWindow(window_2)); | 1179 EXPECT_FALSE(wm::CanActivateWindow(window_2)); |
1182 Shell::Get()->UpdateShelfVisibility(); | 1180 Shell::Get()->UpdateShelfVisibility(); |
1183 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1181 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
1184 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | 1182 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); |
1185 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | 1183 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); |
1186 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | 1184 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); |
1187 } | 1185 } |
1188 | 1186 |
1189 // Tests that the shelf is only hidden for a fullscreen window at the front and | 1187 // Tests that the shelf is only hidden for a fullscreen window at the front and |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 SHELF_HIDDEN, | 1237 SHELF_HIDDEN, |
1240 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state()); | 1238 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state()); |
1241 EXPECT_EQ( | 1239 EXPECT_EQ( |
1242 SHELF_VISIBLE, | 1240 SHELF_VISIBLE, |
1243 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); | 1241 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); |
1244 } | 1242 } |
1245 | 1243 |
1246 // Test for Pinned mode. | 1244 // Test for Pinned mode. |
1247 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { | 1245 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { |
1248 // TODO: investigate failure in mash, http://crbug.com/695686. | 1246 // TODO: investigate failure in mash, http://crbug.com/695686. |
1249 if (WmShell::Get()->IsRunningInMash()) | 1247 if (ShellPort::Get()->IsRunningInMash()) |
1250 return; | 1248 return; |
1251 | 1249 |
1252 WmShelf* shelf = GetPrimaryShelf(); | 1250 WmShelf* shelf = GetPrimaryShelf(); |
1253 | 1251 |
1254 aura::Window* window1 = CreateTestWindow(); | 1252 aura::Window* window1 = CreateTestWindow(); |
1255 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1253 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1256 window1->Show(); | 1254 window1->Show(); |
1257 | 1255 |
1258 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1256 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1259 | 1257 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1327 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1330 display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1328 display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
1331 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1329 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
1332 display.GetWorkAreaInsets().right()); | 1330 display.GetWorkAreaInsets().right()); |
1333 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1331 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
1334 display.bounds().right() - display.work_area().right()); | 1332 display.bounds().right() - display.work_area().right()); |
1335 } | 1333 } |
1336 | 1334 |
1337 TEST_F(ShelfLayoutManagerTest, GestureDrag) { | 1335 TEST_F(ShelfLayoutManagerTest, GestureDrag) { |
1338 // TODO: investigate failure in mash, http://crbug.com/695686. | 1336 // TODO: investigate failure in mash, http://crbug.com/695686. |
1339 if (WmShell::Get()->IsRunningInMash()) | 1337 if (ShellPort::Get()->IsRunningInMash()) |
1340 return; | 1338 return; |
1341 | 1339 |
1342 // Slop is an implementation detail of gesture recognition, and complicates | 1340 // Slop is an implementation detail of gesture recognition, and complicates |
1343 // these tests. Ignore it. | 1341 // these tests. Ignore it. |
1344 ui::GestureConfiguration::GetInstance() | 1342 ui::GestureConfiguration::GetInstance() |
1345 ->set_max_touch_move_in_pixels_for_click(0); | 1343 ->set_max_touch_move_in_pixels_for_click(0); |
1346 WmShelf* shelf = GetPrimaryShelf(); | 1344 WmShelf* shelf = GetPrimaryShelf(); |
1347 { | 1345 { |
1348 SCOPED_TRACE("BOTTOM"); | 1346 SCOPED_TRACE("BOTTOM"); |
1349 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 1347 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 widget_one->Activate(); | 1515 widget_one->Activate(); |
1518 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1516 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1519 wm::GetWindowState(window_two) | 1517 wm::GetWindowState(window_two) |
1520 ->set_autohide_shelf_when_maximized_or_fullscreen(false); | 1518 ->set_autohide_shelf_when_maximized_or_fullscreen(false); |
1521 widget_two->Activate(); | 1519 widget_two->Activate(); |
1522 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1520 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1523 } | 1521 } |
1524 | 1522 |
1525 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { | 1523 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { |
1526 // TODO: investigate failure in mash, http://crbug.com/695686. | 1524 // TODO: investigate failure in mash, http://crbug.com/695686. |
1527 if (WmShell::Get()->IsRunningInMash()) | 1525 if (ShellPort::Get()->IsRunningInMash()) |
1528 return; | 1526 return; |
1529 | 1527 |
1530 WmShelf* shelf = GetPrimaryShelf(); | 1528 WmShelf* shelf = GetPrimaryShelf(); |
1531 | 1529 |
1532 // Create a visible window so auto-hide behavior is enforced. | 1530 // Create a visible window so auto-hide behavior is enforced. |
1533 CreateTestWidget(); | 1531 CreateTestWidget(); |
1534 | 1532 |
1535 // Turn on auto-hide for the shelf. | 1533 // Turn on auto-hide for the shelf. |
1536 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1534 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1537 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1535 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 GetShelfWidget()->Shutdown(); | 1713 GetShelfWidget()->Shutdown(); |
1716 | 1714 |
1717 // Deleting a focused maximized window will switch focus to |window2|. This | 1715 // Deleting a focused maximized window will switch focus to |window2|. This |
1718 // would normally cause the ShelfLayoutManager to update its state. However | 1716 // would normally cause the ShelfLayoutManager to update its state. However |
1719 // during shutdown we want to handle this without crashing. | 1717 // during shutdown we want to handle this without crashing. |
1720 delete window1; | 1718 delete window1; |
1721 } | 1719 } |
1722 | 1720 |
1723 TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { | 1721 TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { |
1724 // TODO: requires unified desktop mode. http://crbug.com/581462. | 1722 // TODO: requires unified desktop mode. http://crbug.com/581462. |
1725 if (WmShell::Get()->IsRunningInMash()) | 1723 if (ShellPort::Get()->IsRunningInMash()) |
1726 return; | 1724 return; |
1727 | 1725 |
1728 Shell::Get()->display_manager()->SetUnifiedDesktopEnabled(true); | 1726 Shell::Get()->display_manager()->SetUnifiedDesktopEnabled(true); |
1729 UpdateDisplay("500x400, 500x400"); | 1727 UpdateDisplay("500x400, 500x400"); |
1730 | 1728 |
1731 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1729 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
1732 EXPECT_TRUE(status_area_widget->IsVisible()); | 1730 EXPECT_TRUE(status_area_widget->IsVisible()); |
1733 // Shelf should be in the first display's area. | 1731 // Shelf should be in the first display's area. |
1734 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1732 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
1735 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 1733 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 // Open keyboard in sticky mode. | 1839 // Open keyboard in sticky mode. |
1842 kb_controller->ShowKeyboard(true); | 1840 kb_controller->ShowKeyboard(true); |
1843 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1841 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
1844 | 1842 |
1845 // Work area should be changed. | 1843 // Work area should be changed. |
1846 EXPECT_NE(orig_work_area, | 1844 EXPECT_NE(orig_work_area, |
1847 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1845 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1848 } | 1846 } |
1849 | 1847 |
1850 } // namespace ash | 1848 } // namespace ash |
OLD | NEW |