| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/event_utils.h" | 8 #include "ui/events/event_utils.h" |
| 9 #include "ui/events/gestures/gesture_provider_aura.h" | 9 #include "ui/events/gestures/gesture_provider_aura.h" |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 const int kTouchId1 = 3; | 71 const int kTouchId1 = 3; |
| 72 | 72 |
| 73 base::TimeDelta time = ui::EventTimeForNow(); | 73 base::TimeDelta time = ui::EventTimeForNow(); |
| 74 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time); | 74 TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::PointF(9, 10), kTouchId0, time); |
| 75 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1)); | 75 EXPECT_TRUE(provider()->OnTouchEvent(&press0_1)); |
| 76 | 76 |
| 77 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time); | 77 TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::PointF(40, 40), kTouchId1, time); |
| 78 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1)); | 78 EXPECT_TRUE(provider()->OnTouchEvent(&press1_1)); |
| 79 | 79 |
| 80 time += base::TimeDelta::FromMilliseconds(10); | 80 time += base::TimeDelta::FromMilliseconds(10); |
| 81 TouchEvent move0_1(ET_TOUCH_MOVED, | 81 TouchEvent move0_1(ET_TOUCH_MOVED, gfx::PointF(10, 10), 0, kTouchId0, time, |
| 82 gfx::PointF(10, 10), | 82 kAngle, |
| 83 0, | 83 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 84 kTouchId0, | 84 kRadiusX, kRadiusY, kForce, |
| 85 time, | 85 /* tilt_x */ 0.f, |
| 86 kRadiusX, | 86 /* tily_t */ 0.f)); |
| 87 kRadiusY, | |
| 88 kAngle, | |
| 89 kForce); | |
| 90 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1)); | 87 EXPECT_TRUE(provider()->OnTouchEvent(&move0_1)); |
| 91 | 88 |
| 92 TouchEvent move1_1(ET_TOUCH_MOVED, | 89 TouchEvent move1_1(ET_TOUCH_MOVED, gfx::PointF(100, 200), 0, kTouchId1, time, |
| 93 gfx::PointF(100, 200), | 90 kAngle, |
| 94 0, | 91 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 95 kTouchId1, | 92 kRadiusX, kRadiusY, kForce, |
| 96 time, | 93 /* tilt_x */ 0.f, |
| 97 kRadiusX, | 94 /* tily_t */ 0.f)); |
| 98 kRadiusY, | |
| 99 kAngle, | |
| 100 kForce); | |
| 101 EXPECT_TRUE(provider()->OnTouchEvent(&move1_1)); | 95 EXPECT_TRUE(provider()->OnTouchEvent(&move1_1)); |
| 102 | 96 |
| 103 time += base::TimeDelta::FromMilliseconds(10); | 97 time += base::TimeDelta::FromMilliseconds(10); |
| 104 TouchEvent move0_2(ET_TOUCH_MOVED, | 98 TouchEvent move0_2(ET_TOUCH_MOVED, gfx::PointF(10, 10), 0, kTouchId0, time, |
| 105 gfx::PointF(10, 10), | |
| 106 0, | |
| 107 kTouchId0, | |
| 108 time, | |
| 109 kRadiusX, | |
| 110 kRadiusY, | |
| 111 kAngle, | 99 kAngle, |
| 112 kForce); | 100 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 101 kRadiusX, kRadiusY, kForce, |
| 102 /* tilt_x */ 0.f, |
| 103 /* tily_t */ 0.f)); |
| 113 // Nothing has changed, so ignore the move. | 104 // Nothing has changed, so ignore the move. |
| 114 EXPECT_FALSE(provider()->OnTouchEvent(&move0_2)); | 105 EXPECT_FALSE(provider()->OnTouchEvent(&move0_2)); |
| 115 | 106 |
| 116 TouchEvent move1_2(ET_TOUCH_MOVED, | 107 TouchEvent move1_2(ET_TOUCH_MOVED, gfx::PointF(100, 200), 0, kTouchId1, time, |
| 117 gfx::PointF(100, 200), | |
| 118 0, | |
| 119 kTouchId1, | |
| 120 time, | |
| 121 kRadiusX, | |
| 122 kRadiusY, | |
| 123 kAngle, | 108 kAngle, |
| 124 kForce); | 109 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 110 kRadiusX, kRadiusY, kForce, |
| 111 /* tilt_x */ 0.f, |
| 112 /* tily_t */ 0.f)); |
| 125 // Nothing has changed, so ignore the move. | 113 // Nothing has changed, so ignore the move. |
| 126 EXPECT_FALSE(provider()->OnTouchEvent(&move1_2)); | 114 EXPECT_FALSE(provider()->OnTouchEvent(&move1_2)); |
| 127 | 115 |
| 128 time += base::TimeDelta::FromMilliseconds(10); | 116 time += base::TimeDelta::FromMilliseconds(10); |
| 129 TouchEvent move0_3(ET_TOUCH_MOVED, | 117 TouchEvent move0_3(ET_TOUCH_MOVED, gfx::PointF(70, 75.1f), 0, kTouchId0, time, |
| 130 gfx::PointF(70, 75.1f), | |
| 131 0, | |
| 132 kTouchId0, | |
| 133 time, | |
| 134 kRadiusX, | |
| 135 kRadiusY, | |
| 136 kAngle, | 118 kAngle, |
| 137 kForce); | 119 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 120 kRadiusX, kRadiusY, kForce, |
| 121 /* tilt_x */ 0.f, |
| 122 /* tily_t */ 0.f)); |
| 138 // Position has changed, so don't ignore the move. | 123 // Position has changed, so don't ignore the move. |
| 139 EXPECT_TRUE(provider()->OnTouchEvent(&move0_3)); | 124 EXPECT_TRUE(provider()->OnTouchEvent(&move0_3)); |
| 140 | 125 |
| 141 time += base::TimeDelta::FromMilliseconds(10); | 126 time += base::TimeDelta::FromMilliseconds(10); |
| 142 TouchEvent move0_4(ET_TOUCH_MOVED, | 127 TouchEvent move0_4(ET_TOUCH_MOVED, gfx::PointF(70, 75.1f), 0, kTouchId0, time, |
| 143 gfx::PointF(70, 75.1f), | |
| 144 0, | |
| 145 kTouchId0, | |
| 146 time, | |
| 147 kRadiusX, | |
| 148 kRadiusY + 1, | |
| 149 kAngle, | 128 kAngle, |
| 150 kForce); | 129 PointerEventDetails(EventPointerType::POINTER_TYPE_TOUCH, |
| 130 kRadiusX, kRadiusY + 1, kForce, |
| 131 /* tilt_x */ 0.f, |
| 132 /* tily_t */ 0.f)); |
| 151 } | 133 } |
| 152 | 134 |
| 153 // TODO(jdduke): Test whether event marked as scroll trigger. | 135 // TODO(jdduke): Test whether event marked as scroll trigger. |
| 154 | 136 |
| 155 } // namespace ui | 137 } // namespace ui |
| OLD | NEW |