Chromium Code Reviews| Index: third_party/WebKit/Source/core/input/EventHandlerTest.cpp |
| diff --git a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp |
| index f8618151f6be13253f4f4efeefa617b8fe13d3b2..b8059b0083e2d1b4465fc799a957d74d3dc6dc7f 100644 |
| --- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp |
| +++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp |
| @@ -16,6 +16,7 @@ |
| #include "core/page/AutoscrollController.h" |
| #include "core/page/Page.h" |
| #include "core/testing/DummyPageHolder.h" |
| +#include "platform/testing/HistogramTester.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace blink { |
| @@ -79,6 +80,22 @@ class MousePressEventBuilder : public WebMouseEvent { |
| } |
| }; |
| +class ScrollBeginEventBuilder : public WebGestureEvent { |
| + public: |
| + ScrollBeginEventBuilder(IntPoint position, |
| + FloatPoint delta, |
| + WebGestureDevice device) |
| + : WebGestureEvent() { |
| + m_type = WebInputEvent::GestureScrollBegin; |
| + x = globalX = position.x(); |
| + y = globalY = position.y(); |
| + data.scrollBegin.deltaYHint = delta.y(); |
| + data.scrollBegin.targetViewport = true; |
| + sourceDevice = device; |
| + m_frameScale = 1; |
| + } |
| +}; |
| + |
| void EventHandlerTest::SetUp() { |
| m_dummyPageHolder = DummyPageHolder::create(IntSize(300, 400)); |
| } |
| @@ -461,6 +478,36 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) { |
| // This test passes if it doesn't crash. |
| } |
| +TEST_F(EventHandlerTest, |
| + ScrollerSizeOfMainThreadScrollingHistogramRecordingTest) { |
| + setHtmlInnerHTML( |
| + "<style>.box { width: 100px; height: 100px; overflow: scroll;" |
| + " opacity: 0.5; } .spacer { height: 1000px;} body {height: 1000px; }" |
| + "</style>" |
| + "<div class='box'><div id='content' class='spacer'></div></div>"); |
|
tdresser
2017/03/28 13:30:12
I suspect this string could be made a bit easier t
yigu
2017/03/29 15:32:03
Done.
|
| + |
| + HistogramTester histogramTester; |
| + |
| + // Test wheel scroll on the box |
| + ScrollBeginEventBuilder wheelScrollBegin( |
| + IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchpad); |
| + |
| + document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin); |
| + histogramTester.expectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Wheel", |
| + 1); |
| + histogramTester.expectBucketCount("Event.Scroll.ScrollerSize.OnScroll_Wheel", |
| + 10000, 1); |
| + |
| + // Test touch scroll on the main frame |
| + ScrollBeginEventBuilder touchScrollBegin( |
| + IntPoint(200, 200), FloatPoint(0.f, 1.f), WebGestureDeviceTouchscreen); |
| + document().frame()->eventHandler().handleGestureEvent(touchScrollBegin); |
| + histogramTester.expectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
| + 1); |
| + histogramTester.expectBucketCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
| + 90000, 1); |
| +} |
| + |
| class TooltipCapturingChromeClient : public EmptyChromeClient { |
| public: |
| TooltipCapturingChromeClient() {} |