Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: content/renderer/input/main_thread_event_queue_unittest.cc

Issue 2233543002: Make first TouchStart and first TouchMove events on a flinging layer non-blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: new fling Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <new> 7 #include <new>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 const WebTouchEvent* last_touch_event = 252 const WebTouchEvent* last_touch_event =
253 static_cast<const WebTouchEvent*>(handled_events_.at(1).get()); 253 static_cast<const WebTouchEvent*>(handled_events_.at(1).get());
254 WebTouchEvent coalesced_event = kTouchEvents[0]; 254 WebTouchEvent coalesced_event = kTouchEvents[0];
255 internal::Coalesce(kTouchEvents[1], &coalesced_event); 255 internal::Coalesce(kTouchEvents[1], &coalesced_event);
256 coalesced_event.dispatchType = 256 coalesced_event.dispatchType =
257 WebInputEvent::DispatchType::ListenersNonBlockingPassive; 257 WebInputEvent::DispatchType::ListenersNonBlockingPassive;
258 EXPECT_EQ(coalesced_event, *last_touch_event); 258 EXPECT_EQ(coalesced_event, *last_touch_event);
259 } 259 }
260 } 260 }
261 261
262 TEST_F(MainThreadEventQueueTest, BlockingTouchesDuringFling) {
263 SyntheticWebTouchEvent kEvents[1];
264 kEvents[0].PressPoint(10, 10);
265 queue_->set_is_flinging(true);
266
267 EXPECT_FALSE(main_task_runner_->HasPendingTask());
268 EXPECT_EQ(0u, event_queue().size());
269 queue_->HandleEvent(&kEvents[0], ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING,
270 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
271 EXPECT_EQ(1u, event_queue().size());
272 EXPECT_TRUE(main_task_runner_->HasPendingTask());
273 main_task_runner_->RunUntilIdle();
274 EXPECT_FALSE(main_task_runner_->HasPendingTask());
275 EXPECT_EQ(0u, event_queue().size());
276 EXPECT_EQ(1u, handled_events_.size());
277 EXPECT_EQ(kEvents[0].size, handled_events_.at(0)->size);
278 EXPECT_EQ(kEvents[0].type, handled_events_.at(0)->type);
279 const WebTouchEvent* last_touch_event =
280 static_cast<const WebTouchEvent*>(handled_events_.at(0).get());
281 kEvents[0].dispatchedDuringFling = true;
282 kEvents[0].dispatchType =
283 WebInputEvent::DispatchType::ListenersForcedNonBlockingPassiveDueToFling;
284 EXPECT_EQ(kEvents[0], *last_touch_event);
285
286 kEvents[0].MovePoint(0, 30, 30);
287 queue_->HandleEvent(&kEvents[0], ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING,
288 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
289 EXPECT_EQ(1u, event_queue().size());
290 EXPECT_TRUE(main_task_runner_->HasPendingTask());
291 main_task_runner_->RunUntilIdle();
292 EXPECT_FALSE(main_task_runner_->HasPendingTask());
293 EXPECT_EQ(0u, event_queue().size());
294 EXPECT_EQ(2u, handled_events_.size());
295 EXPECT_EQ(kEvents[0].size, handled_events_.at(1)->size);
296 EXPECT_EQ(kEvents[0].type, handled_events_.at(1)->type);
297 last_touch_event =
298 static_cast<const WebTouchEvent*>(handled_events_.at(1).get());
299 kEvents[0].dispatchedDuringFling = true;
300 kEvents[0].dispatchType =
301 WebInputEvent::DispatchType::ListenersForcedNonBlockingPassiveDueToFling;
302 EXPECT_EQ(kEvents[0], *last_touch_event);
303
304 kEvents[0].MovePoint(0, 50, 50);
305 queue_->HandleEvent(&kEvents[0], ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING,
306 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
307 EXPECT_EQ(1u, event_queue().size());
308 EXPECT_TRUE(main_task_runner_->HasPendingTask());
309 main_task_runner_->RunUntilIdle();
310 EXPECT_FALSE(main_task_runner_->HasPendingTask());
311 EXPECT_EQ(0u, event_queue().size());
312 EXPECT_EQ(3u, handled_events_.size());
313 EXPECT_EQ(kEvents[0].size, handled_events_.at(2)->size);
314 EXPECT_EQ(kEvents[0].type, handled_events_.at(2)->type);
315 last_touch_event =
dtapuska 2016/08/10 14:47:42 What are you expecting to have dispatchedDuringFli
316 static_cast<const WebTouchEvent*>(handled_events_.at(2).get());
317 EXPECT_EQ(kEvents[0], *last_touch_event);
318
319 kEvents[0].ReleasePoint(0);
320 queue_->HandleEvent(&kEvents[0], ui::LatencyInfo(), DISPATCH_TYPE_BLOCKING,
321 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
322 EXPECT_EQ(1u, event_queue().size());
323 EXPECT_TRUE(main_task_runner_->HasPendingTask());
324 main_task_runner_->RunUntilIdle();
325 EXPECT_FALSE(main_task_runner_->HasPendingTask());
326 EXPECT_EQ(0u, event_queue().size());
327 EXPECT_EQ(4u, handled_events_.size());
328 EXPECT_EQ(kEvents[0].size, handled_events_.at(3)->size);
329 EXPECT_EQ(kEvents[0].type, handled_events_.at(3)->type);
330 last_touch_event =
331 static_cast<const WebTouchEvent*>(handled_events_.at(3).get());
332 EXPECT_EQ(kEvents[0], *last_touch_event);
333 }
334
262 } // namespace content 335 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698