| OLD | NEW |
| 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 11 matching lines...) Expand all Loading... |
| 22 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
| 23 | 23 |
| 24 using testing::_; | 24 using testing::_; |
| 25 | 25 |
| 26 namespace content { | 26 namespace content { |
| 27 | 27 |
| 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 // Keep in sync with enum defined in |
| 33 // RenderWidgetInputHandler::LogPassiveEventListenersUma. |
| 32 enum { | 34 enum { |
| 33 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, | 35 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, |
| 34 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, | 36 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, |
| 35 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, | 37 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, |
| 36 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, | 38 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, |
| 37 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, | 39 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, |
| 38 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, | 40 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, |
| 41 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIVENES
S, |
| 39 PASSIVE_LISTENER_UMA_ENUM_COUNT | 42 PASSIVE_LISTENER_UMA_ENUM_COUNT |
| 40 }; | 43 }; |
| 41 | 44 |
| 42 class MockWebWidget : public blink::WebWidget { | 45 class MockWebWidget : public blink::WebWidget { |
| 43 public: | 46 public: |
| 44 MOCK_METHOD1(handleInputEvent, | 47 MOCK_METHOD1(handleInputEvent, |
| 45 blink::WebInputEventResult(const blink::WebInputEvent&)); | 48 blink::WebInputEventResult(const blink::WebInputEvent&)); |
| 46 }; | 49 }; |
| 47 | 50 |
| 48 } // namespace | 51 } // namespace |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 EXPECT_EQ(gfx::Vector2dF(-10, -5), overscroll.current_fling_velocity); | 280 EXPECT_EQ(gfx::Vector2dF(-10, -5), overscroll.current_fling_velocity); |
| 278 widget()->sink()->ClearMessages(); | 281 widget()->sink()->ClearMessages(); |
| 279 } | 282 } |
| 280 | 283 |
| 281 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) { | 284 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) { |
| 282 SyntheticWebTouchEvent touch; | 285 SyntheticWebTouchEvent touch; |
| 283 touch.PressPoint(10, 10); | 286 touch.PressPoint(10, 10); |
| 284 touch.touchStartOrFirstTouchMove = true; | 287 touch.touchStartOrFirstTouchMove = true; |
| 285 | 288 |
| 286 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 289 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
| 287 .Times(5) | 290 .Times(7) |
| 288 .WillRepeatedly( | 291 .WillRepeatedly( |
| 289 ::testing::Return(blink::WebInputEventResult::NotHandled)); | 292 ::testing::Return(blink::WebInputEventResult::NotHandled)); |
| 290 | 293 |
| 291 widget()->SendInputEvent(touch); | 294 widget()->SendInputEvent(touch); |
| 292 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, | 295 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, |
| 293 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1); | 296 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1); |
| 294 | 297 |
| 295 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking; | 298 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking; |
| 296 widget()->SendInputEvent(touch); | 299 widget()->SendInputEvent(touch); |
| 297 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, | 300 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 313 | 316 |
| 314 touch.MovePoint(0, 10, 10); | 317 touch.MovePoint(0, 10, 10); |
| 315 touch.touchStartOrFirstTouchMove = true; | 318 touch.touchStartOrFirstTouchMove = true; |
| 316 touch.dispatchType = | 319 touch.dispatchType = |
| 317 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling; | 320 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling; |
| 318 widget()->SendInputEvent(touch); | 321 widget()->SendInputEvent(touch); |
| 319 histogram_tester().ExpectBucketCount( | 322 histogram_tester().ExpectBucketCount( |
| 320 EVENT_LISTENER_RESULT_HISTOGRAM, | 323 EVENT_LISTENER_RESULT_HISTOGRAM, |
| 321 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2); | 324 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2); |
| 322 | 325 |
| 326 touch.dispatchType = blink::WebInputEvent::DispatchType:: |
| 327 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 328 widget()->SendInputEvent(touch); |
| 329 histogram_tester().ExpectBucketCount( |
| 330 EVENT_LISTENER_RESULT_HISTOGRAM, |
| 331 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIV
ENESS, |
| 332 1); |
| 333 |
| 334 touch.MovePoint(0, 10, 10); |
| 335 touch.touchStartOrFirstTouchMove = true; |
| 336 touch.dispatchType = blink::WebInputEvent::DispatchType:: |
| 337 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 338 widget()->SendInputEvent(touch); |
| 339 histogram_tester().ExpectBucketCount( |
| 340 EVENT_LISTENER_RESULT_HISTOGRAM, |
| 341 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIV
ENESS, |
| 342 2); |
| 343 |
| 323 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 344 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
| 324 .WillOnce( | 345 .WillOnce( |
| 325 ::testing::Return(blink::WebInputEventResult::HandledSuppressed)); | 346 ::testing::Return(blink::WebInputEventResult::HandledSuppressed)); |
| 326 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; | 347 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; |
| 327 widget()->SendInputEvent(touch); | 348 widget()->SendInputEvent(touch); |
| 328 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, | 349 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, |
| 329 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1); | 350 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1); |
| 330 | 351 |
| 331 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 352 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
| 332 .WillOnce( | 353 .WillOnce( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 360 2); | 381 2); |
| 361 | 382 |
| 362 touch.MovePoint(0, 30, 30); | 383 touch.MovePoint(0, 30, 30); |
| 363 touch.touchStartOrFirstTouchMove = false; | 384 touch.touchStartOrFirstTouchMove = false; |
| 364 widget()->SendInputEvent(touch); | 385 widget()->SendInputEvent(touch); |
| 365 histogram_tester().ExpectTotalCount("Event.Touch.TouchLatencyOutsideFling", | 386 histogram_tester().ExpectTotalCount("Event.Touch.TouchLatencyOutsideFling", |
| 366 2); | 387 2); |
| 367 } | 388 } |
| 368 | 389 |
| 369 } // namespace content | 390 } // namespace content |
| OLD | NEW |