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

Unified Diff: ui/chromeos/touch_exploration_controller_unittest.cc

Issue 2880043002: Implement touch exploration touch typing (Closed)
Patch Set: Add comments. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0879c61fd9889108946be820dd6e6e04761f6fb1 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,83 @@ TEST_F(TouchExplorationTest, ExclusionArea) {
}
}
+TEST_F(TouchExplorationTest, SingleTapInLiftActivationArea) {
+ SwitchTouchExplorationMode(true);
+
+ gfx::Rect lift_activation = BoundsOfRootWindowInDIP();
+ 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, TouchExploreLiftInLiftActivationArea) {
+ SwitchTouchExplorationMode(true);
+
+ gfx::Rect lift_activation = BoundsOfRootWindowInDIP();
+ 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
« no previous file with comments | « ui/chromeos/touch_exploration_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698