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

Unified Diff: ui/events/test/motion_event_test_utils.cc

Issue 2175803002: The helper functions for slop region check and subtraction are modified. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/test/motion_event_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/test/motion_event_test_utils.cc
diff --git a/ui/events/test/motion_event_test_utils.cc b/ui/events/test/motion_event_test_utils.cc
index ec052913d1e26f60013330464186868e18415a4d..ec2b0f0f5ee38d66027b6b484552db542bb6531a 100644
--- a/ui/events/test/motion_event_test_utils.cc
+++ b/ui/events/test/motion_event_test_utils.cc
@@ -119,10 +119,26 @@ MockMotionEvent& MockMotionEvent::MovePoint(size_t index, float x, float y) {
}
MockMotionEvent& MockMotionEvent::ReleasePoint() {
- UpdatePointersAndID();
DCHECK_GT(GetPointerCount(), 0U);
+ switch (GetAction()) {
+ // If the previous action is one of those who need removing a pointer in
+ // UpdatePointersAndID, then the last index will be GetPointerCount() - 2.
+ case ACTION_POINTER_UP:
+ case ACTION_UP:
+ case ACTION_CANCEL:
+ return ReleasePointAtIndex(GetPointerCount() - 2);
+ break;
+ default:
+ break;
+ }
+ return ReleasePointAtIndex(GetPointerCount() - 1);
+}
+
+MockMotionEvent& MockMotionEvent::ReleasePointAtIndex(size_t index) {
+ UpdatePointersAndID();
+ DCHECK_LT(index, GetPointerCount());
if (GetPointerCount() > 1) {
- set_action_index(static_cast<int>(GetPointerCount()) - 1);
+ set_action_index(static_cast<int>(index));
set_action(ACTION_POINTER_UP);
} else {
set_action(ACTION_UP);
@@ -165,17 +181,22 @@ void MockMotionEvent::PushPointer(float x, float y) {
}
void MockMotionEvent::UpdatePointersAndID() {
- set_action_index(-1);
set_unique_event_id(ui::GetNextTouchEventId());
switch (GetAction()) {
+ case ACTION_POINTER_UP: {
+ int index = GetActionIndex();
+ DCHECK_LT(index, static_cast<int>(GetPointerCount()));
+ RemovePointerAt(index);
+ break;
+ }
case ACTION_UP:
- case ACTION_POINTER_UP:
case ACTION_CANCEL:
PopPointer();
- return;
+ break;
default:
break;
}
+ set_action_index(-1);
}
MockMotionEvent& MockMotionEvent::SetPrimaryPointerId(int id) {
« no previous file with comments | « ui/events/test/motion_event_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698