rgbkbd: Add RgbKeyboardCapabilityType metric
- Records the response from GetRgbKeyboardCapabilities. Bug: b/214077425 Test: ash_unittests Change-Id: I0467b0b3600d39f61b9e0f3b47d5563e31f90ef8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3753298 Reviewed-by: Zentaro Kavanagh <zentaro@chromium.org> Commit-Queue: Michael Checo <michaelcheco@google.com> Cr-Commit-Position: refs/heads/main@{#1026017}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
fcebaf80d6
commit
a0888700a5
@@ -797,6 +797,8 @@ component("ash") {
|
||||
"public/cpp/style/scoped_light_mode_as_default.h",
|
||||
"public/cpp/window_finder.h",
|
||||
"public/cpp/window_tree_host_lookup.h",
|
||||
"rgb_keyboard/histogram_util.cc",
|
||||
"rgb_keyboard/histogram_util.h",
|
||||
"rgb_keyboard/rgb_keyboard_manager.cc",
|
||||
"rgb_keyboard/rgb_keyboard_manager.h",
|
||||
"rgb_keyboard/rgb_keyboard_util.cc",
|
||||
|
15
ash/rgb_keyboard/histogram_util.cc
Normal file
15
ash/rgb_keyboard/histogram_util.cc
Normal file
@@ -0,0 +1,15 @@
|
||||
// Copyright 2022 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/rgb_keyboard/histogram_util.h"
|
||||
|
||||
#include "base/metrics/histogram_functions.h"
|
||||
|
||||
namespace ash::rgb_keyboard::metrics {
|
||||
void EmitRgbKeyboardCapabilityType(
|
||||
rgbkbd::RgbKeyboardCapabilities capabilities) {
|
||||
base::UmaHistogramEnumeration(kRgbKeyboardCapabilityTypeHistogramName,
|
||||
RgbKeyboardCapabilityType(capabilities));
|
||||
}
|
||||
} // namespace ash::rgb_keyboard::metrics
|
34
ash/rgb_keyboard/histogram_util.h
Normal file
34
ash/rgb_keyboard/histogram_util.h
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2022 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_RGB_KEYBOARD_HISTOGRAM_UTIL_H_
|
||||
#define ASH_RGB_KEYBOARD_HISTOGRAM_UTIL_H_
|
||||
|
||||
#include "third_party/cros_system_api/dbus/rgbkbd/dbus-constants.h"
|
||||
|
||||
namespace ash::rgb_keyboard::metrics {
|
||||
|
||||
constexpr char kRgbKeyboardCapabilityTypeHistogramName[] =
|
||||
"ChromeOS.RgbKeyboard.RgbKeyboardCapabilityType";
|
||||
|
||||
// The enums below are used in histograms, do not remove/renumber entries. If
|
||||
// you're adding to any of these enums, update the corresponding enum listing in
|
||||
// tools/metrics/histograms/enums.xml: RgbKeyboardCapabilityType.
|
||||
// RgbKeyboardCapabilityType gets its values from RgbKeyboardCapabilities
|
||||
// defined in: third_party/cros_system_api/dbus/rgbkbd/dbus-constants.h.
|
||||
enum class RgbKeyboardCapabilityType {
|
||||
kNone = 0,
|
||||
kIndividualKey = 1,
|
||||
kFourZoneFortyLed = 2,
|
||||
kFourZoneTwelveLed = 3,
|
||||
kFourZoneFifteenLed = 4,
|
||||
kMaxValue = kFourZoneFifteenLed,
|
||||
};
|
||||
|
||||
void EmitRgbKeyboardCapabilityType(
|
||||
rgbkbd::RgbKeyboardCapabilities capabilities);
|
||||
|
||||
} // namespace ash::rgb_keyboard::metrics
|
||||
|
||||
#endif // ASH_RGB_KEYBOARD_HISTOGRAM_UTIL_H_
|
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/ime/ime_controller_impl.h"
|
||||
#include "ash/rgb_keyboard/histogram_util.h"
|
||||
#include "ash/rgb_keyboard/rgb_keyboard_util.h"
|
||||
#include "base/check.h"
|
||||
#include "base/check_op.h"
|
||||
@@ -117,6 +118,7 @@ void RgbKeyboardManager::OnGetRgbKeyboardCapabilities(
|
||||
}
|
||||
|
||||
capabilities_ = reply.value();
|
||||
ash::rgb_keyboard::metrics::EmitRgbKeyboardCapabilityType(capabilities_);
|
||||
VLOG(1) << "RGB Keyboard capabilities="
|
||||
<< static_cast<uint32_t>(capabilities_);
|
||||
|
||||
|
@@ -9,7 +9,9 @@
|
||||
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/ime/ime_controller_impl.h"
|
||||
#include "ash/rgb_keyboard/histogram_util.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chromeos/ash/components/dbus/rgbkbd/fake_rgbkbd_client.h"
|
||||
#include "chromeos/ash/components/dbus/rgbkbd/rgbkbd_client.h"
|
||||
@@ -69,6 +71,51 @@ TEST_F(RgbKeyboardManagerTest, GetKeyboardCapabilities) {
|
||||
client_->get_rgb_keyboard_capabilities());
|
||||
}
|
||||
|
||||
class KeyboardCapabilityHistogramEmittedTest
|
||||
: public RgbKeyboardManagerTest,
|
||||
public testing::WithParamInterface<
|
||||
std::pair<rgbkbd::RgbKeyboardCapabilities,
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType>> {
|
||||
public:
|
||||
KeyboardCapabilityHistogramEmittedTest() {
|
||||
std::tie(capability_, metric_) = GetParam();
|
||||
}
|
||||
|
||||
protected:
|
||||
rgbkbd::RgbKeyboardCapabilities capability_;
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType metric_;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
All,
|
||||
KeyboardCapabilityHistogramEmittedTest,
|
||||
testing::Values(
|
||||
std::make_pair(
|
||||
rgbkbd::RgbKeyboardCapabilities::kNone,
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType::kNone),
|
||||
std::make_pair(rgbkbd::RgbKeyboardCapabilities::kIndividualKey,
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType::
|
||||
kIndividualKey),
|
||||
std::make_pair(rgbkbd::RgbKeyboardCapabilities::kFourZoneFortyLed,
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType::
|
||||
kFourZoneFortyLed),
|
||||
std::make_pair(rgbkbd::RgbKeyboardCapabilities::kFourZoneTwelveLed,
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType::
|
||||
kFourZoneTwelveLed),
|
||||
std::make_pair(rgbkbd::RgbKeyboardCapabilities::kFourZoneFifteenLed,
|
||||
ash::rgb_keyboard::metrics::RgbKeyboardCapabilityType::
|
||||
kFourZoneFifteenLed)));
|
||||
|
||||
TEST_P(KeyboardCapabilityHistogramEmittedTest,
|
||||
KeyboardCapabilityHistogramEmitted) {
|
||||
base::HistogramTester histogram_tester;
|
||||
InitializeManagerWithCapability(capability_);
|
||||
EXPECT_EQ(capability_, client_->get_rgb_keyboard_capabilities());
|
||||
histogram_tester.ExpectBucketCount(
|
||||
rgb_keyboard::metrics::kRgbKeyboardCapabilityTypeHistogramName, metric_,
|
||||
1);
|
||||
}
|
||||
|
||||
TEST_F(RgbKeyboardManagerTest, SetStaticRgbValues) {
|
||||
const uint8_t expected_r = 1;
|
||||
const uint8_t expected_g = 2;
|
||||
|
@@ -83634,6 +83634,19 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
|
||||
<int value="3" label="Revoke tokens for primary and secondary accounts"/>
|
||||
</enum>
|
||||
|
||||
<!--
|
||||
This must be kept current with RgbKeyboardCapabilities located in
|
||||
third_party/cros_system_api/dbus/rgbkbd/dbus-constants.h.
|
||||
-->
|
||||
|
||||
<enum name="RgbKeyboardCapabilityType">
|
||||
<int value="0" label="None"/>
|
||||
<int value="1" label="IndividualKey"/>
|
||||
<int value="2" label="FourZoneFortyLed"/>
|
||||
<int value="3" label="FourZoneTwelveLed"/>
|
||||
<int value="4" label="FourZoneFifteenLed"/>
|
||||
</enum>
|
||||
|
||||
<enum name="RoamingUserDataDirectoryDeletionResult">
|
||||
<obsolete>
|
||||
Removed in 2020-08 (M86).
|
||||
|
@@ -1378,6 +1378,22 @@ incoming reviews. Googlers can read more about this at go/gwsq-gerrit.
|
||||
</summary>
|
||||
</histogram>
|
||||
|
||||
<histogram name="ChromeOS.RgbKeyboard.RgbKeyboardCapabilityType"
|
||||
enum="RgbKeyboardCapabilityType" expires_after="2023-07-07">
|
||||
<owner>michaelcheco@google.com</owner>
|
||||
<owner>dpad@google.com</owner>
|
||||
<owner>jimmyxgong@chromium.org</owner>
|
||||
<owner>zentaro@chromium.org</owner>
|
||||
<owner>cros-peripherals@google.com</owner>
|
||||
<summary>
|
||||
Records whether or not RGB keyboard is supported for the current device.
|
||||
Most devices will return RgbKeyboardCapabilityType::None since RGB keyboard
|
||||
is currently only supported on a handful of devices. We still include these
|
||||
samples since it'll be useful for finding real failures, i.e,
|
||||
RgbKeyboardCapabilityType::None is recorded for a device that supports RGB.
|
||||
</summary>
|
||||
</histogram>
|
||||
|
||||
<histogram name="ChromeOS.SAML.APILogin" enum="ChromeOSSamlApiUsed"
|
||||
expires_after="2022-10-02">
|
||||
<owner>mslus@chromium.org</owner>
|
||||
|
Reference in New Issue
Block a user