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

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: nit Created 3 years, 9 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 f8618151f6be13253f4f4efeefa617b8fe13d3b2..2e225ca1401d9a617ac0af124d0bf1768be40eaa 100644
--- a/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
+++ b/third_party/WebKit/Source/core/input/EventHandlerTest.cpp
@@ -16,6 +16,8 @@
#include "core/page/AutoscrollController.h"
#include "core/page/Page.h"
#include "core/testing/DummyPageHolder.h"
+#include "platform/testing/HistogramTester.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
@@ -461,6 +463,87 @@ TEST_F(EventHandlerTest, dragEndInNewDrag) {
// This test passes if it doesn't crash.
}
+TEST_F(EventHandlerTest, MainThreadScrollingReasonRecordTest) {
+ HistogramTester histogramTester;
+ // Test wheel scroll
+ ScrollManager* scrollManager = new ScrollManager(*(document().frame()));
+ scrollManager->recordMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects |
+ MainThreadScrollingReason::kThreadedScrollingDisabled |
+ MainThreadScrollingReason::kPageOverlay |
+ MainThreadScrollingReason::kHandlingScrollFromMainThread,
+ WebGestureDeviceTouchpad);
+
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 1,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 3,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 5,
+ 1);
+
+ // We only want to record "Handling scroll from main thread" reason if it's
+ // the only reason. If it's not the only reason, the "real" reason for
+ // scrolling on main is something else, and we only want to pay attention to
+ // that reason. So we should only include this reason in the histogram when
+ // its on its own.
+ scrollManager->recordMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHandlingScrollFromMainThread,
+ blink::WebGestureDeviceTouchpad);
+
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 1,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 3,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 5,
+ 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 14,
+ 1);
+
+ scrollManager->recordMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects |
+ MainThreadScrollingReason::kThreadedScrollingDisabled |
+ MainThreadScrollingReason::kPageOverlay |
+ MainThreadScrollingReason::kHandlingScrollFromMainThread,
+ WebGestureDeviceTouchpad);
+
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 1,
+ 2);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 3,
+ 2);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 5,
+ 2);
+ histogramTester.expectBucketCount("Renderer4.MainThreadWheelScrollReason", 14,
+ 1);
+
+ // Test touch scroll
+ scrollManager->recordMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects |
+ MainThreadScrollingReason::kThreadedScrollingDisabled |
+ MainThreadScrollingReason::kPageOverlay |
+ MainThreadScrollingReason::kHandlingScrollFromMainThread,
+ WebGestureDeviceTouchscreen);
+
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 1, 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 3, 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 5, 1);
+
+ scrollManager->recordMainThreadScrollingReasons(
+ MainThreadScrollingReason::kHandlingScrollFromMainThread,
+ blink::WebGestureDeviceTouchscreen);
+
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 1, 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 3, 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 5, 1);
+ histogramTester.expectBucketCount("Renderer4.MainThreadGestureScrollReason",
+ 14, 1);
+}
+
class TooltipCapturingChromeClient : public EmptyChromeClient {
public:
TooltipCapturingChromeClient() {}

Powered by Google App Engine
This is Rietveld 408576698