Chromium Code Reviews| 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 2d162458a97cf5831fe6e583dad96966355b88a4..a950c8ac291055f4bd920b4bd57a9c7537c0584a 100644 | 
| --- a/content/browser/renderer_host/input/gesture_text_selector_unittest.cc | 
| +++ b/content/browser/renderer_host/input/gesture_text_selector_unittest.cc | 
| @@ -131,6 +131,61 @@ TEST_F(GestureTextSelectorTest, PenDragging) { | 
| ASSERT_EQ(2u, event_log_.size()); // NO CHANGE | 
| } | 
| +TEST_F(GestureTextSelectorTest, PenDraggingButtonNotPressed) { | 
| + base::TimeTicks event_time = base::TimeTicks::Now(); | 
| + float x = 50.0f; | 
| + float y = 30.0f; | 
| + | 
| + // 1. ACTION_DOWN with stylus + button | 
| + event_time += base::TimeDelta::FromMilliseconds(10); | 
| + MockMotionEvent action_down(MotionEvent::ACTION_DOWN, event_time, x, y); | 
| + 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); | 
| + x += 20; | 
| + y += 20; | 
| + MockMotionEvent action_move(MotionEvent::ACTION_MOVE, event_time, x, y); | 
| + action_move.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); | 
| + action_move.set_button_state(MotionEvent::BUTTON_SECONDARY); | 
| + EXPECT_TRUE(selector_->OnTouchEvent(action_move)); | 
| + ASSERT_EQ(2u, event_log_.size()); | 
| + EXPECT_STREQ("Show", event_log_[0].c_str()); | 
| + EXPECT_STREQ("SelectRange", event_log_[1].c_str()); | 
| + | 
| + // 3. ACTION_MOVE with stylus + no button | 
| + event_time += base::TimeDelta::FromMilliseconds(10); | 
| + x += 20; | 
| + y += 20; | 
| + action_move = MockMotionEvent(MotionEvent::ACTION_MOVE, event_time, x, y); | 
| + action_move.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); | 
| + action_move.set_button_state(0); | 
| + EXPECT_TRUE(selector_->OnTouchEvent(action_move)); | 
| + EXPECT_EQ(2u, event_log_.size()); // NO CHANGE | 
| + | 
| + // 4. ACTION_MOVE with stylus + button pressed again | 
| + event_time += base::TimeDelta::FromMilliseconds(10); | 
| + x += 20; | 
| + y += 20; | 
| + action_move = MockMotionEvent(MotionEvent::ACTION_MOVE, event_time, x, y); | 
| + action_move.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); | 
| + action_move.set_button_state(MotionEvent::BUTTON_SECONDARY); | 
| + EXPECT_TRUE(selector_->OnTouchEvent(action_move)); | 
| + EXPECT_EQ(4u, event_log_.size()); | 
| + EXPECT_STREQ("SelectRange", event_log_.back().c_str()); | 
| 
 
jdduke (slow)
2014/10/10 14:37:33
Ideally we could check the actual SelectRange coor
 
AviD
2014/10/10 16:06:11
I have added a function to convert the float value
 
 | 
| + | 
| + // 5. ACTION_UP | 
| + event_time += base::TimeDelta::FromMilliseconds(10); | 
| + MockMotionEvent action_up(MotionEvent::ACTION_UP, event_time, x, y); | 
| + action_up.SetToolType(0, MotionEvent::TOOL_TYPE_STYLUS); | 
| + action_up.set_button_state(0); | 
| + EXPECT_TRUE(selector_->OnTouchEvent(action_up)); | 
| + EXPECT_EQ(4u, event_log_.size()); // NO CHANGE | 
| +} | 
| + | 
| TEST_F(GestureTextSelectorTest, TapTriggersLongPressSelection) { | 
| base::TimeTicks event_time = base::TimeTicks::Now(); | 
| const float x1 = 50.0f; |