Index: content/browser/renderer_host/input/gesture_text_selector_unittest.cc |
diff --git a/content/browser/renderer_host/input/gesture_text_selector_unittest.cc b/content/browser/renderer_host/input/gesture_text_selector_unittest.cc |
index 53042447f57e71464a6c9d9addf098b9794d3e57..8977c56ea949394ebc8945b0a7b2c967b6804a04 100644 |
--- a/content/browser/renderer_host/input/gesture_text_selector_unittest.cc |
+++ b/content/browser/renderer_host/input/gesture_text_selector_unittest.cc |
@@ -183,6 +183,76 @@ TEST_F(GestureTextSelectorTest, PenDragging) { |
EXPECT_EQ(3u, event_log_.size()); // NO CHANGE |
} |
+TEST_F(GestureTextSelectorTest, PenDraggingButtonNotPressed) { |
+ base::TimeTicks event_time = base::TimeTicks::Now(); |
+ const float x1 = 50.0f; |
+ const float y1 = 30.0f; |
+ const float x2 = 75.0f; |
+ const float y2 = 60.0f; |
+ const float x3 = 100.0f; |
+ const float y3 = 90.0f; |
+ // 1. ACTION_DOWN with stylus + button |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ MockMotionEvent action_down(MotionEvent::ACTION_DOWN, event_time, x1, y1); |
+ action_down.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); |
+ action_down.set_button_state(MotionEvent::BUTTON_SECONDARY); |
+ EXPECT_TRUE(selector_->OnTouchEvent(action_down)); |
+ EXPECT_TRUE(event_log_.empty()); |
+ |
+ // 2. ACTION_MOVE |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ MockMotionEvent action_move(MotionEvent::ACTION_MOVE, event_time, x2, y2); |
+ action_move.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); |
+ action_move.set_button_state(MotionEvent::BUTTON_SECONDARY); |
+ EXPECT_TRUE(selector_->OnTouchEvent(action_move)); |
+ EXPECT_TRUE(event_log_.empty()); |
+ |
+ // 3. ET_GESTURE_SCROLL_BEGIN |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ const GestureEventData scroll_begin = |
+ CreateGesture(ui::ET_GESTURE_SCROLL_BEGIN, event_time, x1, y1); |
+ EXPECT_TRUE(selector_->OnGestureEvent(scroll_begin)); |
+ EXPECT_EQ(1u, event_log_.size()); // Unselect |
+ |
+ // 4. ET_GESTURE_SCROLL_UPDATE |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ const GestureEventData scroll_update = |
+ CreateGesture(ui::ET_GESTURE_SCROLL_UPDATE, event_time, x2, y2); |
+ EXPECT_TRUE(selector_->OnGestureEvent(scroll_update)); |
+ EXPECT_EQ(3u, event_log_.size()); // Unselect, Show, SelectRange |
+ EXPECT_STREQ("SelectRange", event_log_.back().c_str()); |
+ |
+ // 5. ACTION_MOVE with stylus + no button |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ action_move = MockMotionEvent(MotionEvent::ACTION_MOVE, event_time, x3, y3); |
+ action_move.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); |
+ action_move.set_button_state(0); |
+ EXPECT_TRUE(selector_->OnTouchEvent(action_move)); |
+ EXPECT_EQ(3u, event_log_.size()); // NO CHANGE |
+ |
+ // 7. ET_GESTURE_SCROLL_UPDATE without button |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ const GestureEventData second_scroll_update = |
+ CreateGesture(ui::ET_GESTURE_SCROLL_UPDATE, event_time, x3, y3); |
+ EXPECT_TRUE(selector_->OnGestureEvent(scroll_update)); |
+ EXPECT_EQ(3u, event_log_.size()); // NO CHANGE |
jdduke (slow)
2014/09/23 15:10:48
What if they press the button again?
|
+ |
+ // 8. ACTION_UP |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ MockMotionEvent action_up(MotionEvent::ACTION_UP, event_time, x3, y3); |
+ action_up.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); |
+ action_up.set_button_state(0); |
+ EXPECT_TRUE(selector_->OnTouchEvent(action_up)); |
+ EXPECT_EQ(3u, event_log_.size()); // NO CHANGE |
+ |
+ // 9. ET_GESTURE_SCROLL_END |
+ event_time += base::TimeDelta::FromMilliseconds(10); |
+ const GestureEventData scroll_end = |
+ CreateGesture(ui::ET_GESTURE_SCROLL_END, event_time, x3, y3); |
+ EXPECT_TRUE(selector_->OnGestureEvent(scroll_end)); |
+ EXPECT_EQ(3u, event_log_.size()); // NO CHANGE |
+} |
+ |
TEST_F(GestureTextSelectorTest, TapToSelectWord) { |
base::TimeTicks event_time = base::TimeTicks::Now(); |
const float x1 = 50.0f; |