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); |