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

Unified Diff: ui/events/gesture_detection/mock_motion_event.cc

Issue 181833003: [Android] Out with the Android GR, in with the new unified C++ GR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 10 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
« no previous file with comments | « ui/events/gesture_detection/mock_motion_event.h ('k') | ui/events/gesture_detection/motion_event.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/events/gesture_detection/mock_motion_event.h ('k') | ui/events/gesture_detection/motion_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698