Index: ui/chromeos/touch_exploration_controller_unittest.cc |
diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc |
index b00814b1eb6efc7f6d197292016f8956e693d1a7..70c2c2a27abb722d4ef5c2d605d1a34ebf8528f8 100644 |
--- a/ui/chromeos/touch_exploration_controller_unittest.cc |
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc |
@@ -1634,4 +1634,100 @@ TEST_F(TouchExplorationTest, InBoundariesTouchExploration) { |
EXPECT_TRUE(IsInTouchToMouseMode()); |
} |
+// Corner passthrough should turn on if the user first holds down on either the |
+// right or left corner past a delay and then places a finger anywhere else on |
+// the screen. |
+TEST_F(TouchExplorationTest, ActivateLeftCornerPassthrough) { |
+ SwitchTouchExplorationMode(true); |
+ |
+ gfx::Rect window = BoundsOfRootWindowInDIP(); |
+ 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.
|
+ window.bottom() - GetMaxDistanceFromEdge() / 2); |
+ 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.
|
+ ui::ET_TOUCH_PRESSED, |
+ left_corner_press, |
+ 0, |
+ Now()); |
+ generator_->Dispatch(&first_press); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ 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.
|
+ |
+ AdvanceSimulatedTimePastTapDelay(); |
aboxhall
2014/07/24 18:34:16
Should this be the corner passthrough delay instea
lisayin
2014/07/25 20:11:57
Done.
|
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+ |
+ // The following events should be passed through. |
+ gfx::Point middle_screen(window.right() / 2, window.bottom() / 2); |
+ ui::TouchEvent middle_press( |
+ ui::ET_TOUCH_PRESSED, middle_screen, 1, Now()); |
+ generator_->Dispatch(&middle_press); |
+ generator_->ReleaseTouchId(1); |
+ generator_->PressTouchId(1); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+ |
+ std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
+ ASSERT_EQ(3U, captured_events.size()); |
+ EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
+ EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
+ EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type()); |
+ generator_->ReleaseTouchId(1); |
+ ClearCapturedEvents(); |
+ |
+ generator_->ReleaseTouchId(0); |
+ captured_events = GetCapturedLocatedEvents(); |
+ ASSERT_EQ(0U, captured_events.size()); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+} |
+ |
+TEST_F(TouchExplorationTest, ActivateRightCornerPassthrough) { |
+ SwitchTouchExplorationMode(true); |
+ |
+ gfx::Rect window = BoundsOfRootWindowInDIP(); |
+ gfx::Point right_corner_press(window.right() - GetMaxDistanceFromEdge() / 2, |
+ window.bottom() - GetMaxDistanceFromEdge() / 2); |
+ ui::TouchEvent first_press( |
+ ui::ET_TOUCH_PRESSED, right_corner_press, 0, Now()); |
+ generator_->Dispatch(&first_press); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+ |
+ AdvanceSimulatedTimePastTapDelay(); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+ |
+ // The following events should be passed through. |
+ gfx::Point middle_screen(window.right() / 2, window.bottom() / 2); |
+ ui::TouchEvent middle_press( |
+ ui::ET_TOUCH_PRESSED, middle_screen, 1, Now()); |
+ generator_->Dispatch(&middle_press); |
+ generator_->ReleaseTouchId(1); |
+ generator_->PressTouchId(1); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+ |
+ std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
+ ASSERT_EQ(3U, captured_events.size()); |
+ EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
+ EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
+ EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type()); |
+ generator_->ReleaseTouchId(1); |
+ ClearCapturedEvents(); |
+ |
+ generator_->ReleaseTouchId(0); |
+ captured_events = GetCapturedLocatedEvents(); |
+ ASSERT_EQ(0U, captured_events.size()); |
+ EXPECT_FALSE(IsInGestureInProgressState()); |
+ EXPECT_FALSE(IsInSlideGestureState()); |
+ EXPECT_FALSE(IsInTouchToMouseMode()); |
+} |
+ |
} // namespace ui |