summaryrefslogtreecommitdiffstats
path: root/ui/views/controls/textfield/textfield_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/views/controls/textfield/textfield_unittest.cc')
-rw-r--r--ui/views/controls/textfield/textfield_unittest.cc46
1 files changed, 22 insertions, 24 deletions
diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
index b7a6117..2cd92c0 100644
--- a/ui/views/controls/textfield/textfield_unittest.cc
+++ b/ui/views/controls/textfield/textfield_unittest.cc
@@ -103,8 +103,16 @@ class TestTextfield : public views::Textfield {
// Convenience to make constructing a GestureEvent simpler.
class GestureEventForTest : public ui::GestureEvent {
public:
- GestureEventForTest(int x, int y, ui::GestureEventDetails details)
- : GestureEvent(x, y, 0, base::TimeDelta(), details) {}
+ GestureEventForTest(ui::EventType type,
+ int x,
+ int y,
+ float delta_x,
+ float delta_y)
+ : GestureEvent(x,
+ y,
+ 0,
+ base::TimeDelta(),
+ ui::GestureEventDetails(type, delta_x, delta_y)) {}
private:
DISALLOW_COPY_AND_ASSIGN(GestureEventForTest);
@@ -322,26 +330,23 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
// Simulates a complete tap.
void Tap(const gfx::Point& point) {
GestureEventForTest begin(
- point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_BEGIN));
+ ui::ET_GESTURE_BEGIN, point.x(), point.y(), 0.0f, 0.0f);
textfield_->OnGestureEvent(&begin);
GestureEventForTest tap_down(
- point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN));
+ ui::ET_GESTURE_TAP_DOWN, point.x(), point.y(), 0.0f, 0.0f);
textfield_->OnGestureEvent(&tap_down);
GestureEventForTest show_press(
- point.x(),
- point.y(),
- ui::GestureEventDetails(ui::ET_GESTURE_SHOW_PRESS));
+ ui::ET_GESTURE_SHOW_PRESS, point.x(), point.y(), 0.0f, 0.0f);
textfield_->OnGestureEvent(&show_press);
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP);
- tap_details.set_tap_count(1);
- GestureEventForTest tap(point.x(), point.y(), tap_details);
+ GestureEventForTest tap(
+ ui::ET_GESTURE_TAP, point.x(), point.y(), 1.0f, 0.0f);
textfield_->OnGestureEvent(&tap);
GestureEventForTest end(
- point.x(), point.y(), ui::GestureEventDetails(ui::ET_GESTURE_END));
+ ui::ET_GESTURE_END, point.x(), point.y(), 0.0f, 0.0f);
textfield_->OnGestureEvent(&end);
}
@@ -1952,9 +1957,7 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) {
CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing);
// Tapping on the textfield should turn on the TouchSelectionController.
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP);
- tap_details.set_tap_count(1);
- GestureEventForTest tap(x, 0, tap_details);
+ GestureEventForTest tap(ui::ET_GESTURE_TAP, x, 0, 1.0f, 0.0f);
textfield_->OnGestureEvent(&tap);
EXPECT_TRUE(test_api_->touch_selection_controller());
@@ -1965,8 +1968,7 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) {
// With touch editing enabled, long press should not show context menu.
// Instead, select word and invoke TouchSelectionController.
- GestureEventForTest long_press_1(
- x, 0, ui::GestureEventDetails(ui::ET_GESTURE_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());
@@ -1975,8 +1977,7 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) {
// With touch drag drop enabled, long pressing in the selected region should
// start a drag and remove TouchSelectionController.
ASSERT_TRUE(switches::IsTouchDragDropEnabled());
- GestureEventForTest long_press_2(
- x, 0, ui::GestureEventDetails(ui::ET_GESTURE_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());
@@ -1987,8 +1988,7 @@ TEST_F(TextfieldTest, TouchSelectionAndDraggingTest) {
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kDisableTouchDragDrop);
ASSERT_FALSE(switches::IsTouchDragDropEnabled());
- GestureEventForTest long_press_3(
- x, 0, ui::GestureEventDetails(ui::ET_GESTURE_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_FALSE(test_api_->touch_selection_controller());
@@ -2033,10 +2033,8 @@ TEST_F(TextfieldTest, TestLongPressInitiatesDragDrop) {
switches::kEnableTouchDragDrop);
// Create a long press event in the selected region should start a drag.
- GestureEventForTest long_press(
- kStringPoint.x(),
- kStringPoint.y(),
- ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
+ GestureEventForTest long_press(ui::ET_GESTURE_LONG_PRESS, kStringPoint.x(),
+ kStringPoint.y(), 0.0f, 0.0f);
textfield_->OnGestureEvent(&long_press);
EXPECT_TRUE(textfield_->CanStartDragForView(NULL, kStringPoint,
kStringPoint));