| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "ui/display/screen.h" | 45 #include "ui/display/screen.h" |
| 46 #include "ui/display/test/display_manager_test_api.h" | 46 #include "ui/display/test/display_manager_test_api.h" |
| 47 #include "ui/events/gesture_detection/gesture_configuration.h" | 47 #include "ui/events/gesture_detection/gesture_configuration.h" |
| 48 #include "ui/events/test/event_generator.h" | 48 #include "ui/events/test/event_generator.h" |
| 49 #include "ui/keyboard/keyboard_controller.h" | 49 #include "ui/keyboard/keyboard_controller.h" |
| 50 #include "ui/keyboard/keyboard_ui.h" | 50 #include "ui/keyboard/keyboard_ui.h" |
| 51 #include "ui/keyboard/keyboard_util.h" | 51 #include "ui/keyboard/keyboard_util.h" |
| 52 #include "ui/views/view.h" | 52 #include "ui/views/view.h" |
| 53 #include "ui/views/widget/widget.h" | 53 #include "ui/views/widget/widget.h" |
| 54 | 54 |
| 55 #if defined(OS_WIN) | |
| 56 #include "base/win/windows_version.h" | |
| 57 #endif | |
| 58 | |
| 59 namespace ash { | 55 namespace ash { |
| 60 namespace { | 56 namespace { |
| 61 | 57 |
| 62 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { | 58 void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { |
| 63 widget->GetNativeView()->layer()->GetAnimator()->Step( | 59 widget->GetNativeView()->layer()->GetAnimator()->Step( |
| 64 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); | 60 base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
| 65 } | 61 } |
| 66 | 62 |
| 67 ShelfWidget* GetShelfWidget() { | 63 ShelfWidget* GetShelfWidget() { |
| 68 return test::AshTestBase::GetPrimaryShelf()->shelf_widget(); | 64 return test::AshTestBase::GetPrimaryShelf()->shelf_widget(); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 base::Unretained(&handler))); | 580 base::Unretained(&handler))); |
| 585 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 581 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 586 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 582 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 587 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 583 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 588 | 584 |
| 589 // Avoid a CHECK that makes sure SetAutoHideBehavior is not called too | 585 // Avoid a CHECK that makes sure SetAutoHideBehavior is not called too |
| 590 // frequently. This is to help investigate http://crbug.com/665093 . | 586 // frequently. This is to help investigate http://crbug.com/665093 . |
| 591 shelf->count_auto_hide_changes_ = 0; | 587 shelf->count_auto_hide_changes_ = 0; |
| 592 } | 588 } |
| 593 | 589 |
| 594 // Need to be implemented. http://crbug.com/111279. | |
| 595 #if defined(OS_WIN) | |
| 596 #define MAYBE_SetVisible DISABLED_SetVisible | |
| 597 #else | |
| 598 #define MAYBE_SetVisible SetVisible | |
| 599 #endif | |
| 600 // Makes sure SetVisible updates work area and widget appropriately. | 590 // Makes sure SetVisible updates work area and widget appropriately. |
| 601 TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { | 591 TEST_F(ShelfLayoutManagerTest, SetVisible) { |
| 602 ShelfWidget* shelf_widget = GetShelfWidget(); | 592 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 603 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); | 593 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); |
| 604 // Force an initial layout. | 594 // Force an initial layout. |
| 605 manager->LayoutShelf(); | 595 manager->LayoutShelf(); |
| 606 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 596 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 607 | 597 |
| 608 gfx::Rect status_bounds( | 598 gfx::Rect status_bounds( |
| 609 shelf_widget->status_area_widget()->GetWindowBoundsInScreen()); | 599 shelf_widget->status_area_widget()->GetWindowBoundsInScreen()); |
| 610 gfx::Rect shelf_bounds(shelf_widget->GetWindowBoundsInScreen()); | 600 gfx::Rect shelf_bounds(shelf_widget->GetWindowBoundsInScreen()); |
| 611 int shelf_height = manager->GetIdealBounds().height(); | 601 int shelf_height = manager->GetIdealBounds().height(); |
| (...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 // Now show the shelf. | 1520 // Now show the shelf. |
| 1531 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1521 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1532 | 1522 |
| 1533 // Again both windows should be of the same size. | 1523 // Again both windows should be of the same size. |
| 1534 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 1524 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 1535 widget_two->GetNativeWindow()->bounds().ToString()); | 1525 widget_two->GetNativeWindow()->bounds().ToString()); |
| 1536 EXPECT_EQ(area_when_shelf_shown, | 1526 EXPECT_EQ(area_when_shelf_shown, |
| 1537 widget_one->GetNativeWindow()->bounds().size().GetArea()); | 1527 widget_one->GetNativeWindow()->bounds().size().GetArea()); |
| 1538 } | 1528 } |
| 1539 | 1529 |
| 1540 // This test fails on Windows (likely due to hard-coded pointer coordinate | |
| 1541 // arithmetic), but the Windows ash shell isn't supported any more so it's | |
| 1542 // probably not worth fixing. Also note that this test uses system tray | |
| 1543 // notification bubbles, which needn't exist: see crbug.com/630641 | |
| 1544 #if defined(OS_WIN) | |
| 1545 #define MAYBE_BubbleEnlargesShelfMouseHitArea \ | |
| 1546 DISABLED_BubbleEnlargesShelfMouseHitArea | |
| 1547 #else | |
| 1548 #define MAYBE_BubbleEnlargesShelfMouseHitArea BubbleEnlargesShelfMouseHitArea | |
| 1549 #endif | |
| 1550 // Make sure that the shelf will not hide if the mouse is between a bubble and | 1530 // Make sure that the shelf will not hide if the mouse is between a bubble and |
| 1551 // the shelf. | 1531 // the shelf. This test uses system tray notification bubbles, which needn't |
| 1552 TEST_F(ShelfLayoutManagerTest, MAYBE_BubbleEnlargesShelfMouseHitArea) { | 1532 // exist: see crbug.com/630641 |
| 1533 TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { |
| 1553 WmShelf* shelf = GetPrimaryShelf(); | 1534 WmShelf* shelf = GetPrimaryShelf(); |
| 1554 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1535 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1555 StatusAreaWidget* status_area_widget = | 1536 StatusAreaWidget* status_area_widget = |
| 1556 shelf->shelf_widget()->status_area_widget(); | 1537 shelf->shelf_widget()->status_area_widget(); |
| 1557 SystemTray* tray = GetPrimarySystemTray(); | 1538 SystemTray* tray = GetPrimarySystemTray(); |
| 1558 | 1539 |
| 1559 // Create a visible window so auto-hide behavior is enforced. | 1540 // Create a visible window so auto-hide behavior is enforced. |
| 1560 CreateTestWidget(); | 1541 CreateTestWidget(); |
| 1561 | 1542 |
| 1562 layout_manager->LayoutShelf(); | 1543 layout_manager->LayoutShelf(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 1673 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 1693 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 1674 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
| 1694 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); | 1675 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
| 1695 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); | 1676 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
| 1696 | 1677 |
| 1697 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1678 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1698 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); | 1679 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
| 1699 EXPECT_EQ(initial_bounds, reshow_target_bounds); | 1680 EXPECT_EQ(initial_bounds, reshow_target_bounds); |
| 1700 } | 1681 } |
| 1701 | 1682 |
| 1702 // Flaky crash on Windows (crbug.com/637873). | |
| 1703 #if defined(OS_WIN) | |
| 1704 #define MAYBE_ShutdownHandlesWindowActivation \ | |
| 1705 DISABLED_ShutdownHandlesWindowActivation | |
| 1706 #else | |
| 1707 #define MAYBE_ShutdownHandlesWindowActivation ShutdownHandlesWindowActivation | |
| 1708 #endif | |
| 1709 | |
| 1710 // Tests that during shutdown, that window activation changes are properly | 1683 // Tests that during shutdown, that window activation changes are properly |
| 1711 // handled, and do not crash (crbug.com/458768) | 1684 // handled, and do not crash (crbug.com/458768) |
| 1712 TEST_F(ShelfLayoutManagerTest, MAYBE_ShutdownHandlesWindowActivation) { | 1685 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { |
| 1713 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1686 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1714 | 1687 |
| 1715 aura::Window* window1 = CreateTestWindowInShellWithId(0); | 1688 aura::Window* window1 = CreateTestWindowInShellWithId(0); |
| 1716 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1689 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1717 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1690 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1718 window1->Show(); | 1691 window1->Show(); |
| 1719 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0)); | 1692 std::unique_ptr<aura::Window> window2(CreateTestWindowInShellWithId(0)); |
| 1720 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1693 window2->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1721 window2->Show(); | 1694 window2->Show(); |
| 1722 wm::ActivateWindow(window1); | 1695 wm::ActivateWindow(window1); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 // Open keyboard in sticky mode. | 1822 // Open keyboard in sticky mode. |
| 1850 kb_controller->ShowKeyboard(true); | 1823 kb_controller->ShowKeyboard(true); |
| 1851 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1824 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 1852 | 1825 |
| 1853 // Work area should be changed. | 1826 // Work area should be changed. |
| 1854 EXPECT_NE(orig_work_area, | 1827 EXPECT_NE(orig_work_area, |
| 1855 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1828 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1856 } | 1829 } |
| 1857 | 1830 |
| 1858 } // namespace ash | 1831 } // namespace ash |
| OLD | NEW |