Commit 0522133d authored by Daniel Classon's avatar Daniel Classon Committed by Commit Bot

[OsSettingsMetrics] Add Metric for kTouchpadSpeed (Int pref setting ex.)

Adds a metric for the kTouchpadSpeed setting on the Device Page. It
records the sensitivity value that the slider was set to.

Bug: 1133553
Change-Id: I85cbc27b0bced774672fa1bbbcbc2508ff23092c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2459789
Commit-Queue: Daniel Classon <dclasson@google.com>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816765}
parent f93556a5
......@@ -57,6 +57,7 @@ Polymer({
/**
* TODO(michaelpg): settings-slider should optionally take a min and max so
* we don't have to generate a simple range of natural numbers ourselves.
* These values match the TouchpadSensitivity enum in enums.xml.
* @type {!Array<number>}
* @private
*/
......
......@@ -30,6 +30,14 @@
value: {boolValue: /** @type {boolean} */ (prefValue)}
};
// device_page/pointers.js
case 'settings.touchpad.sensitivity2':
console.log(prefValue);
return {
setting: chromeos.settings.mojom.Setting.kTouchpadSpeed,
value: {intValue: /** @type {number} */ (prefValue)}
};
// pref to setting metric not implemented.
default:
return null;
......
......@@ -717,6 +717,17 @@ void AddDevicePowerStrings(content::WebUIDataSource* html_source) {
AddLocalizedStringsBulk(html_source, kPowerStrings);
}
// Mirrors enum of the same name in enums.xml.
enum class TouchpadSensitivity {
kNONE = 0,
kSlowest = 1,
kSlow = 2,
kMedium = 3,
kFast = 4,
kFastest = 5,
kMaxValue = kFastest,
};
} // namespace
DeviceSection::DeviceSection(Profile* profile,
......@@ -844,6 +855,12 @@ std::string DeviceSection::GetSectionPath() const {
bool DeviceSection::LogMetric(mojom::Setting setting,
base::Value& value) const {
switch (setting) {
case mojom::Setting::kTouchpadSpeed:
base::UmaHistogramEnumeration(
"ChromeOS.Settings.Device.TouchpadSpeedValue",
static_cast<TouchpadSensitivity>(value.GetInt()));
return true;
case mojom::Setting::kKeyboardFunctionKeys:
base::UmaHistogramBoolean("ChromeOS.Settings.Device.KeyboardFunctionKeys",
value.GetBool());
......
......@@ -44,6 +44,8 @@ class SettingsUserActionTracker : public mojom::UserActionRecorder {
TestRecordSettingChangedInt);
FRIEND_TEST_ALL_PREFIXES(SettingsUserActionTrackerTest,
TestRecordSettingChangedBoolPref);
FRIEND_TEST_ALL_PREFIXES(SettingsUserActionTrackerTest,
TestRecordSettingChangedIntPref);
// mojom::UserActionRecorder:
void RecordPageFocus() override;
......
......@@ -35,6 +35,8 @@ class SettingsUserActionTrackerTest : public testing::Test {
mojom::Setting::kBluetoothOnOff);
fake_hierarchy_.AddSettingMetadata(mojom::Section::kDevice,
mojom::Setting::kKeyboardFunctionKeys);
fake_hierarchy_.AddSettingMetadata(mojom::Section::kDevice,
mojom::Setting::kTouchpadSpeed);
fake_hierarchy_.AddSettingMetadata(mojom::Section::kPeople,
mojom::Setting::kAddAccount);
}
......@@ -112,5 +114,29 @@ TEST_F(SettingsUserActionTrackerTest, TestRecordSettingChangedBoolPref) {
mojom::Setting::kKeyboardFunctionKeys);
}
TEST_F(SettingsUserActionTrackerTest, TestRecordSettingChangedIntPref) {
// Record that the touchpad speed slider was changed by the user. This
// setting is controlled by a pref and uses the pref-to-setting-metric
// converter flow.
tracker_.RecordSettingChangeWithDetails(
mojom::Setting::kTouchpadSpeed,
mojom::SettingChangeValue::NewIntValue(4));
// The umbrella metric for which setting was changed should be updated. Note
// that kTouchpadSpeed has enum value of 405.
histogram_tester_.ExpectTotalCount("ChromeOS.Settings.SettingChanged",
/*count=*/1);
histogram_tester_.ExpectBucketCount("ChromeOS.Settings.SettingChanged",
/*sample=*/405,
/*count=*/1);
// The LogMetric fn in the Device section should have been called.
const FakeOsSettingsSection* device_section =
static_cast<const FakeOsSettingsSection*>(
fake_sections_.GetSection(mojom::Section::kDevice));
EXPECT_TRUE(device_section->logged_metrics().back() ==
mojom::Setting::kTouchpadSpeed);
}
} // namespace settings.
} // namespace chromeos.
......@@ -71690,6 +71690,15 @@ would be helpful to identify which type is being sent.
</int>
</enum>
<enum name="TouchpadSensitivity">
<int value="0" label="NONE"/>
<int value="1" label="Slowest"/>
<int value="2" label="Slow"/>
<int value="3" label="Medium"/>
<int value="4" label="Fast"/>
<int value="5" label="Fastest"/>
</enum>
<enum name="TouchTargetAndDispatchResultType">
<int value="0"
label="Non-root-scroller, non-scrollable document, not handled"/>
......@@ -559,6 +559,18 @@ incoming reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="ChromeOS.Settings.Device.TouchpadSpeedValue"
enum="TouchpadSensitivity" expires_after="2021-09-30">
<owner>khorimoto@chromium.org</owner>
<owner>hsuregan@chromium.org</owner>
<owner>cros-customization@google.com</owner>
<summary>
Records when users change the Touchpad Speed on the Device page. The value
saved is equal to the sensitivity value set on the slider, which ranges from
1 to 5.
</summary>
</histogram>
<histogram name="ChromeOS.Settings.Languages.Browser.Interaction"
enum="SettingsLanguagesPageBrowserInteraction" expires_after="2021-03-31">
<owner>myy@chromium.org</owner>
......
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