OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 class TimedEvents { | 482 class TimedEvents { |
483 private: | 483 private: |
484 int simulated_now_; | 484 int simulated_now_; |
485 | 485 |
486 public: | 486 public: |
487 // Use a non-zero start time to pass DCHECKs which ensure events have had a | 487 // Use a non-zero start time to pass DCHECKs which ensure events have had a |
488 // time assigned. | 488 // time assigned. |
489 TimedEvents() : simulated_now_(1) { | 489 TimedEvents() : simulated_now_(1) { |
490 } | 490 } |
491 | 491 |
492 base::TimeDelta Now() { | 492 base::TimeTicks Now() { |
493 base::TimeDelta t = base::TimeDelta::FromMilliseconds(simulated_now_); | 493 base::TimeTicks t = base::TimeTicks::FromInternalValue(simulated_now_); |
494 simulated_now_++; | 494 simulated_now_++; |
495 return t; | 495 return t; |
496 } | 496 } |
497 | 497 |
498 base::TimeDelta LeapForward(int time_in_millis) { | 498 base::TimeTicks LeapForward(int time_in_millis) { |
499 simulated_now_ += time_in_millis; | 499 simulated_now_ += time_in_millis; |
500 return base::TimeDelta::FromMilliseconds(simulated_now_); | 500 return base::TimeTicks::FromInternalValue(simulated_now_); |
501 } | 501 } |
502 | 502 |
503 base::TimeDelta InFuture(int time_in_millis) { | 503 base::TimeTicks InFuture(int time_in_millis) { |
504 return base::TimeDelta::FromMilliseconds(simulated_now_ + time_in_millis); | 504 return base::TimeTicks::FromInternalValue(simulated_now_ + time_in_millis); |
505 } | 505 } |
506 | 506 |
507 void SendScrollEvents(ui::EventProcessor* dispatcher, | 507 void SendScrollEvents(ui::EventProcessor* dispatcher, |
508 int x_start, | 508 int x_start, |
509 int y_start, | 509 int y_start, |
510 int dx, | 510 int dx, |
511 int dy, | 511 int dy, |
512 int touch_id, | 512 int touch_id, |
513 int time_step, | 513 int time_step, |
514 int num_steps, | 514 int num_steps, |
515 GestureEventConsumeDelegate* delegate) { | 515 GestureEventConsumeDelegate* delegate) { |
516 float x = x_start; | 516 float x = x_start; |
517 float y = y_start; | 517 float y = y_start; |
518 | 518 |
519 for (int i = 0; i < num_steps; i++) { | 519 for (int i = 0; i < num_steps; i++) { |
520 x += dx; | 520 x += dx; |
521 y += dy; | 521 y += dy; |
522 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id, | 522 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(x, y), touch_id, |
523 base::TimeDelta::FromMilliseconds(simulated_now_)); | 523 base::TimeTicks::FromInternalValue(simulated_now_)); |
524 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 524 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
525 ASSERT_FALSE(details.dispatcher_destroyed); | 525 ASSERT_FALSE(details.dispatcher_destroyed); |
526 simulated_now_ += time_step; | 526 simulated_now_ += time_step; |
527 } | 527 } |
528 } | 528 } |
529 | 529 |
530 void SendScrollEvent(ui::EventProcessor* dispatcher, | 530 void SendScrollEvent(ui::EventProcessor* dispatcher, |
531 float x, | 531 float x, |
532 float y, | 532 float y, |
533 int touch_id, | 533 int touch_id, |
534 GestureEventConsumeDelegate* delegate) { | 534 GestureEventConsumeDelegate* delegate) { |
535 delegate->Reset(); | 535 delegate->Reset(); |
536 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), touch_id, | 536 ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(), touch_id, |
537 base::TimeDelta::FromMilliseconds(simulated_now_)); | 537 base::TimeTicks::FromInternalValue(simulated_now_)); |
538 move.set_location_f(gfx::PointF(x, y)); | 538 move.set_location_f(gfx::PointF(x, y)); |
539 move.set_root_location_f(gfx::PointF(x, y)); | 539 move.set_root_location_f(gfx::PointF(x, y)); |
540 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 540 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
541 ASSERT_FALSE(details.dispatcher_destroyed); | 541 ASSERT_FALSE(details.dispatcher_destroyed); |
542 simulated_now_++; | 542 simulated_now_++; |
543 } | 543 } |
544 }; | 544 }; |
545 | 545 |
546 // An event handler to keep track of events. | 546 // An event handler to keep track of events. |
547 class TestEventHandler : public ui::EventHandler { | 547 class TestEventHandler : public ui::EventHandler { |
(...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4442 EXPECT_FALSE(queued_delegate2->long_press()); | 4442 EXPECT_FALSE(queued_delegate2->long_press()); |
4443 | 4443 |
4444 queued_delegate->Reset(); | 4444 queued_delegate->Reset(); |
4445 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); | 4445 queued_delegate->WaitUntilReceivedGesture(ui::ET_GESTURE_SHOW_PRESS); |
4446 EXPECT_TRUE(queued_delegate->show_press()); | 4446 EXPECT_TRUE(queued_delegate->show_press()); |
4447 EXPECT_FALSE(queued_delegate->tap_down()); | 4447 EXPECT_FALSE(queued_delegate->tap_down()); |
4448 } | 4448 } |
4449 | 4449 |
4450 } // namespace test | 4450 } // namespace test |
4451 } // namespace aura | 4451 } // namespace aura |
OLD | NEW |