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

Side by Side Diff: content/renderer/render_widget_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 17 matching lines...) Expand all
28 namespace { 28 namespace {
29 29
30 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; 30 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners";
31 31
32 enum { 32 enum {
33 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 33 PASSIVE_LISTENER_UMA_ENUM_PASSIVE,
34 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, 34 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE,
35 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 35 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED,
36 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 36 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE,
37 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 37 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED,
38 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING, 38 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING,
39 PASSIVE_LISTENER_UMA_ENUM_COUNT 39 PASSIVE_LISTENER_UMA_ENUM_COUNT
40 }; 40 };
41 41
42 class MockWebWidget : public blink::WebWidget { 42 class MockWebWidget : public blink::WebWidget {
43 public: 43 public:
44 MOCK_METHOD1(handleInputEvent, 44 MOCK_METHOD1(handleInputEvent,
45 blink::WebInputEventResult(const blink::WebInputEvent&)); 45 blink::WebInputEventResult(const blink::WebInputEvent&));
46 }; 46 };
47 47
48 } // namespace 48 } // namespace
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 EXPECT_EQ(gfx::PointF(1, 1), overscroll.causal_event_viewport_point); 276 EXPECT_EQ(gfx::PointF(1, 1), overscroll.causal_event_viewport_point);
277 EXPECT_EQ(gfx::Vector2dF(-10, -5), overscroll.current_fling_velocity); 277 EXPECT_EQ(gfx::Vector2dF(-10, -5), overscroll.current_fling_velocity);
278 widget()->sink()->ClearMessages(); 278 widget()->sink()->ClearMessages();
279 } 279 }
280 280
281 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) { 281 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) {
282 SyntheticWebTouchEvent touch; 282 SyntheticWebTouchEvent touch;
283 touch.PressPoint(10, 10); 283 touch.PressPoint(10, 10);
284 284
285 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 285 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
286 .Times(4) 286 .Times(5)
287 .WillRepeatedly( 287 .WillRepeatedly(
288 ::testing::Return(blink::WebInputEventResult::NotHandled)); 288 ::testing::Return(blink::WebInputEventResult::NotHandled));
289 289
290 widget()->SendInputEvent(touch); 290 widget()->SendInputEvent(touch);
291 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 291 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
292 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1); 292 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1);
293 293
294 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking; 294 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking;
295 widget()->SendInputEvent(touch); 295 widget()->SendInputEvent(touch);
296 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 296 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
297 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, 297 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE,
298 1); 298 1);
299 299
300 touch.dispatchType = 300 touch.dispatchType =
301 blink::WebInputEvent::DispatchType::ListenersNonBlockingPassive; 301 blink::WebInputEvent::DispatchType::ListenersNonBlockingPassive;
302 widget()->SendInputEvent(touch); 302 widget()->SendInputEvent(touch);
303 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 303 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
304 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 1); 304 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, 1);
305 305
306 touch.dispatchType = 306 touch.dispatchType = blink::WebInputEvent::DispatchType::
307 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingPassive; 307 ListenersForcedNonBlockingPassiveDueToFling;
308 widget()->SendInputEvent(touch); 308 widget()->SendInputEvent(touch);
309 histogram_tester().ExpectBucketCount( 309 histogram_tester().ExpectBucketCount(
310 EVENT_LISTENER_RESULT_HISTOGRAM, 310 EVENT_LISTENER_RESULT_HISTOGRAM,
311 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING, 1); 311 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 1);
312
313 touch.MovePoint(0, 10, 10);
314 touch.dispatchType = blink::WebInputEvent::DispatchType::
315 ListenersForcedNonBlockingPassiveDueToFling;
316 widget()->SendInputEvent(touch);
317 histogram_tester().ExpectBucketCount(
318 EVENT_LISTENER_RESULT_HISTOGRAM,
319 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2);
312 320
313 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 321 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
314 .WillOnce( 322 .WillOnce(
315 ::testing::Return(blink::WebInputEventResult::HandledSuppressed)); 323 ::testing::Return(blink::WebInputEventResult::HandledSuppressed));
316 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; 324 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking;
317 widget()->SendInputEvent(touch); 325 widget()->SendInputEvent(touch);
318 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, 326 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM,
319 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1); 327 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1);
320 328
321 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 329 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
322 .WillOnce( 330 .WillOnce(
323 ::testing::Return(blink::WebInputEventResult::HandledApplication)); 331 ::testing::Return(blink::WebInputEventResult::HandledApplication));
324 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; 332 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking;
325 widget()->SendInputEvent(touch); 333 widget()->SendInputEvent(touch);
326 histogram_tester().ExpectBucketCount( 334 histogram_tester().ExpectBucketCount(
327 EVENT_LISTENER_RESULT_HISTOGRAM, 335 EVENT_LISTENER_RESULT_HISTOGRAM,
328 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 1); 336 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, 1);
329 } 337 }
330 338
331 TEST_F(RenderWidgetUnittest, TouchStartDuringOrOutsideFlingUmaMetrics) { 339 TEST_F(RenderWidgetUnittest, TouchDuringOrOutsideFlingUmaMetrics) {
332 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) 340 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_))
333 .Times(2) 341 .Times(2)
334 .WillRepeatedly( 342 .WillRepeatedly(
335 ::testing::Return(blink::WebInputEventResult::NotHandled)); 343 ::testing::Return(blink::WebInputEventResult::NotHandled));
336 344
337 SyntheticWebTouchEvent touch; 345 SyntheticWebTouchEvent touch;
338 touch.PressPoint(10, 10); 346 touch.PressPoint(10, 10);
339 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; 347 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking;
340 touch.dispatchedDuringFling = true;
341 widget()->SendInputEvent(touch);
342 histogram_tester().ExpectTotalCount(
343 "Event.Touch.TouchStartLatencyDuringFling", 1);
344
345 touch.dispatchedDuringFling = false; 348 touch.dispatchedDuringFling = false;
346 widget()->SendInputEvent(touch); 349 widget()->SendInputEvent(touch);
347 histogram_tester().ExpectTotalCount( 350 histogram_tester().ExpectTotalCount("Event.Touch.TouchLatencyOutsideFling",
348 "Event.Touch.TouchStartLatencyOutsideFling", 1); 351 1);
352
353 touch.MovePoint(0, 10, 10);
354 widget()->SendInputEvent(touch);
355 histogram_tester().ExpectTotalCount("Event.Touch.TouchLatencyOutsideFling",
356 2);
349 } 357 }
350 358
351 } // namespace content 359 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698