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

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

Issue 434583002: Prevent repeated taps from resetting insertion handle position (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased the patch Created 6 years, 5 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 | « content/browser/renderer_host/input/touch_selection_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dee5c98764c3c0130f07a42760ebc3d945e7d1db..55e393af019757c4431890b5b19436f88db97531 100644
--- a/content/browser/renderer_host/input/touch_selection_controller_unittest.cc
+++ b/content/browser/renderer_host/input/touch_selection_controller_unittest.cc
@@ -410,6 +410,49 @@ TEST_F(TouchSelectionControllerTest, InsertionTapped) {
EXPECT_EQ(INSERTION_SHOWN, GetLastEventType());
}
+TEST_F(TouchSelectionControllerTest, InsertionNotResetByRepeatedTapOrPress) {
+ base::TimeTicks event_time = base::TimeTicks::Now();
+ controller().OnTapEvent();
+ controller().OnSelectionEditable(true);
+ SetDraggingEnabled(true);
+
+ gfx::RectF anchor_rect(10, 0, 0, 10);
+ bool visible = true;
+ ChangeInsertion(anchor_rect, visible);
+ EXPECT_EQ(INSERTION_SHOWN, GetLastEventType());
+ EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventAnchor());
+
+ // Tapping again shouldn't reset the active insertion point.
+ controller().OnTapEvent();
+ MockMotionEvent event(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ EXPECT_EQ(INSERTION_SHOWN, GetLastEventType());
+ EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventAnchor());
+
+ event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ EXPECT_EQ(INSERTION_TAPPED, GetLastEventType());
+ EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventAnchor());
+
+ anchor_rect.Offset(5, 15);
+ ChangeInsertion(anchor_rect, visible);
+ EXPECT_EQ(INSERTION_MOVED, GetLastEventType());
+ EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventAnchor());
+
+ // Pressing shouldn't reset the active insertion point.
+ controller().OnLongPressEvent();
+ controller().OnSelectionEmpty(true);
+ event = MockMotionEvent(MockMotionEvent::ACTION_DOWN, event_time, 0, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ EXPECT_EQ(INSERTION_MOVED, GetLastEventType());
+ EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventAnchor());
+
+ event = MockMotionEvent(MockMotionEvent::ACTION_UP, event_time, 0, 0);
+ EXPECT_TRUE(controller().WillHandleTouchEvent(event));
+ EXPECT_EQ(INSERTION_TAPPED, GetLastEventType());
+ EXPECT_EQ(anchor_rect.bottom_left(), GetLastEventAnchor());
+}
+
TEST_F(TouchSelectionControllerTest, SelectionBasic) {
gfx::RectF start_rect(5, 5, 0, 10);
gfx::RectF end_rect(50, 5, 0, 10);
« no previous file with comments | « content/browser/renderer_host/input/touch_selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698