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