| 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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/accelerators/accelerator_controller.h" | 8 #include "ash/common/accelerators/accelerator_controller.h" |
| 9 #include "ash/common/accelerators/accelerator_table.h" | 9 #include "ash/common/accelerators/accelerator_table.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); | 1494 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1495 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); | 1495 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1496 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1496 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1497 display = display::Screen::GetScreen()->GetPrimaryDisplay(); | 1497 display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1498 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1498 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| 1499 display.GetWorkAreaInsets().right()); | 1499 display.GetWorkAreaInsets().right()); |
| 1500 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1500 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| 1501 display.bounds().right() - display.work_area().right()); | 1501 display.bounds().right() - display.work_area().right()); |
| 1502 } | 1502 } |
| 1503 | 1503 |
| 1504 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { | |
| 1505 Shelf* shelf = GetShelf(); | |
| 1506 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | |
| 1507 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | |
| 1508 views::Widget* widget = CreateTestWidget(); | |
| 1509 widget->Maximize(); | |
| 1510 | |
| 1511 ui::test::EventGenerator& generator(GetEventGenerator()); | |
| 1512 | |
| 1513 aura::Window* window = widget->GetNativeWindow(); | |
| 1514 layout_manager->LayoutShelf(); | |
| 1515 | |
| 1516 // Edge swipe when SHELF_VISIBLE should not change visibility state. | |
| 1517 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | |
| 1518 generator.GestureEdgeSwipe(); | |
| 1519 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | |
| 1520 | |
| 1521 // Edge swipe when AUTO_HIDE_HIDDEN should change to AUTO_HIDE_SHOWN. | |
| 1522 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 1523 layout_manager->LayoutShelf(); | |
| 1524 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | |
| 1525 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | |
| 1526 generator.GestureEdgeSwipe(); | |
| 1527 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | |
| 1528 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | |
| 1529 | |
| 1530 widget->SetFullscreen(true); | |
| 1531 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | |
| 1532 layout_manager->UpdateVisibilityState(); | |
| 1533 | |
| 1534 // Edge swipe in fullscreen + AUTO_HIDE_HIDDEN should show the shelf and | |
| 1535 // remain fullscreen. | |
| 1536 EXPECT_TRUE(widget->IsFullscreen()); | |
| 1537 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | |
| 1538 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | |
| 1539 generator.GestureEdgeSwipe(); | |
| 1540 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | |
| 1541 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | |
| 1542 EXPECT_TRUE(widget->IsFullscreen()); | |
| 1543 } | |
| 1544 | |
| 1545 // Tests that gesture edge swipe events are forwarded to the right shelf on the | |
| 1546 // right monitor (crbug.com/449851). | |
| 1547 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipeMultiMonitor) { | |
| 1548 if (!SupportsMultipleDisplays()) | |
| 1549 return; | |
| 1550 | |
| 1551 // Create two displays. | |
| 1552 UpdateDisplay("200x200,100x100"); | |
| 1553 auto root_window_controllers = Shell::GetAllRootWindowControllers(); | |
| 1554 ASSERT_EQ(2U, root_window_controllers.size()); | |
| 1555 Shelf* shelf_1 = root_window_controllers[0]->GetShelf(); | |
| 1556 Shelf* shelf_2 = root_window_controllers[1]->GetShelf(); | |
| 1557 | |
| 1558 // Create two maximized windows, one in each display. | |
| 1559 aura::Window* window_1 = | |
| 1560 CreateTestWindowInParent(root_window_controllers[0]->GetRootWindow()); | |
| 1561 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | |
| 1562 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
| 1563 window_1->Show(); | |
| 1564 aura::Window* window_2 = | |
| 1565 CreateTestWindowInParent(root_window_controllers[1]->GetRootWindow()); | |
| 1566 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | |
| 1567 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | |
| 1568 window_2->Show(); | |
| 1569 | |
| 1570 // Make sure both are set to auto-hide and both are hidden. | |
| 1571 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 1572 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 1573 shelf_1->shelf_layout_manager()->LayoutShelf(); | |
| 1574 shelf_2->shelf_layout_manager()->LayoutShelf(); | |
| 1575 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | |
| 1576 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | |
| 1577 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | |
| 1578 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | |
| 1579 | |
| 1580 ui::test::EventGenerator monitor_1_generator( | |
| 1581 root_window_controllers[0]->GetRootWindow()); | |
| 1582 ui::test::EventGenerator monitor_2_generator( | |
| 1583 root_window_controllers[1]->GetRootWindow()); | |
| 1584 | |
| 1585 // An edge swipe in one display should only affect the shelf in that display. | |
| 1586 monitor_1_generator.GestureEdgeSwipe(); | |
| 1587 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | |
| 1588 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | |
| 1589 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_1->GetAutoHideState()); | |
| 1590 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | |
| 1591 | |
| 1592 // Back to normal after an update. | |
| 1593 Shell::GetInstance()->UpdateShelfVisibility(); | |
| 1594 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | |
| 1595 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | |
| 1596 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | |
| 1597 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | |
| 1598 | |
| 1599 monitor_2_generator.GestureEdgeSwipe(); | |
| 1600 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | |
| 1601 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | |
| 1602 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | |
| 1603 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_2->GetAutoHideState()); | |
| 1604 } | |
| 1605 | |
| 1606 TEST_F(ShelfLayoutManagerTest, GestureDrag) { | 1504 TEST_F(ShelfLayoutManagerTest, GestureDrag) { |
| 1607 // Slop is an implementation detail of gesture recognition, and complicates | 1505 // Slop is an implementation detail of gesture recognition, and complicates |
| 1608 // these tests. Ignore it. | 1506 // these tests. Ignore it. |
| 1609 ui::GestureConfiguration::GetInstance() | 1507 ui::GestureConfiguration::GetInstance() |
| 1610 ->set_max_touch_move_in_pixels_for_click(0); | 1508 ->set_max_touch_move_in_pixels_for_click(0); |
| 1611 Shelf* shelf = GetShelf(); | 1509 Shelf* shelf = GetShelf(); |
| 1612 { | 1510 { |
| 1613 SCOPED_TRACE("BOTTOM"); | 1511 SCOPED_TRACE("BOTTOM"); |
| 1614 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 1512 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 1615 RunGestureDragTests(gfx::Vector2d(0, 120)); | 1513 RunGestureDragTests(gfx::Vector2d(0, 120)); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 | 1930 |
| 2033 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1931 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 2034 EXPECT_TRUE(status_area_widget->IsVisible()); | 1932 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 2035 // Shelf should be in the first display's area. | 1933 // Shelf should be in the first display's area. |
| 2036 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1934 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 2037 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 1935 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 2038 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 1936 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 2039 } | 1937 } |
| 2040 | 1938 |
| 2041 } // namespace ash | 1939 } // namespace ash |
| OLD | NEW |