Index: ui/touch_selection/touch_selection_controller_unittest.cc |
diff --git a/ui/touch_selection/touch_selection_controller_unittest.cc b/ui/touch_selection/touch_selection_controller_unittest.cc |
index be971b1034bd9a002e2bc60d044de4f67857a465..f6e7305f067a0fec6d960115d5e7723975bd3159 100644 |
--- a/ui/touch_selection/touch_selection_controller_unittest.cc |
+++ b/ui/touch_selection/touch_selection_controller_unittest.cc |
@@ -151,7 +151,11 @@ class TouchSelectionControllerTest : public testing::Test, |
} |
void OnTapEvent() { |
- ASSERT_FALSE(controller().WillHandleTapEvent(kIgnoredPoint)); |
+ ASSERT_FALSE(controller().WillHandleTapEvent(kIgnoredPoint, 1)); |
+ } |
+ |
+ void OnDoubleTapEvent() { |
+ ASSERT_FALSE(controller().WillHandleTapEvent(kIgnoredPoint, 2)); |
} |
void Animate() { |
@@ -605,6 +609,38 @@ TEST_F(TouchSelectionControllerTest, SelectionBasic) { |
EXPECT_EQ(gfx::PointF(), GetLastEventStart()); |
} |
+TEST_F(TouchSelectionControllerTest, SelectionAllowedByDoubleTap) { |
+ gfx::RectF start_rect(5, 5, 0, 10); |
+ gfx::RectF end_rect(50, 5, 0, 10); |
+ bool visible = true; |
+ |
+ OnDoubleTapEvent(); |
+ ChangeSelection(start_rect, visible, end_rect, visible); |
+ EXPECT_THAT(GetAndResetEvents(), |
+ ElementsAre(SELECTION_ESTABLISHED, SELECTION_HANDLES_SHOWN)); |
+ EXPECT_EQ(start_rect.bottom_left(), GetLastEventStart()); |
+} |
+ |
+TEST_F(TouchSelectionControllerTest, SelectionAllowedByDoubleTapOnEditable) { |
+ gfx::RectF start_rect(5, 5, 0, 10); |
+ gfx::RectF end_rect(50, 5, 0, 10); |
+ bool visible = true; |
+ |
+ controller().OnSelectionEditable(true); |
+ |
+ // If the user double tap selects text in an editable region, the first tap |
+ // will register insertion and the second tap selection. |
+ OnTapEvent(); |
+ ChangeInsertion(start_rect, visible); |
+ EXPECT_THAT(GetAndResetEvents(), |
+ ElementsAre(SELECTION_ESTABLISHED, INSERTION_HANDLE_SHOWN)); |
+ |
+ OnDoubleTapEvent(); |
+ ChangeSelection(start_rect, visible, end_rect, visible); |
+ EXPECT_THAT(GetAndResetEvents(), |
+ ElementsAre(INSERTION_HANDLE_CLEARED, SELECTION_HANDLES_SHOWN)); |
+} |
+ |
TEST_F(TouchSelectionControllerTest, SelectionAllowsEmptyUpdateAfterLongPress) { |
gfx::RectF start_rect(5, 5, 0, 10); |
gfx::RectF end_rect(50, 5, 0, 10); |
@@ -1070,11 +1106,11 @@ TEST_F(TouchSelectionControllerTest, HandlesShowOnTapInsideRect) { |
EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_ESTABLISHED)); |
// A point outside the rect should not be handled. |
- EXPECT_FALSE(controller().WillHandleTapEvent(outer_point)); |
+ EXPECT_FALSE(controller().WillHandleTapEvent(outer_point, 1)); |
EXPECT_THAT(GetAndResetEvents(), IsEmpty()); |
// A point inside the rect should be handled. |
- EXPECT_TRUE(controller().WillHandleTapEvent(inner_point)); |
+ EXPECT_TRUE(controller().WillHandleTapEvent(inner_point, 1)); |
EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLES_SHOWN)); |
} |