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/config.h" | 10 #include "ash/public/cpp/config.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // Swipe-up. This should not change anything. | 543 // Swipe-up. This should not change anything. |
544 end = start - delta; | 544 end = start - delta; |
545 generator.GestureScrollSequenceWithCallback( | 545 generator.GestureScrollSequenceWithCallback( |
546 below_start, end, kTimeDelta, kNumScrollSteps, | 546 below_start, end, kTimeDelta, kNumScrollSteps, |
547 base::Bind(&ShelfDragCallback::ProcessScroll, | 547 base::Bind(&ShelfDragCallback::ProcessScroll, |
548 base::Unretained(&handler))); | 548 base::Unretained(&handler))); |
549 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 549 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
550 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 550 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
551 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 551 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
552 | 552 |
553 // Close actually, otherwise further event may be affected since widget | 553 // Minimize actually, otherwise further event may be affected since widget |
554 // is fullscreen status. | 554 // is fullscreen status. |
555 widget->Close(); | 555 widget->Minimize(); |
556 RunAllPendingInMessageLoop(); | 556 RunAllPendingInMessageLoop(); |
| 557 EXPECT_FALSE(layout_manager->HasVisibleWindow()); |
557 | 558 |
558 // The shelf should be shown because there are no more visible windows. | 559 // The shelf should be shown because there are no more visible windows. |
559 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 560 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
560 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 561 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
561 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 562 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
562 | 563 |
563 // Swipe-up to hide. This should have no effect because there are no visible | 564 // Swipe-up to hide. This should have no effect because there are no visible |
564 // windows. | 565 // windows. |
565 end = below_start - delta; | 566 end = below_start - delta; |
566 generator.GestureScrollSequenceWithCallback( | 567 generator.GestureScrollSequenceWithCallback( |
567 below_start, end, kTimeDelta, kNumScrollSteps, | 568 below_start, end, kTimeDelta, kNumScrollSteps, |
568 base::Bind(&ShelfDragCallback::ProcessScroll, | 569 base::Bind(&ShelfDragCallback::ProcessScroll, |
569 base::Unretained(&handler))); | 570 base::Unretained(&handler))); |
570 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 571 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
571 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 572 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
572 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 573 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 574 EXPECT_EQ(shelf_shown.ToString(), |
| 575 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 576 |
| 577 // Swipe-down to hide. This should have no effect because there are no visible |
| 578 // windows. |
| 579 end = start + delta; |
| 580 generator.GestureScrollSequenceWithCallback( |
| 581 start, end, kTimeDelta, kNumScrollSteps, |
| 582 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 583 base::Unretained(&handler))); |
| 584 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 585 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 586 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 587 EXPECT_EQ(shelf_shown.ToString(), |
| 588 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 589 |
| 590 widget->Restore(); |
| 591 RunAllPendingInMessageLoop(); |
| 592 EXPECT_TRUE(layout_manager->HasVisibleWindow()); |
| 593 |
| 594 // Swipe up on the shelf. This should show the shelf and disable auto-hide |
| 595 // since there is one visible window. |
| 596 end = below_start - delta; |
| 597 generator.GestureScrollSequenceWithCallback( |
| 598 below_start, end, kTimeDelta, kNumScrollSteps, |
| 599 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 600 base::Unretained(&handler))); |
| 601 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 602 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 603 |
| 604 widget->Close(); |
| 605 RunAllPendingInMessageLoop(); |
| 606 EXPECT_FALSE(layout_manager->HasVisibleWindow()); |
| 607 |
| 608 // Swipe-up to hide. This should have no effect because there are no visible |
| 609 // windows. |
| 610 generator.GestureScrollSequenceWithCallback( |
| 611 below_start, end, kTimeDelta, kNumScrollSteps, |
| 612 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 613 base::Unretained(&handler))); |
| 614 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 615 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 616 EXPECT_EQ(shelf_shown.ToString(), |
| 617 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 618 |
| 619 // Swipe-down to hide. This should have no effect because there are no visible |
| 620 // windows. |
| 621 end = start + delta; |
| 622 generator.GestureScrollSequenceWithCallback( |
| 623 start, end, kTimeDelta, kNumScrollSteps, |
| 624 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 625 base::Unretained(&handler))); |
| 626 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 627 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 628 EXPECT_EQ(shelf_shown.ToString(), |
| 629 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
573 } | 630 } |
574 | 631 |
575 // Makes sure SetVisible updates work area and widget appropriately. | 632 // Makes sure SetVisible updates work area and widget appropriately. |
576 TEST_F(ShelfLayoutManagerTest, SetVisible) { | 633 TEST_F(ShelfLayoutManagerTest, SetVisible) { |
577 ShelfWidget* shelf_widget = GetShelfWidget(); | 634 ShelfWidget* shelf_widget = GetShelfWidget(); |
578 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); | 635 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); |
579 // Force an initial layout. | 636 // Force an initial layout. |
580 manager->LayoutShelf(); | 637 manager->LayoutShelf(); |
581 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 638 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
582 | 639 |
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 // Open keyboard in sticky mode. | 1893 // Open keyboard in sticky mode. |
1837 kb_controller->ShowKeyboard(true); | 1894 kb_controller->ShowKeyboard(true); |
1838 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1895 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
1839 | 1896 |
1840 // Work area should be changed. | 1897 // Work area should be changed. |
1841 EXPECT_NE(orig_work_area, | 1898 EXPECT_NE(orig_work_area, |
1842 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1899 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1843 } | 1900 } |
1844 | 1901 |
1845 } // namespace ash | 1902 } // namespace ash |
OLD | NEW |