OLD | NEW |
---|---|
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 Loading... | |
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); |
sadrul
2016/01/29 16:30:43
Can you explain why this change was necessary?
Navid Zolghadr
2016/02/01 15:41:33
Without this it was failing in one of the ASSERTs.
sadrul
2016/02/01 16:07:08
Which one?
Navid Zolghadr
2016/02/01 16:21:30
The test was this one WebContentsViewAuraTest.Repe
sadrul
2016/02/01 16:46:40
Interesting. Should PlatformTouchPointBuilder take
Navid Zolghadr
2016/02/01 16:53:14
Not sure how you like PlatformTouchPointBuilder ta
sadrul
2016/02/01 17:06:34
I was thinking 0.5? Or is that not the default pre
Navid Zolghadr
2016/02/01 17:54:48
I believe Mustaq can give a better answer here but
| |
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, |
402 int move_y) { | 405 int move_y) { |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |