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/logging.h" | 6 #include "base/logging.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 gfx::RectF BoundsForSingleMockTouchAtLocation(float x, float y) { | 51 gfx::RectF BoundsForSingleMockTouchAtLocation(float x, float y) { |
52 float diameter = MockMotionEvent::TOUCH_MAJOR; | 52 float diameter = MockMotionEvent::TOUCH_MAJOR; |
53 return gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter); | 53 return gfx::RectF(x - diameter / 2, y - diameter / 2, diameter, diameter); |
54 } | 54 } |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 class GestureProviderTest : public testing::Test, public GestureProviderClient { | 58 class GestureProviderTest : public testing::Test, public GestureProviderClient { |
59 public: | 59 public: |
60 GestureProviderTest() {} | 60 GestureProviderTest() {} |
61 virtual ~GestureProviderTest() {} | 61 ~GestureProviderTest() override {} |
62 | 62 |
63 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | 63 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, |
64 MotionEvent::Action action, | 64 MotionEvent::Action action, |
65 float x, | 65 float x, |
66 float y) { | 66 float y) { |
67 return MockMotionEvent(action, event_time, x, y); | 67 return MockMotionEvent(action, event_time, x, y); |
68 } | 68 } |
69 | 69 |
70 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | 70 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, |
71 MotionEvent::Action action, | 71 MotionEvent::Action action, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return MockMotionEvent(); | 116 return MockMotionEvent(); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, | 120 static MockMotionEvent ObtainMotionEvent(base::TimeTicks event_time, |
121 MotionEvent::Action action) { | 121 MotionEvent::Action action) { |
122 return ObtainMotionEvent(event_time, action, kFakeCoordX, kFakeCoordY); | 122 return ObtainMotionEvent(event_time, action, kFakeCoordX, kFakeCoordY); |
123 } | 123 } |
124 | 124 |
125 // Test | 125 // Test |
126 virtual void SetUp() override { SetUpWithConfig(GetDefaultConfig()); } | 126 void SetUp() override { SetUpWithConfig(GetDefaultConfig()); } |
127 | 127 |
128 virtual void TearDown() override { | 128 void TearDown() override { |
129 gestures_.clear(); | 129 gestures_.clear(); |
130 gesture_provider_.reset(); | 130 gesture_provider_.reset(); |
131 } | 131 } |
132 | 132 |
133 // GestureProviderClient | 133 // GestureProviderClient |
134 virtual void OnGestureEvent(const GestureEventData& gesture) override { | 134 void OnGestureEvent(const GestureEventData& gesture) override { |
135 if (gesture.type() == ET_GESTURE_SCROLL_BEGIN) | 135 if (gesture.type() == ET_GESTURE_SCROLL_BEGIN) |
136 active_scroll_begin_event_.reset(new GestureEventData(gesture)); | 136 active_scroll_begin_event_.reset(new GestureEventData(gesture)); |
137 gestures_.push_back(gesture); | 137 gestures_.push_back(gesture); |
138 } | 138 } |
139 | 139 |
140 void SetUpWithConfig(const GestureProvider::Config& config) { | 140 void SetUpWithConfig(const GestureProvider::Config& config) { |
141 gesture_provider_.reset(new GestureProvider(config, this)); | 141 gesture_provider_.reset(new GestureProvider(config, this)); |
142 gesture_provider_->SetMultiTouchZoomSupportEnabled(false); | 142 gesture_provider_->SetMultiTouchZoomSupportEnabled(false); |
143 } | 143 } |
144 | 144 |
(...skipping 2348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); | 2493 EXPECT_TRUE(gesture_provider_->OnTouchEvent(event)); |
2494 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); | 2494 EXPECT_EQ(ET_GESTURE_TAP, GetMostRecentGestureEventType()); |
2495 | 2495 |
2496 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); | 2496 EXPECT_EQ(1, GetMostRecentGestureEvent().details.tap_count()); |
2497 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); | 2497 EXPECT_EQ(1, GetMostRecentGestureEvent().details.touch_points()); |
2498 EXPECT_EQ(gfx::RectF(0, 0, 20, 20), | 2498 EXPECT_EQ(gfx::RectF(0, 0, 20, 20), |
2499 GetMostRecentGestureEvent().details.bounding_box()); | 2499 GetMostRecentGestureEvent().details.bounding_box()); |
2500 } | 2500 } |
2501 | 2501 |
2502 } // namespace ui | 2502 } // namespace ui |
OLD | NEW |