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

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

Issue 1617863002: Set the correct pressure for pointer events based on force (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Applying comments Created 4 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 unified diff | Download patch
« no previous file with comments | « ui/events/event_unittest.cc ('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/event_generator.h" 5 #include "ui/events/test/event_generator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 363 }
364 364
365 void EventGenerator::GestureScrollSequenceWithCallback( 365 void EventGenerator::GestureScrollSequenceWithCallback(
366 const gfx::Point& start, 366 const gfx::Point& start,
367 const gfx::Point& end, 367 const gfx::Point& end,
368 const base::TimeDelta& step_delay, 368 const base::TimeDelta& step_delay,
369 int steps, 369 int steps,
370 const ScrollStepCallback& callback) { 370 const ScrollStepCallback& callback) {
371 const int kTouchId = 5; 371 const int kTouchId = 5;
372 base::TimeDelta timestamp = Now(); 372 base::TimeDelta timestamp = Now();
373 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, kTouchId, timestamp); 373 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, 0, kTouchId,
374 timestamp, 5.0f, 5.0f, 0.0f, 1.0f);
374 Dispatch(&press); 375 Dispatch(&press);
375 376
376 callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF()); 377 callback.Run(ui::ET_GESTURE_SCROLL_BEGIN, gfx::Vector2dF());
377 378
378 float dx = static_cast<float>(end.x() - start.x()) / steps; 379 float dx = static_cast<float>(end.x() - start.x()) / steps;
379 float dy = static_cast<float>(end.y() - start.y()) / steps; 380 float dy = static_cast<float>(end.y() - start.y()) / steps;
380 gfx::PointF location(start); 381 gfx::PointF location(start);
381 for (int i = 0; i < steps; ++i) { 382 for (int i = 0; i < steps; ++i) {
382 location.Offset(dx, dy); 383 location.Offset(dx, dy);
383 timestamp += step_delay; 384 timestamp += step_delay;
384 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), kTouchId, timestamp); 385 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), 0, kTouchId,
386 timestamp, 5.0f, 5.0f, 0.0f, 1.0f);
385 move.set_location_f(location); 387 move.set_location_f(location);
386 move.set_root_location_f(location); 388 move.set_root_location_f(location);
387 Dispatch(&move); 389 Dispatch(&move);
388 callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy)); 390 callback.Run(ui::ET_GESTURE_SCROLL_UPDATE, gfx::Vector2dF(dx, dy));
389 } 391 }
390 392
391 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, kTouchId, timestamp); 393 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, 0, kTouchId,
394 timestamp, 5.0f, 5.0f, 0.0f, 1.0f);
392 Dispatch(&release); 395 Dispatch(&release);
393 396
394 callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF()); 397 callback.Run(ui::ET_GESTURE_SCROLL_END, gfx::Vector2dF());
395 } 398 }
396 399
397 void EventGenerator::GestureMultiFingerScroll(int count, 400 void EventGenerator::GestureMultiFingerScroll(int count,
398 const gfx::Point start[], 401 const gfx::Point start[],
399 int event_separation_time_ms, 402 int event_separation_time_ms,
400 int steps, 403 int steps,
401 int move_x, 404 int move_x,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return default_delegate; 712 return default_delegate;
710 } 713 }
711 714
712 EventGeneratorDelegate* EventGenerator::delegate() { 715 EventGeneratorDelegate* EventGenerator::delegate() {
713 return const_cast<EventGeneratorDelegate*>( 716 return const_cast<EventGeneratorDelegate*>(
714 const_cast<const EventGenerator*>(this)->delegate()); 717 const_cast<const EventGenerator*>(this)->delegate());
715 } 718 }
716 719
717 } // namespace test 720 } // namespace test
718 } // namespace ui 721 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/event_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698