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_controller.h" | 10 #include "ash/display/display_controller.h" |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); | 1111 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); |
1112 StepWidgetLayerAnimatorToEnd(shelf_widget); | 1112 StepWidgetLayerAnimatorToEnd(shelf_widget); |
1113 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 1113 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
1114 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | 1114 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
1115 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( | 1115 EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
1116 window).work_area().bottom(), | 1116 window).work_area().bottom(), |
1117 widget->GetWorkAreaBoundsInScreen().bottom()); | 1117 widget->GetWorkAreaBoundsInScreen().bottom()); |
1118 } | 1118 } |
1119 | 1119 |
1120 // Basic assertions around the dimming of the shelf. | 1120 // Basic assertions around the dimming of the shelf. |
1121 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { | 1121 TEST_F(ShelfLayoutManagerTest, TestDimmingBehavior) { |
1122 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1122 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
1123 // it isn't over the shelf. | 1123 // it isn't over the shelf. |
1124 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1124 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1125 gfx::Point()); | 1125 gfx::Point()); |
1126 generator.MoveMouseTo(0, 0); | 1126 generator.MoveMouseTo(0, 0); |
1127 | 1127 |
1128 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1128 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1129 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); | 1129 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); |
1130 | 1130 |
1131 views::Widget* widget = new views::Widget; | 1131 views::Widget* widget = new views::Widget; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 generator.MoveTouch(off_shelf); | 1184 generator.MoveTouch(off_shelf); |
1185 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1185 EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
1186 generator.MoveTouch(on_shelf); | 1186 generator.MoveTouch(on_shelf); |
1187 generator.ReleaseTouch(); | 1187 generator.ReleaseTouch(); |
1188 | 1188 |
1189 // After restore, the dimming object should be deleted again. | 1189 // After restore, the dimming object should be deleted again. |
1190 widget->Restore(); | 1190 widget->Restore(); |
1191 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); | 1191 EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
1192 } | 1192 } |
1193 | 1193 |
1194 // Test that dimming works correctly with multiple displays. | |
1195 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { | |
1196 if (!SupportsMultipleDisplays()) | |
1197 return; | |
1198 | |
1199 // Create two displays. | |
1200 Shell* shell = Shell::GetInstance(); | |
1201 UpdateDisplay("0+0-200x200,+200+0-100x100"); | |
1202 EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays()); | |
1203 | |
1204 DisplayController* display_controller = shell->display_controller(); | |
1205 aura::Window::Windows root_windows = display_controller->GetAllRootWindows(); | |
1206 EXPECT_EQ(root_windows.size(), 2U); | |
1207 | |
1208 std::vector<ShelfWidget*> shelf_widgets; | |
1209 for (auto& root_window : root_windows) { | |
1210 ShelfLayoutManager* shelf = | |
1211 GetRootWindowController(root_window)->GetShelfLayoutManager(); | |
1212 shelf_widgets.push_back(shelf->shelf_widget()); | |
1213 | |
1214 // For disabling the dimming animation to work, the animation must be | |
1215 // disabled prior to creating the dimmer. | |
1216 shelf_widgets.back()->DisableDimmingAnimationsForTest(); | |
1217 | |
1218 // Create a maximized window to create the dimmer. | |
1219 views::Widget* widget = new views::Widget; | |
1220 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
1221 params.context = root_window; | |
1222 params.bounds = root_window->GetBoundsInScreen(); | |
1223 params.show_state = ui::SHOW_STATE_MAXIMIZED; | |
1224 widget->Init(params); | |
1225 widget->Show(); | |
1226 } | |
1227 | |
1228 ui::test::EventGenerator& generator(GetEventGenerator()); | |
1229 | |
1230 generator.MoveMouseTo(root_windows[0]->GetBoundsInScreen().CenterPoint()); | |
1231 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1232 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1233 | |
1234 generator.MoveMouseTo( | |
1235 shelf_widgets[0]->GetWindowBoundsInScreen().CenterPoint()); | |
1236 EXPECT_EQ(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1237 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1238 | |
1239 generator.MoveMouseTo( | |
1240 shelf_widgets[1]->GetWindowBoundsInScreen().CenterPoint()); | |
1241 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1242 EXPECT_EQ(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1243 | |
1244 generator.MoveMouseTo(root_windows[1]->GetBoundsInScreen().CenterPoint()); | |
1245 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1246 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1247 } | |
1248 | |
1249 // Assertions around the dimming of the shelf in conjunction with menus. | 1194 // Assertions around the dimming of the shelf in conjunction with menus. |
1250 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { | 1195 TEST_F(ShelfLayoutManagerTest, TestDimmingBehaviorWithMenus) { |
1251 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1196 // Since ShelfLayoutManager queries for mouse location, move the mouse so |
1252 // it isn't over the shelf. | 1197 // it isn't over the shelf. |
1253 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1198 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
1254 gfx::Point()); | 1199 gfx::Point()); |
1255 generator.MoveMouseTo(0, 0); | 1200 generator.MoveMouseTo(0, 0); |
1256 | 1201 |
1257 ShelfLayoutManager* shelf = GetShelfLayoutManager(); | 1202 ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
1258 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); | 1203 shelf->shelf_widget()->DisableDimmingAnimationsForTest(); |
1259 | 1204 |
1260 views::Widget* widget = new views::Widget; | 1205 views::Widget* widget = new views::Widget; |
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 2215 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
2271 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); | 2216 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
2272 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); | 2217 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
2273 | 2218 |
2274 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2219 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
2275 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); | 2220 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
2276 EXPECT_EQ(initial_bounds, reshow_target_bounds); | 2221 EXPECT_EQ(initial_bounds, reshow_target_bounds); |
2277 } | 2222 } |
2278 | 2223 |
2279 } // namespace ash | 2224 } // namespace ash |
OLD | NEW |