Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: content/browser/renderer_host/input/gesture_text_selector_unittest.cc

Issue 590483002: Check if Button is pressed for changing selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per review and unittests updated Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698