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..f8ff35244fff6b57bdbd4ea6f68a931e7beee7f7 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,39 @@ 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 |
tdresser
2017/03/30 14:41:35
Missing .
|
+ 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 |
tdresser
2017/03/30 14:41:35
Missing .
|
+ 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", |
+ 200000, 1); |
+} |
+ |
class TooltipCapturingChromeClient : public EmptyChromeClient { |
public: |
TooltipCapturingChromeClient() {} |