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/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_shelf_aura.h" |
8 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
9 #include "ash/common/accelerators/accelerator_controller.h" | 9 #include "ash/common/accelerators/accelerator_controller.h" |
10 #include "ash/common/accelerators/accelerator_table.h" | 10 #include "ash/common/accelerators/accelerator_table.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } else if (SHELF_ALIGNMENT_RIGHT == | 166 } else if (SHELF_ALIGNMENT_RIGHT == |
167 GetShelfLayoutManager()->GetAlignment()) { | 167 GetShelfLayoutManager()->GetAlignment()) { |
168 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right()); | 168 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right()); |
169 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right()); | 169 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right()); |
170 } else if (SHELF_ALIGNMENT_LEFT == | 170 } else if (SHELF_ALIGNMENT_LEFT == |
171 GetShelfLayoutManager()->GetAlignment()) { | 171 GetShelfLayoutManager()->GetAlignment()) { |
172 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x()); | 172 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x()); |
173 EXPECT_EQ(shelf_widget_bounds_.x(), shelf_bounds.x()); | 173 EXPECT_EQ(shelf_widget_bounds_.x(), shelf_bounds.x()); |
174 } | 174 } |
175 | 175 |
176 // if the shelf is being dimmed test dimmer bounds as well. | |
177 if (GetShelfWidget()->GetDimsShelf()) | |
178 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), | |
179 GetShelfWidget()->GetDimmerBoundsForTest()); | |
180 | |
181 // Auto hidden shelf has a visible height of 0 in MD (where this inequality | 176 // Auto hidden shelf has a visible height of 0 in MD (where this inequality |
182 // does not apply); whereas auto hidden shelf has a visible height of 3 in | 177 // does not apply); whereas auto hidden shelf has a visible height of 3 in |
183 // non-MD. | 178 // non-MD. |
184 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf(); | 179 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf(); |
185 if (!ash::MaterialDesignController::IsImmersiveModeMaterial() || | 180 if (!ash::MaterialDesignController::IsImmersiveModeMaterial() || |
186 shelf->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) { | 181 shelf->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) { |
187 EXPECT_GE(shelf_bounds.height(), | 182 EXPECT_GE(shelf_bounds.height(), |
188 auto_hidden_shelf_widget_bounds_.height()); | 183 auto_hidden_shelf_widget_bounds_.height()); |
189 } | 184 } |
190 | 185 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 370 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
376 | 371 |
377 // Swipe up to show the shelf. | 372 // Swipe up to show the shelf. |
378 generator.GestureScrollSequenceWithCallback( | 373 generator.GestureScrollSequenceWithCallback( |
379 end, start, kTimeDelta, kNumScrollSteps, | 374 end, start, kTimeDelta, kNumScrollSteps, |
380 base::Bind(&ShelfDragCallback::ProcessScroll, | 375 base::Bind(&ShelfDragCallback::ProcessScroll, |
381 base::Unretained(&handler))); | 376 base::Unretained(&handler))); |
382 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 377 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
383 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 378 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
384 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 379 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
385 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | |
386 GetShelfWidget()->GetWindowBoundsInScreen()); | |
387 EXPECT_EQ(shelf_shown.ToString(), | 380 EXPECT_EQ(shelf_shown.ToString(), |
388 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 381 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
389 | 382 |
390 // Swipe up again. The shelf should hide. | 383 // Swipe up again. The shelf should hide. |
391 end = start - delta; | 384 end = start - delta; |
392 generator.GestureScrollSequenceWithCallback( | 385 generator.GestureScrollSequenceWithCallback( |
393 start, end, kTimeDelta, kNumScrollSteps, | 386 start, end, kTimeDelta, kNumScrollSteps, |
394 base::Bind(&ShelfDragCallback::ProcessScroll, | 387 base::Bind(&ShelfDragCallback::ProcessScroll, |
395 base::Unretained(&handler))); | 388 base::Unretained(&handler))); |
396 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 389 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
(...skipping 25 matching lines...) Expand all Loading... |
422 | 415 |
423 // Swipe down again to hide. | 416 // Swipe down again to hide. |
424 end = start + delta; | 417 end = start + delta; |
425 generator.GestureScrollSequenceWithCallback( | 418 generator.GestureScrollSequenceWithCallback( |
426 start, end, kTimeDelta, kNumScrollSteps, | 419 start, end, kTimeDelta, kNumScrollSteps, |
427 base::Bind(&ShelfDragCallback::ProcessScroll, | 420 base::Bind(&ShelfDragCallback::ProcessScroll, |
428 base::Unretained(&handler))); | 421 base::Unretained(&handler))); |
429 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 422 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
430 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 423 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
431 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 424 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
432 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | |
433 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 425 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
434 EXPECT_EQ(shelf_hidden.ToString(), | 426 EXPECT_EQ(shelf_hidden.ToString(), |
435 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 427 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
436 | 428 |
437 // Swipe up in extended hit region to show it. | 429 // Swipe up in extended hit region to show it. |
438 gfx::Point extended_start = start; | 430 gfx::Point extended_start = start; |
439 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 431 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
440 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1); | 432 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1); |
441 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 433 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
442 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + | 434 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + |
443 1); | 435 1); |
444 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 436 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
445 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 437 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
446 end = extended_start - delta; | 438 end = extended_start - delta; |
447 generator.GestureScrollSequenceWithCallback( | 439 generator.GestureScrollSequenceWithCallback( |
448 extended_start, end, kTimeDelta, kNumScrollSteps, | 440 extended_start, end, kTimeDelta, kNumScrollSteps, |
449 base::Bind(&ShelfDragCallback::ProcessScroll, | 441 base::Bind(&ShelfDragCallback::ProcessScroll, |
450 base::Unretained(&handler))); | 442 base::Unretained(&handler))); |
451 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 443 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
452 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 444 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
453 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 445 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
454 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | |
455 GetShelfWidget()->GetWindowBoundsInScreen()); | |
456 EXPECT_EQ(shelf_shown.ToString(), | 446 EXPECT_EQ(shelf_shown.ToString(), |
457 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 447 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
458 | 448 |
459 // Swipe down again to hide. | 449 // Swipe down again to hide. |
460 end = start + delta; | 450 end = start + delta; |
461 generator.GestureScrollSequenceWithCallback( | 451 generator.GestureScrollSequenceWithCallback( |
462 start, end, kTimeDelta, kNumScrollSteps, | 452 start, end, kTimeDelta, kNumScrollSteps, |
463 base::Bind(&ShelfDragCallback::ProcessScroll, | 453 base::Bind(&ShelfDragCallback::ProcessScroll, |
464 base::Unretained(&handler))); | 454 base::Unretained(&handler))); |
465 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 455 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
466 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 456 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
467 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 457 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
468 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | |
469 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 458 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
470 EXPECT_EQ(shelf_hidden.ToString(), | 459 EXPECT_EQ(shelf_hidden.ToString(), |
471 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 460 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
472 | 461 |
473 // Swipe up outside the hit area. This should not change anything. | 462 // Swipe up outside the hit area. This should not change anything. |
474 gfx::Point outside_start = | 463 gfx::Point outside_start = |
475 gfx::Point((GetShelfWidget()->GetWindowBoundsInScreen().x() + | 464 gfx::Point((GetShelfWidget()->GetWindowBoundsInScreen().x() + |
476 GetShelfWidget()->GetWindowBoundsInScreen().right()) / | 465 GetShelfWidget()->GetWindowBoundsInScreen().right()) / |
477 2, | 466 2, |
478 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); | 467 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); |
(...skipping 14 matching lines...) Expand all Loading... |
493 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 482 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
494 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 483 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
495 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 484 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
496 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); | 485 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
497 end = below_start - delta; | 486 end = below_start - delta; |
498 generator.GestureScrollSequence(below_start, end, kTimeDelta, | 487 generator.GestureScrollSequence(below_start, end, kTimeDelta, |
499 kNumScrollSteps); | 488 kNumScrollSteps); |
500 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 489 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
501 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 490 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
502 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 491 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
503 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | |
504 GetShelfWidget()->GetWindowBoundsInScreen()); | |
505 EXPECT_EQ(shelf_shown.ToString(), | 492 EXPECT_EQ(shelf_shown.ToString(), |
506 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 493 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
507 | 494 |
508 // Swipe down again to hide. | 495 // Swipe down again to hide. |
509 end = start + delta; | 496 end = start + delta; |
510 generator.GestureScrollSequenceWithCallback( | 497 generator.GestureScrollSequenceWithCallback( |
511 start, end, kTimeDelta, kNumScrollSteps, | 498 start, end, kTimeDelta, kNumScrollSteps, |
512 base::Bind(&ShelfDragCallback::ProcessScroll, | 499 base::Bind(&ShelfDragCallback::ProcessScroll, |
513 base::Unretained(&handler))); | 500 base::Unretained(&handler))); |
514 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 501 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
515 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 502 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
516 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 503 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
517 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | |
518 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 504 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
519 EXPECT_EQ(shelf_hidden.ToString(), | 505 EXPECT_EQ(shelf_hidden.ToString(), |
520 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 506 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
521 | 507 |
522 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| | 508 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| |
523 // is fullscreen. (eg browser immersive fullscreen). | 509 // is fullscreen. (eg browser immersive fullscreen). |
524 widget->SetFullscreen(true); | 510 widget->SetFullscreen(true); |
525 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | 511 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); |
526 layout_manager->UpdateVisibilityState(); | 512 layout_manager->UpdateVisibilityState(); |
527 | 513 |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 911 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
926 ShelfWidget* shelf_widget = GetShelfWidget(); | 912 ShelfWidget* shelf_widget = GetShelfWidget(); |
927 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); | 913 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); |
928 StepWidgetLayerAnimatorToEnd(shelf_widget); | 914 StepWidgetLayerAnimatorToEnd(shelf_widget); |
929 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 915 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
930 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 916 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
931 EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(), | 917 EXPECT_EQ(screen->GetPrimaryDisplay().work_area().bottom(), |
932 widget->GetWorkAreaBoundsInScreen().bottom()); | 918 widget->GetWorkAreaBoundsInScreen().bottom()); |
933 } | 919 } |
934 | 920 |
935 // Basic assertions around the dimming of the shelf. | |
936 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { | |
937 ui::test::EventGenerator& generator(GetEventGenerator()); | |
938 | |
939 ShelfWidget* shelf_widget = GetShelfWidget(); | |
940 shelf_widget->DisableDimmingAnimationsForTest(); | |
941 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); | |
942 gfx::Point off_shelf = display.bounds().CenterPoint(); | |
943 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); | |
944 views::Widget* widget = CreateTestWidget(); | |
945 | |
946 // Test there is no dimming object active at this point. | |
947 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | |
948 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); | |
949 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | |
950 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); | |
951 | |
952 // After maximization, the shelf should be visible and the dimmer created. | |
953 widget->Maximize(); | |
954 | |
955 on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); | |
956 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | |
957 | |
958 // Moving the mouse off the shelf should dim the bar. | |
959 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | |
960 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | |
961 | |
962 // Adding touch events outside the shelf should still keep the shelf in | |
963 // dimmed state. | |
964 generator.PressTouch(); | |
965 generator.MoveTouch(off_shelf); | |
966 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | |
967 // Move the touch into the shelf area should undim. | |
968 generator.MoveTouch(on_shelf); | |
969 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
970 generator.ReleaseTouch(); | |
971 // And a release dims again. | |
972 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | |
973 | |
974 // Moving the mouse on the shelf should undim the bar. | |
975 generator.MoveMouseTo(on_shelf); | |
976 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
977 | |
978 // No matter what the touch events do, the shelf should stay undimmed. | |
979 generator.PressTouch(); | |
980 generator.MoveTouch(off_shelf); | |
981 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
982 generator.MoveTouch(on_shelf); | |
983 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
984 generator.MoveTouch(off_shelf); | |
985 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
986 generator.MoveTouch(on_shelf); | |
987 generator.ReleaseTouch(); | |
988 | |
989 // After restore, the dimming object should be deleted again. | |
990 widget->Restore(); | |
991 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); | |
992 } | |
993 | |
994 // Test that dimming works correctly with multiple displays. | |
995 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { | |
996 if (!SupportsMultipleDisplays()) | |
997 return; | |
998 | |
999 // Create two displays. | |
1000 UpdateDisplay("0+0-200x200,+200+0-100x100"); | |
1001 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
1002 EXPECT_EQ(root_windows.size(), 2U); | |
1003 | |
1004 std::vector<ShelfWidget*> shelf_widgets; | |
1005 for (auto* root_window : root_windows) { | |
1006 ShelfLayoutManager* shelf = | |
1007 GetRootWindowController(root_window)->GetShelfLayoutManager(); | |
1008 shelf_widgets.push_back(shelf->shelf_widget()); | |
1009 | |
1010 // For disabling the dimming animation to work, the animation must be | |
1011 // disabled prior to creating the dimmer. | |
1012 shelf_widgets.back()->DisableDimmingAnimationsForTest(); | |
1013 | |
1014 // Create a maximized window to create the dimmer. | |
1015 views::Widget::InitParams params; | |
1016 params.context = root_window; | |
1017 params.bounds = root_window->GetBoundsInScreen(); | |
1018 params.show_state = ui::SHOW_STATE_MAXIMIZED; | |
1019 CreateTestWidgetWithParams(params); | |
1020 } | |
1021 | |
1022 ui::test::EventGenerator& generator(GetEventGenerator()); | |
1023 | |
1024 generator.MoveMouseTo(root_windows[0]->GetBoundsInScreen().CenterPoint()); | |
1025 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1026 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1027 | |
1028 generator.MoveMouseTo( | |
1029 shelf_widgets[0]->GetWindowBoundsInScreen().CenterPoint()); | |
1030 EXPECT_EQ(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1031 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1032 | |
1033 generator.MoveMouseTo( | |
1034 shelf_widgets[1]->GetWindowBoundsInScreen().CenterPoint()); | |
1035 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1036 EXPECT_EQ(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1037 | |
1038 generator.MoveMouseTo(root_windows[1]->GetBoundsInScreen().CenterPoint()); | |
1039 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | |
1040 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | |
1041 } | |
1042 | |
1043 // Assertions around the dimming of the shelf in conjunction with menus. | |
1044 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { | |
1045 ui::test::EventGenerator& generator(GetEventGenerator()); | |
1046 generator.MoveMouseTo(0, 0); | |
1047 | |
1048 ShelfWidget* shelf_widget = GetShelfWidget(); | |
1049 shelf_widget->DisableDimmingAnimationsForTest(); | |
1050 | |
1051 // After maximization, the shelf should be visible and the dimmer created. | |
1052 views::Widget* widget = CreateTestWidget(); | |
1053 widget->Maximize(); | |
1054 | |
1055 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); | |
1056 gfx::Point off_shelf = display.bounds().CenterPoint(); | |
1057 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); | |
1058 | |
1059 // Moving the mouse on the shelf should undim the bar. | |
1060 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | |
1061 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1062 | |
1063 // Simulate a menu opening. | |
1064 shelf_widget->ForceUndimming(true); | |
1065 | |
1066 // Moving the mouse off the shelf should not dim the bar. | |
1067 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | |
1068 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1069 | |
1070 // No matter what the touch events do, the shelf should stay undimmed. | |
1071 generator.PressTouch(); | |
1072 generator.MoveTouch(off_shelf); | |
1073 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1074 generator.MoveTouch(on_shelf); | |
1075 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1076 generator.MoveTouch(off_shelf); | |
1077 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1078 generator.ReleaseTouch(); | |
1079 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1080 | |
1081 // "Closing the menu" should now turn off the menu since no event is inside | |
1082 // the shelf any longer. | |
1083 shelf_widget->ForceUndimming(false); | |
1084 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | |
1085 | |
1086 // Moving the mouse again on the shelf which should undim the bar again. | |
1087 // This time we check that the bar stays undimmed when the mouse remains on | |
1088 // the bar and the "menu gets closed". | |
1089 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | |
1090 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1091 shelf_widget->ForceUndimming(true); | |
1092 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | |
1093 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1094 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | |
1095 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1096 shelf_widget->ForceUndimming(true); | |
1097 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
1098 } | |
1099 | |
1100 // Verifies the shelf is visible when status/shelf is focused. | 921 // Verifies the shelf is visible when status/shelf is focused. |
1101 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { | 922 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { |
1102 WmShelf* shelf = GetPrimaryShelf(); | 923 WmShelf* shelf = GetPrimaryShelf(); |
1103 views::Widget* widget = CreateTestWidget(); | 924 views::Widget* widget = CreateTestWidget(); |
1104 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 925 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
1105 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 926 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
1106 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 927 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
1107 | 928 |
1108 // Focus the shelf. Have to go through the focus cycler as normal focus | 929 // Focus the shelf. Have to go through the focus cycler as normal focus |
1109 // requests to it do nothing. | 930 // requests to it do nothing. |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 // Now show the shelf. | 1526 // Now show the shelf. |
1706 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1527 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1707 | 1528 |
1708 // Again both windows should be of the same size. | 1529 // Again both windows should be of the same size. |
1709 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 1530 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
1710 widget_two->GetNativeWindow()->bounds().ToString()); | 1531 widget_two->GetNativeWindow()->bounds().ToString()); |
1711 EXPECT_EQ(area_when_shelf_shown, | 1532 EXPECT_EQ(area_when_shelf_shown, |
1712 widget_one->GetNativeWindow()->bounds().size().GetArea()); | 1533 widget_one->GetNativeWindow()->bounds().size().GetArea()); |
1713 } | 1534 } |
1714 | 1535 |
1715 // Confirm that the shelf is dimmed only when content is maximized and | |
1716 // shelf is not autohidden. | |
1717 TEST_F(ShelfLayoutManagerTest, Dimming) { | |
1718 WmShelf* shelf = GetPrimaryShelf(); | |
1719 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
1720 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | |
1721 w1->Show(); | |
1722 wm::ActivateWindow(w1.get()); | |
1723 | |
1724 // Normal window doesn't dim shelf. | |
1725 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | |
1726 ShelfWidget* shelf_widget = GetShelfWidget(); | |
1727 EXPECT_FALSE(shelf_widget->GetDimsShelf()); | |
1728 | |
1729 // Maximized window does. | |
1730 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
1731 EXPECT_TRUE(shelf_widget->GetDimsShelf()); | |
1732 | |
1733 // Change back to normal stops dimming. | |
1734 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | |
1735 EXPECT_FALSE(shelf_widget->GetDimsShelf()); | |
1736 | |
1737 // Changing back to maximized dims again. | |
1738 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
1739 EXPECT_TRUE(shelf_widget->GetDimsShelf()); | |
1740 | |
1741 // Changing shelf to autohide stops dimming. | |
1742 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
1743 EXPECT_FALSE(shelf_widget->GetDimsShelf()); | |
1744 } | |
1745 | |
1746 // This test fails on Windows (likely due to hard-coded pointer coordinate | 1536 // This test fails on Windows (likely due to hard-coded pointer coordinate |
1747 // arithmetic), but the Windows ash shell isn't supported any more so it's | 1537 // arithmetic), but the Windows ash shell isn't supported any more so it's |
1748 // probably not worth fixing. Also note that this test uses system tray | 1538 // probably not worth fixing. Also note that this test uses system tray |
1749 // notification bubbles, which needn't exist: see crbug.com/630641 | 1539 // notification bubbles, which needn't exist: see crbug.com/630641 |
1750 #if defined(OS_WIN) | 1540 #if defined(OS_WIN) |
1751 #define MAYBE_BubbleEnlargesShelfMouseHitArea \ | 1541 #define MAYBE_BubbleEnlargesShelfMouseHitArea \ |
1752 DISABLED_BubbleEnlargesShelfMouseHitArea | 1542 DISABLED_BubbleEnlargesShelfMouseHitArea |
1753 #else | 1543 #else |
1754 #define MAYBE_BubbleEnlargesShelfMouseHitArea BubbleEnlargesShelfMouseHitArea | 1544 #define MAYBE_BubbleEnlargesShelfMouseHitArea BubbleEnlargesShelfMouseHitArea |
1755 #endif | 1545 #endif |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 // Open keyboard in sticky mode. | 1845 // Open keyboard in sticky mode. |
2056 kb_controller->ShowKeyboard(true); | 1846 kb_controller->ShowKeyboard(true); |
2057 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1847 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
2058 | 1848 |
2059 // Work area should be changed. | 1849 // Work area should be changed. |
2060 EXPECT_NE(orig_work_area, | 1850 EXPECT_NE(orig_work_area, |
2061 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1851 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
2062 } | 1852 } |
2063 | 1853 |
2064 } // namespace ash | 1854 } // namespace ash |
OLD | NEW |