| 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 d0e43a535aba0b1c94a47752d23605396540e973..b1d498d136017f6269132de8c3627803ffb802ba 100644
|
| --- a/ui/chromeos/touch_exploration_controller_unittest.cc
|
| +++ b/ui/chromeos/touch_exploration_controller_unittest.cc
|
| @@ -685,7 +685,7 @@ TEST_F(TouchExplorationTest, DoubleTapLongPress) {
|
| gfx::Point second_tap_location(23, 24);
|
| generator_->set_current_location(second_tap_location);
|
| generator_->PressTouch();
|
| - simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(8000));
|
| + simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
|
| generator_->ReleaseTouch();
|
|
|
| const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
|
| @@ -696,9 +696,206 @@ TEST_F(TouchExplorationTest, DoubleTapLongPress) {
|
| EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
|
| EXPECT_EQ(tap_location, captured_events[1]->location());
|
| base::TimeDelta released_time = captured_events[1]->time_stamp();
|
| - EXPECT_EQ(
|
| - base::TimeDelta::FromMilliseconds(8000),
|
| - released_time - pressed_time);
|
| + EXPECT_EQ(gesture_detector_config_.longpress_timeout,
|
| + released_time - pressed_time);
|
| }
|
|
|
| +// Tapping and releasing with a second finger when in touch exploration mode
|
| +// should send a touch press and released to the location of the last
|
| +// successful touch exploration and return to touch explore.
|
| +TEST_F(TouchExplorationTest, SplitTap) {
|
| + SwitchTouchExplorationMode(true);
|
| + gfx::Point tap_location(11, 12);
|
| +
|
| + // Confirm events from other fingers go through as is.
|
| + ui::TouchEvent touch0_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now());
|
| + ui::TouchEvent touch1_press(
|
| + ui::ET_TOUCH_PRESSED, gfx::Point(33, 34), 1, Now());
|
| + ui::TouchEvent touch1_release(
|
| + ui::ET_TOUCH_RELEASED, gfx::Point(33, 34), 1, Now());
|
| +
|
| + // Tap and hold at one location, and get a mouse move event in touch explore.
|
| + generator_->Dispatch(&touch0_press);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + EXPECT_TRUE(IsInTouchToMouseMode());
|
| +
|
| + std::vector<ui::LocatedEvent*> events =
|
| + GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
|
| + ASSERT_EQ(1U, events.size());
|
| +
|
| + EXPECT_EQ(tap_location, events[0]->location());
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
|
| + ClearCapturedEvents();
|
| +
|
| + // Now tap and release at a different location. This should result in a
|
| + // single touch and release at the location of the first (held) tap,
|
| + // not at the location of the second tap and release.
|
| + // After the release, there is still a finger in touch explore mode.
|
| + generator_->Dispatch(&touch1_press);
|
| + generator_->Dispatch(&touch1_release);
|
| + EXPECT_FALSE(IsInNoFingersDownState());
|
| +
|
| + const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(2U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(tap_location, captured_events[0]->location());
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
|
| + EXPECT_EQ(tap_location, captured_events[1]->location());
|
| +}
|
| +
|
| +// If split tap is started but the touch explore finger is released first,
|
| +// there should still be a touch press and release sent to the location of
|
| +// the last successful touch exploration.
|
| +// All fingers should be released after the click goes through.
|
| +TEST_F(TouchExplorationTest, SplitTapRelease) {
|
| + SwitchTouchExplorationMode(true);
|
| +
|
| + gfx::Point tap_location(11, 12);
|
| +
|
| + // Confirm events from other fingers go through as is.
|
| + ui::TouchEvent touch0_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now());
|
| + ui::TouchEvent touch1_press(
|
| + ui::ET_TOUCH_PRESSED, gfx::Point(33, 34), 1, Now());
|
| + ui::TouchEvent touch0_release(ui::ET_TOUCH_RELEASED, tap_location, 0, Now());
|
| + ui::TouchEvent touch1_release(
|
| + ui::ET_TOUCH_RELEASED, gfx::Point(33, 34), 1, Now());
|
| +
|
| + // Tap and hold at one location, and get a mouse move event in touch explore.
|
| + generator_->Dispatch(&touch0_press);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + EXPECT_TRUE(IsInTouchToMouseMode());
|
| +
|
| + std::vector<ui::LocatedEvent*> events =
|
| + GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
|
| + ASSERT_EQ(1U, events.size());
|
| +
|
| + EXPECT_EQ(tap_location, events[0]->location());
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
|
| + ClearCapturedEvents();
|
| +
|
| + // Now tap at a different location. Release at the first location,
|
| + // then release at the second. This should result in a
|
| + // single touch and release at the location of the first (held) tap,
|
| + // not at the location of the second tap and release.
|
| + generator_->Dispatch(&touch1_press);
|
| + generator_->Dispatch(&touch0_release);
|
| + generator_->Dispatch(&touch1_release);
|
| + EXPECT_TRUE(IsInNoFingersDownState());
|
| +
|
| + const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(2U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(tap_location, captured_events[0]->location());
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
|
| + EXPECT_EQ(tap_location, captured_events[1]->location());
|
| +}
|
| +
|
| +// When in touch exploration mode, making a long press with a second finger
|
| +// should send a touch press and released to the location of the last
|
| +// successful touch exploration. There should be a delay between the
|
| +// touch and release events (right click).
|
| +TEST_F(TouchExplorationTest, SplitTapLongPress) {
|
| + SwitchTouchExplorationMode(true);
|
| + gfx::Point tap_location(11, 12);
|
| +
|
| + // Confirm events from other fingers go through as is.
|
| + ui::TouchEvent touch0_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now());
|
| + ui::TouchEvent touch1_press(
|
| + ui::ET_TOUCH_PRESSED, gfx::Point(33, 34), 1, Now());
|
| + simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
|
| + ui::TouchEvent touch1_release(
|
| + ui::ET_TOUCH_RELEASED, gfx::Point(33, 34), 1, Now());
|
| +
|
| + // Tap and hold at one location, and get a mouse move event in touch explore.
|
| + generator_->Dispatch(&touch0_press);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + EXPECT_TRUE(IsInTouchToMouseMode());
|
| +
|
| + std::vector<ui::LocatedEvent*> events =
|
| + GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
|
| + ASSERT_EQ(1U, events.size());
|
| +
|
| + EXPECT_EQ(tap_location, events[0]->location());
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
|
| + ClearCapturedEvents();
|
| +
|
| + // Now tap and release at a different location. This should result in a
|
| + // single touch and release at the location of the first (held) tap,
|
| + // not at the location of the second tap and release.
|
| + // After the release, there is still a finger in touch explore mode.
|
| + generator_->Dispatch(&touch1_press);
|
| + generator_->Dispatch(&touch1_release);
|
| + EXPECT_FALSE(IsInNoFingersDownState());
|
| +
|
| + const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(2U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(tap_location, captured_events[0]->location());
|
| + base::TimeDelta pressed_time = captured_events[0]->time_stamp();
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
|
| + EXPECT_EQ(tap_location, captured_events[1]->location());
|
| + base::TimeDelta released_time = captured_events[1]->time_stamp();
|
| + EXPECT_EQ(gesture_detector_config_.longpress_timeout,
|
| + released_time - pressed_time);
|
| +}
|
| +
|
| +// If split tap is started but the touch explore finger is released first,
|
| +// there should still be a touch press and release sent to the location of
|
| +// the last successful touch exploration. If the remaining finger is held
|
| +// as a longpress, there should be a delay between the sent touch and release
|
| +// events (right click).
|
| +// All fingers should be released after the click goes through.
|
| +TEST_F(TouchExplorationTest, SplitTapReleaseLongPress) {
|
| + SwitchTouchExplorationMode(true);
|
| + gfx::Point tap_location(11, 12);
|
| +
|
| + // Confirm events from other fingers go through as is.
|
| + ui::TouchEvent touch0_press(ui::ET_TOUCH_PRESSED, tap_location, 0, Now());
|
| + ui::TouchEvent touch1_press(
|
| + ui::ET_TOUCH_PRESSED, gfx::Point(33, 34), 1, Now());
|
| + ui::TouchEvent touch0_release(ui::ET_TOUCH_RELEASED, tap_location, 0, Now());
|
| + simulated_clock_->Advance(gesture_detector_config_.longpress_timeout);
|
| + ui::TouchEvent touch1_release(
|
| + ui::ET_TOUCH_RELEASED, gfx::Point(33, 34), 1, Now());
|
| +
|
| + // Tap and hold at one location, and get a mouse move event in touch explore.
|
| + generator_->Dispatch(&touch0_press);
|
| + AdvanceSimulatedTimePastTapDelay();
|
| + EXPECT_TRUE(IsInTouchToMouseMode());
|
| +
|
| + std::vector<ui::LocatedEvent*> events =
|
| + GetCapturedEventsOfType(ui::ET_MOUSE_MOVED);
|
| + ASSERT_EQ(1U, events.size());
|
| +
|
| + EXPECT_EQ(tap_location, events[0]->location());
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED);
|
| + EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY);
|
| + ClearCapturedEvents();
|
| +
|
| + // Now tap at a different location. Release at the first location,
|
| + // then release at the second. This should result in a
|
| + // single touch and release at the location of the first (held) tap,
|
| + // not at the location of the second tap and release.
|
| + // After the release, TouchToMouseMode should still be on.
|
| + generator_->Dispatch(&touch1_press);
|
| + generator_->Dispatch(&touch0_release);
|
| + generator_->Dispatch(&touch1_release);
|
| + EXPECT_TRUE(IsInTouchToMouseMode());
|
| +
|
| + const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents();
|
| + ASSERT_EQ(2U, captured_events.size());
|
| + EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type());
|
| + EXPECT_EQ(tap_location, captured_events[0]->location());
|
| + base::TimeDelta pressed_time = captured_events[0]->time_stamp();
|
| + EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type());
|
| + EXPECT_EQ(tap_location, captured_events[1]->location());
|
| + base::TimeDelta released_time = captured_events[1]->time_stamp();
|
| + EXPECT_EQ(gesture_detector_config_.longpress_timeout,
|
| + released_time - pressed_time);
|
| + }
|
| +
|
| +
|
| } // namespace ui
|
|
|