| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 396 |
| 397 void EventGenerator::ScrollSequence(const gfx::Point& start, | 397 void EventGenerator::ScrollSequence(const gfx::Point& start, |
| 398 const base::TimeDelta& step_delay, | 398 const base::TimeDelta& step_delay, |
| 399 float x_offset, | 399 float x_offset, |
| 400 float y_offset, | 400 float y_offset, |
| 401 int steps, | 401 int steps, |
| 402 int num_fingers) { | 402 int num_fingers) { |
| 403 base::TimeDelta timestamp = Now(); | 403 base::TimeDelta timestamp = Now(); |
| 404 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, | 404 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, |
| 405 start, | 405 start, |
| 406 start, |
| 406 timestamp, | 407 timestamp, |
| 407 0, | 408 0, |
| 408 0, 0, | 409 0, 0, |
| 409 0, 0, | 410 0, 0, |
| 410 num_fingers); | 411 num_fingers); |
| 411 Dispatch(&fling_cancel); | 412 Dispatch(&fling_cancel); |
| 412 | 413 |
| 413 float dx = x_offset / steps; | 414 float dx = x_offset / steps; |
| 414 float dy = y_offset / steps; | 415 float dy = y_offset / steps; |
| 415 for (int i = 0; i < steps; ++i) { | 416 for (int i = 0; i < steps; ++i) { |
| 416 timestamp += step_delay; | 417 timestamp += step_delay; |
| 417 ui::ScrollEvent move(ui::ET_SCROLL, | 418 ui::ScrollEvent move(ui::ET_SCROLL, |
| 418 start, | 419 start, |
| 420 start, |
| 419 timestamp, | 421 timestamp, |
| 420 0, | 422 0, |
| 421 dx, dy, | 423 dx, dy, |
| 422 dx, dy, | 424 dx, dy, |
| 423 num_fingers); | 425 num_fingers); |
| 424 Dispatch(&move); | 426 Dispatch(&move); |
| 425 } | 427 } |
| 426 | 428 |
| 427 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, | 429 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, |
| 428 start, | 430 start, |
| 431 start, |
| 429 timestamp, | 432 timestamp, |
| 430 0, | 433 0, |
| 431 x_offset, y_offset, | 434 x_offset, y_offset, |
| 432 x_offset, y_offset, | 435 x_offset, y_offset, |
| 433 num_fingers); | 436 num_fingers); |
| 434 Dispatch(&fling_start); | 437 Dispatch(&fling_start); |
| 435 } | 438 } |
| 436 | 439 |
| 437 void EventGenerator::ScrollSequence(const gfx::Point& start, | 440 void EventGenerator::ScrollSequence(const gfx::Point& start, |
| 438 const base::TimeDelta& step_delay, | 441 const base::TimeDelta& step_delay, |
| 439 const std::vector<gfx::PointF>& offsets, | 442 const std::vector<gfx::PointF>& offsets, |
| 440 int num_fingers) { | 443 int num_fingers) { |
| 441 size_t steps = offsets.size(); | 444 size_t steps = offsets.size(); |
| 442 base::TimeDelta timestamp = Now(); | 445 base::TimeDelta timestamp = Now(); |
| 443 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, | 446 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, |
| 444 start, | 447 start, |
| 448 start, |
| 445 timestamp, | 449 timestamp, |
| 446 0, | 450 0, |
| 447 0, 0, | 451 0, 0, |
| 448 0, 0, | 452 0, 0, |
| 449 num_fingers); | 453 num_fingers); |
| 450 Dispatch(&fling_cancel); | 454 Dispatch(&fling_cancel); |
| 451 | 455 |
| 452 for (size_t i = 0; i < steps; ++i) { | 456 for (size_t i = 0; i < steps; ++i) { |
| 453 timestamp += step_delay; | 457 timestamp += step_delay; |
| 454 ui::ScrollEvent scroll(ui::ET_SCROLL, | 458 ui::ScrollEvent scroll(ui::ET_SCROLL, |
| 455 start, | 459 start, |
| 460 start, |
| 456 timestamp, | 461 timestamp, |
| 457 0, | 462 0, |
| 458 offsets[i].x(), offsets[i].y(), | 463 offsets[i].x(), offsets[i].y(), |
| 459 offsets[i].x(), offsets[i].y(), | 464 offsets[i].x(), offsets[i].y(), |
| 460 num_fingers); | 465 num_fingers); |
| 461 Dispatch(&scroll); | 466 Dispatch(&scroll); |
| 462 } | 467 } |
| 463 | 468 |
| 464 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, | 469 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, |
| 465 start, | 470 start, |
| 471 start, |
| 466 timestamp, | 472 timestamp, |
| 467 0, | 473 0, |
| 468 offsets[steps - 1].x(), offsets[steps - 1].y(), | 474 offsets[steps - 1].x(), offsets[steps - 1].y(), |
| 469 offsets[steps - 1].x(), offsets[steps - 1].y(), | 475 offsets[steps - 1].x(), offsets[steps - 1].y(), |
| 470 num_fingers); | 476 num_fingers); |
| 471 Dispatch(&fling_start); | 477 Dispatch(&fling_start); |
| 472 } | 478 } |
| 473 | 479 |
| 474 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) { | 480 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) { |
| 475 DispatchKeyEvent(true, key_code, flags); | 481 DispatchKeyEvent(true, key_code, flags); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return default_delegate; | 629 return default_delegate; |
| 624 } | 630 } |
| 625 | 631 |
| 626 EventGeneratorDelegate* EventGenerator::delegate() { | 632 EventGeneratorDelegate* EventGenerator::delegate() { |
| 627 return const_cast<EventGeneratorDelegate*>( | 633 return const_cast<EventGeneratorDelegate*>( |
| 628 const_cast<const EventGenerator*>(this)->delegate()); | 634 const_cast<const EventGenerator*>(this)->delegate()); |
| 629 } | 635 } |
| 630 | 636 |
| 631 } // namespace test | 637 } // namespace test |
| 632 } // namespace ui | 638 } // namespace ui |
| OLD | NEW |