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

Side by Side Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 410783002: Corner Passthrough for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@side-gestures
Patch Set: Added tests and Rebase off Master Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/chromeos/touch_exploration_controller.h" 5 #include "ui/chromeos/touch_exploration_controller.h"
6 6
7 #include "base/test/simple_test_tick_clock.h" 7 #include "base/test/simple_test_tick_clock.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/test/aura_test_base.h" 10 #include "ui/aura/test/aura_test_base.h"
(...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 EXPECT_FALSE(IsInGestureInProgressState()); 1627 EXPECT_FALSE(IsInGestureInProgressState());
1628 EXPECT_FALSE(IsInSlideGestureState()); 1628 EXPECT_FALSE(IsInSlideGestureState());
1629 EXPECT_FALSE(IsInTouchToMouseMode()); 1629 EXPECT_FALSE(IsInTouchToMouseMode());
1630 1630
1631 AdvanceSimulatedTimePastTapDelay(); 1631 AdvanceSimulatedTimePastTapDelay();
1632 EXPECT_FALSE(IsInGestureInProgressState()); 1632 EXPECT_FALSE(IsInGestureInProgressState());
1633 EXPECT_FALSE(IsInSlideGestureState()); 1633 EXPECT_FALSE(IsInSlideGestureState());
1634 EXPECT_TRUE(IsInTouchToMouseMode()); 1634 EXPECT_TRUE(IsInTouchToMouseMode());
1635 } 1635 }
1636 1636
1637 // Corner passthrough should turn on if the user first holds down on either the
1638 // right or left corner past a delay and then places a finger anywhere else on
1639 // the screen.
1640 TEST_F(TouchExplorationTest, ActivateLeftCornerPassthrough) {
1641 SwitchTouchExplorationMode(true);
1642
1643 gfx::Rect window = BoundsOfRootWindowInDIP();
1644 gfx::Point left_corner_press(10,
aboxhall 2014/07/24 18:34:16 nit: left_corner rather than left_corner_press.
lisayin 2014/07/25 20:11:57 Done.
1645 window.bottom() - GetMaxDistanceFromEdge() / 2);
1646 ui::TouchEvent first_press(
aboxhall 2014/07/24 18:34:16 Everything below this line is common to this and t
lisayin 2014/07/25 20:11:57 Done.
1647 ui::ET_TOUCH_PRESSED,
1648 left_corner_press,
1649 0,
1650 Now());
1651 generator_->Dispatch(&first_press);
1652 EXPECT_FALSE(IsInGestureInProgressState());
1653 EXPECT_FALSE(IsInSlideGestureState());
1654 EXPECT_FALSE(IsInTouchToMouseMode());
aboxhall 2014/07/24 18:34:16 Explicitly test for CORNER_PASSTHROUGH mode here?
lisayin 2014/07/25 20:11:57 Done.
1655
1656 AdvanceSimulatedTimePastTapDelay();
aboxhall 2014/07/24 18:34:16 Should this be the corner passthrough delay instea
lisayin 2014/07/25 20:11:57 Done.
1657 EXPECT_FALSE(IsInGestureInProgressState());
1658 EXPECT_FALSE(IsInSlideGestureState());
1659 EXPECT_FALSE(IsInTouchToMouseMode());
1660
1661 // The following events should be passed through.
1662 gfx::Point middle_screen(window.right() / 2, window.bottom() / 2);
1663 ui::TouchEvent middle_press(
1664 ui::ET_TOUCH_PRESSED, middle_screen, 1, Now());
1665 generator_->Dispatch(&middle_press);
1666 generator_->ReleaseTouchId(1);
1667 generator_->PressTouchId(1);
1668 EXPECT_FALSE(IsInGestureInProgressState());
1669 EXPECT_FALSE(IsInSlideGestureState());
1670 EXPECT_FALSE(IsInTouchToMouseMode());
1671
1672 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1673 ASSERT_EQ(3U, captured_events.size());
1674 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1675 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
1676 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type());
1677 generator_->ReleaseTouchId(1);
1678 ClearCapturedEvents();
1679
1680 generator_->ReleaseTouchId(0);
1681 captured_events = GetCapturedLocatedEvents();
1682 ASSERT_EQ(0U, captured_events.size());
1683 EXPECT_FALSE(IsInGestureInProgressState());
1684 EXPECT_FALSE(IsInSlideGestureState());
1685 EXPECT_FALSE(IsInTouchToMouseMode());
1686 }
1687
1688 TEST_F(TouchExplorationTest, ActivateRightCornerPassthrough) {
1689 SwitchTouchExplorationMode(true);
1690
1691 gfx::Rect window = BoundsOfRootWindowInDIP();
1692 gfx::Point right_corner_press(window.right() - GetMaxDistanceFromEdge() / 2,
1693 window.bottom() - GetMaxDistanceFromEdge() / 2);
1694 ui::TouchEvent first_press(
1695 ui::ET_TOUCH_PRESSED, right_corner_press, 0, Now());
1696 generator_->Dispatch(&first_press);
1697 EXPECT_FALSE(IsInGestureInProgressState());
1698 EXPECT_FALSE(IsInSlideGestureState());
1699 EXPECT_FALSE(IsInTouchToMouseMode());
1700
1701 AdvanceSimulatedTimePastTapDelay();
1702 EXPECT_FALSE(IsInGestureInProgressState());
1703 EXPECT_FALSE(IsInSlideGestureState());
1704 EXPECT_FALSE(IsInTouchToMouseMode());
1705
1706 // The following events should be passed through.
1707 gfx::Point middle_screen(window.right() / 2, window.bottom() / 2);
1708 ui::TouchEvent middle_press(
1709 ui::ET_TOUCH_PRESSED, middle_screen, 1, Now());
1710 generator_->Dispatch(&middle_press);
1711 generator_->ReleaseTouchId(1);
1712 generator_->PressTouchId(1);
1713 EXPECT_FALSE(IsInGestureInProgressState());
1714 EXPECT_FALSE(IsInSlideGestureState());
1715 EXPECT_FALSE(IsInTouchToMouseMode());
1716
1717 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents();
1718 ASSERT_EQ(3U, captured_events.size());
1719 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
1720 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
1721 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type());
1722 generator_->ReleaseTouchId(1);
1723 ClearCapturedEvents();
1724
1725 generator_->ReleaseTouchId(0);
1726 captured_events = GetCapturedLocatedEvents();
1727 ASSERT_EQ(0U, captured_events.size());
1728 EXPECT_FALSE(IsInGestureInProgressState());
1729 EXPECT_FALSE(IsInSlideGestureState());
1730 EXPECT_FALSE(IsInTouchToMouseMode());
1731 }
1732
1637 } // namespace ui 1733 } // namespace ui
OLDNEW
« ui/chromeos/touch_exploration_controller.cc ('K') | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698