| Index: ui/views/controls/textfield/textfield_unittest.cc
|
| diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
|
| index 1bfa636298637241610b268afdb088214f66c0cf..f43c06c9012c9b0d7eb063e8e46700276cc5d8c0 100644
|
| --- a/ui/views/controls/textfield/textfield_unittest.cc
|
| +++ b/ui/views/controls/textfield/textfield_unittest.cc
|
| @@ -1931,84 +1931,45 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) {
|
| textfield_->SetText(ASCIIToUTF16("hello world"));
|
| EXPECT_FALSE(test_api_->touch_selection_controller());
|
| const int x = GetCursorPositionX(2);
|
| - GestureEventForTest tap(ui::ET_GESTURE_TAP, x, 0, 1.0f, 0.0f);
|
| - GestureEventForTest tap_down(ui::ET_GESTURE_TAP_DOWN, x, 0, 0.0f, 0.0f);
|
| - GestureEventForTest long_press(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f);
|
| CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
|
|
|
| // Tapping on the textfield should turn on the TouchSelectionController.
|
| + GestureEventForTest tap(ui::ET_GESTURE_TAP, x, 0, 1.0f, 0.0f);
|
| textfield_->OnGestureEvent(&tap);
|
| EXPECT_TRUE(test_api_->touch_selection_controller());
|
|
|
| // Un-focusing the textfield should reset the TouchSelectionController
|
| textfield_->GetFocusManager()->ClearFocus();
|
| EXPECT_FALSE(test_api_->touch_selection_controller());
|
| + textfield_->RequestFocus();
|
|
|
| // With touch editing enabled, long press should not show context menu.
|
| // Instead, select word and invoke TouchSelectionController.
|
| - textfield_->OnGestureEvent(&tap_down);
|
| - textfield_->OnGestureEvent(&long_press);
|
| + GestureEventForTest long_press_1(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f);
|
| + textfield_->OnGestureEvent(&long_press_1);
|
| EXPECT_STR_EQ("hello", textfield_->GetSelectedText());
|
| EXPECT_TRUE(test_api_->touch_selection_controller());
|
| + EXPECT_TRUE(long_press_1.handled());
|
|
|
| // With touch drag drop enabled, long pressing in the selected region should
|
| // start a drag and remove TouchSelectionController.
|
| ASSERT_TRUE(switches::IsTouchDragDropEnabled());
|
| - textfield_->OnGestureEvent(&tap_down);
|
| - textfield_->OnGestureEvent(&long_press);
|
| + GestureEventForTest long_press_2(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f);
|
| + textfield_->OnGestureEvent(&long_press_2);
|
| EXPECT_STR_EQ("hello", textfield_->GetSelectedText());
|
| EXPECT_FALSE(test_api_->touch_selection_controller());
|
| + EXPECT_FALSE(long_press_2.handled());
|
|
|
| // After disabling touch drag drop, long pressing again in the selection
|
| // region should not do anything.
|
| CommandLine::ForCurrentProcess()->AppendSwitch(
|
| switches::kDisableTouchDragDrop);
|
| ASSERT_FALSE(switches::IsTouchDragDropEnabled());
|
| - textfield_->OnGestureEvent(&tap_down);
|
| - textfield_->OnGestureEvent(&long_press);
|
| + GestureEventForTest long_press_3(ui::ET_GESTURE_LONG_PRESS, x, 0, 0.0f, 0.0f);
|
| + textfield_->OnGestureEvent(&long_press_3);
|
| EXPECT_STR_EQ("hello", textfield_->GetSelectedText());
|
| - EXPECT_TRUE(test_api_->touch_selection_controller());
|
| - EXPECT_TRUE(long_press.handled());
|
| -}
|
| -
|
| -TEST_F(TextfieldTest, TouchScrubbingSelection) {
|
| - InitTextfield();
|
| - textfield_->SetText(ASCIIToUTF16("hello world"));
|
| EXPECT_FALSE(test_api_->touch_selection_controller());
|
| -
|
| - CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
|
| -
|
| - // Simulate touch-scrubbing.
|
| - int scrubbing_start = GetCursorPositionX(1);
|
| - int scrubbing_end = GetCursorPositionX(6);
|
| -
|
| - GestureEventForTest tap_down(ui::ET_GESTURE_TAP_DOWN, scrubbing_start, 0,
|
| - 0.0f, 0.0f);
|
| - textfield_->OnGestureEvent(&tap_down);
|
| -
|
| - GestureEventForTest tap_cancel(ui::ET_GESTURE_TAP_CANCEL, scrubbing_start, 0,
|
| - 0.0f, 0.0f);
|
| - textfield_->OnGestureEvent(&tap_cancel);
|
| -
|
| - GestureEventForTest scroll_begin(ui::ET_GESTURE_SCROLL_BEGIN, scrubbing_start,
|
| - 0, 0.0f, 0.0f);
|
| - textfield_->OnGestureEvent(&scroll_begin);
|
| -
|
| - GestureEventForTest scroll_update(ui::ET_GESTURE_SCROLL_UPDATE, scrubbing_end,
|
| - 0, scrubbing_end - scrubbing_start, 0.0f);
|
| - textfield_->OnGestureEvent(&scroll_update);
|
| -
|
| - GestureEventForTest scroll_end(ui::ET_GESTURE_SCROLL_END, scrubbing_end, 0,
|
| - 0.0f, 0.0f);
|
| - textfield_->OnGestureEvent(&scroll_end);
|
| -
|
| - GestureEventForTest end(ui::ET_GESTURE_END, scrubbing_end, 0, 0.0f, 0.0f);
|
| - textfield_->OnGestureEvent(&end);
|
| -
|
| - // In the end, part of text should have been selected and handles should have
|
| - // appeared.
|
| - EXPECT_STR_EQ("ello ", textfield_->GetSelectedText());
|
| - EXPECT_TRUE(test_api_->touch_selection_controller());
|
| + EXPECT_FALSE(long_press_3.handled());
|
| }
|
| #endif
|
|
|
|
|