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..6a4268196170aaf2f42111d8618fad97dd1d37d8 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; |
|
bokan
2017/03/28 15:30:15
This should be false. It's used in Android WebView
|
| + 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, NonCompositedMainThreadScrollingReasonTest) { |
| + setHtmlInnerHTML( |
| + "<style>.box { width: 100px; height: 100px; overflow: scroll; }" |
| + ".translucent { opacity: 0.5; will-change:transform;} .spacer { height: " |
| + "1000px;} body {height: 1000px; }" |
| + ".border { border: 5px solid; border-radius: 2px; } </style>" |
| + "<div class='translucent box'><div class='spacer'></div></div>" |
| + "<div class='border box'><div class='spacer'></div></div>"); |
|
bokan
2017/03/28 15:30:15
Please add at least one case that checks that a co
|
| + |
| + HistogramTester histogramTester; |
| + // Test wheel scroll |
| + ScrollBeginEventBuilder wheelScrollBegin( |
| + IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchpad); |
| + document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin); |
| + histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 17, |
| + 1); |
| + |
| + wheelScrollBegin.y = wheelScrollBegin.globalY = 150; |
| + document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin); |
|
bokan
2017/03/28 15:30:15
You should send a ScrollEnd after each scrollBegin
|
| + histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 20, |
| + 1); |
| + // Test touch scroll |
| + ScrollBeginEventBuilder touchScrollBegin( |
| + IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchscreen); |
| + document().frame()->eventHandler().handleGestureEvent(touchScrollBegin); |
| + histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason", |
| + 17, 1); |
| + |
| + document().frame()->eventHandler().handleGestureEvent(touchScrollBegin); |
| + histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason", |
| + 17, 2); |
| +} |
| + |
| class TooltipCapturingChromeClient : public EmptyChromeClient { |
| public: |
| TooltipCapturingChromeClient() {} |