Index: ui/events/gesture_detection/mock_motion_event.cc |
diff --git a/ui/events/gesture_detection/mock_motion_event.cc b/ui/events/gesture_detection/mock_motion_event.cc |
index 794bcba765207f932105b6988e5fd1040dd9f480..59d938e207d2d1f5bb183f4ca8210a739ce20273 100644 |
--- a/ui/events/gesture_detection/mock_motion_event.cc |
+++ b/ui/events/gesture_detection/mock_motion_event.cc |
@@ -4,6 +4,8 @@ |
#include "ui/events/gesture_detection/mock_motion_event.h" |
+#include "base/logging.h" |
+ |
using base::TimeTicks; |
namespace ui { |
@@ -11,6 +13,12 @@ namespace { |
const float kTouchMajor = 10.f; |
} // namespace |
+MockMotionEvent::MockMotionEvent() |
+ : action(ACTION_CANCEL), pointer_count(1) {} |
+ |
+MockMotionEvent::MockMotionEvent(Action action) |
+ : action(action), pointer_count(1) {} |
+ |
MockMotionEvent::MockMotionEvent(Action action, |
TimeTicks time, |
float x, |
@@ -98,4 +106,38 @@ scoped_ptr<MotionEvent> MockMotionEvent::Cancel() const { |
return cancel_event.PassAs<MotionEvent>(); |
} |
+void MockMotionEvent::PressPoint(float x, float y) { |
+ // Reset the pointer count if the previously released and/or cancelled pointer |
+ // was the last pointer in the event. |
+ if (pointer_count == 1 && (action == ACTION_UP || action == ACTION_CANCEL)) |
+ pointer_count = 0; |
+ |
+ DCHECK_LT(pointer_count + 1, static_cast<size_t>(MAX_POINTERS)); |
+ points[pointer_count++] = gfx::PointF(x, y); |
+ action = pointer_count > 1 ? ACTION_POINTER_DOWN : ACTION_DOWN; |
+} |
+ |
+void MockMotionEvent::MovePoint(size_t index, float x, float y) { |
+ DCHECK_LT(index, pointer_count); |
+ points[index] = gfx::PointF(x, y); |
+ action = ACTION_MOVE; |
+} |
+ |
+void MockMotionEvent::ReleasePoint() { |
+ DCHECK_GT(pointer_count, 0U); |
+ if (pointer_count > 1) { |
+ --pointer_count; |
+ action = ACTION_POINTER_UP; |
+ } else { |
+ action = ACTION_UP; |
+ } |
+} |
+ |
+void MockMotionEvent::CancelPoint() { |
+ DCHECK_GT(pointer_count, 0U); |
+ if (pointer_count > 1) |
+ --pointer_count; |
+ action = ACTION_CANCEL; |
+} |
+ |
} // namespace ui |