| Index: ui/views/controls/textfield/native_textfield_views_unittest.cc
|
| diff --git a/ui/views/controls/textfield/native_textfield_views_unittest.cc b/ui/views/controls/textfield/native_textfield_views_unittest.cc
|
| index df0b24e44f4f2bacba1f9758034617705f0cd0e9..f5ad3e0cb0ba53deeb1a96d86ed95f92a5522c9a 100644
|
| --- a/ui/views/controls/textfield/native_textfield_views_unittest.cc
|
| +++ b/ui/views/controls/textfield/native_textfield_views_unittest.cc
|
| @@ -1917,6 +1917,77 @@ TEST_F(NativeTextfieldViewsTest, TouchScrubbingSelection) {
|
| EXPECT_STR_EQ("ello ", textfield_->GetSelectedText());
|
| EXPECT_TRUE(GetTouchSelectionController());
|
| }
|
| +
|
| +TEST_F(NativeTextfieldViewsTest, TouchSelectionInDisabledTextfield) {
|
| + // Create a disabled textfield.
|
| + InitTextfield(Textfield::STYLE_DEFAULT);
|
| + textfield_->SetText(ASCIIToUTF16("hello world"));
|
| + textfield_->SetEnabled(false);
|
| + EXPECT_FALSE(GetTouchSelectionController());
|
| +
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
|
| +
|
| + // Simulate a complete tap.
|
| + int touch_x = GetCursorPositionX(2);
|
| + int touch_y = 0;
|
| +
|
| + GestureEventForTest begin(ui::ET_GESTURE_BEGIN, touch_x, touch_y, 0.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&begin);
|
| +
|
| + GestureEventForTest tap_down(ui::ET_GESTURE_TAP_DOWN, touch_x, touch_y, 0.0f,
|
| + 0.0f);
|
| + textfield_view_->OnGestureEvent(&tap_down);
|
| +
|
| + GestureEventForTest show_press(ui::ET_GESTURE_SHOW_PRESS, touch_x, touch_y,
|
| + 0.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&show_press);
|
| +
|
| + GestureEventForTest tap(ui::ET_GESTURE_TAP, touch_x, touch_y, 1.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&tap);
|
| +
|
| + GestureEventForTest end(ui::ET_GESTURE_END, touch_x, touch_y, 0.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&end);
|
| +
|
| + // In the end, there should be no selection handles in the textfield.
|
| + EXPECT_FALSE(GetTouchSelectionController());
|
| +}
|
| +
|
| +TEST_F(NativeTextfieldViewsTest, TouchSelectionInNonFocusableTextfield) {
|
| + // Create a non-focusable textfield.
|
| + InitTextfield(Textfield::STYLE_DEFAULT);
|
| + textfield_->SetText(ASCIIToUTF16("hello world"));
|
| + textfield_->set_focusable(false);
|
| + textfield_->GetFocusManager()->ClearFocus();
|
| + EXPECT_FALSE(GetTouchSelectionController());
|
| +
|
| + CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
|
| +
|
| + // Simulate a complete tap.
|
| + int touch_x = GetCursorPositionX(2);
|
| + int touch_y = 0;
|
| +
|
| + GestureEventForTest begin(ui::ET_GESTURE_BEGIN, touch_x, touch_y, 0.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&begin);
|
| +
|
| + GestureEventForTest tap_down(ui::ET_GESTURE_TAP_DOWN, touch_x, touch_y, 0.0f,
|
| + 0.0f);
|
| + textfield_view_->OnGestureEvent(&tap_down);
|
| +
|
| + GestureEventForTest show_press(ui::ET_GESTURE_SHOW_PRESS, touch_x, touch_y,
|
| + 0.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&show_press);
|
| +
|
| + GestureEventForTest tap(ui::ET_GESTURE_TAP, touch_x, touch_y, 1.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&tap);
|
| +
|
| + GestureEventForTest end(ui::ET_GESTURE_END, touch_x, touch_y, 0.0f, 0.0f);
|
| + textfield_view_->OnGestureEvent(&end);
|
| +
|
| + // In the end, the textfield should not be focused and there should be no
|
| + // selection handles in the textfield.
|
| + EXPECT_FALSE(textfield_->HasFocus());
|
| + EXPECT_FALSE(GetTouchSelectionController());
|
| +}
|
| #endif
|
|
|
| // Long_Press gesture in NativeTextfieldViews can initiate a drag and drop now.
|
|
|