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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/test/motion_event_test_utils.h" 5 #include "ui/events/test/motion_event_test_utils.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/events/base_event_utils.h" 10 #include "ui/events/base_event_utils.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 float dx = x - p.x; 111 float dx = x - p.x;
112 float dy = x - p.y; 112 float dy = x - p.y;
113 p.x = x; 113 p.x = x;
114 p.y = y; 114 p.y = y;
115 p.raw_x += dx; 115 p.raw_x += dx;
116 p.raw_y += dy; 116 p.raw_y += dy;
117 set_action(ACTION_MOVE); 117 set_action(ACTION_MOVE);
118 return *this; 118 return *this;
119 } 119 }
120 120
121 MockMotionEvent& MockMotionEvent::ReleasePoint() { 121 MockMotionEvent& MockMotionEvent::ReleasePoint() {
tdresser 2016/07/22 15:57:45 It should be pretty easy to make this a thin wrapp
sahel 2016/07/22 19:46:42 Done.
122 UpdatePointersAndID(); 122 UpdatePointersAndID();
123 DCHECK_GT(GetPointerCount(), 0U); 123 DCHECK_GT(GetPointerCount(), 0U);
124 if (GetPointerCount() > 1) { 124 if (GetPointerCount() > 1) {
125 set_action_index(static_cast<int>(GetPointerCount()) - 1); 125 set_action_index(static_cast<int>(GetPointerCount()) - 1);
126 set_action(ACTION_POINTER_UP); 126 set_action(ACTION_POINTER_UP);
127 } else { 127 } else {
128 set_action(ACTION_UP); 128 set_action(ACTION_UP);
129 } 129 }
130 return *this; 130 return *this;
131 } 131 }
132 132
133 MockMotionEvent& MockMotionEvent::ReleasePointAt(size_t index) {
tdresser 2016/07/22 15:57:45 ReleasePointAtIndex? It's a bit confusing that we
sahel 2016/07/22 19:46:42 Done.
134 DCHECK_LT(index, GetPointerCount());
135 if (index == GetPointerCount() - 1)
136 return ReleasePoint();
137 set_unique_event_id(ui::GetNextTouchEventId());
138 RemovePointerAt(index);
139 set_action_index(index);
140 set_action(ACTION_POINTER_UP);
141 return *this;
142 }
143
133 MockMotionEvent& MockMotionEvent::CancelPoint() { 144 MockMotionEvent& MockMotionEvent::CancelPoint() {
134 UpdatePointersAndID(); 145 UpdatePointersAndID();
135 DCHECK_GT(GetPointerCount(), 0U); 146 DCHECK_GT(GetPointerCount(), 0U);
136 set_action(ACTION_CANCEL); 147 set_action(ACTION_CANCEL);
137 return *this; 148 return *this;
138 } 149 }
139 150
140 MockMotionEvent& MockMotionEvent::SetTouchMajor(float new_touch_major) { 151 MockMotionEvent& MockMotionEvent::SetTouchMajor(float new_touch_major) {
141 for (size_t i = 0; i < GetPointerCount(); ++i) 152 for (size_t i = 0; i < GetPointerCount(); ++i)
142 pointer(i).touch_major = new_touch_major; 153 pointer(i).touch_major = new_touch_major;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 ss << ", "; 243 ss << ", ";
233 } 244 }
234 ss << "]\n}"; 245 ss << "]\n}";
235 } 246 }
236 247
237 return ss.str(); 248 return ss.str();
238 } 249 }
239 250
240 } // namespace test 251 } // namespace test
241 } // namespace ui 252 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698