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..9498f0a9a292d3bfb4515571f35bd0f7d60fc059 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,30 @@ 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; |
+ } |
+}; |
+ |
+class ScrollEndEventBuilder : public WebGestureEvent { |
+ public: |
+ ScrollEndEventBuilder() : WebGestureEvent() { |
+ m_type = WebInputEvent::GestureScrollEnd; |
+ m_frameScale = 1; |
+ } |
+}; |
+ |
void EventHandlerTest::SetUp() { |
m_dummyPageHolder = DummyPageHolder::create(IntSize(300, 400)); |
} |
@@ -461,6 +486,41 @@ 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>"); |
+ |
+ HistogramTester histogramTester; |
+ |
+ // Test wheel scroll on the box. |
+ ScrollBeginEventBuilder wheelScrollBegin( |
+ IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchpad); |
+ ScrollEndEventBuilder wheelScrollEnd; |
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin); |
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd); |
+ 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); |
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd); |
+ histogramTester.expectTotalCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
+ 1); |
+ histogramTester.expectBucketCount("Event.Scroll.ScrollerSize.OnScroll_Touch", |
+ 200000, 1); |
bokan
2017/03/31 20:23:50
Why is this in the 200,000+ bucket? Isn't the fram
yigu
2017/03/31 20:38:32
IntPoint(200, 200) is the scrolling start position
bokan
2017/04/04 15:25:45
Right, but the viewport is 300x400 which is < 200,
|
+} |
+ |
class TooltipCapturingChromeClient : public EmptyChromeClient { |
public: |
TooltipCapturingChromeClient() {} |