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

Unified Diff: ui/touch_selection/touch_selection_controller_unittest.cc

Issue 1358263002: [Android] Support double-tap selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix contextual search Created 5 years, 3 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/touch_selection/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: 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));
}
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698