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

Side by Side Diff: ui/events/test/motion_event_test_utils.cc

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « ui/events/test/motion_event_test_utils.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/gesture_detection/bitset_32.h" 10 #include "ui/events/gesture_detection/bitset_32.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 case ACTION_UP: 159 case ACTION_UP:
160 case ACTION_POINTER_UP: 160 case ACTION_POINTER_UP:
161 case ACTION_CANCEL: 161 case ACTION_CANCEL:
162 PopPointer(); 162 PopPointer();
163 return; 163 return;
164 default: 164 default:
165 break; 165 break;
166 } 166 }
167 } 167 }
168 168
169 void MockMotionEvent::SetPrimaryPointerId(int id) {
170 DCHECK_GT(GetPointerCount(), 0U);
171 pointer(0).id = id;
172 }
173
169 std::string ToString(const MotionEvent& event) { 174 std::string ToString(const MotionEvent& event) {
170 std::stringstream ss; 175 std::stringstream ss;
171 ss << "MotionEvent {" 176 ss << "MotionEvent {"
172 << "\n ID: " << event.GetId() << "\n Action: " << event.GetAction(); 177 << "\n Action: " << event.GetAction();
173 if (event.GetAction() == MotionEvent::ACTION_POINTER_DOWN || 178 if (event.GetAction() == MotionEvent::ACTION_POINTER_DOWN ||
174 event.GetAction() == MotionEvent::ACTION_POINTER_UP) 179 event.GetAction() == MotionEvent::ACTION_POINTER_UP)
175 ss << "\n ActionIndex: " << event.GetActionIndex(); 180 ss << "\n ActionIndex: " << event.GetActionIndex();
176 ss << "\n Flags: " << event.GetFlags() 181 ss << "\n Flags: " << event.GetFlags()
177 << "\n ButtonState: " << event.GetButtonState() << "\n Pointers: ["; 182 << "\n ButtonState: " << event.GetButtonState() << "\n Pointers: [";
178 const size_t pointer_count = event.GetPointerCount(); 183 const size_t pointer_count = event.GetPointerCount();
179 const size_t history_size = event.GetHistorySize(); 184 const size_t history_size = event.GetHistorySize();
180 185
181 BitSet32 pointer_ids; 186 BitSet32 pointer_ids;
182 for (size_t i = 0; i < pointer_count; ++i) { 187 for (size_t i = 0; i < pointer_count; ++i) {
183 pointer_ids.mark_bit(event.GetPointerId(i)); 188 pointer_ids.mark_bit(event.GetPointerId(i));
184 189
185 // Print the pointers sorted by id. 190 // Print the pointers sorted by id.
186 while (!pointer_ids.is_empty()) { 191 while (!pointer_ids.is_empty()) {
187 int pi = event.FindPointerIndexOfId(pointer_ids.first_marked_bit()); 192 int pi = event.FindPointerIndexOfId(pointer_ids.first_marked_bit());
188 DCHECK_GE(pi, 0); 193 DCHECK_GE(pi, 0);
189 pointer_ids.clear_first_marked_bit(); 194 pointer_ids.clear_first_marked_bit();
190 ss << "{" 195 ss << "{"
196 << "\n PointerId: (" << event.GetPointerId(pi) << ")"
191 << "\n Pos: (" << event.GetX(pi) << ", " << event.GetY(pi) << ")" 197 << "\n Pos: (" << event.GetX(pi) << ", " << event.GetY(pi) << ")"
192 << "\n RawPos: (" << event.GetX(pi) << ", " << event.GetY(pi) << ")" 198 << "\n RawPos: (" << event.GetX(pi) << ", " << event.GetY(pi) << ")"
193 << "\n Size: (" << event.GetTouchMajor(pi) << ", " 199 << "\n Size: (" << event.GetTouchMajor(pi) << ", "
194 << event.GetTouchMinor(pi) << ")" 200 << event.GetTouchMinor(pi) << ")"
195 << "\n Orientation: " << event.GetOrientation(pi) 201 << "\n Orientation: " << event.GetOrientation(pi)
196 << "\n Pressure: " << event.GetOrientation(pi) 202 << "\n Pressure: " << event.GetOrientation(pi)
197 << "\n Tool: " << event.GetToolType(pi); 203 << "\n Tool: " << event.GetToolType(pi);
198 if (history_size) { 204 if (history_size) {
199 ss << "\n History: ["; 205 ss << "\n History: [";
200 for (size_t h = 0; h < history_size; ++h) { 206 for (size_t h = 0; h < history_size; ++h) {
(...skipping 11 matching lines...) Expand all
212 ss << ", "; 218 ss << ", ";
213 } 219 }
214 ss << "]\n}"; 220 ss << "]\n}";
215 } 221 }
216 222
217 return ss.str(); 223 return ss.str();
218 } 224 }
219 225
220 } // namespace test 226 } // namespace test
221 } // namespace ui 227 } // namespace ui
OLDNEW
« 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