Commit 231cd963 authored by Shimi Zhang's avatar Shimi Zhang Committed by Commit Bot

Cursor Control: Add UMA counter

Records if a GestureScrollBegin is used as cursor control.

Bug: 1126778
Change-Id: Id0e9a8aec1c20f1eaf21d9a44dbfcb622b919fc4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517900
Commit-Queue: Shimi Zhang <ctzsm@chromium.org>
Reviewed-by: default avatarStephen Chenney <schenney@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823846}
parent 962cbbe8
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/browser/renderer_host/input/synthetic_gesture.h" #include "content/browser/renderer_host/input/synthetic_gesture.h"
...@@ -837,6 +838,7 @@ class TouchActionBrowserTestEnableCursorControl ...@@ -837,6 +838,7 @@ class TouchActionBrowserTestEnableCursorControl
// scroll, and changes the selection. // scroll, and changes the selection.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
BasicCursorControl) { BasicCursorControl) {
base::HistogramTester histograms;
LoadURL(kContentEditableDataURL.c_str()); LoadURL(kContentEditableDataURL.c_str());
EXPECT_EQ(32, EXPECT_EQ(32,
...@@ -855,6 +857,10 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, ...@@ -855,6 +857,10 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
EXPECT_EQ(anchor_offset, focus_offset); EXPECT_EQ(anchor_offset, focus_offset);
EXPECT_GT(32, anchor_offset); EXPECT_GT(32, anchor_offset);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
true, 1);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
false, 0);
} }
// Perform a horizontal swipe over an editable element from right to left (the // Perform a horizontal swipe over an editable element from right to left (the
...@@ -863,6 +869,7 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, ...@@ -863,6 +869,7 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
// changed and scroll should happen. // changed and scroll should happen.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
NoCursorControlForHorizontalScrollable) { NoCursorControlForHorizontalScrollable) {
base::HistogramTester histograms;
LoadURL(kContentEditableHorizontalScrollableDataURL.c_str()); LoadURL(kContentEditableHorizontalScrollableDataURL.c_str());
EXPECT_EQ(32, EXPECT_EQ(32,
...@@ -883,6 +890,10 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, ...@@ -883,6 +890,10 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
EXPECT_EQ(32, anchor_offset); EXPECT_EQ(32, anchor_offset);
EXPECT_LT(0.f, ExecuteScriptAndExtractDouble( EXPECT_LT(0.f, ExecuteScriptAndExtractDouble(
"document.getElementById('scroller').scrollLeft")); "document.getElementById('scroller').scrollLeft"));
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
true, 0);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
false, 1);
} }
// Perform a horizontal swipe over an editable element from right to left // Perform a horizontal swipe over an editable element from right to left
...@@ -914,6 +925,7 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, ...@@ -914,6 +925,7 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
// scroll, and changes the selection. // scroll, and changes the selection.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
CursorControlOnInput) { CursorControlOnInput) {
base::HistogramTester histograms;
// input size larger than the text size, not horizontally scrollable. // input size larger than the text size, not horizontally scrollable.
LoadURL(base::StringPrintf(kInputTagCursorControl.c_str(), 40).c_str()); LoadURL(base::StringPrintf(kInputTagCursorControl.c_str(), 40).c_str());
...@@ -931,12 +943,17 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, ...@@ -931,12 +943,17 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
EXPECT_EQ(selection_start, selection_end); EXPECT_EQ(selection_start, selection_end);
EXPECT_GT(32, selection_start); EXPECT_GT(32, selection_start);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
true, 1);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
false, 0);
} }
// Perform a horizontal swipe over an horizontal scrollable input element from // Perform a horizontal swipe over an horizontal scrollable input element from
// right to left. Ensure the swipe is doing scrolling other than cursor control. // right to left. Ensure the swipe is doing scrolling other than cursor control.
IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
NoCursorControlOnHorizontalScrollableInput) { NoCursorControlOnHorizontalScrollableInput) {
base::HistogramTester histograms;
// Make the input size smaller than the text size, so it horizontally // Make the input size smaller than the text size, so it horizontally
// scrollable. // scrollable.
LoadURL(base::StringPrintf(kInputTagCursorControl.c_str(), 20).c_str()); LoadURL(base::StringPrintf(kInputTagCursorControl.c_str(), 20).c_str());
...@@ -955,6 +972,10 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl, ...@@ -955,6 +972,10 @@ IN_PROC_BROWSER_TEST_F(TouchActionBrowserTestEnableCursorControl,
EXPECT_EQ(selection_start, selection_end); EXPECT_EQ(selection_start, selection_end);
EXPECT_EQ(32, selection_start); EXPECT_EQ(32, selection_start);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
true, 0);
histograms.ExpectBucketCount("Blink.Input.GestureScrollBeginAsCursorControl",
false, 1);
} }
} // namespace content } // namespace content
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/check_op.h" #include "base/check_op.h"
#include "base/debug/crash_logging.h" #include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h" #include "base/debug/dump_without_crashing.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h" #include "base/notreached.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
...@@ -116,6 +117,8 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent( ...@@ -116,6 +117,8 @@ FilterGestureEventResult TouchActionFilter::FilterGestureEvent(
FilterGestureEventResult res; FilterGestureEventResult res;
if (!drop_scroll_events_) { if (!drop_scroll_events_) {
SetCursorControlIfNecessary(gesture_event, touch_action); SetCursorControlIfNecessary(gesture_event, touch_action);
UMA_HISTOGRAM_BOOLEAN("Blink.Input.GestureScrollBeginAsCursorControl",
gesture_event->data.scroll_begin.cursor_control);
res = FilterGestureEventResult::kFilterGestureEventAllowed; res = FilterGestureEventResult::kFilterGestureEventAllowed;
} else if (active_touch_action_.has_value()) { } else if (active_touch_action_.has_value()) {
res = FilterGestureEventResult::kFilterGestureEventFiltered; res = FilterGestureEventResult::kFilterGestureEventFiltered;
......
...@@ -1042,6 +1042,14 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -1042,6 +1042,14 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="Blink.Input.GestureScrollBeginAsCursorControl"
enum="BooleanSuccess" expires_after="M89">
<owner>ctzsm@chromium.org</owner>
<owner>changwan@chromium.org</owner>
<owner>input-dev@chromium.org</owner>
<summary>Records if a GestureScrollBegin is for cursor control.</summary>
</histogram>
<histogram name="Blink.IntersectionObservation.UpdateTime" units="microseconds" <histogram name="Blink.IntersectionObservation.UpdateTime" units="microseconds"
expires_after="2021-03-21"> expires_after="2021-03-21">
<!-- Name completed by histogram_suffixes name="BlinkUpdateTimeAggregatedSuffixes" --> <!-- Name completed by histogram_suffixes name="BlinkUpdateTimeAggregatedSuffixes" -->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment