| 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 14 matching lines...) Expand all Loading... |
| 25 #include "ui/gfx/geometry/rect.h" | 25 #include "ui/gfx/geometry/rect.h" |
| 26 | 26 |
| 27 using testing::_; | 27 using testing::_; |
| 28 | 28 |
| 29 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; | 33 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; |
| 34 | 34 |
| 35 // Keep in sync with enum defined in |
| 36 // RenderWidgetInputHandler::LogPassiveEventListenersUma. |
| 35 enum { | 37 enum { |
| 36 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, | 38 PASSIVE_LISTENER_UMA_ENUM_PASSIVE, |
| 37 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, | 39 PASSIVE_LISTENER_UMA_ENUM_UNCANCELABLE, |
| 38 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, | 40 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, |
| 39 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, | 41 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, |
| 40 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, | 42 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE_AND_CANCELED, |
| 41 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, | 43 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, |
| 44 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIVENES
S, |
| 42 PASSIVE_LISTENER_UMA_ENUM_COUNT | 45 PASSIVE_LISTENER_UMA_ENUM_COUNT |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 class MockWebWidget : public blink::WebWidget { | 48 class MockWebWidget : public blink::WebWidget { |
| 46 public: | 49 public: |
| 47 MOCK_METHOD1(handleInputEvent, | 50 MOCK_METHOD1(handleInputEvent, |
| 48 blink::WebInputEventResult(const blink::WebInputEvent&)); | 51 blink::WebInputEventResult(const blink::WebInputEvent&)); |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 } // namespace | 54 } // namespace |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 EXPECT_EQ(gfx::Vector2dF(10, 5), overscroll.current_fling_velocity); | 288 EXPECT_EQ(gfx::Vector2dF(10, 5), overscroll.current_fling_velocity); |
| 286 widget()->sink()->ClearMessages(); | 289 widget()->sink()->ClearMessages(); |
| 287 } | 290 } |
| 288 | 291 |
| 289 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) { | 292 TEST_F(RenderWidgetUnittest, RenderWidgetInputEventUmaMetrics) { |
| 290 SyntheticWebTouchEvent touch; | 293 SyntheticWebTouchEvent touch; |
| 291 touch.PressPoint(10, 10); | 294 touch.PressPoint(10, 10); |
| 292 touch.touchStartOrFirstTouchMove = true; | 295 touch.touchStartOrFirstTouchMove = true; |
| 293 | 296 |
| 294 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 297 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
| 295 .Times(5) | 298 .Times(7) |
| 296 .WillRepeatedly( | 299 .WillRepeatedly( |
| 297 ::testing::Return(blink::WebInputEventResult::NotHandled)); | 300 ::testing::Return(blink::WebInputEventResult::NotHandled)); |
| 298 | 301 |
| 299 widget()->SendInputEvent(touch); | 302 widget()->SendInputEvent(touch); |
| 300 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, | 303 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, |
| 301 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1); | 304 PASSIVE_LISTENER_UMA_ENUM_CANCELABLE, 1); |
| 302 | 305 |
| 303 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking; | 306 touch.dispatchType = blink::WebInputEvent::DispatchType::EventNonBlocking; |
| 304 widget()->SendInputEvent(touch); | 307 widget()->SendInputEvent(touch); |
| 305 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, | 308 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 321 | 324 |
| 322 touch.MovePoint(0, 10, 10); | 325 touch.MovePoint(0, 10, 10); |
| 323 touch.touchStartOrFirstTouchMove = true; | 326 touch.touchStartOrFirstTouchMove = true; |
| 324 touch.dispatchType = | 327 touch.dispatchType = |
| 325 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling; | 328 blink::WebInputEvent::DispatchType::ListenersForcedNonBlockingDueToFling; |
| 326 widget()->SendInputEvent(touch); | 329 widget()->SendInputEvent(touch); |
| 327 histogram_tester().ExpectBucketCount( | 330 histogram_tester().ExpectBucketCount( |
| 328 EVENT_LISTENER_RESULT_HISTOGRAM, | 331 EVENT_LISTENER_RESULT_HISTOGRAM, |
| 329 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2); | 332 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_FLING, 2); |
| 330 | 333 |
| 334 touch.dispatchType = blink::WebInputEvent::DispatchType:: |
| 335 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 336 widget()->SendInputEvent(touch); |
| 337 histogram_tester().ExpectBucketCount( |
| 338 EVENT_LISTENER_RESULT_HISTOGRAM, |
| 339 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIV
ENESS, |
| 340 1); |
| 341 |
| 342 touch.MovePoint(0, 10, 10); |
| 343 touch.touchStartOrFirstTouchMove = true; |
| 344 touch.dispatchType = blink::WebInputEvent::DispatchType:: |
| 345 ListenersForcedNonBlockingDueToMainThreadResponsiveness; |
| 346 widget()->SendInputEvent(touch); |
| 347 histogram_tester().ExpectBucketCount( |
| 348 EVENT_LISTENER_RESULT_HISTOGRAM, |
| 349 PASSIVE_LISTENER_UMA_ENUM_FORCED_NON_BLOCKING_DUE_TO_MAIN_THREAD_RESPONSIV
ENESS, |
| 350 2); |
| 351 |
| 331 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 352 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
| 332 .WillOnce( | 353 .WillOnce( |
| 333 ::testing::Return(blink::WebInputEventResult::HandledSuppressed)); | 354 ::testing::Return(blink::WebInputEventResult::HandledSuppressed)); |
| 334 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; | 355 touch.dispatchType = blink::WebInputEvent::DispatchType::Blocking; |
| 335 widget()->SendInputEvent(touch); | 356 widget()->SendInputEvent(touch); |
| 336 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, | 357 histogram_tester().ExpectBucketCount(EVENT_LISTENER_RESULT_HISTOGRAM, |
| 337 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1); | 358 PASSIVE_LISTENER_UMA_ENUM_SUPPRESSED, 1); |
| 338 | 359 |
| 339 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 360 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
| 340 .WillOnce( | 361 .WillOnce( |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 blink::WebRect popup_emulated_rect(130, 170, 100, 400); | 519 blink::WebRect popup_emulated_rect(130, 170, 100, 400); |
| 499 widget()->setWindowRect(popup_emulated_rect); | 520 widget()->setWindowRect(popup_emulated_rect); |
| 500 | 521 |
| 501 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); | 522 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); |
| 502 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); | 523 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); |
| 503 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); | 524 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); |
| 504 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); | 525 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); |
| 505 } | 526 } |
| 506 | 527 |
| 507 } // namespace content | 528 } // namespace content |
| OLD | NEW |