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

Unified Diff: third_party/WebKit/Source/core/input/EventHandlerTest.cpp

Issue 2773593005: Move logic of recording main thread scrolling reasons from cc to blink::ScrollManager (Closed)
Patch Set: Remove the UnknownNonCompositedRegion bucket Created 3 years, 8 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
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 2161408f393ec7d446dfdfd76ba156d7e96eecda..2d58bb1540fdc31ea1191cca5e558a714e8a2d0a 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,29 @@ 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();
+ 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 +485,48 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) {
// This test passes if it doesn't crash.
}
+TEST_F(EventHandlerTest, NonCompositedMainThreadScrollingReasonTest) {
+ setHtmlInnerHTML(
+ "<style>.box { overflow:scroll; width: 100px; height: 100px; }"
+ " .translucent { opacity: 0.5; }"
+ " .spacer { height: 1000px; }"
+ " .composited { will-change: transform; }"
+ " body { height: 2000px; width: 1000px; } "
+ "</style>"
+ "<div class='translucent box'><div class='spacer'></div></div>");
+
+ page().settings().setAcceleratedCompositingEnabled(true);
+ document().view()->setParentVisible(true);
+ document().view()->setSelfVisible(true);
+ document().view()->updateAllLifecyclePhases();
+
+ HistogramTester histogramTester;
+ // Test wheel scroll.
+ ScrollBeginEventBuilder wheelScrollBegin(
+ IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchpad);
+ ScrollEndEventBuilder wheelScrollEnd;
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(wheelScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 17,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 19,
+ 1);
+
+ // Test touch scroll.
+ ScrollBeginEventBuilder touchScrollBegin(
+ IntPoint(50, 50), FloatPoint(0.f, 1.f), WebGestureDeviceTouchscreen);
+ ScrollEndEventBuilder touchScrollEnd;
+ document().frame()->eventHandler().handleGestureEvent(touchScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(touchScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 17, 1);
+
+ document().frame()->eventHandler().handleGestureEvent(touchScrollBegin);
+ document().frame()->eventHandler().handleGestureEvent(touchScrollEnd);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 17, 2);
+}
+
bokan 2017/04/06 21:45:09 Please add a case with some nested scrollers, an e
yigu 2017/04/07 16:35:32 Done.
class TooltipCapturingChromeClient : public EmptyChromeClient {
public:
TooltipCapturingChromeClient() {}

Powered by Google App Engine
This is Rietveld 408576698