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

Unified Diff: ui/events/blink/input_handler_proxy_unittest.cc

Issue 2651883007: Re-landing "UMA metrics for fractions of wheel and touch scrolls blocked on the main thread." (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/blink/input_handler_proxy.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/blink/input_handler_proxy_unittest.cc
diff --git a/ui/events/blink/input_handler_proxy_unittest.cc b/ui/events/blink/input_handler_proxy_unittest.cc
index 6e5ffbb2823a1a4c5cdf52a3e310bf0ef4df93c3..85e9b46ee9a37d25771c020cfe4741a78ca31420 100644
--- a/ui/events/blink/input_handler_proxy_unittest.cc
+++ b/ui/events/blink/input_handler_proxy_unittest.cc
@@ -327,7 +327,7 @@ const cc::InputHandler::ScrollStatus kImplThreadScrollState(
const cc::InputHandler::ScrollStatus kMainThreadScrollState(
cc::InputHandler::SCROLL_ON_MAIN_THREAD,
- cc::MainThreadScrollingReason::kNotScrollingOnMain);
+ cc::MainThreadScrollingReason::kHandlingScrollFromMainThread);
const cc::InputHandler::ScrollStatus kScrollIgnoredScrollState(
cc::InputHandler::SCROLL_IGNORED,
@@ -3011,6 +3011,186 @@ TEST_P(InputHandlerProxyTest, MainThreadScrollingMouseWheelHistograms) {
base::Bucket(5, 1), base::Bucket(14, 1)));
}
+TEST_P(InputHandlerProxyTest, GestureScrollingThreadStatusHistogram) {
+ VERIFY_AND_RESET_MOCKS();
+
+ WebTouchEvent touch_start(WebInputEvent::TouchStart,
+ WebInputEvent::NoModifiers,
+ WebInputEvent::TimeStampForTesting);
+ touch_start.touchesLength = 1;
+ touch_start.touches[0] =
+ CreateWebTouchPoint(WebTouchPoint::StatePressed, 10, 10);
+
+ WebGestureEvent gesture_scroll_begin;
+ gesture_scroll_begin.setType(WebInputEvent::GestureScrollBegin);
+ gesture_scroll_begin.sourceDevice = blink::WebGestureDeviceTouchscreen;
+
+ WebGestureEvent gesture_scroll_end;
+ gesture_scroll_end.setType(WebInputEvent::GestureScrollEnd);
+ gesture_scroll_end.sourceDevice = blink::WebGestureDeviceTouchscreen;
+
+ // Touch start with passive event listener.
+ EXPECT_CALL(mock_input_handler_,
+ EventListenerTypeForTouchStartAt(
+ testing::Property(&gfx::Point::x, testing::Gt(0))))
+ .WillOnce(testing::Return(
+ cc::InputHandler::TouchStartEventListenerType::NO_HANDLER));
+ EXPECT_CALL(
+ mock_input_handler_,
+ GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
+ .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
+
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(touch_start));
+
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_begin));
+
+ EXPECT_THAT(histogram_tester().GetAllSamples(
+ "Renderer4.GestureScrollingThreadStatus"),
+ testing::ElementsAre(base::Bucket(0, 1)));
+
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_end));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // Touch event with HANDLER_ON_SCROLLING_LAYER event listener.
+ EXPECT_CALL(mock_input_handler_,
+ EventListenerTypeForTouchStartAt(
+ testing::Property(&gfx::Point::x, testing::Gt(0))))
+ .WillOnce(testing::Return(cc::InputHandler::TouchStartEventListenerType::
+ HANDLER_ON_SCROLLING_LAYER));
+
+ expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(touch_start));
+
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_begin));
+
+ EXPECT_THAT(histogram_tester().GetAllSamples(
+ "Renderer4.GestureScrollingThreadStatus"),
+ testing::ElementsAre(base::Bucket(0, 1), base::Bucket(1, 1)));
+
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_end));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // Gesture scrolling on main thread.
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kMainThreadScrollState));
+ expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_begin));
+
+ EXPECT_THAT(histogram_tester().GetAllSamples(
+ "Renderer4.GestureScrollingThreadStatus"),
+ testing::ElementsAre(base::Bucket(0, 1), base::Bucket(1, 1),
+ base::Bucket(2, 1)));
+
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_end));
+
+ VERIFY_AND_RESET_MOCKS();
+}
+
+TEST_P(InputHandlerProxyTest, WheelScrollingThreadStatusHistogram) {
+ VERIFY_AND_RESET_MOCKS();
+
+ WebMouseWheelEvent wheel(WebInputEvent::MouseWheel, WebInputEvent::ControlKey,
+ WebInputEvent::TimeStampForTesting);
+
+ WebGestureEvent gesture_scroll_begin;
+ gesture_scroll_begin.setType(WebInputEvent::GestureScrollBegin);
+ gesture_scroll_begin.sourceDevice = blink::WebGestureDeviceTouchpad;
+
+ WebGestureEvent gesture_scroll_end;
+ gesture_scroll_end.setType(WebInputEvent::GestureScrollEnd);
+ gesture_scroll_end.sourceDevice = blink::WebGestureDeviceTouchpad;
+
+ // Wheel event with passive event listener.
+ EXPECT_CALL(mock_input_handler_,
+ GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
+ .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
+
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_begin));
+
+ EXPECT_THAT(
+ histogram_tester().GetAllSamples("Renderer4.WheelScrollingThreadStatus"),
+ testing::ElementsAre(base::Bucket(0, 1)));
+
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_end));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // Wheel event with blocking event listener.
+ EXPECT_CALL(mock_input_handler_,
+ GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
+ .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
+ expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ EXPECT_EQ(expected_disposition_, input_handler_->HandleInputEvent(wheel));
+
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kImplThreadScrollState));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_begin));
+
+ EXPECT_THAT(
+ histogram_tester().GetAllSamples("Renderer4.WheelScrollingThreadStatus"),
+ testing::ElementsAre(base::Bucket(0, 1), base::Bucket(1, 1)));
+
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ expected_disposition_ = InputHandlerProxy::DID_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_end));
+
+ VERIFY_AND_RESET_MOCKS();
+
+ // Wheel scrolling on main thread.
+ EXPECT_CALL(mock_input_handler_, ScrollBegin(testing::_, testing::_))
+ .WillOnce(testing::Return(kMainThreadScrollState));
+ expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_begin));
+
+ EXPECT_THAT(
+ histogram_tester().GetAllSamples("Renderer4.WheelScrollingThreadStatus"),
+ testing::ElementsAre(base::Bucket(0, 1), base::Bucket(1, 1),
+ base::Bucket(2, 1)));
+
+ EXPECT_CALL(mock_input_handler_, ScrollEnd(testing::_));
+ expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
+ EXPECT_EQ(expected_disposition_,
+ input_handler_->HandleInputEvent(gesture_scroll_end));
+
+ VERIFY_AND_RESET_MOCKS();
+}
+
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) {
base::HistogramTester histogram_tester;
« no previous file with comments | « ui/events/blink/input_handler_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698