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 c05e181298cc1a42d93945d1609b9e0132a66dd5..f77299296e47211c67eda3b2e01e0e24774a7648 100644 |
--- a/ui/chromeos/touch_exploration_controller_unittest.cc |
+++ b/ui/chromeos/touch_exploration_controller_unittest.cc |
@@ -190,6 +190,10 @@ class TouchExplorationControllerTestApi { |
touch_exploration_controller_->SetExcludeBounds(bounds); |
} |
+ void SetLiftActivationBounds(const gfx::Rect& bounds) { |
+ touch_exploration_controller_->SetLiftActivationBounds(bounds); |
+ } |
+ |
private: |
std::unique_ptr<TouchExplorationController> touch_exploration_controller_; |
@@ -413,6 +417,10 @@ class TouchExplorationTest : public aura::test::AuraTestBase { |
touch_exploration_controller_->SetExcludeBounds(bounds); |
} |
+ void SetLiftActivationBounds(const gfx::Rect& bounds) { |
+ touch_exploration_controller_->SetLiftActivationBounds(bounds); |
+ } |
+ |
std::unique_ptr<test::EventGenerator> generator_; |
ui::GestureDetector::Config gesture_detector_config_; |
// Owned by |ui|. |
@@ -1976,4 +1984,85 @@ TEST_F(TouchExplorationTest, ExclusionArea) { |
} |
} |
+TEST_F(TouchExplorationTest, SingleTapInActivationArea) { |
dmazzoni
2017/05/19 19:44:49
Maybe ...InLiftActivationArea to be clear?
David Tseng
2017/05/24 15:40:19
Done.
|
+ SwitchTouchExplorationMode(true); |
+ |
+ gfx::Rect window = BoundsOfRootWindowInDIP(); |
+ gfx::Rect lift_activation = window; |
+ lift_activation.Inset(0, 0, 0, 30); |
+ SetLiftActivationBounds(lift_activation); |
+ |
+ // Tap at one location, and get tap and mouse move events. |
+ gfx::Point tap_location = lift_activation.CenterPoint(); |
+ |
+ // The user has to have previously selected something. |
+ SetTouchAccessibilityAnchorPoint(tap_location); |
+ |
+ generator_->set_current_location(tap_location); |
+ generator_->PressTouchId(1); |
+ generator_->ReleaseTouchId(1); |
+ AdvanceSimulatedTimePastTapDelay(); |
+ |
+ const EventList& captured_events = GetCapturedEvents(); |
+ 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_MOUSE_MOVED, captured_events[2]->type()); |
+ ClearCapturedEvents(); |
+ |
+ gfx::Point out_tap_location(tap_location.x(), lift_activation.bottom() + 20); |
+ SetTouchAccessibilityAnchorPoint(out_tap_location); |
+ generator_->set_current_location(out_tap_location); |
+ generator_->PressTouchId(1); |
+ generator_->ReleaseTouchId(1); |
+ AdvanceSimulatedTimePastTapDelay(); |
+ |
+ const EventList& out_captured_events = GetCapturedEvents(); |
+ ASSERT_EQ(1U, out_captured_events.size()); |
+ EXPECT_EQ(ui::ET_MOUSE_MOVED, out_captured_events[0]->type()); |
+} |
+ |
+TEST_F(TouchExplorationTest, TouchExploreLiftInActivationArea) { |
+ SwitchTouchExplorationMode(true); |
+ |
+ gfx::Rect window = BoundsOfRootWindowInDIP(); |
+ gfx::Rect lift_activation = window; |
+ lift_activation.Inset(0, 0, 0, 30); |
+ SetLiftActivationBounds(lift_activation); |
+ |
+ // Explore at one location, and get tap and mouse move events. |
+ gfx::Point tap_location = lift_activation.CenterPoint(); |
+ EnterTouchExplorationModeAtLocation(tap_location); |
+ ClearCapturedEvents(); |
+ |
+ // A touch release should trigger a tap. |
+ ui::TouchEvent touch_explore_release( |
+ ui::ET_TOUCH_RELEASED, tap_location, Now(), |
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); |
+ generator_->Dispatch(&touch_explore_release); |
+ AdvanceSimulatedTimePastTapDelay(); |
+ |
+ const EventList& captured_events = GetCapturedEvents(); |
+ 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_MOUSE_MOVED, captured_events[2]->type()); |
+ ClearCapturedEvents(); |
+ |
+ // Touch explore inside the activation bounds, but lift outside. |
+ gfx::Point out_tap_location(tap_location.x(), lift_activation.bottom() + 20); |
+ SetTouchAccessibilityAnchorPoint(out_tap_location); |
+ EnterTouchExplorationModeAtLocation(tap_location); |
+ ClearCapturedEvents(); |
+ ui::TouchEvent out_touch_explore_release( |
+ ui::ET_TOUCH_RELEASED, out_tap_location, Now(), |
+ ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); |
+ generator_->Dispatch(&out_touch_explore_release); |
+ AdvanceSimulatedTimePastTapDelay(); |
+ |
+ const EventList& out_captured_events = GetCapturedEvents(); |
+ ASSERT_EQ(1U, out_captured_events.size()); |
+ EXPECT_EQ(ui::ET_MOUSE_MOVED, out_captured_events[0]->type()); |
+} |
+ |
} // namespace ui |