| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 406 |
| 407 void EventGenerator::ScrollSequence(const gfx::Point& start, | 407 void EventGenerator::ScrollSequence(const gfx::Point& start, |
| 408 const base::TimeDelta& step_delay, | 408 const base::TimeDelta& step_delay, |
| 409 float x_offset, | 409 float x_offset, |
| 410 float y_offset, | 410 float y_offset, |
| 411 int steps, | 411 int steps, |
| 412 int num_fingers) { | 412 int num_fingers) { |
| 413 base::TimeDelta timestamp = Now(); | 413 base::TimeDelta timestamp = Now(); |
| 414 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, | 414 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, |
| 415 start, | 415 start, |
| 416 start, |
| 416 timestamp, | 417 timestamp, |
| 417 0, | 418 0, |
| 418 0, 0, | 419 0, 0, |
| 419 0, 0, | 420 0, 0, |
| 420 num_fingers); | 421 num_fingers); |
| 421 Dispatch(&fling_cancel); | 422 Dispatch(&fling_cancel); |
| 422 | 423 |
| 423 float dx = x_offset / steps; | 424 float dx = x_offset / steps; |
| 424 float dy = y_offset / steps; | 425 float dy = y_offset / steps; |
| 425 for (int i = 0; i < steps; ++i) { | 426 for (int i = 0; i < steps; ++i) { |
| 426 timestamp += step_delay; | 427 timestamp += step_delay; |
| 427 ui::ScrollEvent move(ui::ET_SCROLL, | 428 ui::ScrollEvent move(ui::ET_SCROLL, |
| 428 start, | 429 start, |
| 430 start, |
| 429 timestamp, | 431 timestamp, |
| 430 0, | 432 0, |
| 431 dx, dy, | 433 dx, dy, |
| 432 dx, dy, | 434 dx, dy, |
| 433 num_fingers); | 435 num_fingers); |
| 434 Dispatch(&move); | 436 Dispatch(&move); |
| 435 } | 437 } |
| 436 | 438 |
| 437 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, | 439 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, |
| 438 start, | 440 start, |
| 441 start, |
| 439 timestamp, | 442 timestamp, |
| 440 0, | 443 0, |
| 441 x_offset, y_offset, | 444 x_offset, y_offset, |
| 442 x_offset, y_offset, | 445 x_offset, y_offset, |
| 443 num_fingers); | 446 num_fingers); |
| 444 Dispatch(&fling_start); | 447 Dispatch(&fling_start); |
| 445 } | 448 } |
| 446 | 449 |
| 447 void EventGenerator::ScrollSequence(const gfx::Point& start, | 450 void EventGenerator::ScrollSequence(const gfx::Point& start, |
| 448 const base::TimeDelta& step_delay, | 451 const base::TimeDelta& step_delay, |
| 449 const std::vector<gfx::PointF>& offsets, | 452 const std::vector<gfx::PointF>& offsets, |
| 450 int num_fingers) { | 453 int num_fingers) { |
| 451 size_t steps = offsets.size(); | 454 size_t steps = offsets.size(); |
| 452 base::TimeDelta timestamp = Now(); | 455 base::TimeDelta timestamp = Now(); |
| 453 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, | 456 ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL, |
| 454 start, | 457 start, |
| 458 start, |
| 455 timestamp, | 459 timestamp, |
| 456 0, | 460 0, |
| 457 0, 0, | 461 0, 0, |
| 458 0, 0, | 462 0, 0, |
| 459 num_fingers); | 463 num_fingers); |
| 460 Dispatch(&fling_cancel); | 464 Dispatch(&fling_cancel); |
| 461 | 465 |
| 462 for (size_t i = 0; i < steps; ++i) { | 466 for (size_t i = 0; i < steps; ++i) { |
| 463 timestamp += step_delay; | 467 timestamp += step_delay; |
| 464 ui::ScrollEvent scroll(ui::ET_SCROLL, | 468 ui::ScrollEvent scroll(ui::ET_SCROLL, |
| 465 start, | 469 start, |
| 470 start, |
| 466 timestamp, | 471 timestamp, |
| 467 0, | 472 0, |
| 468 offsets[i].x(), offsets[i].y(), | 473 offsets[i].x(), offsets[i].y(), |
| 469 offsets[i].x(), offsets[i].y(), | 474 offsets[i].x(), offsets[i].y(), |
| 470 num_fingers); | 475 num_fingers); |
| 471 Dispatch(&scroll); | 476 Dispatch(&scroll); |
| 472 } | 477 } |
| 473 | 478 |
| 474 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, | 479 ui::ScrollEvent fling_start(ui::ET_SCROLL_FLING_START, |
| 475 start, | 480 start, |
| 481 start, |
| 476 timestamp, | 482 timestamp, |
| 477 0, | 483 0, |
| 478 offsets[steps - 1].x(), offsets[steps - 1].y(), | 484 offsets[steps - 1].x(), offsets[steps - 1].y(), |
| 479 offsets[steps - 1].x(), offsets[steps - 1].y(), | 485 offsets[steps - 1].x(), offsets[steps - 1].y(), |
| 480 num_fingers); | 486 num_fingers); |
| 481 Dispatch(&fling_start); | 487 Dispatch(&fling_start); |
| 482 } | 488 } |
| 483 | 489 |
| 484 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) { | 490 void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) { |
| 485 DispatchKeyEvent(true, key_code, flags); | 491 DispatchKeyEvent(true, key_code, flags); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 return default_delegate; | 639 return default_delegate; |
| 634 } | 640 } |
| 635 | 641 |
| 636 EventGeneratorDelegate* EventGenerator::delegate() { | 642 EventGeneratorDelegate* EventGenerator::delegate() { |
| 637 return const_cast<EventGeneratorDelegate*>( | 643 return const_cast<EventGeneratorDelegate*>( |
| 638 const_cast<const EventGenerator*>(this)->delegate()); | 644 const_cast<const EventGenerator*>(this)->delegate()); |
| 639 } | 645 } |
| 640 | 646 |
| 641 } // namespace test | 647 } // namespace test |
| 642 } // namespace ui | 648 } // namespace ui |
| OLD | NEW |