summaryrefslogtreecommitdiffstats
path: root/ui/views/touchui/touch_selection_controller_impl_unittest.cc
diff options
context:
space:
mode:
authorvarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-13 04:12:44 +0000
committervarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-13 04:12:44 +0000
commit135835314b3410ff043f0816aa8a9fa6ad69e178 (patch)
tree26dd5f99e785aa53c1ad282ffeb409f5d09abb6f /ui/views/touchui/touch_selection_controller_impl_unittest.cc
parent32501428e756c5d700b0551db0295adb507e6a9b (diff)
downloadchromium_src-135835314b3410ff043f0816aa8a9fa6ad69e178.zip
chromium_src-135835314b3410ff043f0816aa8a9fa6ad69e178.tar.gz
chromium_src-135835314b3410ff043f0816aa8a9fa6ad69e178.tar.bz2
Minor fix to logic that selects whether two selection handles or one is shown.
BUG=256761,259453 Review URL: https://chromiumcodereview.appspot.com/19054010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211536 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/touchui/touch_selection_controller_impl_unittest.cc')
-rw-r--r--ui/views/touchui/touch_selection_controller_impl_unittest.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
index 505acd8..83427fd 100644
--- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc
+++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
@@ -430,6 +430,41 @@ TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) {
VERIFY_HANDLE_POSITIONS(false);
}
+TEST_F(TouchSelectionControllerImplTest,
+ HiddenSelectionHandleRetainsCursorPosition) {
+ // Create a textfield with lots of text in it.
+ CreateTextfield();
+ std::string textfield_text("some text");
+ for (int i = 0; i < 10; ++i)
+ textfield_text += textfield_text;
+ textfield_->SetText(ASCIIToUTF16(textfield_text));
+
+ // Tap the textfield to invoke selection.
+ ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(),
+ ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0);
+ textfield_view_->OnGestureEvent(&tap);
+
+ // Select some text such that one handle is hidden.
+ textfield_->SelectRange(ui::Range(10, textfield_text.length()));
+
+ // Check that one selection handle is hidden.
+ EXPECT_FALSE(IsSelectionHandle1Visible());
+ EXPECT_TRUE(IsSelectionHandle2Visible());
+ EXPECT_EQ(ui::Range(10, textfield_text.length()),
+ textfield_->GetSelectedRange());
+
+ // Drag the visible handle around and make sure the selection end point of the
+ // invisible handle does not change.
+ size_t visible_handle_position = textfield_->GetSelectedRange().end();
+ for (int i = 0; i < 10; ++i) {
+ SimulateSelectionHandleDrag(gfx::Point(-10, 0), 2);
+ // Make sure that the visible handle is being dragged.
+ EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end());
+ visible_handle_position = textfield_->GetSelectedRange().end();
+ EXPECT_EQ((size_t) 10, textfield_->GetSelectedRange().start());
+ }
+}
+
#if defined(USE_AURA)
TEST_F(TouchSelectionControllerImplTest,
DoubleTapInTextfieldWithCursorHandleShouldSelectWord) {