Commit f9c37034 authored by chinsenj's avatar chinsenj Committed by Commit Bot

capture_mode: Add metrics for a user's capture config when they capture.

This CL adds metrics for the configuration a user has when they capture.
I.e. taking a fullscreen screenshot, window screenshot, etc.

Test: manual + added
Bug: 1140182
Change-Id: Ibe4f6289d754d76e1e6ecba1d9442cdfc96d0d3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2538062
Commit-Queue: Jeremy Chinsen <chinsenj@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828968}
parent 109bc266
......@@ -13,6 +13,8 @@ namespace {
constexpr char kBarButtonHistogramName[] =
"Ash.CaptureModeController.BarButtons";
constexpr char kCaptureConfigurationHistogramName[] =
"Ash.CaptureModeController.CaptureConfiguration";
constexpr char kCaptureRegionAdjustmentHistogramName[] =
"Ash.CaptureModeController.CaptureRegionAdjusted";
constexpr char kConsecutiveScreenshotHistogramName[] =
......@@ -35,6 +37,28 @@ std::string GetCaptureModeHistogramName(std::string prefix) {
return prefix;
}
// Maps given |type| and |source| to CaptureModeConfiguration enum.
CaptureModeConfiguration GetConfiguration(CaptureModeType type,
CaptureModeSource source) {
switch (source) {
case CaptureModeSource::kFullscreen:
return type == CaptureModeType::kImage
? CaptureModeConfiguration::kFullscreenScreenshot
: CaptureModeConfiguration::kFullscreenRecording;
case CaptureModeSource::kRegion:
return type == CaptureModeType::kImage
? CaptureModeConfiguration::kRegionScreenshot
: CaptureModeConfiguration::kRegionRecording;
case CaptureModeSource::kWindow:
return type == CaptureModeType::kImage
? CaptureModeConfiguration::kWindowScreenshot
: CaptureModeConfiguration::kWindowRecording;
default:
NOTREACHED();
return CaptureModeConfiguration::kFullscreenScreenshot;
}
}
} // namespace
void RecordCaptureModeBarButtonType(CaptureModeBarButtonType button_type) {
......@@ -42,6 +66,13 @@ void RecordCaptureModeBarButtonType(CaptureModeBarButtonType button_type) {
GetCaptureModeHistogramName(kBarButtonHistogramName), button_type);
}
void RecordCaptureModeConfiguration(CaptureModeType type,
CaptureModeSource source) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kCaptureConfigurationHistogramName),
GetConfiguration(type, source));
}
void RecordCaptureModeEntryType(CaptureModeEntryType entry_type) {
base::UmaHistogramEnumeration(
GetCaptureModeHistogramName(kEntryHistogramName), entry_type);
......
......@@ -7,6 +7,8 @@
#include <stdint.h>
#include "ash/capture_mode/capture_mode_types.h"
namespace ash {
// Enumeration of capture bar buttons that can be pressed while in capture mode.
......@@ -22,6 +24,19 @@ enum class CaptureModeBarButtonType {
kMaxValue = kExit,
};
// Enumeration of the various configurations a user can have while in capture
// mode. Note that these values are persisted to histograms so existing values
// should remain unchanged and new values should be added to the end.
enum class CaptureModeConfiguration {
kFullscreenScreenshot,
kRegionScreenshot,
kWindowScreenshot,
kFullscreenRecording,
kRegionRecording,
kWindowRecording,
kMaxValue = kWindowRecording,
};
// Enumeration of actions that can be taken to enter capture mode. Note that
// these values are persisted to histograms so existing values should remain
// unchanged and new values should be added to the end.
......@@ -37,6 +52,10 @@ enum class CaptureModeEntryType {
// Records capture mode bar button presses given by |button_type|.
void RecordCaptureModeBarButtonType(CaptureModeBarButtonType button_type);
// Records a user's configuration when they perform a capture.
void RecordCaptureModeConfiguration(CaptureModeType type,
CaptureModeSource source);
// Records the method the user enters capture mode given by |entry_type|.
void RecordCaptureModeEntryType(CaptureModeEntryType entry_type);
......
......@@ -358,6 +358,7 @@ void CaptureModeSession::ReportSessionHistograms() {
num_capture_region_adjusted_ = 0;
RecordCaptureModeSwitchesFromInitialMode(capture_source_changed_);
RecordCaptureModeConfiguration(controller_->type(), controller_->source());
}
void CaptureModeSession::StartCountDown(
......
......@@ -1490,6 +1490,78 @@ TEST_F(CaptureModeTest, FullscreenCapture) {
EXPECT_FALSE(controller->IsActive());
}
// Tests that metrics are recorded properly for capture mode configurations when
// taking a screenshot.
TEST_F(CaptureModeTest, ScreenshotConfigurationHistogram) {
constexpr char kClamshellHistogram[] =
"Ash.CaptureModeController.CaptureConfiguration.ClamshellMode";
constexpr char kTabletHistogram[] =
"Ash.CaptureModeController.CaptureConfiguration.TabletMode";
base::HistogramTester histogram_tester;
// Use a set display size as we will be choosing points in this test.
UpdateDisplay("800x800");
// Create a window for window captures later.
std::unique_ptr<aura::Window> window1(
CreateTestWindow(gfx::Rect(600, 600, 100, 100)));
// Perform a fullscreen screenshot.
auto* controller = StartCaptureSession(CaptureModeSource::kFullscreen,
CaptureModeType::kImage);
controller->PerformCapture();
histogram_tester.ExpectBucketCount(
kClamshellHistogram, CaptureModeConfiguration::kFullscreenScreenshot, 1);
// Perform a region screenshot.
controller =
StartCaptureSession(CaptureModeSource::kRegion, CaptureModeType::kImage);
const gfx::Rect capture_region(200, 200, 400, 400);
SelectRegion(capture_region);
controller->PerformCapture();
histogram_tester.ExpectBucketCount(
kClamshellHistogram, CaptureModeConfiguration::kRegionScreenshot, 1);
// Perform a window screenshot.
controller =
StartCaptureSession(CaptureModeSource::kWindow, CaptureModeType::kImage);
auto* event_generator = GetEventGenerator();
event_generator->MoveMouseToCenterOf(window1.get());
EXPECT_EQ(window1.get(),
controller->capture_mode_session()->GetSelectedWindow());
controller->PerformCapture();
histogram_tester.ExpectBucketCount(
kClamshellHistogram, CaptureModeConfiguration::kWindowScreenshot, 1);
// Switch to tablet mode.
auto* tablet_mode_controller = Shell::Get()->tablet_mode_controller();
tablet_mode_controller->SetEnabledForTest(true);
ASSERT_TRUE(tablet_mode_controller->InTabletMode());
// Perform a fullscreen screenshot.
controller = StartCaptureSession(CaptureModeSource::kFullscreen,
CaptureModeType::kImage);
controller->PerformCapture();
histogram_tester.ExpectBucketCount(
kTabletHistogram, CaptureModeConfiguration::kFullscreenScreenshot, 1);
// Perform a region screenshot.
controller =
StartCaptureSession(CaptureModeSource::kRegion, CaptureModeType::kImage);
controller->PerformCapture();
histogram_tester.ExpectBucketCount(
kTabletHistogram, CaptureModeConfiguration::kRegionScreenshot, 1);
// Perform a window screenshot.
controller =
StartCaptureSession(CaptureModeSource::kWindow, CaptureModeType::kImage);
event_generator->MoveMouseToCenterOf(window1.get());
EXPECT_EQ(window1.get(),
controller->capture_mode_session()->GetSelectedWindow());
controller->PerformCapture();
histogram_tester.ExpectBucketCount(
kTabletHistogram, CaptureModeConfiguration::kWindowScreenshot, 1);
}
// A test class that uses a mock time task environment.
class CaptureModeMockTimeTest : public CaptureModeTest {
public:
......
......@@ -9274,6 +9274,15 @@ Called by update_bad_message_reasons.py.-->
<int value="5" label="Exit Button"/>
</enum>
<enum name="CaptureModeConfiguration">
<int value="0" label="Fullscreen screenshot"/>
<int value="1" label="Region screenshot"/>
<int value="2" label="Window screenshot"/>
<int value="3" label="Fullscreen recording"/>
<int value="4" label="Region recording"/>
<int value="5" label="Window recording"/>
</enum>
<enum name="CaptureModeEntryType">
<int value="0" label="Partial Screenshot Accelerator"/>
<int value="1" label="Window Screenshot Accelerator"/>
......@@ -195,6 +195,19 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<token key="TabletOrClamshell" variants="DisplayModes"/>
</histogram>
<histogram
name="Ash.CaptureModeController.CaptureConfiguration.{TabletOrClamshell}"
enum="CaptureModeConfiguration" expires_after="2021-11-13">
<owner>chinsenj@chromium.org</owner>
<owner>gzadina@google.com</owner>
<summary>
Recorded whenever a user performs a screen capture in {TabletOrClamshell}.
The recorded enum indicates the configuration used for the capture. I.e. the
capture source and the capture type.
</summary>
<token key="TabletOrClamshell" variants="DisplayModes"/>
</histogram>
<histogram
name="Ash.CaptureModeController.CaptureRegionAdjusted.{TabletOrClamshell}"
units="adjustments" expires_after="2021-11-06">
......
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