From 558e8326e021562ceec044aed036a403365a2a4d Mon Sep 17 00:00:00 2001 From: "evy@chromium.org" Date: Tue, 10 Jun 2014 23:32:19 +0000 Subject: Added a new test to ui/chromeos/touch_exploration_controller_unittest.cc that tests the case where the user double-taps but holds their finger down the second time, for a long-press. Checked for touch pressed and touch released events, and that the time between press and release was the same as the length of the long-press. BUG=377040 NOTRY=true Review URL: https://codereview.chromium.org/317003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276206 0039d316-1c4b-4281-b951-d872f2087c98 --- .../touch_exploration_controller_unittest.cc | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'ui/chromeos') diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc index e572f1e..d0e43a5 100644 --- a/ui/chromeos/touch_exploration_controller_unittest.cc +++ b/ui/chromeos/touch_exploration_controller_unittest.cc @@ -651,4 +651,54 @@ TEST_F(TouchExplorationTest, DoubleTap) { EXPECT_TRUE(IsInNoFingersDownState()); } + +// Double-tapping where the user holds their finger down for the second time +// for a longer press should send a touch press and released (right click) +// to the location of the last successful touch exploration. +TEST_F(TouchExplorationTest, DoubleTapLongPress) { + SwitchTouchExplorationMode(true); + + // Tap at one location, and get a mouse move event. + gfx::Point tap_location(11, 12); + generator_->set_current_location(tap_location); + generator_->PressTouch(); + generator_->ReleaseTouch(); + AdvanceSimulatedTimePastTapDelay(); + + std::vector 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 double-tap and hold at a different location. + // This should result in a single touch long press and release + // at the location of the tap, not at the location of the double-tap. + // There should be a time delay between the touch press and release. + gfx::Point first_tap_location(33, 34); + generator_->set_current_location(first_tap_location); + generator_->PressTouch(); + generator_->ReleaseTouch(); + gfx::Point second_tap_location(23, 24); + generator_->set_current_location(second_tap_location); + generator_->PressTouch(); + simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(8000)); + generator_->ReleaseTouch(); + + const ScopedVector& 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( + base::TimeDelta::FromMilliseconds(8000), + released_time - pressed_time); +} + } // namespace ui -- cgit v1.1