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

Unified Diff: content/browser/renderer_host/input/touch_selection_controller_unittest.cc

Issue 516573003: Use platform slop/timeout values for selection handle tap detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 6 years, 4 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
Index: content/browser/renderer_host/input/touch_selection_controller_unittest.cc
diff --git a/content/browser/renderer_host/input/touch_selection_controller_unittest.cc b/content/browser/renderer_host/input/touch_selection_controller_unittest.cc
index 460ed20250f5e3982c8f1c24f6cf36e49f70cc9d..5bdf57273fdadb5440308246953041cd8361dde9 100644
--- a/content/browser/renderer_host/input/touch_selection_controller_unittest.cc
+++ b/content/browser/renderer_host/input/touch_selection_controller_unittest.cc
@@ -12,6 +12,9 @@ using ui::test::MockMotionEvent;
namespace content {
namespace {
+const int kDefaultTapTimeoutMs = 200;
+const float kDefaulTapSlop = 10.f;
+
class MockTouchHandleDrawable : public TouchHandleDrawable {
public:
explicit MockTouchHandleDrawable(bool* contains_point)
@@ -47,7 +50,10 @@ class TouchSelectionControllerTest : public testing::Test,
// testing::Test implementation.
virtual void SetUp() OVERRIDE {
- controller_.reset(new TouchSelectionController(this));
+ controller_.reset(new TouchSelectionController(
+ this,
+ base::TimeDelta::FromMilliseconds(kDefaultTapTimeoutMs),
+ kDefaulTapSlop));
}
virtual void TearDown() OVERRIDE { controller_.reset(); }
@@ -391,6 +397,21 @@ TEST_F(TouchSelectionControllerTest, InsertionTapped) {
ChangeInsertion(start_rect, visible);
ASSERT_EQ(INSERTION_SHOWN, GetLastEventType());
+ // No tap should be signalled if the drag was too long.
+ event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ event = MockMotionEvent(MockMotionEvent::ACTION_MOVE, event_time, 100, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 100, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ EXPECT_EQ(INSERTION_DRAG_STARTED, GetLastEventType());
+
+ // Reset the insertion.
+ ClearInsertion();
+ controller().OnTapEvent();
+ ChangeInsertion(start_rect, visible);
+ ASSERT_EQ(INSERTION_SHOWN, GetLastEventType());
+
// No tap should be signalled if the touch sequence is cancelled.
event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
EXPECT_TRUE(controller().WillHandleTouchEvent(event));

Powered by Google App Engine
This is Rietveld 408576698