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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 base::TimeDelta::FromMilliseconds(simulated_now_)); | 590 base::TimeDelta::FromMilliseconds(simulated_now_)); |
591 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); | 591 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&move); |
592 ASSERT_FALSE(details.dispatcher_destroyed); | 592 ASSERT_FALSE(details.dispatcher_destroyed); |
593 simulated_now_++; | 593 simulated_now_++; |
594 } | 594 } |
595 }; | 595 }; |
596 | 596 |
597 // An event handler to keep track of events. | 597 // An event handler to keep track of events. |
598 class TestEventHandler : public ui::EventHandler { | 598 class TestEventHandler : public ui::EventHandler { |
599 public: | 599 public: |
600 TestEventHandler() : touch_released_count_(0), touch_pressed_count_(0), | 600 TestEventHandler() : touch_released_count_(0), |
601 touch_moved_count_(0), touch_stationary_count_(0), | 601 touch_pressed_count_(0), |
| 602 touch_moved_count_(0), |
602 touch_cancelled_count_(0) { | 603 touch_cancelled_count_(0) { |
603 } | 604 } |
604 | 605 |
605 virtual ~TestEventHandler() {} | 606 virtual ~TestEventHandler() {} |
606 | 607 |
607 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | 608 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { |
608 switch (event->type()) { | 609 switch (event->type()) { |
609 case ui::ET_TOUCH_RELEASED: | 610 case ui::ET_TOUCH_RELEASED: |
610 touch_released_count_++; | 611 touch_released_count_++; |
611 break; | 612 break; |
612 case ui::ET_TOUCH_PRESSED: | 613 case ui::ET_TOUCH_PRESSED: |
613 touch_pressed_count_++; | 614 touch_pressed_count_++; |
614 break; | 615 break; |
615 case ui::ET_TOUCH_MOVED: | 616 case ui::ET_TOUCH_MOVED: |
616 touch_moved_count_++; | 617 touch_moved_count_++; |
617 break; | 618 break; |
618 case ui::ET_TOUCH_STATIONARY: | |
619 touch_stationary_count_++; | |
620 break; | |
621 case ui::ET_TOUCH_CANCELLED: | 619 case ui::ET_TOUCH_CANCELLED: |
622 touch_cancelled_count_++; | 620 touch_cancelled_count_++; |
623 break; | 621 break; |
624 default: | 622 default: |
625 break; | 623 break; |
626 } | 624 } |
627 } | 625 } |
628 | 626 |
629 void Reset() { | 627 void Reset() { |
630 touch_released_count_ = 0; | 628 touch_released_count_ = 0; |
631 touch_pressed_count_ = 0; | 629 touch_pressed_count_ = 0; |
632 touch_moved_count_ = 0; | 630 touch_moved_count_ = 0; |
633 touch_stationary_count_ = 0; | |
634 touch_cancelled_count_ = 0; | 631 touch_cancelled_count_ = 0; |
635 } | 632 } |
636 | 633 |
637 int touch_released_count() const { return touch_released_count_; } | 634 int touch_released_count() const { return touch_released_count_; } |
638 int touch_pressed_count() const { return touch_pressed_count_; } | 635 int touch_pressed_count() const { return touch_pressed_count_; } |
639 int touch_moved_count() const { return touch_moved_count_; } | 636 int touch_moved_count() const { return touch_moved_count_; } |
640 int touch_stationary_count() const { return touch_stationary_count_; } | |
641 int touch_cancelled_count() const { return touch_cancelled_count_; } | 637 int touch_cancelled_count() const { return touch_cancelled_count_; } |
642 | 638 |
643 private: | 639 private: |
644 int touch_released_count_; | 640 int touch_released_count_; |
645 int touch_pressed_count_; | 641 int touch_pressed_count_; |
646 int touch_moved_count_; | 642 int touch_moved_count_; |
647 int touch_stationary_count_; | |
648 int touch_cancelled_count_; | 643 int touch_cancelled_count_; |
649 | 644 |
650 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); | 645 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); |
651 }; | 646 }; |
652 | 647 |
653 // Removes the target window from its parent when it receives a touch-cancel | 648 // Removes the target window from its parent when it receives a touch-cancel |
654 // event. | 649 // event. |
655 class RemoveOnTouchCancelHandler : public TestEventHandler { | 650 class RemoveOnTouchCancelHandler : public TestEventHandler { |
656 public: | 651 public: |
657 RemoveOnTouchCancelHandler() {} | 652 RemoveOnTouchCancelHandler() {} |
(...skipping 3617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4275 DispatchEventUsingWindowDispatcher(&move1); | 4270 DispatchEventUsingWindowDispatcher(&move1); |
4276 EXPECT_NE(default_flags, delegate->flags()); | 4271 EXPECT_NE(default_flags, delegate->flags()); |
4277 } | 4272 } |
4278 | 4273 |
4279 INSTANTIATE_TEST_CASE_P(GestureRecognizer, | 4274 INSTANTIATE_TEST_CASE_P(GestureRecognizer, |
4280 GestureRecognizerTest, | 4275 GestureRecognizerTest, |
4281 ::testing::Bool()); | 4276 ::testing::Bool()); |
4282 | 4277 |
4283 } // namespace test | 4278 } // namespace test |
4284 } // namespace aura | 4279 } // namespace aura |
OLD | NEW |