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

Unified Diff: third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp

Issue 1827793004: Add initial UMA metrics for ScrollAnchoring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase master Created 4 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/layout/ScrollAnchorTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
index f52e831c167a4f6402a05480ed27d987ad4668de..194ae5e604e12b76cd094bed82b273253e8e7973 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchorTest.cpp
@@ -7,6 +7,7 @@
#include "core/layout/LayoutBox.h"
#include "core/layout/LayoutTestHelper.h"
#include "core/paint/PaintLayerScrollableArea.h"
+#include "platform/testing/HistogramTester.h"
namespace blink {
@@ -83,6 +84,31 @@ TEST_F(ScrollAnchorTest, Basic)
EXPECT_EQ(nullptr, scrollAnchor(viewport).anchorObject());
}
+TEST_F(ScrollAnchorTest, UMAMetricUpdated)
+{
+ HistogramTester histogramTester;
+ setBodyInnerHTML(
+ "<style> body { height: 1000px } div { height: 100px } </style>"
+ "<div id='block1'>abc</div>"
+ "<div id='block2'>def</div>");
+
+ ScrollableArea* viewport = layoutViewport();
+
+ // Scroll position not adjusted, metric not updated.
+ scrollLayoutViewport(DoubleSize(0, 150));
+ histogramTester.expectTotalCount(
+ "Layout.ScrollAnchor.AdjustedScrollOffset", 0);
+
+ // Height changed, verify metric updated once.
+ setHeight(document().getElementById("block1"), 200);
+ histogramTester.expectUniqueSample(
+ "Layout.ScrollAnchor.AdjustedScrollOffset", 1, 1);
+
+ EXPECT_EQ(250, viewport->scrollPosition().y());
+ EXPECT_EQ(document().getElementById("block2")->layoutObject(),
+ scrollAnchor(viewport).anchorObject());
+}
+
TEST_F(ScrollAnchorTest, AnchorWithLayerInScrollingDiv)
{
setBodyInnerHTML(
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.cpp ('k') | third_party/WebKit/Source/platform/testing/HistogramTester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698