Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 690103008: Implemented swipe to close in overview mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed ET_SCROLL_FLING_CANCEL handling from TransparentButton and removed WindowSelector.MultiWind… Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <algorithm> 5 #include <algorithm>
6 #include <map>
7 #include <vector>
6 8
7 #include "ash/accessibility_delegate.h" 9 #include "ash/accessibility_delegate.h"
10 #include "ash/ash_switches.h"
8 #include "ash/drag_drop/drag_drop_controller.h" 11 #include "ash/drag_drop/drag_drop_controller.h"
9 #include "ash/root_window_controller.h" 12 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 13 #include "ash/screen_util.h"
11 #include "ash/shelf/shelf.h" 14 #include "ash/shelf/shelf.h"
12 #include "ash/shelf/shelf_widget.h" 15 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 16 #include "ash/shell.h"
14 #include "ash/shell_window_ids.h" 17 #include "ash/shell_window_ids.h"
15 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
16 #include "ash/test/shelf_test_api.h" 19 #include "ash/test/shelf_test_api.h"
17 #include "ash/test/shelf_view_test_api.h" 20 #include "ash/test/shelf_view_test_api.h"
18 #include "ash/test/shell_test_api.h" 21 #include "ash/test/shell_test_api.h"
19 #include "ash/test/test_shelf_delegate.h" 22 #include "ash/test/test_shelf_delegate.h"
20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 23 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
21 #include "ash/wm/mru_window_tracker.h" 24 #include "ash/wm/mru_window_tracker.h"
22 #include "ash/wm/overview/window_grid.h" 25 #include "ash/wm/overview/window_grid.h"
23 #include "ash/wm/overview/window_selector.h" 26 #include "ash/wm/overview/window_selector.h"
24 #include "ash/wm/overview/window_selector_controller.h" 27 #include "ash/wm/overview/window_selector_controller.h"
25 #include "ash/wm/overview/window_selector_item.h" 28 #include "ash/wm/overview/window_selector_item.h"
26 #include "ash/wm/panels/panel_layout_manager.h" 29 #include "ash/wm/panels/panel_layout_manager.h"
27 #include "ash/wm/window_state.h" 30 #include "ash/wm/window_state.h"
28 #include "ash/wm/window_util.h" 31 #include "ash/wm/window_util.h"
29 #include "ash/wm/wm_event.h" 32 #include "ash/wm/wm_event.h"
30 #include "base/basictypes.h" 33 #include "base/basictypes.h"
34 #include "base/command_line.h"
31 #include "base/compiler_specific.h" 35 #include "base/compiler_specific.h"
32 #include "base/memory/scoped_vector.h" 36 #include "base/memory/scoped_vector.h"
33 #include "base/run_loop.h" 37 #include "base/run_loop.h"
34 #include "base/strings/string_piece.h" 38 #include "base/strings/string_piece.h"
35 #include "base/strings/utf_string_conversions.h" 39 #include "base/strings/utf_string_conversions.h"
36 #include "ui/aura/client/aura_constants.h" 40 #include "ui/aura/client/aura_constants.h"
37 #include "ui/aura/client/cursor_client.h" 41 #include "ui/aura/client/cursor_client.h"
38 #include "ui/aura/client/focus_client.h" 42 #include "ui/aura/client/focus_client.h"
39 #include "ui/aura/test/test_window_delegate.h" 43 #include "ui/aura/test/test_window_delegate.h"
40 #include "ui/aura/test/test_windows.h" 44 #include "ui/aura/test/test_windows.h"
(...skipping 10 matching lines...) Expand all
51 #include "ui/views/widget/widget_delegate.h" 55 #include "ui/views/widget/widget_delegate.h"
52 #include "ui/wm/core/window_util.h" 56 #include "ui/wm/core/window_util.h"
53 #include "ui/wm/public/activation_delegate.h" 57 #include "ui/wm/public/activation_delegate.h"
54 58
55 namespace ash { 59 namespace ash {
56 namespace { 60 namespace {
57 61
58 typedef std::vector<aura::Window*> WindowList; 62 typedef std::vector<aura::Window*> WindowList;
59 typedef std::map<const aura::Window*, int> WindowIndexMap; 63 typedef std::map<const aura::Window*, int> WindowIndexMap;
60 64
65 // A short drag distance that will not cause an overview item to close.
66 const int kShortDragDistance = 10;
67
68 // A far drag distance that will cause an overview item to close.
69 const int kFarDragDistance = 200;
70
61 class NonActivatableActivationDelegate 71 class NonActivatableActivationDelegate
62 : public aura::client::ActivationDelegate { 72 : public aura::client::ActivationDelegate {
63 public: 73 public:
64 bool ShouldActivate() const override { return false; } 74 bool ShouldActivate() const override { return false; }
65 }; 75 };
66 76
67 void CancelDrag(DragDropController* controller, bool* canceled) { 77 void CancelDrag(DragDropController* controller, bool* canceled) {
68 if (controller->IsDragDropInProgress()) { 78 if (controller->IsDragDropInProgress()) {
69 *canceled = true; 79 *canceled = true;
70 controller->DragCancel(); 80 controller->DragCancel();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 views::Widget::InitParams params; 136 views::Widget::InitParams params;
127 params.bounds = bounds; 137 params.bounds = bounds;
128 params.type = views::Widget::InitParams::TYPE_PANEL; 138 params.type = views::Widget::InitParams::TYPE_PANEL;
129 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 139 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
130 widget->Init(params); 140 widget->Init(params);
131 widget->Show(); 141 widget->Show();
132 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow()); 142 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow());
133 return widget; 143 return widget;
134 } 144 }
135 145
146 scoped_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) {
147 scoped_ptr<views::Widget> widget(new views::Widget);
148 views::Widget::InitParams params;
149 params.bounds = bounds;
150 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
151 widget->Init(params);
152 widget->Show();
153 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow());
154 return widget.Pass();
155 }
156
136 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) { 157 bool WindowsOverlapping(aura::Window* window1, aura::Window* window2) {
137 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1); 158 gfx::RectF window1_bounds = GetTransformedTargetBounds(window1);
138 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2); 159 gfx::RectF window2_bounds = GetTransformedTargetBounds(window2);
139 return window1_bounds.Intersects(window2_bounds); 160 return window1_bounds.Intersects(window2_bounds);
140 } 161 }
141 162
142 void ToggleOverview() { 163 void ToggleOverview() {
143 ash::Shell::GetInstance()->window_selector_controller()->ToggleOverview(); 164 ash::Shell::GetInstance()->window_selector_controller()->ToggleOverview();
144 } 165 }
145 166
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 284 }
264 285
265 private: 286 private:
266 aura::test::TestWindowDelegate delegate_; 287 aura::test::TestWindowDelegate delegate_;
267 NonActivatableActivationDelegate non_activatable_activation_delegate_; 288 NonActivatableActivationDelegate non_activatable_activation_delegate_;
268 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; 289 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_;
269 290
270 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); 291 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest);
271 }; 292 };
272 293
294 class WindowSelectorSwipeToCloseDisabledTest : public WindowSelectorTest {
295 public:
296 WindowSelectorSwipeToCloseDisabledTest() {}
297 virtual ~WindowSelectorSwipeToCloseDisabledTest() {}
298
299 // WindowSelectorTest:
300 virtual void SetUp() override;
301
302 private:
303 DISALLOW_COPY_AND_ASSIGN(WindowSelectorSwipeToCloseDisabledTest);
304 };
305
306 void WindowSelectorSwipeToCloseDisabledTest::SetUp() {
307 CommandLine::ForCurrentProcess()->AppendSwitch(
308 switches::kAshDisableSwipeToCloseInOverviewMode);
309 WindowSelectorTest::SetUp();
310 }
311
273 // Tests that an a11y alert is sent on entering overview mode. 312 // Tests that an a11y alert is sent on entering overview mode.
274 TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) { 313 TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) {
275 gfx::Rect bounds(0, 0, 400, 400); 314 gfx::Rect bounds(0, 0, 400, 400);
276 AccessibilityDelegate* delegate = 315 AccessibilityDelegate* delegate =
277 ash::Shell::GetInstance()->accessibility_delegate(); 316 ash::Shell::GetInstance()->accessibility_delegate();
278 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); 317 scoped_ptr<aura::Window> window1(CreateWindow(bounds));
279 EXPECT_NE(delegate->GetLastAccessibilityAlert(), 318 EXPECT_NE(delegate->GetLastAccessibilityAlert(),
280 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); 319 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED);
281 ToggleOverview(); 320 ToggleOverview();
282 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), 321 EXPECT_EQ(delegate->GetLastAccessibilityAlert(),
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, 474 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2,
436 ui::EF_NONE, ui::EF_NONE); 475 ui::EF_NONE, ui::EF_NONE);
437 476
438 // Now the transparent window should be intercepting this event. 477 // Now the transparent window should be intercepting this event.
439 EXPECT_NE(window, static_cast<aura::Window*>( 478 EXPECT_NE(window, static_cast<aura::Window*>(
440 targeter->FindTargetForEvent(root_target, &event2))); 479 targeter->FindTargetForEvent(root_target, &event2)));
441 } 480 }
442 481
443 // Tests that clicking on the close button effectively closes the window. 482 // Tests that clicking on the close button effectively closes the window.
444 TEST_F(WindowSelectorTest, CloseButton) { 483 TEST_F(WindowSelectorTest, CloseButton) {
445 scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(200, 300, 250, 450)));
446
447 // We need a widget for the close button to work, a bare window will crash. 484 // We need a widget for the close button to work, a bare window will crash.
448 scoped_ptr<views::Widget> widget(new views::Widget); 485 scoped_ptr<views::Widget> widget =
449 views::Widget::InitParams params; 486 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
450 params.bounds = gfx::Rect(0, 0, 400, 400);
451 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
452 params.parent = window1->parent();
453 widget->Init(params);
454 widget->Show();
455 ToggleOverview(); 487 ToggleOverview();
456 488
457 aura::Window* window2 = widget->GetNativeWindow(); 489 aura::Window* window = widget->GetNativeWindow();
458 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); 490 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
459 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); 491 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1);
460 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); 492 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
461 493
462 EXPECT_FALSE(widget->IsClosed()); 494 EXPECT_FALSE(widget->IsClosed());
463 event_generator.ClickLeftButton(); 495 event_generator.ClickLeftButton();
464 EXPECT_TRUE(widget->IsClosed()); 496 EXPECT_TRUE(widget->IsClosed());
465 } 497 }
466 498
467 // Tests that clicking on the close button on a secondary display effectively 499 // Tests that clicking on the close button on a secondary display effectively
468 // closes the window. 500 // closes the window.
469 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { 501 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) {
470 if (!SupportsMultipleDisplays()) 502 if (!SupportsMultipleDisplays())
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 gfx::Rect panel2_transformed_bounds( 1455 gfx::Rect panel2_transformed_bounds(
1424 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(panel2.get()))); 1456 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(panel2.get())));
1425 gfx::Point tap_target(panel2_transformed_bounds.right() - 2, 1457 gfx::Point tap_target(panel2_transformed_bounds.right() - 2,
1426 panel2_transformed_bounds.bottom() - 2); 1458 panel2_transformed_bounds.bottom() - 2);
1427 1459
1428 ui::test::EventGenerator generator(root_windows[1]); 1460 ui::test::EventGenerator generator(root_windows[1]);
1429 generator.GestureTapAt(tap_target); 1461 generator.GestureTapAt(tap_target);
1430 EXPECT_EQ(panel2.get(), GetFocusedWindow()); 1462 EXPECT_EQ(panel2.get(), GetFocusedWindow());
1431 } 1463 }
1432 1464
1465 // Verify swipe to close doesn't work when swipe to close is disabled.
1466 TEST_F(WindowSelectorSwipeToCloseDisabledTest, WindowTapDragFarDistance) {
1467 // We need a widget for the close button to work, a bare window will crash.
1468 scoped_ptr<views::Widget> widget =
1469 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1470
1471 ToggleOverview();
1472 ASSERT_TRUE(IsSelecting());
1473
1474 aura::Window* window = widget->GetNativeWindow();
1475 gfx::Rect bounds = ToNearestRect(GetTransformedBoundsInRootWindow(window));
1476 ui::test::EventGenerator event_generator(window->GetRootWindow());
1477
1478 ASSERT_FALSE(widget->IsClosed());
1479
1480 gfx::Point start(bounds.CenterPoint());
1481 gfx::Point end(start.x() - kFarDragDistance, start.y());
1482 event_generator.GestureScrollSequence(
1483 start, end, base::TimeDelta::FromMilliseconds(10), 5);
1484
1485 EXPECT_FALSE(widget->IsClosed());
1486
1487 RunAllPendingInMessageLoop();
1488 EXPECT_TRUE(IsSelecting());
1489 }
1490
1491 // Test dragging a window a short distance.
1492 TEST_F(WindowSelectorTest, WindowTapDragShortDistance) {
1493 // We need a widget for the close button to work, a bare window will crash.
1494 scoped_ptr<views::Widget> widget =
1495 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1496
1497 ToggleOverview();
1498
1499 aura::Window* window = widget->GetNativeWindow();
1500 gfx::Rect bounds = ToNearestRect(GetTransformedBoundsInRootWindow(window));
1501 ui::test::EventGenerator event_generator(window->GetRootWindow());
1502
1503 ASSERT_FALSE(widget->IsClosed());
1504
1505 gfx::Point start(bounds.CenterPoint());
1506 gfx::Point end(start.x() - kShortDragDistance, start.y());
1507 event_generator.GestureScrollSequence(
1508 start, end, base::TimeDelta::FromMilliseconds(10), 5);
1509
1510 EXPECT_FALSE(widget->IsClosed());
1511
1512 RunAllPendingInMessageLoop();
1513 EXPECT_TRUE(IsSelecting());
1514 }
1515
1516 // Test dragging a window a far distance.
1517 TEST_F(WindowSelectorTest, WindowTapDragFarDistance) {
1518 // We need a widget for the close button to work, a bare window will crash.
1519 scoped_ptr<views::Widget> widget =
1520 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1521
1522 ToggleOverview();
1523 ASSERT_TRUE(IsSelecting());
1524
1525 aura::Window* window = widget->GetNativeWindow();
1526 gfx::Rect bounds = ToNearestRect(GetTransformedBoundsInRootWindow(window));
1527 ui::test::EventGenerator event_generator(window->GetRootWindow());
1528
1529 ASSERT_FALSE(widget->IsClosed());
1530
1531 gfx::Point start(bounds.CenterPoint());
1532 gfx::Point end(start.x() - kFarDragDistance, start.y());
1533 event_generator.GestureScrollSequence(
1534 start, end, base::TimeDelta::FromMilliseconds(10), 5);
1535
1536 EXPECT_TRUE(widget->IsClosed());
1537
1538 RunAllPendingInMessageLoop();
1539 EXPECT_FALSE(IsSelecting());
1540 }
1541
1542 // Test dragging a window in a multi window SelectorItem a far distance.
1543 TEST_F(WindowSelectorTest, MultiWindowTapDragFarDistance) {
1544 scoped_ptr<views::Widget> widget1(
1545 CreatePanelWindowWidget(gfx::Rect(0, 0, 300, 100)));
1546 scoped_ptr<views::Widget> widget2(
1547 CreatePanelWindowWidget(gfx::Rect(100, 0, 100, 100)));
1548 aura::Window* window1 = widget1->GetNativeWindow();
1549 wm::ActivateWindow(window1);
1550 ToggleOverview();
1551
1552 gfx::Rect bounds1 = ToNearestRect(GetTransformedBoundsInRootWindow(window1));
1553 ui::test::EventGenerator event_generator1(window1->GetRootWindow());
1554
1555 ASSERT_FALSE(widget1->IsClosed());
1556 ASSERT_FALSE(widget2->IsClosed());
1557
1558 gfx::Point start(bounds1.CenterPoint());
1559 gfx::Point end(start.x() - kFarDragDistance, start.y());
1560 event_generator1.GestureScrollSequence(
1561 start, end, base::TimeDelta::FromMilliseconds(10), 5);
1562
1563 EXPECT_TRUE(widget1->IsClosed());
1564 EXPECT_FALSE(widget2->IsClosed());
1565
1566 RunAllPendingInMessageLoop();
1567 EXPECT_TRUE(IsSelecting());
1568 }
1569
1570 // Test dragging all windows in a multi window SelectorItem a short distance.
1571 TEST_F(WindowSelectorTest, MultiWindowTapDragLabelShortDistance) {
1572 scoped_ptr<views::Widget> widget1(
1573 CreatePanelWindowWidget(gfx::Rect(0, 0, 300, 100)));
1574 scoped_ptr<views::Widget> widget2(
1575 CreatePanelWindowWidget(gfx::Rect(100, 0, 100, 100)));
1576 aura::Window* window1 = widget1->GetNativeWindow();
1577 wm::ActivateWindow(window1);
1578 ToggleOverview();
1579
1580 gfx::Rect bounds = GetWindowItemsForRoot(0).back()->target_bounds();
1581 ui::test::EventGenerator event_generator1(window1->GetRootWindow());
1582
1583 ASSERT_FALSE(widget1->IsClosed());
1584 ASSERT_FALSE(widget2->IsClosed());
1585
1586 gfx::Point start(bounds.CenterPoint().x(), bounds.y() + 3);
1587 gfx::Point end(start.x() - kShortDragDistance, start.y());
1588 event_generator1.GestureScrollSequence(
1589 start, end, base::TimeDelta::FromMilliseconds(10), 5);
1590
1591 EXPECT_FALSE(widget1->IsClosed());
1592 EXPECT_FALSE(widget2->IsClosed());
1593
1594 RunAllPendingInMessageLoop();
1595
1596 RunAllPendingInMessageLoop();
1597 EXPECT_TRUE(IsSelecting());
1598 }
1599
1600 // Test dragging all windows in a multi window SelectorItem a far distance.
1601 TEST_F(WindowSelectorTest, MultiWindowTapDragLabelFarDistance) {
1602 scoped_ptr<views::Widget> widget1(
1603 CreatePanelWindowWidget(gfx::Rect(0, 0, 300, 100)));
1604 scoped_ptr<views::Widget> widget2(
1605 CreatePanelWindowWidget(gfx::Rect(100, 0, 100, 100)));
1606 aura::Window* window1 = widget1->GetNativeWindow();
1607 wm::ActivateWindow(window1);
1608 ToggleOverview();
1609
1610 gfx::Rect bounds = GetWindowItemsForRoot(0).back()->target_bounds();
1611 ui::test::EventGenerator event_generator1(window1->GetRootWindow());
1612
1613 ASSERT_FALSE(widget1->IsClosed());
1614 ASSERT_FALSE(widget2->IsClosed());
1615
1616 gfx::Point start(bounds.CenterPoint().x(), bounds.y() + 3);
1617 gfx::Point end(start.x() - kFarDragDistance, start.y());
1618 event_generator1.GestureScrollSequence(
1619 start, end, base::TimeDelta::FromMilliseconds(10), 5);
1620
1621 EXPECT_TRUE(widget1->IsClosed());
1622 EXPECT_TRUE(widget2->IsClosed());
1623
1624 RunAllPendingInMessageLoop();
1625 EXPECT_FALSE(IsSelecting());
1626 }
1627
1628 // Test a low velocity fling.
1629 TEST_F(WindowSelectorTest, LowVelocityFling) {
1630 const float kFlingVelocity = 2000;
1631 const int kSmallSwipeDistance = 25;
1632
1633 // We need a widget for the close button to work, a bare window will crash.
1634 scoped_ptr<views::Widget> widget =
1635 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1636
1637 ToggleOverview();
1638
1639 aura::Window* window = widget->GetNativeWindow();
1640 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
1641 ui::test::EventGenerator event_generator(window->GetRootWindow());
1642
1643 ASSERT_FALSE(widget->IsClosed());
1644
1645 gfx::Point start(bounds.CenterPoint().x(), bounds.CenterPoint().y());
1646 gfx::Point end(start.x() - kSmallSwipeDistance, start.y());
1647 const base::TimeDelta kScrollDuration =
1648 event_generator.CalculateScrollDurationForFlingVelocity(
1649 start, end, kFlingVelocity, 10);
1650 event_generator.GestureScrollSequence(start, end, kScrollDuration, 10);
1651
1652 EXPECT_FALSE(widget->IsClosed());
1653
1654 RunAllPendingInMessageLoop();
1655 EXPECT_TRUE(IsSelecting());
1656 }
1657
1658 // Test a high velocity fling.
1659 TEST_F(WindowSelectorTest, HighVelocityFling) {
1660 const float kFlingVelocity = 10000;
1661 const int kSmallSwipeDistance = 25;
1662
1663 // We need a widget for the close button to work, a bare window will crash.
1664 scoped_ptr<views::Widget> widget =
1665 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1666
1667 ToggleOverview();
1668 ASSERT_TRUE(IsSelecting());
1669
1670 aura::Window* window = widget->GetNativeWindow();
1671 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
1672 ui::test::EventGenerator event_generator(window->GetRootWindow());
1673
1674 ASSERT_FALSE(widget->IsClosed());
1675
1676 gfx::Point start(bounds.CenterPoint().x(), bounds.CenterPoint().y());
1677 gfx::Point end(start.x() - kSmallSwipeDistance, start.y());
1678 const base::TimeDelta kScrollDuration =
1679 event_generator.CalculateScrollDurationForFlingVelocity(
1680 start, end, kFlingVelocity, 10);
1681 event_generator.GestureScrollSequence(start, end, kScrollDuration, 10);
1682
1683 EXPECT_TRUE(widget->IsClosed());
1684
1685 RunAllPendingInMessageLoop();
1686 EXPECT_FALSE(IsSelecting());
1687 }
1688
1433 } // namespace ash 1689 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698