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 "ui/chromeos/touch_exploration_controller.h" | 5 #include "ui/chromeos/touch_exploration_controller.h" |
6 | 6 |
7 #include "base/test/simple_test_tick_clock.h" | 7 #include "base/test/simple_test_tick_clock.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
11 #include "ui/aura/test/event_generator.h" | 11 #include "ui/aura/test/event_generator.h" |
12 #include "ui/aura/test/test_cursor_client.h" | 12 #include "ui/aura/test/test_cursor_client.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
15 #include "ui/events/event_utils.h" | 15 #include "ui/events/event_utils.h" |
16 #include "ui/events/gestures/gesture_provider_aura.h" | |
16 #include "ui/gfx/geometry/point.h" | 17 #include "ui/gfx/geometry/point.h" |
17 #include "ui/gl/gl_implementation.h" | 18 #include "ui/gl/gl_implementation.h" |
18 #include "ui/gl/gl_surface.h" | 19 #include "ui/gl/gl_surface.h" |
19 | 20 |
20 namespace ui { | 21 namespace ui { |
21 | 22 |
22 namespace { | 23 namespace { |
23 // Records all mouse and touch events. | 24 // Records all mouse, touch, gesture, and key events. |
24 class EventCapturer : public ui::EventHandler { | 25 class EventCapturer : public ui::EventHandler { |
25 public: | 26 public: |
26 EventCapturer() {} | 27 EventCapturer() {} |
27 virtual ~EventCapturer() {} | 28 virtual ~EventCapturer() {} |
28 | 29 |
29 void Reset() { | 30 void Reset() { |
30 events_.clear(); | 31 events_.clear(); |
31 } | 32 } |
32 | 33 |
33 virtual void OnEvent(ui::Event* event) OVERRIDE { | 34 virtual void OnEvent(ui::Event* event) OVERRIDE { |
34 if (event->IsMouseEvent()) { | 35 if (event->IsMouseEvent()) { |
35 events_.push_back( | 36 events_.push_back( |
36 new ui::MouseEvent(static_cast<ui::MouseEvent&>(*event))); | 37 new ui::MouseEvent(static_cast<ui::MouseEvent&>(*event))); |
37 } else if (event->IsTouchEvent()) { | 38 } else if (event->IsTouchEvent()) { |
38 events_.push_back( | 39 events_.push_back( |
39 new ui::TouchEvent(static_cast<ui::TouchEvent&>(*event))); | 40 new ui::TouchEvent(static_cast<ui::TouchEvent&>(*event))); |
41 } else if (event->IsGestureEvent()) { | |
42 events_.push_back( | |
43 new ui::GestureEvent(static_cast<ui::GestureEvent&>(*event))); | |
44 } else if (event->IsKeyEvent()) { | |
45 events_.push_back(new ui::KeyEvent(static_cast<ui::KeyEvent&>(*event))); | |
40 } else { | 46 } else { |
41 return; | 47 return; |
42 } | 48 } |
43 // Stop event propagation so we don't click on random stuff that | 49 // Stop event propagation so we don't click on random stuff that |
44 // might break test assumptions. | 50 // might break test assumptions. |
45 event->StopPropagation(); | 51 event->StopPropagation(); |
46 // If there is a possibility that we're in an infinite loop, we should | 52 // If there is a possibility that we're in an infinite loop, we should |
47 // exit early with a sensible error rather than letting the test time out. | 53 // exit early with a sensible error rather than letting the test time out. |
48 ASSERT_LT(events_.size(), 100u); | 54 ASSERT_LT(events_.size(), 100u); |
49 } | 55 } |
50 const ScopedVector<ui::LocatedEvent>& captured_events() const { | 56 |
51 return events_; | 57 const ScopedVector<ui::Event>& captured_events() const { return events_; } |
52 } | |
53 | 58 |
54 private: | 59 private: |
55 ScopedVector<ui::LocatedEvent> events_; | 60 ScopedVector<ui::Event> events_; |
56 | 61 |
57 DISALLOW_COPY_AND_ASSIGN(EventCapturer); | 62 DISALLOW_COPY_AND_ASSIGN(EventCapturer); |
58 }; | 63 }; |
59 | 64 |
60 } // namespace | 65 } // namespace |
61 | 66 |
62 class TouchExplorationTest : public aura::test::AuraTestBase { | 67 class TouchExplorationTest : public aura::test::AuraTestBase { |
63 public: | 68 public: |
64 TouchExplorationTest() | 69 TouchExplorationTest() |
65 : simulated_clock_(new base::SimpleTestTickClock()) {} | 70 : simulated_clock_(new base::SimpleTestTickClock()) {} |
(...skipping 15 matching lines...) Expand all Loading... | |
81 virtual void TearDown() OVERRIDE { | 86 virtual void TearDown() OVERRIDE { |
82 root_window()->RemovePreTargetHandler(&event_capturer_); | 87 root_window()->RemovePreTargetHandler(&event_capturer_); |
83 SwitchTouchExplorationMode(false); | 88 SwitchTouchExplorationMode(false); |
84 cursor_client_.reset(); | 89 cursor_client_.reset(); |
85 aura::test::AuraTestBase::TearDown(); | 90 aura::test::AuraTestBase::TearDown(); |
86 } | 91 } |
87 | 92 |
88 protected: | 93 protected: |
89 aura::client::CursorClient* cursor_client() { return cursor_client_.get(); } | 94 aura::client::CursorClient* cursor_client() { return cursor_client_.get(); } |
90 | 95 |
91 const ScopedVector<ui::LocatedEvent>& GetCapturedEvents() { | 96 const ScopedVector<ui::Event>& GetCapturedEvents() { |
92 return event_capturer_.captured_events(); | 97 return event_capturer_.captured_events(); |
93 } | 98 } |
94 | 99 |
95 std::vector<ui::LocatedEvent*> GetCapturedEventsOfType(int type) { | 100 std::vector<ui::LocatedEvent*> GetCapturedLocatedEvents() { |
96 const ScopedVector<ui::LocatedEvent>& all_events = GetCapturedEvents(); | 101 const ScopedVector<ui::Event>& all_events = GetCapturedEvents(); |
97 std::vector<ui::LocatedEvent*> events; | 102 std::vector<ui::LocatedEvent*> located_events; |
103 for (size_t i = 0; i < all_events.size(); ++i) { | |
104 if (all_events[i]->IsMouseEvent() || all_events[i]->IsTouchEvent() || | |
evy
2014/06/26 00:02:36
A previous comment from Dominic:
When there are m
| |
105 all_events[i]->IsGestureEvent()) { | |
106 located_events.push_back(static_cast<ui::LocatedEvent*>(all_events[i])); | |
107 } | |
108 } | |
109 return located_events; | |
110 } | |
111 | |
112 std::vector<ui::Event*> GetCapturedEventsOfType(int type) { | |
113 const ScopedVector<ui::Event>& all_events = GetCapturedEvents(); | |
114 std::vector<ui::Event*> events; | |
98 for (size_t i = 0; i < all_events.size(); ++i) { | 115 for (size_t i = 0; i < all_events.size(); ++i) { |
99 if (type == all_events[i]->type()) | 116 if (type == all_events[i]->type()) |
100 events.push_back(all_events[i]); | 117 events.push_back(all_events[i]); |
101 } | 118 } |
102 return events; | 119 return events; |
103 } | 120 } |
104 | 121 |
122 std::vector<ui::LocatedEvent*> GetCapturedLocatedEventsOfType(int type) { | |
123 std::vector<ui::LocatedEvent*> located_events = GetCapturedLocatedEvents(); | |
124 std::vector<ui::LocatedEvent*> events; | |
125 for (size_t i = 0; i < located_events.size(); ++i) { | |
126 if (type == located_events[i]->type()) | |
127 events.push_back(located_events[i]); | |
128 } | |
129 return events; | |
130 } | |
131 | |
105 void ClearCapturedEvents() { | 132 void ClearCapturedEvents() { |
106 event_capturer_.Reset(); | 133 event_capturer_.Reset(); |
107 } | 134 } |
108 | 135 |
109 void AdvanceSimulatedTimePastTapDelay() { | 136 void AdvanceSimulatedTimePastTapDelay() { |
110 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000)); | 137 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000)); |
111 touch_exploration_controller_->CallTapTimerNowForTesting(); | 138 touch_exploration_controller_->CallTapTimerNowForTesting(); |
112 } | 139 } |
113 | 140 |
114 void SwitchTouchExplorationMode(bool on) { | 141 void SwitchTouchExplorationMode(bool on) { |
(...skipping 21 matching lines...) Expand all Loading... | |
136 aura::client::GetCursorClient(root_window()); | 163 aura::client::GetCursorClient(root_window()); |
137 return cursor_client && | 164 return cursor_client && |
138 cursor_client->IsMouseEventsEnabled() && | 165 cursor_client->IsMouseEventsEnabled() && |
139 !cursor_client->IsCursorVisible(); | 166 !cursor_client->IsCursorVisible(); |
140 } | 167 } |
141 | 168 |
142 bool IsInNoFingersDownState() { | 169 bool IsInNoFingersDownState() { |
143 return touch_exploration_controller_->IsInNoFingersDownStateForTesting(); | 170 return touch_exploration_controller_->IsInNoFingersDownStateForTesting(); |
144 } | 171 } |
145 | 172 |
173 bool IsInGestureInProgressState() { | |
174 return touch_exploration_controller_ | |
175 ->IsInGestureInProgressStateForTesting(); | |
176 } | |
177 | |
146 base::TimeDelta Now() { | 178 base::TimeDelta Now() { |
147 // This is the same as what EventTimeForNow() does, but here we do it | 179 // This is the same as what EventTimeForNow() does, but here we do it |
148 // with our simulated clock. | 180 // with our simulated clock. |
149 return base::TimeDelta::FromInternalValue( | 181 return base::TimeDelta::FromInternalValue( |
150 simulated_clock_->NowTicks().ToInternalValue()); | 182 simulated_clock_->NowTicks().ToInternalValue()); |
151 } | 183 } |
152 | 184 |
153 scoped_ptr<aura::test::EventGenerator> generator_; | 185 scoped_ptr<aura::test::EventGenerator> generator_; |
154 ui::GestureDetector::Config gesture_detector_config_; | 186 ui::GestureDetector::Config gesture_detector_config_; |
155 // Owned by |generator_|. | 187 // Owned by |generator_|. |
(...skipping 27 matching lines...) Expand all Loading... | |
183 ASSERT_TRUE(e1->IsMouseEvent()); | 215 ASSERT_TRUE(e1->IsMouseEvent()); |
184 ASSERT_TRUE(e2->IsMouseEvent()); | 216 ASSERT_TRUE(e2->IsMouseEvent()); |
185 ui::MouseEvent* mouse_event1 = static_cast<ui::MouseEvent*>(e1); | 217 ui::MouseEvent* mouse_event1 = static_cast<ui::MouseEvent*>(e1); |
186 ui::MouseEvent* mouse_event2 = static_cast<ui::MouseEvent*>(e2); | 218 ui::MouseEvent* mouse_event2 = static_cast<ui::MouseEvent*>(e2); |
187 EXPECT_EQ(mouse_event1->type(), mouse_event2->type()); | 219 EXPECT_EQ(mouse_event1->type(), mouse_event2->type()); |
188 EXPECT_EQ(mouse_event1->location(), mouse_event2->location()); | 220 EXPECT_EQ(mouse_event1->location(), mouse_event2->location()); |
189 EXPECT_EQ(mouse_event1->root_location(), mouse_event2->root_location()); | 221 EXPECT_EQ(mouse_event1->root_location(), mouse_event2->root_location()); |
190 EXPECT_EQ(mouse_event1->flags(), mouse_event2->flags()); | 222 EXPECT_EQ(mouse_event1->flags(), mouse_event2->flags()); |
191 } | 223 } |
192 | 224 |
225 // Executes a number of assertions to confirm that |e1| and |e2| are key events | |
226 // and are equal to each other. | |
227 void ConfirmEventsAreKeyAndEqual(ui::Event* e1, ui::Event* e2) { | |
228 ASSERT_TRUE(e1->IsKeyEvent()); | |
229 ASSERT_TRUE(e2->IsKeyEvent()); | |
230 ui::KeyEvent* key_event1 = static_cast<ui::KeyEvent*>(e1); | |
231 ui::KeyEvent* key_event2 = static_cast<ui::KeyEvent*>(e2); | |
232 EXPECT_EQ(key_event1->type(), key_event2->type()); | |
233 EXPECT_EQ(key_event1->key_code(), key_event2->key_code()); | |
234 EXPECT_EQ(key_event1->code(), key_event2->code()); | |
235 EXPECT_EQ(key_event1->flags(), key_event2->flags()); | |
236 } | |
237 | |
193 #define CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(e1, e2) \ | 238 #define CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(e1, e2) \ |
194 ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreTouchAndEqual(e1, e2)) | 239 ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreTouchAndEqual(e1, e2)) |
195 | 240 |
196 #define CONFIRM_EVENTS_ARE_MOUSE_AND_EQUAL(e1, e2) \ | 241 #define CONFIRM_EVENTS_ARE_MOUSE_AND_EQUAL(e1, e2) \ |
197 ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreMouseAndEqual(e1, e2)) | 242 ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreMouseAndEqual(e1, e2)) |
198 | 243 |
244 #define CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(e1, e2) \ | |
245 ASSERT_NO_FATAL_FAILURE(ConfirmEventsAreKeyAndEqual(e1, e2)) | |
246 | |
199 // TODO(mfomitchev): Need to investigate why we don't get mouse enter/exit | 247 // TODO(mfomitchev): Need to investigate why we don't get mouse enter/exit |
200 // events when running these tests as part of ui_unittests. We do get them when | 248 // events when running these tests as part of ui_unittests. We do get them when |
201 // the tests are run as part of ash unit tests. | 249 // the tests are run as part of ash unit tests. |
202 | 250 |
251 // If a swipe has been successfully completed, then six key events will be | |
252 // dispatched that correspond to shift+search+direction | |
253 void AssertDirectionalNavigationEvents(const ScopedVector<ui::Event>& events, | |
254 ui::KeyboardCode direction) { | |
255 ASSERT_EQ(6U, events.size()); | |
256 std::vector<ui::KeyEvent> key_sequence; | |
257 ui::KeyEvent shift_pressed( | |
258 ui::ET_KEY_PRESSED, ui::VKEY_SHIFT, ui::EF_SHIFT_DOWN, false); | |
259 ui::KeyEvent search_pressed( | |
260 ui::ET_KEY_PRESSED, ui::VKEY_LWIN, ui::EF_SHIFT_DOWN, false); | |
261 ui::KeyEvent direction_pressed( | |
262 ui::ET_KEY_PRESSED, direction, ui::EF_SHIFT_DOWN, false); | |
263 ui::KeyEvent direction_released( | |
264 ui::ET_KEY_RELEASED, direction, ui::EF_SHIFT_DOWN, false); | |
265 ui::KeyEvent search_released( | |
266 ui::ET_KEY_RELEASED, VKEY_LWIN, ui::EF_SHIFT_DOWN, false); | |
267 ui::KeyEvent shift_released( | |
268 ui::ET_KEY_RELEASED, ui::VKEY_SHIFT, ui::EF_NONE, false); | |
269 CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&shift_pressed, | |
270 static_cast<ui::KeyEvent*>(events[0])); | |
271 CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&search_pressed, | |
272 static_cast<ui::KeyEvent*>(events[1])); | |
273 CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&direction_pressed, | |
274 static_cast<ui::KeyEvent*>(events[2])); | |
275 CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&direction_released, | |
276 static_cast<ui::KeyEvent*>(events[3])); | |
277 CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&search_released, | |
278 static_cast<ui::KeyEvent*>(events[4])); | |
279 CONFIRM_EVENTS_ARE_KEY_AND_EQUAL(&shift_released, | |
280 static_cast<ui::KeyEvent*>(events[5])); | |
281 } | |
282 | |
203 TEST_F(TouchExplorationTest, EntersTouchToMouseModeAfterPressAndDelay) { | 283 TEST_F(TouchExplorationTest, EntersTouchToMouseModeAfterPressAndDelay) { |
204 SwitchTouchExplorationMode(true); | 284 SwitchTouchExplorationMode(true); |
205 EXPECT_FALSE(IsInTouchToMouseMode()); | 285 EXPECT_FALSE(IsInTouchToMouseMode()); |
206 generator_->PressTouch(); | 286 generator_->PressTouch(); |
207 AdvanceSimulatedTimePastTapDelay(); | 287 AdvanceSimulatedTimePastTapDelay(); |
208 EXPECT_TRUE(IsInTouchToMouseMode()); | 288 EXPECT_TRUE(IsInTouchToMouseMode()); |
209 } | 289 } |
210 | 290 |
211 TEST_F(TouchExplorationTest, EntersTouchToMouseModeAfterMoveOutsideSlop) { | 291 TEST_F(TouchExplorationTest, EntersTouchToMouseModeAfterMoveOutsideSlop) { |
212 int slop = gesture_detector_config_.touch_slop; | 292 int slop = gesture_detector_config_.touch_slop; |
213 int half_slop = slop / 2; | 293 int half_slop = slop / 2; |
214 | 294 |
215 SwitchTouchExplorationMode(true); | 295 SwitchTouchExplorationMode(true); |
216 EXPECT_FALSE(IsInTouchToMouseMode()); | 296 EXPECT_FALSE(IsInTouchToMouseMode()); |
217 generator_->set_current_location(gfx::Point(11, 12)); | 297 generator_->set_current_location(gfx::Point(11, 12)); |
218 generator_->PressTouch(); | 298 generator_->PressTouch(); |
219 generator_->MoveTouch(gfx::Point(11 + half_slop, 12)); | 299 generator_->MoveTouch(gfx::Point(11 + half_slop, 12)); |
220 EXPECT_FALSE(IsInTouchToMouseMode()); | 300 EXPECT_FALSE(IsInTouchToMouseMode()); |
221 generator_->MoveTouch(gfx::Point(11, 12 + half_slop)); | 301 generator_->MoveTouch(gfx::Point(11, 12 + half_slop)); |
222 EXPECT_FALSE(IsInTouchToMouseMode()); | 302 EXPECT_FALSE(IsInTouchToMouseMode()); |
303 AdvanceSimulatedTimePastTapDelay(); | |
223 generator_->MoveTouch(gfx::Point(11 + slop + 1, 12)); | 304 generator_->MoveTouch(gfx::Point(11 + slop + 1, 12)); |
224 EXPECT_TRUE(IsInTouchToMouseMode()); | 305 EXPECT_TRUE(IsInTouchToMouseMode()); |
225 } | 306 } |
226 | 307 |
227 TEST_F(TouchExplorationTest, OneFingerTap) { | 308 TEST_F(TouchExplorationTest, OneFingerTap) { |
228 SwitchTouchExplorationMode(true); | 309 SwitchTouchExplorationMode(true); |
229 gfx::Point location(11, 12); | 310 gfx::Point location(11, 12); |
230 generator_->set_current_location(location); | 311 generator_->set_current_location(location); |
231 generator_->PressTouch(); | 312 generator_->PressTouch(); |
232 generator_->ReleaseTouch(); | 313 generator_->ReleaseTouch(); |
233 AdvanceSimulatedTimePastTapDelay(); | 314 AdvanceSimulatedTimePastTapDelay(); |
234 | 315 |
235 std::vector<ui::LocatedEvent*> events = | 316 std::vector<ui::LocatedEvent*> events = |
236 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 317 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
237 ASSERT_EQ(1U, events.size()); | 318 ASSERT_EQ(1U, events.size()); |
238 | 319 |
239 EXPECT_EQ(location, events[0]->location()); | 320 EXPECT_EQ(location, events[0]->location()); |
240 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 321 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
241 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 322 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
242 EXPECT_TRUE(IsInNoFingersDownState()); | 323 EXPECT_TRUE(IsInNoFingersDownState()); |
243 } | 324 } |
244 | 325 |
245 TEST_F(TouchExplorationTest, ActualMouseMovesUnaffected) { | 326 TEST_F(TouchExplorationTest, ActualMouseMovesUnaffected) { |
246 SwitchTouchExplorationMode(true); | 327 SwitchTouchExplorationMode(true); |
247 | 328 |
248 gfx::Point location_start(11, 12); | 329 gfx::Point location_start(11, 12); |
249 gfx::Point location_end(13, 14); | 330 gfx::Point location_end(13, 14); |
250 generator_->set_current_location(location_start); | 331 generator_->set_current_location(location_start); |
251 generator_->PressTouch(); | 332 generator_->PressTouch(); |
252 AdvanceSimulatedTimePastTapDelay(); | 333 AdvanceSimulatedTimePastTapDelay(); |
253 generator_->MoveTouch(location_end); | 334 generator_->MoveTouch(location_end); |
254 | 335 |
255 gfx::Point location_real_mouse_move(15, 16); | 336 gfx::Point location_real_mouse_move(15, 16); |
256 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, | 337 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, |
257 location_real_mouse_move, | 338 location_real_mouse_move, |
258 location_real_mouse_move, | 339 location_real_mouse_move, |
259 0, | 340 0, |
260 0); | 341 0); |
261 generator_->Dispatch(&mouse_move); | 342 generator_->Dispatch(&mouse_move); |
262 generator_->ReleaseTouch(); | 343 generator_->ReleaseTouch(); |
263 AdvanceSimulatedTimePastTapDelay(); | 344 AdvanceSimulatedTimePastTapDelay(); |
264 | 345 |
265 std::vector<ui::LocatedEvent*> events = | 346 std::vector<ui::LocatedEvent*> events = |
266 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 347 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
267 ASSERT_EQ(4U, events.size()); | 348 ASSERT_EQ(4U, events.size()); |
268 | 349 |
269 EXPECT_EQ(location_start, events[0]->location()); | 350 EXPECT_EQ(location_start, events[0]->location()); |
270 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 351 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
271 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 352 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
272 | 353 |
273 EXPECT_EQ(location_end, events[1]->location()); | 354 EXPECT_EQ(location_end, events[1]->location()); |
274 EXPECT_TRUE(events[1]->flags() & ui::EF_IS_SYNTHESIZED); | 355 EXPECT_TRUE(events[1]->flags() & ui::EF_IS_SYNTHESIZED); |
275 EXPECT_TRUE(events[1]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 356 EXPECT_TRUE(events[1]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
276 | 357 |
(...skipping 24 matching lines...) Expand all Loading... | |
301 // affected by the touch exploration mode, while the touch events from another | 382 // affected by the touch exploration mode, while the touch events from another |
302 // finger get rewritten. | 383 // finger get rewritten. |
303 SwitchTouchExplorationMode(true); | 384 SwitchTouchExplorationMode(true); |
304 ui::TouchEvent touch_move(ui::ET_TOUCH_MOVED, | 385 ui::TouchEvent touch_move(ui::ET_TOUCH_MOVED, |
305 gfx::Point(11, 12), | 386 gfx::Point(11, 12), |
306 1, | 387 1, |
307 Now()); | 388 Now()); |
308 generator_->Dispatch(&touch_move); | 389 generator_->Dispatch(&touch_move); |
309 EXPECT_TRUE(cursor_client()->IsCursorVisible()); | 390 EXPECT_TRUE(cursor_client()->IsCursorVisible()); |
310 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled()); | 391 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled()); |
311 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 392 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
312 ASSERT_EQ(1u, captured_events.size()); | 393 ASSERT_EQ(1u, captured_events.size()); |
313 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_move); | 394 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_move); |
314 ClearCapturedEvents(); | 395 ClearCapturedEvents(); |
315 | 396 |
316 // The press from the second finger should get rewritten. | 397 // The press from the second finger should get rewritten. |
317 generator_->PressTouchId(2); | 398 generator_->PressTouchId(2); |
318 AdvanceSimulatedTimePastTapDelay(); | 399 AdvanceSimulatedTimePastTapDelay(); |
319 EXPECT_TRUE(IsInTouchToMouseMode()); | 400 EXPECT_TRUE(IsInTouchToMouseMode()); |
320 ScopedVector<ui::LocatedEvent>::const_iterator it; | 401 captured_events = GetCapturedLocatedEvents(); |
402 std::vector<ui::LocatedEvent*>::const_iterator it; | |
321 for (it = captured_events.begin(); it != captured_events.end(); ++it) { | 403 for (it = captured_events.begin(); it != captured_events.end(); ++it) { |
322 if ((*it)->type() == ui::ET_MOUSE_MOVED) | 404 if ((*it)->type() == ui::ET_MOUSE_MOVED) |
323 break; | 405 break; |
324 } | 406 } |
325 EXPECT_NE(captured_events.end(), it); | 407 EXPECT_NE(captured_events.end(), it); |
326 ClearCapturedEvents(); | 408 ClearCapturedEvents(); |
327 | 409 |
328 // The release of the first finger shouldn't be affected. | 410 // The release of the first finger shouldn't be affected. |
329 ui::TouchEvent touch_release(ui::ET_TOUCH_RELEASED, | 411 ui::TouchEvent touch_release(ui::ET_TOUCH_RELEASED, |
330 gfx::Point(11, 12), | 412 gfx::Point(11, 12), |
331 1, | 413 1, |
332 Now()); | 414 Now()); |
333 generator_->Dispatch(&touch_release); | 415 generator_->Dispatch(&touch_release); |
416 captured_events = GetCapturedLocatedEvents(); | |
334 ASSERT_EQ(1u, captured_events.size()); | 417 ASSERT_EQ(1u, captured_events.size()); |
335 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_release); | 418 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_release); |
336 ClearCapturedEvents(); | 419 ClearCapturedEvents(); |
337 | 420 |
338 // The move and release from the second finger should get rewritten. | 421 // The move and release from the second finger should get rewritten. |
339 generator_->MoveTouchId(gfx::Point(13, 14), 2); | 422 generator_->MoveTouchId(gfx::Point(13, 14), 2); |
340 generator_->ReleaseTouchId(2); | 423 generator_->ReleaseTouchId(2); |
341 AdvanceSimulatedTimePastTapDelay(); | 424 AdvanceSimulatedTimePastTapDelay(); |
342 | 425 captured_events = GetCapturedLocatedEvents(); |
343 ASSERT_EQ(2u, captured_events.size()); | 426 ASSERT_EQ(2u, captured_events.size()); |
344 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); | 427 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); |
345 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); | 428 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); |
346 EXPECT_TRUE(IsInNoFingersDownState()); | 429 EXPECT_TRUE(IsInNoFingersDownState()); |
347 } | 430 } |
348 | 431 |
349 TEST_F(TouchExplorationTest, TwoFingerTouch) { | 432 TEST_F(TouchExplorationTest, TwoFingerTouch) { |
350 SwitchTouchExplorationMode(true); | 433 SwitchTouchExplorationMode(true); |
351 generator_->PressTouchId(1); | 434 generator_->PressTouchId(1); |
352 ClearCapturedEvents(); | 435 ClearCapturedEvents(); |
353 | 436 |
354 // Confirm events from the second finger go through as is. | 437 // Confirm events from the second finger go through as is. |
355 ui::TouchEvent touch_press( | 438 ui::TouchEvent touch_press( |
356 ui::ET_TOUCH_PRESSED, | 439 ui::ET_TOUCH_PRESSED, |
357 gfx::Point(10, 11), | 440 gfx::Point(10, 11), |
358 2, | 441 2, |
359 Now()); | 442 Now()); |
360 generator_->Dispatch(&touch_press); | 443 generator_->Dispatch(&touch_press); |
361 EXPECT_TRUE(cursor_client()->IsCursorVisible()); | 444 EXPECT_TRUE(cursor_client()->IsCursorVisible()); |
362 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled()); | 445 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled()); |
363 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 446 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
364 // TODO(mfomitchev): mouse enter/exit events | 447 // TODO(mfomitchev): mouse enter/exit events |
365 // There will be a ET_MOUSE_EXITED event synthesized when the mouse cursor is | 448 // There will be a ET_MOUSE_EXITED event synthesized when the mouse cursor is |
366 // hidden - ignore it. | 449 // hidden - ignore it. |
367 ScopedVector<ui::LocatedEvent>::const_iterator it; | 450 std::vector<ui::LocatedEvent*>::const_iterator it; |
368 for (it = captured_events.begin(); it != captured_events.end(); ++it) { | 451 for (it = captured_events.begin(); it != captured_events.end(); ++it) { |
369 if ((*it)->type() == ui::ET_TOUCH_PRESSED) { | 452 if ((*it)->type() == ui::ET_TOUCH_PRESSED) { |
370 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(*it, &touch_press); | 453 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(*it, &touch_press); |
371 break; | 454 break; |
372 } | 455 } |
373 } | 456 } |
374 EXPECT_NE(captured_events.end(), it); | 457 EXPECT_NE(captured_events.end(), it); |
375 ClearCapturedEvents(); | 458 ClearCapturedEvents(); |
376 ui::TouchEvent touch_move( | 459 ui::TouchEvent touch_move( |
377 ui::ET_TOUCH_MOVED, | 460 ui::ET_TOUCH_MOVED, |
378 gfx::Point(20, 21), | 461 gfx::Point(20, 21), |
379 2, | 462 2, |
380 Now()); | 463 Now()); |
381 generator_->Dispatch(&touch_move); | 464 generator_->Dispatch(&touch_move); |
465 captured_events = GetCapturedLocatedEvents(); | |
382 ASSERT_EQ(1u, captured_events.size()); | 466 ASSERT_EQ(1u, captured_events.size()); |
383 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_move); | 467 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch_move); |
384 ClearCapturedEvents(); | 468 ClearCapturedEvents(); |
385 | 469 |
386 // Confirm mouse moves go through unaffected. | 470 // Confirm mouse moves go through unaffected. |
387 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, | 471 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, |
388 gfx::Point(13, 14), | 472 gfx::Point(13, 14), |
389 gfx::Point(13, 14), | 473 gfx::Point(13, 14), |
390 0, | 474 0, |
391 0); | 475 0); |
392 generator_->Dispatch(&mouse_move); | 476 generator_->Dispatch(&mouse_move); |
393 // TODO(mfomitchev): mouse enter/exit events | 477 // TODO(mfomitchev): mouse enter/exit events |
394 // Ignore synthesized ET_MOUSE_ENTERED/ET_MOUSE_EXITED | 478 // Ignore synthesized ET_MOUSE_ENTERED/ET_MOUSE_EXITED |
479 captured_events = GetCapturedLocatedEvents(); | |
395 for (it = captured_events.begin(); it != captured_events.end(); ++it) { | 480 for (it = captured_events.begin(); it != captured_events.end(); ++it) { |
396 if ((*it)->type() == ui::ET_MOUSE_MOVED) { | 481 if ((*it)->type() == ui::ET_MOUSE_MOVED) { |
397 CONFIRM_EVENTS_ARE_MOUSE_AND_EQUAL(*it, &mouse_move); | 482 CONFIRM_EVENTS_ARE_MOUSE_AND_EQUAL(*it, &mouse_move); |
398 break; | 483 break; |
399 } | 484 } |
400 } | 485 } |
401 EXPECT_NE(captured_events.end(), it); | 486 EXPECT_NE(captured_events.end(), it); |
402 ClearCapturedEvents(); | 487 ClearCapturedEvents(); |
403 | 488 |
404 // Events from the first finger should not go through while the second finger | 489 // Events from the first finger should not go through while the second finger |
405 // is touching. | 490 // is touching. |
406 gfx::Point touch1_location = gfx::Point(15, 16); | 491 gfx::Point touch1_location = gfx::Point(15, 16); |
407 generator_->MoveTouchId(touch1_location, 1); | 492 generator_->MoveTouchId(touch1_location, 1); |
408 EXPECT_EQ(0u, GetCapturedEvents().size()); | 493 captured_events = GetCapturedLocatedEvents(); |
494 EXPECT_EQ(0u, GetCapturedLocatedEvents().size()); | |
tdresser
2014/06/26 13:31:49
It looks like you're caching |GetCapturedLocatedEv
| |
409 | 495 |
410 EXPECT_TRUE(cursor_client()->IsCursorVisible()); | 496 EXPECT_TRUE(cursor_client()->IsCursorVisible()); |
411 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled()); | 497 EXPECT_FALSE(cursor_client()->IsMouseEventsEnabled()); |
412 | 498 |
413 // A release of the second finger should be rewritten as a mouse move | 499 // A release of the second finger should be rewritten as a mouse move |
414 // of that finger to the |touch1_location| and we stay in passthrough | 500 // of that finger to the |touch1_location| and we stay in passthrough |
415 // mode. | 501 // mode. |
416 ui::TouchEvent touch_release( | 502 ui::TouchEvent touch_release( |
417 ui::ET_TOUCH_RELEASED, | 503 ui::ET_TOUCH_RELEASED, |
418 gfx::Point(25, 26), | 504 gfx::Point(25, 26), |
419 2, | 505 2, |
420 Now()); | 506 Now()); |
421 generator_->Dispatch(&touch_release); | 507 generator_->Dispatch(&touch_release); |
508 captured_events = GetCapturedLocatedEvents(); | |
422 EXPECT_FALSE(IsInTouchToMouseMode()); | 509 EXPECT_FALSE(IsInTouchToMouseMode()); |
423 ASSERT_EQ(captured_events.size(), 1u); | 510 ASSERT_EQ(captured_events.size(), 1u); |
424 EXPECT_EQ(touch1_location, captured_events[0]->location()); | 511 EXPECT_EQ(touch1_location, captured_events[0]->location()); |
425 } | 512 } |
426 | 513 |
427 TEST_F(TouchExplorationTest, MultiFingerTouch) { | 514 TEST_F(TouchExplorationTest, MultiFingerTouch) { |
428 SwitchTouchExplorationMode(true); | 515 SwitchTouchExplorationMode(true); |
429 generator_->PressTouchId(1); | 516 generator_->PressTouchId(1); |
430 generator_->PressTouchId(2); | 517 generator_->PressTouchId(2); |
431 ClearCapturedEvents(); | 518 ClearCapturedEvents(); |
(...skipping 28 matching lines...) Expand all Loading... | |
460 4, | 547 4, |
461 Now()); | 548 Now()); |
462 generator_->Dispatch(&touch3_press); | 549 generator_->Dispatch(&touch3_press); |
463 generator_->Dispatch(&touch3_move1); | 550 generator_->Dispatch(&touch3_move1); |
464 generator_->Dispatch(&touch4_press); | 551 generator_->Dispatch(&touch4_press); |
465 generator_->Dispatch(&touch3_move2); | 552 generator_->Dispatch(&touch3_move2); |
466 generator_->Dispatch(&touch4_move); | 553 generator_->Dispatch(&touch4_move); |
467 generator_->Dispatch(&touch3_release); | 554 generator_->Dispatch(&touch3_release); |
468 generator_->Dispatch(&touch4_release); | 555 generator_->Dispatch(&touch4_release); |
469 | 556 |
470 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 557 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
471 ASSERT_EQ(7u, captured_events.size()); | 558 ASSERT_EQ(7u, captured_events.size()); |
472 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch3_press); | 559 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch3_press); |
473 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[1], &touch3_move1); | 560 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[1], &touch3_move1); |
474 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[2], &touch4_press); | 561 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[2], &touch4_press); |
475 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[3], &touch3_move2); | 562 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[3], &touch3_move2); |
476 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[4], &touch4_move); | 563 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[4], &touch4_move); |
477 | 564 |
478 // The release of finger 3 is rewritten as a move to the former location | 565 // The release of finger 3 is rewritten as a move to the former location |
479 // of finger 1. | 566 // of finger 1. |
480 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[5]->type()); | 567 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[5]->type()); |
481 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[6], &touch4_release); | 568 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[6], &touch4_release); |
482 } | 569 } |
483 | 570 |
484 // Test the case when there are multiple fingers on the screen and the first | 571 // Test the case when there are multiple fingers on the screen and the first |
485 // finger is released. This should be ignored, but then the second finger | 572 // finger is released. This should be ignored, but then the second finger |
486 // release should be passed through. | 573 // release should be passed through. |
487 TEST_F(TouchExplorationTest, FirstFingerLifted) { | 574 TEST_F(TouchExplorationTest, FirstFingerLifted) { |
488 SwitchTouchExplorationMode(true); | 575 SwitchTouchExplorationMode(true); |
489 generator_->PressTouchId(1); | 576 generator_->PressTouchId(1); |
490 generator_->PressTouchId(2); | 577 generator_->PressTouchId(2); |
491 gfx::Point touch2_location(10, 11); | 578 gfx::Point touch2_location(10, 11); |
492 generator_->MoveTouchId(touch2_location, 2); | 579 generator_->MoveTouchId(touch2_location, 2); |
493 generator_->PressTouchId(3); | 580 generator_->PressTouchId(3); |
494 gfx::Point touch3_location(20, 21); | 581 gfx::Point touch3_location(20, 21); |
495 generator_->MoveTouchId(touch3_location, 3); | 582 generator_->MoveTouchId(touch3_location, 3); |
496 ClearCapturedEvents(); | 583 ClearCapturedEvents(); |
497 | 584 |
498 // Release of finger 1 should be ignored. | 585 // Release of finger 1 should be ignored. |
499 generator_->ReleaseTouchId(1); | 586 generator_->ReleaseTouchId(1); |
500 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 587 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
501 ASSERT_EQ(0u, captured_events.size()); | 588 ASSERT_EQ(0u, captured_events.size()); |
502 | 589 |
503 // Move of finger 2 should be passed through. | 590 // Move of finger 2 should be passed through. |
504 gfx::Point touch2_new_location(20, 11); | 591 gfx::Point touch2_new_location(20, 11); |
505 generator_->MoveTouchId(touch2_new_location, 2); | 592 generator_->MoveTouchId(touch2_new_location, 2); |
593 captured_events = GetCapturedLocatedEvents(); | |
506 ASSERT_EQ(1u, captured_events.size()); | 594 ASSERT_EQ(1u, captured_events.size()); |
507 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type()); | 595 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type()); |
508 EXPECT_EQ(touch2_new_location, captured_events[0]->location()); | 596 EXPECT_EQ(touch2_new_location, captured_events[0]->location()); |
509 ClearCapturedEvents(); | 597 ClearCapturedEvents(); |
510 | 598 |
511 // Release of finger 2 should be passed through. | 599 // Release of finger 2 should be passed through. |
512 ui::TouchEvent touch2_release( | 600 ui::TouchEvent touch2_release( |
513 ui::ET_TOUCH_RELEASED, | 601 ui::ET_TOUCH_RELEASED, |
514 gfx::Point(14, 15), | 602 gfx::Point(14, 15), |
515 2, | 603 2, |
516 Now()); | 604 Now()); |
517 generator_->Dispatch(&touch2_release); | 605 generator_->Dispatch(&touch2_release); |
606 captured_events = GetCapturedLocatedEvents(); | |
607 | |
518 ASSERT_EQ(1u, captured_events.size()); | 608 ASSERT_EQ(1u, captured_events.size()); |
609 EXPECT_EQ(touch2_release.type(), captured_events[0]->type()); | |
610 EXPECT_EQ(touch2_release.touch_id(), | |
611 (static_cast<ui::TouchEvent*>(captured_events[0]))->touch_id()); | |
519 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch2_release); | 612 CONFIRM_EVENTS_ARE_TOUCH_AND_EQUAL(captured_events[0], &touch2_release); |
520 } | 613 } |
521 | 614 |
522 // Test the case when there are multiple fingers on the screen and the | 615 // Test the case when there are multiple fingers on the screen and the |
523 // second finger is released. This should be rewritten as a move to the | 616 // second finger is released. This should be rewritten as a move to the |
524 // location of the first finger. | 617 // location of the first finger. |
525 TEST_F(TouchExplorationTest, SecondFingerLifted) { | 618 TEST_F(TouchExplorationTest, SecondFingerLifted) { |
526 SwitchTouchExplorationMode(true); | 619 SwitchTouchExplorationMode(true); |
527 gfx::Point touch1_location(0, 11); | 620 gfx::Point touch1_location(0, 11); |
528 generator_->set_current_location(touch1_location); | 621 generator_->set_current_location(touch1_location); |
529 generator_->PressTouchId(1); | 622 generator_->PressTouchId(1); |
530 generator_->PressTouchId(2); | 623 generator_->PressTouchId(2); |
531 gfx::Point touch2_location(10, 11); | 624 gfx::Point touch2_location(10, 11); |
532 generator_->MoveTouchId(touch2_location, 2); | 625 generator_->MoveTouchId(touch2_location, 2); |
533 generator_->PressTouchId(3); | 626 generator_->PressTouchId(3); |
534 gfx::Point touch3_location(20, 21); | 627 gfx::Point touch3_location(20, 21); |
535 generator_->MoveTouchId(touch3_location, 3); | 628 generator_->MoveTouchId(touch3_location, 3); |
536 ClearCapturedEvents(); | 629 ClearCapturedEvents(); |
537 | 630 |
538 // Release of finger 2 should be rewritten as a move to the location | 631 // Release of finger 2 should be rewritten as a move to the location |
539 // of the first finger. | 632 // of the first finger. |
540 generator_->ReleaseTouchId(2); | 633 generator_->ReleaseTouchId(2); |
541 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 634 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
542 ASSERT_EQ(1u, captured_events.size()); | 635 ASSERT_EQ(1u, captured_events.size()); |
543 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type()); | 636 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type()); |
544 EXPECT_EQ(2, static_cast<ui::TouchEvent*>(captured_events[0])->touch_id()); | 637 EXPECT_EQ(2, static_cast<ui::TouchEvent*>(captured_events[0])->touch_id()); |
545 EXPECT_EQ(touch1_location, captured_events[0]->location()); | 638 EXPECT_EQ(touch1_location, captured_events[0]->location()); |
546 ClearCapturedEvents(); | 639 ClearCapturedEvents(); |
547 | 640 |
548 // Move of finger 1 should be rewritten as a move of finger 2. | 641 // Move of finger 1 should be rewritten as a move of finger 2. |
549 gfx::Point touch1_new_location(0, 41); | 642 gfx::Point touch1_new_location(0, 41); |
550 generator_->MoveTouchId(touch1_new_location, 1); | 643 generator_->MoveTouchId(touch1_new_location, 1); |
644 captured_events = GetCapturedLocatedEvents(); | |
551 ASSERT_EQ(1u, captured_events.size()); | 645 ASSERT_EQ(1u, captured_events.size()); |
552 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type()); | 646 EXPECT_EQ(ui::ET_TOUCH_MOVED, captured_events[0]->type()); |
553 EXPECT_EQ(2, static_cast<ui::TouchEvent*>(captured_events[0])->touch_id()); | 647 EXPECT_EQ(2, static_cast<ui::TouchEvent*>(captured_events[0])->touch_id()); |
554 EXPECT_EQ(touch1_new_location, captured_events[0]->location()); | 648 EXPECT_EQ(touch1_new_location, captured_events[0]->location()); |
555 ClearCapturedEvents(); | 649 ClearCapturedEvents(); |
556 | 650 |
557 // Release of finger 1 should be rewritten as release of finger 2. | 651 // Release of finger 1 should be rewritten as release of finger 2. |
558 gfx::Point touch1_final_location(0, 41); | 652 gfx::Point touch1_final_location(0, 41); |
559 ui::TouchEvent touch1_release( | 653 ui::TouchEvent touch1_release( |
560 ui::ET_TOUCH_RELEASED, | 654 ui::ET_TOUCH_RELEASED, |
561 touch1_final_location, | 655 touch1_final_location, |
562 1, | 656 1, |
563 Now()); | 657 Now()); |
564 generator_->Dispatch(&touch1_release); | 658 generator_->Dispatch(&touch1_release); |
659 captured_events = GetCapturedLocatedEvents(); | |
565 ASSERT_EQ(1u, captured_events.size()); | 660 ASSERT_EQ(1u, captured_events.size()); |
566 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); | 661 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[0]->type()); |
567 EXPECT_EQ(2, static_cast<ui::TouchEvent*>(captured_events[0])->touch_id()); | 662 EXPECT_EQ(2, static_cast<ui::TouchEvent*>(captured_events[0])->touch_id()); |
568 EXPECT_EQ(touch1_final_location, captured_events[0]->location()); | 663 EXPECT_EQ(touch1_final_location, captured_events[0]->location()); |
569 } | 664 } |
570 | 665 |
571 // If an event is received after the double-tap timeout has elapsed, but | 666 // If an event is received after the double-tap timeout has elapsed, but |
572 // before the timer has fired, a mouse move should still be generated. | 667 // before the timer has fired, a mouse move should still be generated. |
573 TEST_F(TouchExplorationTest, TimerFiresLateDuringTouchExploration) { | 668 TEST_F(TouchExplorationTest, TimerFiresLateDuringTouchExploration) { |
574 SwitchTouchExplorationMode(true); | 669 SwitchTouchExplorationMode(true); |
575 | 670 |
576 // Send a press, then add another finger after the double-tap timeout. | 671 // Send a press, then add another finger after the double-tap timeout. |
577 generator_->PressTouchId(1); | 672 generator_->PressTouchId(1); |
578 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000)); | 673 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(1000)); |
579 generator_->PressTouchId(2); | 674 generator_->PressTouchId(2); |
580 std::vector<ui::LocatedEvent*> events = | 675 std::vector<ui::LocatedEvent*> events = |
581 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 676 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
582 ASSERT_EQ(1U, events.size()); | 677 ASSERT_EQ(1U, events.size()); |
583 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 678 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
584 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 679 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
585 | 680 |
586 generator_->ReleaseTouchId(2); | 681 generator_->ReleaseTouchId(2); |
587 generator_->ReleaseTouchId(1); | 682 generator_->ReleaseTouchId(1); |
588 AdvanceSimulatedTimePastTapDelay(); | 683 AdvanceSimulatedTimePastTapDelay(); |
589 EXPECT_TRUE(IsInNoFingersDownState()); | 684 EXPECT_TRUE(IsInNoFingersDownState()); |
590 } | 685 } |
591 | 686 |
(...skipping 12 matching lines...) Expand all Loading... | |
604 // Send a tap at location2, after the double-tap timeout, but before the | 699 // Send a tap at location2, after the double-tap timeout, but before the |
605 // timer fires. | 700 // timer fires. |
606 gfx::Point location1(33, 34); | 701 gfx::Point location1(33, 34); |
607 generator_->set_current_location(location1); | 702 generator_->set_current_location(location1); |
608 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(301)); | 703 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(301)); |
609 generator_->PressTouch(); | 704 generator_->PressTouch(); |
610 generator_->ReleaseTouch(); | 705 generator_->ReleaseTouch(); |
611 AdvanceSimulatedTimePastTapDelay(); | 706 AdvanceSimulatedTimePastTapDelay(); |
612 | 707 |
613 std::vector<ui::LocatedEvent*> events = | 708 std::vector<ui::LocatedEvent*> events = |
614 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 709 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
615 ASSERT_EQ(2U, events.size()); | 710 ASSERT_EQ(2U, events.size()); |
616 EXPECT_EQ(location0, events[0]->location()); | 711 EXPECT_EQ(location0, events[0]->location()); |
617 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 712 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
618 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 713 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
619 EXPECT_EQ(location1, events[1]->location()); | 714 EXPECT_EQ(location1, events[1]->location()); |
620 EXPECT_TRUE(events[1]->flags() & ui::EF_IS_SYNTHESIZED); | 715 EXPECT_TRUE(events[1]->flags() & ui::EF_IS_SYNTHESIZED); |
621 EXPECT_TRUE(events[1]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 716 EXPECT_TRUE(events[1]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
622 EXPECT_TRUE(IsInNoFingersDownState()); | 717 EXPECT_TRUE(IsInNoFingersDownState()); |
623 } | 718 } |
624 | 719 |
625 // Double-tapping should send a touch press and release through to the location | 720 // Double-tapping should send a touch press and release through to the location |
626 // of the last successful touch exploration. | 721 // of the last successful touch exploration. |
627 TEST_F(TouchExplorationTest, DoubleTap) { | 722 TEST_F(TouchExplorationTest, DoubleTap) { |
628 SwitchTouchExplorationMode(true); | 723 SwitchTouchExplorationMode(true); |
629 | 724 |
630 // Tap at one location, and get a mouse move event. | 725 // Tap at one location, and get a mouse move event. |
631 gfx::Point tap_location(11, 12); | 726 gfx::Point tap_location(11, 12); |
632 generator_->set_current_location(tap_location); | 727 generator_->set_current_location(tap_location); |
633 generator_->PressTouch(); | 728 generator_->PressTouch(); |
634 generator_->ReleaseTouch(); | 729 generator_->ReleaseTouch(); |
635 AdvanceSimulatedTimePastTapDelay(); | 730 AdvanceSimulatedTimePastTapDelay(); |
636 | 731 |
637 std::vector<ui::LocatedEvent*> events = | 732 std::vector<ui::LocatedEvent*> events = |
638 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 733 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
639 ASSERT_EQ(1U, events.size()); | 734 ASSERT_EQ(1U, events.size()); |
640 | 735 |
641 EXPECT_EQ(tap_location, events[0]->location()); | 736 EXPECT_EQ(tap_location, events[0]->location()); |
642 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 737 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
643 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 738 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
644 ClearCapturedEvents(); | 739 ClearCapturedEvents(); |
645 | 740 |
646 // Now double-tap at a different location. This should result in | 741 // Now double-tap at a different location. This should result in |
647 // a single touch press and release at the location of the tap, | 742 // a single touch press and release at the location of the tap, |
648 // not at the location of the double-tap. | 743 // not at the location of the double-tap. |
649 gfx::Point double_tap_location(33, 34); | 744 gfx::Point double_tap_location(33, 34); |
650 generator_->set_current_location(double_tap_location); | 745 generator_->set_current_location(double_tap_location); |
651 generator_->PressTouch(); | 746 generator_->PressTouch(); |
652 generator_->ReleaseTouch(); | 747 generator_->ReleaseTouch(); |
653 generator_->PressTouch(); | 748 generator_->PressTouch(); |
654 generator_->ReleaseTouch(); | 749 generator_->ReleaseTouch(); |
655 | 750 |
656 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 751 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
657 ASSERT_EQ(2U, captured_events.size()); | 752 ASSERT_EQ(2U, captured_events.size()); |
658 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 753 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
659 EXPECT_EQ(tap_location, captured_events[0]->location()); | 754 EXPECT_EQ(tap_location, captured_events[0]->location()); |
660 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 755 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
661 EXPECT_EQ(tap_location, captured_events[1]->location()); | 756 EXPECT_EQ(tap_location, captured_events[1]->location()); |
662 EXPECT_TRUE(IsInNoFingersDownState()); | 757 EXPECT_TRUE(IsInNoFingersDownState()); |
663 } | 758 } |
664 | 759 |
665 // Double-tapping where the user holds their finger down for the second time | 760 // Double-tapping where the user holds their finger down for the second time |
666 // for a longer press should send a touch press and released (right click) | 761 // for a longer press should send a touch press and released (right click) |
667 // to the location of the last successful touch exploration. | 762 // to the location of the last successful touch exploration. |
668 TEST_F(TouchExplorationTest, DoubleTapLongPress) { | 763 TEST_F(TouchExplorationTest, DoubleTapLongPress) { |
669 SwitchTouchExplorationMode(true); | 764 SwitchTouchExplorationMode(true); |
670 | 765 |
671 // Tap at one location, and get a mouse move event. | 766 // Tap at one location, and get a mouse move event. |
672 gfx::Point tap_location(11, 12); | 767 gfx::Point tap_location(11, 12); |
673 generator_->set_current_location(tap_location); | 768 generator_->set_current_location(tap_location); |
674 generator_->PressTouch(); | 769 generator_->PressTouch(); |
675 generator_->ReleaseTouch(); | 770 generator_->ReleaseTouch(); |
676 AdvanceSimulatedTimePastTapDelay(); | 771 AdvanceSimulatedTimePastTapDelay(); |
677 | 772 |
678 std::vector<ui::LocatedEvent*> events = | 773 std::vector<ui::LocatedEvent*> events = |
679 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 774 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
680 ASSERT_EQ(1U, events.size()); | 775 ASSERT_EQ(1U, events.size()); |
681 | 776 |
682 EXPECT_EQ(tap_location, events[0]->location()); | 777 EXPECT_EQ(tap_location, events[0]->location()); |
683 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 778 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
684 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 779 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
685 ClearCapturedEvents(); | 780 ClearCapturedEvents(); |
686 | 781 |
687 // Now double-tap and hold at a different location. | 782 // Now double-tap and hold at a different location. |
688 // This should result in a single touch long press and release | 783 // This should result in a single touch long press and release |
689 // at the location of the tap, not at the location of the double-tap. | 784 // at the location of the tap, not at the location of the double-tap. |
690 // There should be a time delay between the touch press and release. | 785 // There should be a time delay between the touch press and release. |
691 gfx::Point first_tap_location(33, 34); | 786 gfx::Point first_tap_location(33, 34); |
692 generator_->set_current_location(first_tap_location); | 787 generator_->set_current_location(first_tap_location); |
693 generator_->PressTouch(); | 788 generator_->PressTouch(); |
694 generator_->ReleaseTouch(); | 789 generator_->ReleaseTouch(); |
695 gfx::Point second_tap_location(23, 24); | 790 gfx::Point second_tap_location(23, 24); |
696 generator_->set_current_location(second_tap_location); | 791 generator_->set_current_location(second_tap_location); |
697 generator_->PressTouch(); | 792 generator_->PressTouch(); |
698 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 793 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
699 generator_->ReleaseTouch(); | 794 generator_->ReleaseTouch(); |
700 | 795 |
701 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 796 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
702 ASSERT_EQ(2U, captured_events.size()); | 797 ASSERT_EQ(2U, captured_events.size()); |
703 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 798 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
704 EXPECT_EQ(tap_location, captured_events[0]->location()); | 799 EXPECT_EQ(tap_location, captured_events[0]->location()); |
705 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 800 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
706 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 801 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
707 EXPECT_EQ(tap_location, captured_events[1]->location()); | 802 EXPECT_EQ(tap_location, captured_events[1]->location()); |
708 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 803 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
709 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 804 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
710 released_time - pressed_time); | 805 released_time - pressed_time); |
711 } | 806 } |
712 | 807 |
713 // Single-tapping should send a touch press and release through to the location | 808 // Single-tapping should send a touch press and release through to the location |
714 // of the last successful touch exploration if the grace period has not | 809 // of the last successful touch exploration if the grace period has not |
715 // elapsed. | 810 // elapsed. |
716 TEST_F(TouchExplorationTest, SingleTap) { | 811 TEST_F(TouchExplorationTest, SingleTap) { |
717 SwitchTouchExplorationMode(true); | 812 SwitchTouchExplorationMode(true); |
718 | 813 |
719 // Tap once to simulate a mouse moved event. | 814 // Tap once to simulate a mouse moved event. |
720 gfx::Point initial_location(11, 12); | 815 gfx::Point initial_location(11, 12); |
721 generator_->set_current_location(initial_location); | 816 generator_->set_current_location(initial_location); |
722 generator_->PressTouch(); | 817 generator_->PressTouch(); |
818 AdvanceSimulatedTimePastTapDelay(); | |
819 ClearCapturedEvents(); | |
723 | 820 |
724 // Move to another location for single tap | 821 // Move to another location for single tap |
725 gfx::Point tap_location(22, 23); | 822 gfx::Point tap_location(22, 23); |
726 generator_->MoveTouch(tap_location); | 823 generator_->MoveTouch(tap_location); |
727 generator_->ReleaseTouch(); | 824 generator_->ReleaseTouch(); |
728 | 825 |
729 // Allow time to pass within the grace period of releasing before | 826 // Allow time to pass within the grace period of releasing before |
730 // tapping again. | 827 // tapping again. |
731 gfx::Point final_location(33, 34); | 828 gfx::Point final_location(33, 34); |
732 generator_->set_current_location(final_location); | 829 generator_->set_current_location(final_location); |
733 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(250)); | 830 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(250)); |
734 generator_->PressTouch(); | 831 generator_->PressTouch(); |
735 generator_->ReleaseTouch(); | 832 generator_->ReleaseTouch(); |
736 | 833 |
737 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 834 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
738 ASSERT_EQ(4U, captured_events.size()); | 835 ASSERT_EQ(4U, captured_events.size()); |
739 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); | 836 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); |
740 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); | 837 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[1]->type()); |
741 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type()); | 838 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[2]->type()); |
742 EXPECT_EQ(tap_location, captured_events[2]->location()); | 839 EXPECT_EQ(tap_location, captured_events[2]->location()); |
743 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[3]->type()); | 840 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[3]->type()); |
744 EXPECT_EQ(tap_location, captured_events[3]->location()); | 841 EXPECT_EQ(tap_location, captured_events[3]->location()); |
745 } | 842 } |
746 | 843 |
747 // Double-tapping without coming from touch exploration (no previous touch | 844 // Double-tapping without coming from touch exploration (no previous touch |
748 // exploration event) should not generate any events. | 845 // exploration event) should not generate any events. |
749 TEST_F(TouchExplorationTest, DoubleTapNoTouchExplore) { | 846 TEST_F(TouchExplorationTest, DoubleTapNoTouchExplore) { |
750 SwitchTouchExplorationMode(true); | 847 SwitchTouchExplorationMode(true); |
751 | 848 |
752 // Double-tap without any previous touch. | 849 // Double-tap without any previous touch. |
753 // Touch exploration mode has not been entered, so there is no previous | 850 // Touch exploration mode has not been entered, so there is no previous |
754 // touch exploration event. The double-tap should be discarded, and no events | 851 // touch exploration event. The double-tap should be discarded, and no events |
755 // should be generated at all. | 852 // should be generated at all. |
756 gfx::Point double_tap_location(33, 34); | 853 gfx::Point double_tap_location(33, 34); |
757 generator_->set_current_location(double_tap_location); | 854 generator_->set_current_location(double_tap_location); |
758 generator_->PressTouch(); | 855 generator_->PressTouch(); |
759 generator_->ReleaseTouch(); | 856 generator_->ReleaseTouch(); |
760 generator_->PressTouch(); | 857 generator_->PressTouch(); |
761 generator_->ReleaseTouch(); | 858 generator_->ReleaseTouch(); |
762 | 859 |
763 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 860 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
764 ASSERT_EQ(0U, captured_events.size()); | 861 ASSERT_EQ(0U, captured_events.size()); |
765 } | 862 } |
766 | 863 |
767 // Tapping and releasing with a second finger when in touch exploration mode | 864 // Tapping and releasing with a second finger when in touch exploration mode |
768 // should send a touch press and released to the location of the last | 865 // should send a touch press and released to the location of the last |
769 // successful touch exploration and return to touch explore. | 866 // successful touch exploration and return to touch explore. |
770 TEST_F(TouchExplorationTest, SplitTap) { | 867 TEST_F(TouchExplorationTest, SplitTap) { |
771 SwitchTouchExplorationMode(true); | 868 SwitchTouchExplorationMode(true); |
772 gfx::Point initial_touch_location(11, 12); | 869 gfx::Point initial_touch_location(11, 12); |
773 gfx::Point second_touch_location(33, 34); | 870 gfx::Point second_touch_location(33, 34); |
774 | 871 |
775 // Tap and hold at one location, and get a mouse move event in touch explore. | 872 // Tap and hold at one location, and get a mouse move event in touch explore. |
776 EnterTouchExplorationModeAtLocation(initial_touch_location); | 873 EnterTouchExplorationModeAtLocation(initial_touch_location); |
777 std::vector<ui::LocatedEvent*> events = | 874 std::vector<ui::LocatedEvent*> events = |
778 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 875 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
779 ASSERT_EQ(1U, events.size()); | 876 ASSERT_EQ(1U, events.size()); |
780 | 877 |
781 EXPECT_EQ(initial_touch_location, events[0]->location()); | 878 EXPECT_EQ(initial_touch_location, events[0]->location()); |
782 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 879 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
783 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 880 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
784 ClearCapturedEvents(); | 881 ClearCapturedEvents(); |
785 | 882 |
786 // Now tap and release at a different location. This should result in a | 883 // Now tap and release at a different location. This should result in a |
787 // single touch and release at the location of the first (held) tap, | 884 // single touch and release at the location of the first (held) tap, |
788 // not at the location of the second tap and release. | 885 // not at the location of the second tap and release. |
789 // After the release, there is still a finger in touch explore mode. | 886 // After the release, there is still a finger in touch explore mode. |
790 ui::TouchEvent split_tap_press( | 887 ui::TouchEvent split_tap_press( |
791 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 888 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
792 generator_->Dispatch(&split_tap_press); | 889 generator_->Dispatch(&split_tap_press); |
793 ui::TouchEvent split_tap_release( | 890 ui::TouchEvent split_tap_release( |
794 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 891 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
795 generator_->Dispatch(&split_tap_release); | 892 generator_->Dispatch(&split_tap_release); |
796 EXPECT_FALSE(IsInNoFingersDownState()); | 893 EXPECT_FALSE(IsInNoFingersDownState()); |
797 | 894 |
798 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 895 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
799 ASSERT_EQ(2U, captured_events.size()); | 896 ASSERT_EQ(2U, captured_events.size()); |
800 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 897 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
801 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 898 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
802 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 899 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
803 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 900 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
804 } | 901 } |
805 | 902 |
806 // If split tap is started but the touch explore finger is released first, | 903 // If split tap is started but the touch explore finger is released first, |
807 // there should still be a touch press and release sent to the location of | 904 // there should still be a touch press and release sent to the location of |
808 // the last successful touch exploration. | 905 // the last successful touch exploration. |
809 // Both fingers should be released after the click goes through. | 906 // Both fingers should be released after the click goes through. |
810 TEST_F(TouchExplorationTest, SplitTapRelease) { | 907 TEST_F(TouchExplorationTest, SplitTapRelease) { |
811 SwitchTouchExplorationMode(true); | 908 SwitchTouchExplorationMode(true); |
812 | 909 |
813 gfx::Point initial_touch_location(11, 12); | 910 gfx::Point initial_touch_location(11, 12); |
814 gfx::Point second_touch_location(33, 34); | 911 gfx::Point second_touch_location(33, 34); |
815 | 912 |
816 // Tap and hold at one location, and get a mouse move event in touch explore. | 913 // Tap and hold at one location, and get a mouse move event in touch explore. |
817 EnterTouchExplorationModeAtLocation(initial_touch_location); | 914 EnterTouchExplorationModeAtLocation(initial_touch_location); |
818 | 915 |
819 std::vector<ui::LocatedEvent*> events = | 916 std::vector<ui::LocatedEvent*> events = |
820 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 917 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
821 ASSERT_EQ(1U, events.size()); | 918 ASSERT_EQ(1U, events.size()); |
822 | 919 |
823 ClearCapturedEvents(); | 920 ClearCapturedEvents(); |
824 | 921 |
825 // Now tap at a different location. Release at the first location, | 922 // Now tap at a different location. Release at the first location, |
826 // then release at the second. This should result in a | 923 // then release at the second. This should result in a |
827 // single touch and release at the location of the first (held) tap, | 924 // single touch and release at the location of the first (held) tap, |
828 // not at the location of the second tap and release. | 925 // not at the location of the second tap and release. |
829 ui::TouchEvent split_tap_press( | 926 ui::TouchEvent split_tap_press( |
830 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 927 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
831 generator_->Dispatch(&split_tap_press); | 928 generator_->Dispatch(&split_tap_press); |
832 ui::TouchEvent touch_explore_release( | 929 ui::TouchEvent touch_explore_release( |
833 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); | 930 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); |
834 generator_->Dispatch(&touch_explore_release); | 931 generator_->Dispatch(&touch_explore_release); |
835 ui::TouchEvent split_tap_release( | 932 ui::TouchEvent split_tap_release( |
836 ui::ET_TOUCH_RELEASED, second_touch_location , 1, Now()); | 933 ui::ET_TOUCH_RELEASED, second_touch_location , 1, Now()); |
837 generator_->Dispatch(&split_tap_release); | 934 generator_->Dispatch(&split_tap_release); |
838 EXPECT_TRUE(IsInNoFingersDownState()); | 935 EXPECT_TRUE(IsInNoFingersDownState()); |
839 | 936 |
840 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 937 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
841 ASSERT_EQ(2U, captured_events.size()); | 938 ASSERT_EQ(2U, captured_events.size()); |
842 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 939 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
843 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 940 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
844 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 941 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
845 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 942 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
846 } | 943 } |
847 | 944 |
848 // When in touch exploration mode, making a long press with a second finger | 945 // When in touch exploration mode, making a long press with a second finger |
849 // should send a touch press and released to the location of the last | 946 // should send a touch press and released to the location of the last |
850 // successful touch exploration. There should be a delay between the | 947 // successful touch exploration. There should be a delay between the |
851 // touch and release events (right click). | 948 // touch and release events (right click). |
852 TEST_F(TouchExplorationTest, SplitTapLongPress) { | 949 TEST_F(TouchExplorationTest, SplitTapLongPress) { |
853 SwitchTouchExplorationMode(true); | 950 SwitchTouchExplorationMode(true); |
854 gfx::Point initial_touch_location(11, 12); | 951 gfx::Point initial_touch_location(11, 12); |
855 gfx::Point second_touch_location(33, 34); | 952 gfx::Point second_touch_location(33, 34); |
856 | 953 |
857 // Tap and hold at one location, and get a mouse move event in touch explore. | 954 // Tap and hold at one location, and get a mouse move event in touch explore. |
858 EnterTouchExplorationModeAtLocation(initial_touch_location); | 955 EnterTouchExplorationModeAtLocation(initial_touch_location); |
859 std::vector<ui::LocatedEvent*> events = | 956 std::vector<ui::LocatedEvent*> events = |
860 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 957 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
861 ASSERT_EQ(1U, events.size()); | 958 ASSERT_EQ(1U, events.size()); |
862 | 959 |
863 ClearCapturedEvents(); | 960 ClearCapturedEvents(); |
864 | 961 |
865 // Now tap and release at a different location. This should result in a | 962 // Now tap and release at a different location. This should result in a |
866 // single touch and release at the location of the first (held) tap, | 963 // single touch and release at the location of the first (held) tap, |
867 // not at the location of the second tap and release. | 964 // not at the location of the second tap and release. |
868 // After the release, there is still a finger in touch explore mode. | 965 // After the release, there is still a finger in touch explore mode. |
869 ui::TouchEvent split_tap_press( | 966 ui::TouchEvent split_tap_press( |
870 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 967 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
871 generator_->Dispatch(&split_tap_press); | 968 generator_->Dispatch(&split_tap_press); |
872 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 969 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
873 ui::TouchEvent split_tap_release( | 970 ui::TouchEvent split_tap_release( |
874 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 971 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
875 generator_->Dispatch(&split_tap_release); | 972 generator_->Dispatch(&split_tap_release); |
876 EXPECT_FALSE(IsInNoFingersDownState()); | 973 EXPECT_FALSE(IsInNoFingersDownState()); |
877 | 974 |
878 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 975 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
879 ASSERT_EQ(2U, captured_events.size()); | 976 ASSERT_EQ(2U, captured_events.size()); |
880 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 977 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
881 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 978 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
882 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 979 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
883 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 980 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
884 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 981 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
885 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 982 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
886 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 983 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
887 released_time - pressed_time); | 984 released_time - pressed_time); |
888 } | 985 } |
889 | 986 |
890 // If split tap is started but the touch explore finger is released first, | 987 // If split tap is started but the touch explore finger is released first, |
891 // there should still be a touch press and release sent to the location of | 988 // there should still be a touch press and release sent to the location of |
892 // the last successful touch exploration. If the remaining finger is held | 989 // the last successful touch exploration. If the remaining finger is held |
893 // as a longpress, there should be a delay between the sent touch and release | 990 // as a longpress, there should be a delay between the sent touch and release |
894 // events (right click).All fingers should be released after the click | 991 // events (right click).All fingers should be released after the click |
895 // goes through. | 992 // goes through. |
896 TEST_F(TouchExplorationTest, SplitTapReleaseLongPress) { | 993 TEST_F(TouchExplorationTest, SplitTapReleaseLongPress) { |
897 SwitchTouchExplorationMode(true); | 994 SwitchTouchExplorationMode(true); |
898 gfx::Point initial_touch_location(11, 12); | 995 gfx::Point initial_touch_location(11, 12); |
899 gfx::Point second_touch_location(33, 34); | 996 gfx::Point second_touch_location(33, 34); |
900 | 997 |
901 // Tap and hold at one location, and get a mouse move event in touch explore. | 998 // Tap and hold at one location, and get a mouse move event in touch explore. |
902 EnterTouchExplorationModeAtLocation(initial_touch_location); | 999 EnterTouchExplorationModeAtLocation(initial_touch_location); |
903 std::vector<ui::LocatedEvent*> events = | 1000 std::vector<ui::LocatedEvent*> events = |
904 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 1001 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
905 ASSERT_EQ(1U, events.size()); | 1002 ASSERT_EQ(1U, events.size()); |
906 ClearCapturedEvents(); | 1003 ClearCapturedEvents(); |
907 | 1004 |
908 // Now tap at a different location. Release at the first location, | 1005 // Now tap at a different location. Release at the first location, |
909 // then release at the second. This should result in a | 1006 // then release at the second. This should result in a |
910 // single touch and release at the location of the first (held) tap, | 1007 // single touch and release at the location of the first (held) tap, |
911 // not at the location of the second tap and release. | 1008 // not at the location of the second tap and release. |
912 // After the release, TouchToMouseMode should still be on. | 1009 // After the release, TouchToMouseMode should still be on. |
913 ui::TouchEvent split_tap_press( | 1010 ui::TouchEvent split_tap_press( |
914 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 1011 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
915 generator_->Dispatch(&split_tap_press); | 1012 generator_->Dispatch(&split_tap_press); |
916 ui::TouchEvent touch_explore_release( | 1013 ui::TouchEvent touch_explore_release( |
917 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); | 1014 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); |
918 generator_->Dispatch(&touch_explore_release); | 1015 generator_->Dispatch(&touch_explore_release); |
919 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); | 1016 simulated_clock_->Advance(gesture_detector_config_.longpress_timeout); |
920 ui::TouchEvent split_tap_release( | 1017 ui::TouchEvent split_tap_release( |
921 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 1018 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
922 generator_->Dispatch(&split_tap_release); | 1019 generator_->Dispatch(&split_tap_release); |
923 EXPECT_TRUE(IsInTouchToMouseMode()); | 1020 EXPECT_TRUE(IsInTouchToMouseMode()); |
924 | 1021 |
925 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 1022 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
926 ASSERT_EQ(2U, captured_events.size()); | 1023 ASSERT_EQ(2U, captured_events.size()); |
927 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 1024 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
928 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 1025 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
929 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 1026 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
930 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 1027 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
931 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 1028 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
932 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 1029 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
933 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 1030 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
934 released_time - pressed_time); | 1031 released_time - pressed_time); |
935 } | 1032 } |
936 | 1033 |
937 TEST_F(TouchExplorationTest, SplitTapLongPressMultiFinger) { | 1034 TEST_F(TouchExplorationTest, SplitTapLongPressMultiFinger) { |
938 SwitchTouchExplorationMode(true); | 1035 SwitchTouchExplorationMode(true); |
939 gfx::Point initial_touch_location(11, 12); | 1036 gfx::Point initial_touch_location(11, 12); |
940 gfx::Point second_touch_location(33, 34); | 1037 gfx::Point second_touch_location(33, 34); |
941 gfx::Point third_touch_location(16, 17); | 1038 gfx::Point third_touch_location(16, 17); |
942 | 1039 |
943 // Tap and hold at one location, and get a mouse move event in touch explore. | 1040 // Tap and hold at one location, and get a mouse move event in touch explore. |
944 EnterTouchExplorationModeAtLocation(initial_touch_location); | 1041 EnterTouchExplorationModeAtLocation(initial_touch_location); |
945 | 1042 |
946 std::vector<ui::LocatedEvent*> events = | 1043 std::vector<ui::LocatedEvent*> events = |
947 GetCapturedEventsOfType(ui::ET_MOUSE_MOVED); | 1044 GetCapturedLocatedEventsOfType(ui::ET_MOUSE_MOVED); |
948 ASSERT_EQ(1U, events.size()); | 1045 ASSERT_EQ(1U, events.size()); |
949 | 1046 |
950 EXPECT_EQ(initial_touch_location, events[0]->location()); | 1047 EXPECT_EQ(initial_touch_location, events[0]->location()); |
951 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); | 1048 EXPECT_TRUE(events[0]->flags() & ui::EF_IS_SYNTHESIZED); |
952 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); | 1049 EXPECT_TRUE(events[0]->flags() & ui::EF_TOUCH_ACCESSIBILITY); |
953 ClearCapturedEvents(); | 1050 ClearCapturedEvents(); |
954 | 1051 |
955 // Now tap at a different location and hold for long press. | 1052 // Now tap at a different location and hold for long press. |
956 ui::TouchEvent split_tap_press( | 1053 ui::TouchEvent split_tap_press( |
957 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); | 1054 ui::ET_TOUCH_PRESSED, second_touch_location, 1, Now()); |
(...skipping 11 matching lines...) Expand all Loading... | |
969 ui::TouchEvent touch_explore_release( | 1066 ui::TouchEvent touch_explore_release( |
970 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); | 1067 ui::ET_TOUCH_RELEASED, initial_touch_location, 0, Now()); |
971 generator_->Dispatch(&touch_explore_release); | 1068 generator_->Dispatch(&touch_explore_release); |
972 ui::TouchEvent split_tap_release( | 1069 ui::TouchEvent split_tap_release( |
973 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); | 1070 ui::ET_TOUCH_RELEASED, second_touch_location, 1, Now()); |
974 generator_->Dispatch(&split_tap_release); | 1071 generator_->Dispatch(&split_tap_release); |
975 ui::TouchEvent third_tap_release( | 1072 ui::TouchEvent third_tap_release( |
976 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now()); | 1073 ui::ET_TOUCH_RELEASED, third_touch_location, 2, Now()); |
977 generator_->Dispatch(&third_tap_release); | 1074 generator_->Dispatch(&third_tap_release); |
978 | 1075 |
979 const ScopedVector<ui::LocatedEvent>& captured_events = GetCapturedEvents(); | 1076 std::vector<ui::LocatedEvent*> captured_events = GetCapturedLocatedEvents(); |
980 ASSERT_EQ(2U, captured_events.size()); | 1077 ASSERT_EQ(2U, captured_events.size()); |
981 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); | 1078 EXPECT_EQ(ui::ET_TOUCH_PRESSED, captured_events[0]->type()); |
982 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); | 1079 EXPECT_EQ(initial_touch_location, captured_events[0]->location()); |
983 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); | 1080 base::TimeDelta pressed_time = captured_events[0]->time_stamp(); |
984 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); | 1081 EXPECT_EQ(ui::ET_TOUCH_RELEASED, captured_events[1]->type()); |
985 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); | 1082 EXPECT_EQ(initial_touch_location, captured_events[1]->location()); |
986 base::TimeDelta released_time = captured_events[1]->time_stamp(); | 1083 base::TimeDelta released_time = captured_events[1]->time_stamp(); |
987 EXPECT_EQ(gesture_detector_config_.longpress_timeout, | 1084 EXPECT_EQ(gesture_detector_config_.longpress_timeout, |
988 released_time - pressed_time); | 1085 released_time - pressed_time); |
989 EXPECT_TRUE(IsInNoFingersDownState()); | 1086 EXPECT_TRUE(IsInNoFingersDownState()); |
990 } | 1087 } |
991 | 1088 |
1089 // Finger must have moved more than slop, faster than the minimum swipe | |
1090 // velocity, and before the tap timer fires in order to enter | |
1091 // GestureInProgress state. Otherwise, if the tap timer fires before the a | |
1092 // gesture is completed, enter touch exploration. | |
1093 TEST_F(TouchExplorationTest, EnterGestureInProgressState) { | |
1094 SwitchTouchExplorationMode(true); | |
1095 EXPECT_FALSE(IsInTouchToMouseMode()); | |
1096 EXPECT_FALSE(IsInGestureInProgressState()); | |
1097 float delta_distance = gesture_detector_config_.touch_slop + 1; | |
1098 ui::TouchEvent first_press(ui::ET_TOUCH_PRESSED, gfx::Point(0, 1), 0, Now()); | |
1099 generator_->Dispatch(&first_press); | |
1100 gfx::Point second_location(delta_distance, 1); | |
1101 simulated_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | |
1102 generator_->MoveTouch(second_location); | |
1103 EXPECT_TRUE(IsInGestureInProgressState()); | |
1104 EXPECT_FALSE(IsInTouchToMouseMode()); | |
1105 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); | |
1106 ASSERT_EQ(0U, captured_events.size()); | |
1107 | |
1108 // Exit out of gesture mode once grace period is over and enter touch | |
1109 // exploration. | |
1110 AdvanceSimulatedTimePastTapDelay(); | |
1111 ASSERT_EQ(1U, captured_events.size()); | |
1112 EXPECT_EQ(ui::ET_MOUSE_MOVED, captured_events[0]->type()); | |
1113 EXPECT_TRUE(IsInTouchToMouseMode()); | |
1114 EXPECT_FALSE(IsInGestureInProgressState()); | |
1115 } | |
1116 | |
1117 // A swipe+direction gesture should trigger a Shift+Search+Direction | |
1118 // keyboard event. | |
1119 TEST_F(TouchExplorationTest, GestureSwipe) { | |
1120 SwitchTouchExplorationMode(true); | |
1121 std::vector<ui::KeyboardCode> directions; | |
1122 directions.push_back(ui::VKEY_RIGHT); | |
1123 directions.push_back(ui::VKEY_LEFT); | |
1124 directions.push_back(ui::VKEY_UP); | |
1125 directions.push_back(ui::VKEY_DOWN); | |
1126 | |
1127 for (std::vector<ui::KeyboardCode>::const_iterator it = directions.begin(); | |
1128 it != directions.end(); | |
1129 ++it) { | |
1130 int x = 30; | |
1131 int y = 31; | |
1132 ui::TouchEvent origin(ui::ET_TOUCH_PRESSED, gfx::Point(x, y), 0, Now()); | |
1133 generator_->Dispatch(&origin); | |
1134 | |
1135 ui::KeyboardCode direction = *it; | |
1136 float delta_distance = gesture_detector_config_.touch_slop + 1; | |
1137 scoped_ptr<gfx::Point> swipe; | |
1138 switch (direction) { | |
1139 case ui::VKEY_RIGHT: | |
1140 swipe.reset(new gfx::Point(x + delta_distance, y)); | |
1141 break; | |
1142 case ui::VKEY_LEFT: | |
1143 swipe.reset(new gfx::Point(x - delta_distance, y)); | |
1144 break; | |
1145 case ui::VKEY_UP: | |
1146 swipe.reset(new gfx::Point(x, y - delta_distance)); | |
1147 break; | |
1148 case ui::VKEY_DOWN: | |
1149 swipe.reset(new gfx::Point(x, y + delta_distance)); | |
1150 break; | |
1151 default: | |
1152 return; | |
1153 } | |
1154 | |
1155 // A swipe is made when a fling starts | |
1156 float delta_time = | |
1157 delta_distance / gesture_detector_config_.maximum_fling_velocity; | |
1158 simulated_clock_->Advance(base::TimeDelta::FromSecondsD(delta_time)); | |
1159 generator_->MoveTouch(*swipe); | |
1160 EXPECT_TRUE(IsInGestureInProgressState()); | |
1161 EXPECT_FALSE(IsInTouchToMouseMode()); | |
1162 const ScopedVector<ui::Event>& captured_events = GetCapturedEvents(); | |
1163 ASSERT_EQ(0U, captured_events.size()); | |
1164 generator_->ReleaseTouch(); | |
1165 | |
1166 // The swipe registered and sent the appropriate key events. | |
1167 AssertDirectionalNavigationEvents(captured_events, direction); | |
1168 EXPECT_TRUE(IsInNoFingersDownState()); | |
1169 EXPECT_FALSE(IsInTouchToMouseMode()); | |
1170 EXPECT_FALSE(IsInGestureInProgressState()); | |
1171 ClearCapturedEvents(); | |
1172 } | |
1173 } | |
1174 | |
992 } // namespace ui | 1175 } // namespace ui |
OLD | NEW |