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

capture_mode: Add metrics for the number of times a user adjusts region.

This CL adds metrics for counting the number of times a user adjusts a
capture region. Visit go/capture-mode-metrics to see other planned
metrics.

Test: manual + added
Bug: 1140182
Change-Id: Ib058be572eff6c539e8673cd9a25d340e053b521
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2523492Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarWeilun Shi <sweilun@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarSammie Quon <sammiequon@chromium.org>
Commit-Queue: Jeremy Chinsen <chinsenj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826386}
parent ae580ab8
......@@ -313,6 +313,9 @@ void CaptureModeController::PerformCapture() {
return;
}
if (source_ == CaptureModeSource::kRegion)
capture_mode_session_->ReportRegionCaptureHistograms();
if (type_ == CaptureModeType::kImage)
CaptureImage();
else
......
......@@ -11,9 +11,11 @@ namespace ash {
namespace {
constexpr char kEntryHistogramName[] = "Ash.CaptureModeController.EntryPoint";
constexpr char kCaptureRegionAdjustmentHistogramName[] =
"Ash.CaptureModeController.CaptureRegionAdjusted";
constexpr char kBarButtonHistogramName[] =
"Ash.CaptureModeController.BarButtons";
constexpr char kEntryHistogramName[] = "Ash.CaptureModeController.EntryPoint";
// Appends the proper suffix to |prefix| based on whether the user is in tablet
// mode or not.
......@@ -35,4 +37,10 @@ void RecordCaptureModeEntryType(CaptureModeEntryType entry_type) {
GetCaptureModeHistogramName(kEntryHistogramName), entry_type);
}
void RecordNumberOfCaptureRegionAdjustments(int num_adjustments) {
base::UmaHistogramCounts100(
GetCaptureModeHistogramName(kCaptureRegionAdjustmentHistogramName),
num_adjustments);
}
} // namespace ash
......@@ -38,6 +38,13 @@ void RecordCaptureModeBarButtonType(CaptureModeBarButtonType button_type);
// Records the method the user enters capture mode given by |entry_type|.
void RecordCaptureModeEntryType(CaptureModeEntryType entry_type);
// Records the number of times a user adjusts a capture region. This includes
// moving and resizing. The count is started when a user sets the capture source
// as a region. The count is recorded and reset when a user performs a capture.
// The count is just reset when a user selects a new region or the user switches
// capture sources.
void RecordNumberOfCaptureRegionAdjustments(int num_adjustments);
} // namespace ash
#endif // ASH_CAPTURE_MODE_CAPTURE_MODE_METRICS_H_
......@@ -323,6 +323,7 @@ void CaptureModeSession::OnCaptureSourceChanged(CaptureModeSource new_source) {
previous_location_in_root_)
? ui::mojom::CursorType::kPointer
: ui::mojom::CursorType::kCell);
num_capture_region_adjusted_ = 0;
} else {
cursor_setter_.reset();
}
......@@ -340,6 +341,12 @@ void CaptureModeSession::OnCaptureTypeChanged(CaptureModeType new_type) {
UpdateCaptureLabelWidget();
}
void CaptureModeSession::ReportRegionCaptureHistograms() {
DCHECK_EQ(controller_->source(), CaptureModeSource::kRegion);
RecordNumberOfCaptureRegionAdjustments(num_capture_region_adjusted_);
num_capture_region_adjusted_ = 0;
}
void CaptureModeSession::StartCountDown(
base::OnceClosure countdown_finished_callback) {
DCHECK(capture_label_widget_);
......@@ -715,9 +722,13 @@ void CaptureModeSession::OnLocatedEventPressed(
// restart to the select phase.
is_selecting_region_ = true;
UpdateCaptureRegion(gfx::Rect(), /*is_resizing=*/true);
num_capture_region_adjusted_ = 0;
return;
}
if (fine_tune_position_ != FineTunePosition::kNone)
++num_capture_region_adjusted_;
// In order to hide the drag affordance circles on click, we need to repaint
// the capture region.
if (capture_mode_util::ShouldHideDragAffordance(fine_tune_position_)) {
......
......@@ -71,6 +71,10 @@ class ASH_EXPORT CaptureModeSession : public ui::LayerOwner,
void OnCaptureSourceChanged(CaptureModeSource new_source);
void OnCaptureTypeChanged(CaptureModeType new_type);
// Called when the capture source is region and the user performs a capture.
// Records |num_capture_region_adjusted_| to corresponding histogram.
void ReportRegionCaptureHistograms();
// Called when starting 3-seconds count down before recording video.
void StartCountDown(base::OnceClosure countdown_finished_callback);
......@@ -247,6 +251,11 @@ class ASH_EXPORT CaptureModeSession : public ui::LayerOwner,
// True when dragging is in progress.
bool is_drag_in_progress_ = false;
// Counter used to track the number of times a user adjusts a capture region.
// This should be reset when a user creates a new capture region, changes
// capture sources or when a user performs a capture.
int num_capture_region_adjusted_ = 0;
};
} // namespace ash
......
......@@ -1345,4 +1345,87 @@ TEST_F(CaptureModeTest, CancelCaptureDuringCountDown) {
SendKey(ui::VKEY_ESCAPE, event_generator);
}
// Tests that metrics are recorded properly for capture region adjustments.
TEST_F(CaptureModeTest, NumberOfCaptureRegionAdjustmentsHistogram) {
constexpr char kClamshellHistogram[] =
"Ash.CaptureModeController.CaptureRegionAdjusted.ClamshellMode";
constexpr char kTabletHistogram[] =
"Ash.CaptureModeController.CaptureRegionAdjusted.TabletMode";
base::HistogramTester histogram_tester;
UpdateDisplay("800x800");
auto* controller = StartImageRegionCapture();
// Create the initial region.
const gfx::Rect target_region(gfx::Rect(200, 200, 400, 400));
SelectRegion(target_region);
auto resize_and_reset_region = [](ui::test::EventGenerator* event_generator,
const gfx::Point& top_right) {
// Enlarges the region and then resize it back to its original size.
event_generator->set_current_screen_location(top_right);
event_generator->DragMouseTo(top_right + gfx::Vector2d(50, 50));
event_generator->DragMouseTo(top_right);
};
auto move_and_reset_region = [](ui::test::EventGenerator* event_generator,
const gfx::Point& drag_point) {
// Moves the region and then moves it back to its original position.
event_generator->set_current_screen_location(drag_point);
event_generator->DragMouseTo(drag_point + gfx::Vector2d(-50, -50));
event_generator->DragMouseTo(drag_point);
};
// Resize the region twice by dragging the top right of the region out and
// then back again.
auto* event_generator = GetEventGenerator();
auto top_right = target_region.top_right();
resize_and_reset_region(event_generator, top_right);
// Move the region twice by dragging within the region.
const gfx::Point drag_point(300, 300);
move_and_reset_region(event_generator, drag_point);
// Perform a capture to record the count.
controller->PerformCapture();
histogram_tester.ExpectBucketCount(kClamshellHistogram, 4, 1);
// Create a new image region capture. Move the region twice then change
// sources to fullscreen and back to region. This toggle should reset the
// count. Perform a capture to record the count.
StartImageRegionCapture();
move_and_reset_region(event_generator, drag_point);
controller->SetSource(CaptureModeSource::kFullscreen);
controller->SetSource(CaptureModeSource::kRegion);
controller->PerformCapture();
histogram_tester.ExpectBucketCount(kClamshellHistogram, 0, 1);
// Enter tablet mode and restart the capture session. The capture region
// should be remembered.
auto* tablet_mode_controller = Shell::Get()->tablet_mode_controller();
tablet_mode_controller->SetEnabledForTest(true);
ASSERT_TRUE(tablet_mode_controller->InTabletMode());
StartImageRegionCapture();
ASSERT_EQ(target_region, controller->user_capture_region());
// Resize the region twice by dragging the top right of the region out and
// then back again.
resize_and_reset_region(event_generator, top_right);
// Move the region twice by dragging within the region.
move_and_reset_region(event_generator, drag_point);
// Perform a capture to record the count.
controller->PerformCapture();
histogram_tester.ExpectBucketCount(kTabletHistogram, 4, 1);
// Restart the region capture and resize it. Then create a new region by
// dragging outside of the existing capture region. This should reset the
// counter. Change source to record a sample.
StartImageRegionCapture();
resize_and_reset_region(event_generator, top_right);
SelectRegion(gfx::Rect(0, 0, 100, 100));
controller->PerformCapture();
histogram_tester.ExpectBucketCount(kTabletHistogram, 0, 1);
}
} // namespace ash
......@@ -199,6 +199,24 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</token>
</histogram>
<histogram
name="Ash.CaptureModeController.CaptureRegionAdjusted.{TabletOrClamshell}"
units="adjustments" expires_after="2021-11-06">
<owner>chinsenj@chromium.org</owner>
<owner>gzadina@google.com</owner>
<summary>
Recorded whenever a user is in a region capture session in
{TabletOrClamshell} and performs a capture or they switch the capture
source. The recorded count indicates the number of times the user adjusts
the region. This counts each time they move the region or resize it. It is
reset whenever a user creates a new region or the count is recorded.
</summary>
<token key="TabletOrClamshell">
<variant name="ClamshellMode" summary="Clamshell mode"/>
<variant name="TabletMode" summary="Tablet mode"/>
</token>
</histogram>
<histogram name="Ash.CaptureModeController.EntryPoint.{TabletOrClamshell}"
enum="CaptureModeEntryType" expires_after="2021-09-29">
<owner>chinsenj@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