| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" | 8 #include "ui/events/gesture_detection/touch_disposition_gesture_filter.h" |
| 9 #include "ui/events/test/mock_motion_event.h" | 9 #include "ui/events/test/mock_motion_event.h" |
| 10 | 10 |
| 11 using ui::test::MockMotionEvent; | 11 using ui::test::MockMotionEvent; |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 const int kDefaultEventFlags = EF_ALT_DOWN | EF_SHIFT_DOWN; | 16 const int kDefaultEventFlags = EF_ALT_DOWN | EF_SHIFT_DOWN; |
| 17 | 17 |
| 18 } // namespace | 18 } // namespace |
| 19 | 19 |
| 20 class TouchDispositionGestureFilterTest | 20 class TouchDispositionGestureFilterTest |
| 21 : public testing::Test, | 21 : public testing::Test, |
| 22 public TouchDispositionGestureFilterClient { | 22 public TouchDispositionGestureFilterClient { |
| 23 public: | 23 public: |
| 24 TouchDispositionGestureFilterTest() | 24 TouchDispositionGestureFilterTest() |
| 25 : cancel_after_next_gesture_(false), sent_gesture_count_(0) {} | 25 : cancel_after_next_gesture_(false), sent_gesture_count_(0) {} |
| 26 virtual ~TouchDispositionGestureFilterTest() {} | 26 virtual ~TouchDispositionGestureFilterTest() {} |
| 27 | 27 |
| 28 // testing::Test | 28 // testing::Test |
| 29 virtual void SetUp() OVERRIDE { | 29 virtual void SetUp() override { |
| 30 queue_.reset(new TouchDispositionGestureFilter(this)); | 30 queue_.reset(new TouchDispositionGestureFilter(this)); |
| 31 touch_event_.set_flags(kDefaultEventFlags); | 31 touch_event_.set_flags(kDefaultEventFlags); |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual void TearDown() OVERRIDE { | 34 virtual void TearDown() override { |
| 35 queue_.reset(); | 35 queue_.reset(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // TouchDispositionGestureFilterClient | 38 // TouchDispositionGestureFilterClient |
| 39 virtual void ForwardGestureEvent(const GestureEventData& event) OVERRIDE { | 39 virtual void ForwardGestureEvent(const GestureEventData& event) override { |
| 40 ++sent_gesture_count_; | 40 ++sent_gesture_count_; |
| 41 last_sent_gesture_.reset(new GestureEventData(event)); | 41 last_sent_gesture_.reset(new GestureEventData(event)); |
| 42 sent_gestures_.push_back(event.type()); | 42 sent_gestures_.push_back(event.type()); |
| 43 if (event.type() == ET_GESTURE_SHOW_PRESS) | 43 if (event.type() == ET_GESTURE_SHOW_PRESS) |
| 44 show_press_bounding_box_ = event.details.bounding_box(); | 44 show_press_bounding_box_ = event.details.bounding_box(); |
| 45 if (cancel_after_next_gesture_) { | 45 if (cancel_after_next_gesture_) { |
| 46 cancel_after_next_gesture_ = false; | 46 cancel_after_next_gesture_ = false; |
| 47 CancelTouchPoint(); | 47 CancelTouchPoint(); |
| 48 SendTouchNotConsumedAck(); | 48 SendTouchNotConsumedAck(); |
| 49 } | 49 } |
| (...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 | 1144 |
| 1145 // Synthetic gestures lack flags. | 1145 // Synthetic gestures lack flags. |
| 1146 PressTouchPoint(1, 1); | 1146 PressTouchPoint(1, 1); |
| 1147 SendTouchNotConsumedAck(); | 1147 SendTouchNotConsumedAck(); |
| 1148 EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL), | 1148 EXPECT_TRUE(GesturesMatch(Gestures(ET_GESTURE_TAP_CANCEL), |
| 1149 GetAndResetSentGestures())); | 1149 GetAndResetSentGestures())); |
| 1150 EXPECT_EQ(0, LastSentGestureFlags()); | 1150 EXPECT_EQ(0, LastSentGestureFlags()); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 } // namespace ui | 1153 } // namespace ui |
| OLD | NEW |