Commit cabc6526 authored by Mounir Lamouri's avatar Mounir Lamouri Committed by Commit Bot

Media Controls: remove timeline related metrics.

They were not used anymore.

Bug: 1142522
Fixed: 1142522
Change-Id: I01bf92f378ce85fedb6f972782267d0fbcd57f5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2498650Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821261}
parent 7c4ff65f
...@@ -71,8 +71,6 @@ blink_modules_sources("media_controls") { ...@@ -71,8 +71,6 @@ blink_modules_sources("media_controls") {
"elements/media_control_time_display_element.h", "elements/media_control_time_display_element.h",
"elements/media_control_timeline_element.cc", "elements/media_control_timeline_element.cc",
"elements/media_control_timeline_element.h", "elements/media_control_timeline_element.h",
"elements/media_control_timeline_metrics.cc",
"elements/media_control_timeline_metrics.h",
"elements/media_control_toggle_closed_captions_button_element.cc", "elements/media_control_toggle_closed_captions_button_element.cc",
"elements/media_control_toggle_closed_captions_button_element.h", "elements/media_control_toggle_closed_captions_button_element.h",
"elements/media_control_volume_control_container_element.cc", "elements/media_control_volume_control_container_element.cc",
......
...@@ -110,31 +110,19 @@ void MediaControlTimelineElement::DefaultEventHandler(Event& event) { ...@@ -110,31 +110,19 @@ void MediaControlTimelineElement::DefaultEventHandler(Event& event) {
Platform::Current()->RecordAction( Platform::Current()->RecordAction(
UserMetricsAction("Media.Controls.ScrubbingBegin")); UserMetricsAction("Media.Controls.ScrubbingBegin"));
GetMediaControls().BeginScrubbing(MediaControlsImpl::IsTouchEvent(&event)); GetMediaControls().BeginScrubbing(MediaControlsImpl::IsTouchEvent(&event));
Element* thumb = UserAgentShadowRoot()->getElementById(
shadow_element_names::kIdSliderThumb);
bool started_from_thumb = thumb && thumb == event.target()->ToNode();
metrics_.StartGesture(started_from_thumb);
} else if (EndScrubbingEvent(event)) { } else if (EndScrubbingEvent(event)) {
Platform::Current()->RecordAction( Platform::Current()->RecordAction(
UserMetricsAction("Media.Controls.ScrubbingEnd")); UserMetricsAction("Media.Controls.ScrubbingEnd"));
GetMediaControls().EndScrubbing(); GetMediaControls().EndScrubbing();
metrics_.RecordEndGesture(TrackWidth(), MediaElement().duration());
} }
if (event.type() == event_type_names::kFocus) if (event.type() == event_type_names::kFocus)
UpdateAria(); UpdateAria();
if (event.type() == event_type_names::kKeydown)
metrics_.StartKey();
auto* keyboard_event = DynamicTo<KeyboardEvent>(event);
if (event.type() == event_type_names::kKeyup && keyboard_event)
metrics_.RecordEndKey(TrackWidth(), keyboard_event->keyCode());
MediaControlInputElement::DefaultEventHandler(event); MediaControlInputElement::DefaultEventHandler(event);
if (IsA<MouseEvent>(event) || keyboard_event || IsA<GestureEvent>(event) || if (IsA<MouseEvent>(event) || IsA<KeyboardEvent>(event) ||
IsA<PointerEvent>(event)) { IsA<GestureEvent>(event) || IsA<PointerEvent>(event)) {
MaybeRecordInteracted(); MaybeRecordInteracted();
} }
...@@ -160,8 +148,6 @@ void MediaControlTimelineElement::DefaultEventHandler(Event& event) { ...@@ -160,8 +148,6 @@ void MediaControlTimelineElement::DefaultEventHandler(Event& event) {
if (time > duration) if (time > duration)
time = duration; time = duration;
metrics_.OnInput(MediaElement().currentTime(), time);
// FIXME: This will need to take the timeline offset into consideration // FIXME: This will need to take the timeline offset into consideration
// once that concept is supported, see https://crbug.com/312699 // once that concept is supported, see https://crbug.com/312699
if (MediaElement().seekable()->Contain(time)) if (MediaElement().seekable()->Contain(time))
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_TIMELINE_ELEMENT_H_ #define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_TIMELINE_ELEMENT_H_
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_slider_element.h" #include "third_party/blink/renderer/modules/media_controls/elements/media_control_slider_element.h"
#include "third_party/blink/renderer/modules/media_controls/elements/media_control_timeline_metrics.h"
#include "third_party/blink/renderer/modules/modules_export.h" #include "third_party/blink/renderer/modules/modules_export.h"
namespace blink { namespace blink {
...@@ -53,8 +52,6 @@ class MediaControlTimelineElement : public MediaControlSliderElement { ...@@ -53,8 +52,6 @@ class MediaControlTimelineElement : public MediaControlSliderElement {
void UpdateAria(); void UpdateAria();
MediaControlTimelineMetrics metrics_;
bool is_touching_ = false; bool is_touching_ = false;
bool controls_hidden_ = false; bool controls_hidden_ = false;
......
// Copyright 2017 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 "third_party/blink/renderer/modules/media_controls/elements/media_control_timeline_metrics.h"
#include <stdint.h>
#include <cmath>
#include <limits>
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/keyboard_codes.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
namespace blink {
namespace {
// Correponds to UMA MediaTimelineSeekType enum. Enum values can be added, but
// must never be renumbered or deleted and reused.
enum class SeekType {
kClick = 0,
kDragFromCurrentPosition = 1,
kDragFromElsewhere = 2,
kKeyboardArrowKey = 3,
kKeyboardPageUpDownKey = 4,
kKeyboardHomeEndKey = 5,
// Update kLast when adding new values.
kLast = kKeyboardHomeEndKey
};
// Exclusive upper bounds for the positive buckets of UMA MediaTimelinePercent
// enum, which are reflected to form the negative buckets. The custom enum is
// because UMA count histograms don't support negative values. Values must not
// be added/modified/removed due to the way the negative buckets are formed.
constexpr double kPercentIntervals[] = {
0, // Dedicated zero bucket so upper bound is inclusive, unlike the others.
0.1, 0.2, 0.3, 0.5, 0.7, 1.0, 1.5, 2.0, 3.0, 5.0, 7.0, 10.0,
15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 60.0, 70.0, 80.0, 90.0,
100.0 // 100% upper bound is inclusive, unlike the others.
};
// Must match length of UMA MediaTimelinePercent enum.
constexpr int32_t kPercentBucketCount = 51;
static_assert(base::size(kPercentIntervals) * 2 - 1 == kPercentBucketCount,
"Intervals must match UMA MediaTimelinePercent enum");
// Corresponds to two UMA enums of different sizes! Values are the exclusive
// upper bounds for buckets of UMA MediaTimelineAbsTimeDelta enum with the same
// index, and also for the positive buckets of UMA MediaTimelineTimeDelta enum,
// which are reflected to form the negative buckets. MediaTimelineTimeDelta
// needed a custom enum because UMA count histograms don't support negative
// values, and MediaTimelineAbsTimeDelta uses the same mechanism so the values
// can be compared easily. Values must not be added/modified/removed due to the
// way the negative buckets are formed.
constexpr double kTimeDeltaMSIntervals[] = {
1, // 1ms
16, // 16ms
32, // 32ms
64, // 64ms
128, // 128ms
256, // 256ms
512, // 512ms
1000, // 1s
2000, // 2s
4000, // 4s
8000, // 8s
15000, // 15s
30000, // 30s
60000, // 1m
120000, // 2m
240000, // 4m
480000, // 8m
900000, // 15m
1800000, // 30m
3600000, // 1h
7200000, // 2h
14400000, // 4h
28800000, // 8h
57600000, // 16h
std::numeric_limits<double>::infinity()};
// Must match length of UMA MediaTimelineAbsTimeDelta enum.
constexpr int32_t kAbsTimeDeltaBucketCount = 25;
// Must match length of UMA MediaTimelineTimeDelta enum.
constexpr int32_t kTimeDeltaBucketCount = 49;
static_assert(base::size(kTimeDeltaMSIntervals) == kAbsTimeDeltaBucketCount,
"Intervals must match UMA MediaTimelineAbsTimeDelta enum");
static_assert(base::size(kTimeDeltaMSIntervals) * 2 - 1 ==
kTimeDeltaBucketCount,
"Intervals must match UMA MediaTimelineTimeDelta enum");
// Calculates index of UMA MediaTimelinePercent enum corresponding to |percent|.
// Negative values use kPercentIntervals in reverse.
int32_t ToPercentSample(double percent) {
constexpr int32_t kNonNegativeBucketCount = base::size(kPercentIntervals);
constexpr int32_t kNegativeBucketCount = base::size(kPercentIntervals) - 1;
bool negative = percent < 0;
double abs_percent = std::abs(percent);
if (abs_percent == 0)
return kNegativeBucketCount; // Dedicated zero bucket.
for (int32_t i = 0; i < kNonNegativeBucketCount; i++) {
if (abs_percent < kPercentIntervals[i])
return kNegativeBucketCount + (negative ? -i : +i);
}
// No NOTREACHED since the +/-100 bounds are inclusive (even if they are
// slightly exceeded due to floating point inaccuracies).
return negative ? 0 : kPercentBucketCount - 1;
}
// Calculates index of UMA MediaTimelineAbsTimeDelta enum corresponding to
// |sumAbsDeltaSeconds|.
int32_t ToAbsTimeDeltaSample(double sum_abs_delta_seconds) {
double sum_abs_delta_ms = 1000 * sum_abs_delta_seconds;
if (sum_abs_delta_ms == 0)
return 0; // Dedicated zero bucket.
for (int32_t i = 0; i < kAbsTimeDeltaBucketCount; i++) {
if (sum_abs_delta_ms < kTimeDeltaMSIntervals[i])
return i;
}
NOTREACHED() << "sumAbsDeltaSeconds shouldn't be infinite";
return kAbsTimeDeltaBucketCount - 1;
}
// Calculates index of UMA MediaTimelineTimeDelta enum corresponding to
// |deltaSeconds|. Negative values use kTimeDeltaMSIntervals in reverse.
int32_t ToTimeDeltaSample(double delta_seconds) {
constexpr int32_t kNonNegativeBucketCount = base::size(kTimeDeltaMSIntervals);
constexpr int32_t kNegativeBucketCount =
base::size(kTimeDeltaMSIntervals) - 1;
bool negative = delta_seconds < 0;
double abs_delta_ms = 1000 * std::abs(delta_seconds);
if (abs_delta_ms == 0)
return kNegativeBucketCount; // Dedicated zero bucket.
for (int32_t i = 0; i < kNonNegativeBucketCount; i++) {
if (abs_delta_ms < kTimeDeltaMSIntervals[i])
return kNegativeBucketCount + (negative ? -i : +i);
}
NOTREACHED() << "deltaSeconds shouldn't be infinite";
return negative ? 0 : kTimeDeltaBucketCount - 1;
}
// Helper for RECORD_TIMELINE_UMA_BY_WIDTH.
#define ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, minWidth, maxWidth, metric, \
sample, HistogramType, ...) \
else if (width >= minWidth) { \
DEFINE_STATIC_LOCAL( \
HistogramType, metric##minWidth##_##maxWidth##Histogram, \
("Media.Timeline." #metric "." #minWidth "_" #maxWidth, \
##__VA_ARGS__)); \
metric##minWidth##_##maxWidth##Histogram.Count(sample); \
}
// Records UMA with a histogram suffix based on timelineWidth.
#define RECORD_TIMELINE_UMA_BY_WIDTH(timelineWidth, metric, sample, \
HistogramType, ...) \
do { \
int width = timelineWidth; /* Avoid multiple evaluation. */ \
if (false) { \
/* This if(false) allows all the conditions below to start with else. */ \
} \
ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, 512, inf, metric, sample, \
HistogramType, ##__VA_ARGS__) \
ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, 256, 511, metric, sample, \
HistogramType, ##__VA_ARGS__) \
ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, 128, 255, metric, sample, \
HistogramType, ##__VA_ARGS__) \
ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, 80, 127, metric, sample, \
HistogramType, ##__VA_ARGS__) \
ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, 48, 79, metric, sample, \
HistogramType, ##__VA_ARGS__) \
ELSEIF_WIDTH_RECORD_TIMELINE_UMA(width, 32, 47, metric, sample, \
HistogramType, ##__VA_ARGS__) \
else { \
/* Skip logging if timeline is narrower than minimum suffix bucket. */ \
} \
} while (false)
void RecordDragGestureDurationByWidth(int timeline_width,
base::TimeDelta duration) {
int32_t sample = base::saturated_cast<int32_t>(duration.InMilliseconds());
RECORD_TIMELINE_UMA_BY_WIDTH(timeline_width, DragGestureDuration, sample,
CustomCountHistogram, 1 /* 1 ms */,
60000 /* 1 minute */, 50);
}
void RecordDragPercentByWidth(int timeline_width, double percent) {
int32_t sample = ToPercentSample(percent);
RECORD_TIMELINE_UMA_BY_WIDTH(timeline_width, DragPercent, sample,
EnumerationHistogram, kPercentBucketCount);
}
void RecordDragSumAbsTimeDeltaByWidth(int timeline_width,
double sum_abs_delta_seconds) {
int32_t sample = ToAbsTimeDeltaSample(sum_abs_delta_seconds);
RECORD_TIMELINE_UMA_BY_WIDTH(timeline_width, DragSumAbsTimeDelta, sample,
EnumerationHistogram, kAbsTimeDeltaBucketCount);
}
void RecordDragTimeDeltaByWidth(int timeline_width, double delta_seconds) {
int32_t sample = ToTimeDeltaSample(delta_seconds);
RECORD_TIMELINE_UMA_BY_WIDTH(timeline_width, DragTimeDelta, sample,
EnumerationHistogram, kTimeDeltaBucketCount);
}
void RecordSeekTypeByWidth(int timeline_width, SeekType type) {
int32_t sample = static_cast<int32_t>(type);
constexpr int32_t kBucketCount = static_cast<int32_t>(SeekType::kLast) + 1;
RECORD_TIMELINE_UMA_BY_WIDTH(timeline_width, SeekType, sample,
EnumerationHistogram, kBucketCount);
}
#undef RECORD_TIMELINE_UMA_BY_WIDTH
#undef ELSEIF_WIDTH_RECORD_TIMELINE_UMA
} // namespace
void MediaControlTimelineMetrics::StartGesture(bool from_thumb) {
// Initialize gesture tracking.
state_ = from_thumb ? State::kGestureFromThumb : State::kGestureFromElsewhere;
drag_start_time_ticks_ = base::TimeTicks::Now();
drag_delta_media_seconds_ = 0;
drag_sum_abs_delta_media_seconds_ = 0;
}
void MediaControlTimelineMetrics::RecordEndGesture(
int timeline_width,
double media_duration_seconds) {
State end_state = state_;
state_ = State::kInactive; // Reset tracking.
SeekType seek_type =
SeekType::kLast; // Arbitrary inital val to appease MSVC.
switch (end_state) {
case State::kInactive:
case State::kKeyDown:
return; // Pointer and keys were interleaved. Skip UMA in this edge case.
case State::kGestureFromThumb:
case State::kGestureFromElsewhere:
return; // Empty gesture with no calls to gestureInput.
case State::kDragFromThumb:
seek_type = SeekType::kDragFromCurrentPosition;
break;
case State::kClick:
seek_type = SeekType::kClick;
break;
case State::kDragFromElsewhere:
seek_type = SeekType::kDragFromElsewhere;
break;
}
RecordSeekTypeByWidth(timeline_width, seek_type);
if (seek_type == SeekType::kClick)
return; // Metrics below are only for drags.
RecordDragGestureDurationByWidth(
timeline_width, base::TimeTicks::Now() - drag_start_time_ticks_);
if (std::isfinite(media_duration_seconds)) {
RecordDragPercentByWidth(timeline_width, 100.0 * drag_delta_media_seconds_ /
media_duration_seconds);
}
RecordDragSumAbsTimeDeltaByWidth(timeline_width,
drag_sum_abs_delta_media_seconds_);
RecordDragTimeDeltaByWidth(timeline_width, drag_delta_media_seconds_);
}
void MediaControlTimelineMetrics::StartKey() {
state_ = State::kKeyDown;
}
void MediaControlTimelineMetrics::RecordEndKey(int timeline_width,
int key_code) {
State end_state = state_;
state_ = State::kInactive; // Reset tracking.
if (end_state != State::kKeyDown)
return; // Pointer and keys were interleaved. Skip UMA in this edge case.
SeekType type;
switch (key_code) {
case VKEY_UP:
case VKEY_DOWN:
case VKEY_LEFT:
case VKEY_RIGHT:
type = SeekType::kKeyboardArrowKey;
break;
case VKEY_PRIOR: // PageUp
case VKEY_NEXT: // PageDown
type = SeekType::kKeyboardPageUpDownKey;
break;
case VKEY_HOME:
case VKEY_END:
type = SeekType::kKeyboardHomeEndKey;
break;
default:
return; // Other keys don't seek (at time of writing).
}
RecordSeekTypeByWidth(timeline_width, type);
}
void MediaControlTimelineMetrics::OnInput(double from_seconds,
double to_seconds) {
switch (state_) {
case State::kInactive:
// Unexpected input.
state_ = State::kInactive;
break;
case State::kGestureFromThumb:
// Drag confirmed now input has been received.
state_ = State::kDragFromThumb;
break;
case State::kGestureFromElsewhere:
// Click/drag confirmed now input has been received. Assume it's a click
// until further input is received.
state_ = State::kClick;
break;
case State::kClick:
// Drag confirmed now further input has been received.
state_ = State::kDragFromElsewhere;
break;
case State::kDragFromThumb:
case State::kDragFromElsewhere:
// Continue tracking drag.
break;
case State::kKeyDown:
// Continue tracking key.
break;
}
// The following tracking is only for drags. Note that we exclude kClick here,
// as even if it progresses to a kDragFromElsewhere, the first input event
// corresponds to the position jump from the pointer down on the track.
if (state_ != State::kDragFromThumb && state_ != State::kDragFromElsewhere)
return;
float delta_media_seconds = static_cast<float>(to_seconds - from_seconds);
drag_delta_media_seconds_ += delta_media_seconds;
drag_sum_abs_delta_media_seconds_ += std::abs(delta_media_seconds);
}
} // namespace blink
// Copyright 2017 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 THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_TIMELINE_METRICS_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_TIMELINE_METRICS_H_
#include "base/time/time.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink {
// Helpers for tracking and reporting media control timeline metrics to UMA.
class MediaControlTimelineMetrics {
DISALLOW_NEW();
public:
// Start tracking a pointer gesture. |fromThumb| indicates whether the user
// started dragging from the thumb, as opposed to pressing down their pointer
// on some other part of the timeline track (causing time to jump).
void StartGesture(bool from_thumb);
// Finish tracking and report a pointer gesture.
void RecordEndGesture(int timeline_width, double media_duration_seconds);
// Start tracking a keydown. Ok to call multiple times if key repeats.
void StartKey();
// Finish tracking and report a keyup. Call only once even if key repeats.
void RecordEndKey(int timeline_width, int key_code);
// Track an incremental input event caused by the current pointer gesture or
// pressed key. Each sequence of calls to this should usually be sandwiched by
// startGesture/Key and recordEndGesture/Key.
void OnInput(double from_seconds, double to_seconds);
private:
enum class State {
// No active gesture. Progresses to kKeyDown on |startKey|, or
// kGestureFromThumb/kGestureFromElsewhere on |startGesture|.
kInactive,
// Pointer down on thumb. Progresses to kDragFromThumb in |onInput|.
kGestureFromThumb,
// Thumb is being dragged (drag started from thumb).
kDragFromThumb,
// Pointer down on track. Progresses to kClick in |onInput|.
kGestureFromElsewhere,
// Pointer down followed by input. Assumed to be a click, unless additional
// |onInput| are received - if so progresses to kDragFromElsewhere.
kClick,
// Thumb is being dragged (drag started from track).
kDragFromElsewhere,
// A key is currently pressed down.
kKeyDown
};
bool has_never_been_playing_ = true;
State state_ = State::kInactive;
// The following are only valid during a pointer gesture.
base::TimeTicks drag_start_time_ticks_;
float drag_delta_media_seconds_ = 0;
float drag_sum_abs_delta_media_seconds_ = 0;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_TIMELINE_METRICS_H_
...@@ -680,158 +680,6 @@ TEST_F(MediaControlsImplTest, TimeIndicatorsUpdatedOnSeeking) { ...@@ -680,158 +680,6 @@ TEST_F(MediaControlsImplTest, TimeIndicatorsUpdatedOnSeeking) {
EXPECT_EQ(duration / 4, timeline->valueAsNumber()); EXPECT_EQ(duration / 4, timeline->valueAsNumber());
} }
TEST_F(MediaControlsImplTest, TimelineMetricsClick) {
double duration = 540; // 9 minutes
LoadMediaWithDuration(duration);
EnsureSizing();
test::RunPendingTasks();
ASSERT_TRUE(IsElementVisible(*TimelineElement()));
DOMRect* timelineRect = TimelineElement()->getBoundingClientRect();
ASSERT_LT(0, timelineRect->width());
EXPECT_EQ(0, MediaControls().MediaElement().currentTime());
gfx::PointF trackCenter(timelineRect->left() + timelineRect->width() / 2,
timelineRect->top() + timelineRect->height() / 2);
MouseDownAt(trackCenter);
MouseUpAt(trackCenter);
test::RunPendingTasks();
EXPECT_LE(0.49 * duration, MediaControls().MediaElement().currentTime());
EXPECT_GE(0.51 * duration, MediaControls().MediaElement().currentTime());
GetHistogramTester().ExpectUniqueSample("Media.Timeline.SeekType." TIMELINE_W,
0 /* SeekType::kClick */, 1);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragGestureDuration." TIMELINE_W, 0);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragPercent." TIMELINE_W, 0);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragSumAbsTimeDelta." TIMELINE_W, 0);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragTimeDelta." TIMELINE_W, 0);
}
TEST_F(MediaControlsImplTest, TimelineMetricsDragFromCurrentPosition) {
double duration = 540; // 9 minutes
LoadMediaWithDuration(duration);
EnsureSizing();
test::RunPendingTasks();
ASSERT_TRUE(IsElementVisible(*TimelineElement()));
DOMRect* timeline_rect = TimelineTrackElement()->getBoundingClientRect();
ASSERT_LT(0, timeline_rect->width());
EXPECT_EQ(0, MediaControls().MediaElement().currentTime());
DOMRect* thumb_rect =
TimelineElement()
->UserAgentShadowRoot()
->getElementById(shadow_element_names::kIdSliderThumb)
->getBoundingClientRect();
gfx::PointF thumb(thumb_rect->x() + (thumb_rect->width() / 2),
thumb_rect->y() + 1);
float y = timeline_rect->top() + timeline_rect->height() / 2;
gfx::PointF track_two_thirds(
timeline_rect->left() + timeline_rect->width() * 2 / 3, y);
MouseDownAt(thumb);
MouseMoveTo(track_two_thirds);
MouseUpAt(track_two_thirds);
EXPECT_LE(0.66 * duration, MediaControls().MediaElement().currentTime());
EXPECT_GE(0.68 * duration, MediaControls().MediaElement().currentTime());
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.SeekType." TIMELINE_W,
1 /* SeekType::kDragFromCurrentPosition */, 1);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragGestureDuration." TIMELINE_W, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragPercent." TIMELINE_W, 47 /* [60.0%, 70.0%) */, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragSumAbsTimeDelta." TIMELINE_W, 16 /* [4m, 8m) */, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragTimeDelta." TIMELINE_W, 40 /* [4m, 8m) */, 1);
}
TEST_F(MediaControlsImplTest, TimelineMetricsDragFromElsewhere) {
double duration = 540; // 9 minutes
LoadMediaWithDuration(duration);
EnsureSizing();
test::RunPendingTasks();
ASSERT_TRUE(IsElementVisible(*TimelineElement()));
DOMRect* timelineRect = TimelineTrackElement()->getBoundingClientRect();
ASSERT_LT(0, timelineRect->width());
EXPECT_EQ(0, MediaControls().MediaElement().currentTime());
float y = timelineRect->top() + timelineRect->height() / 2;
gfx::PointF trackOneThird(
timelineRect->left() + timelineRect->width() * 1 / 3, y);
gfx::PointF trackTwoThirds(
timelineRect->left() + timelineRect->width() * 2 / 3, y);
MouseDownAt(trackOneThird);
MouseMoveTo(trackTwoThirds);
MouseUpAt(trackTwoThirds);
EXPECT_LE(0.66 * duration, MediaControls().MediaElement().currentTime());
EXPECT_GE(0.68 * duration, MediaControls().MediaElement().currentTime());
GetHistogramTester().ExpectUniqueSample("Media.Timeline.SeekType." TIMELINE_W,
2 /* SeekType::kDragFromElsewhere */,
1);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragGestureDuration." TIMELINE_W, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragPercent." TIMELINE_W, 42 /* [30.0%, 35.0%) */, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragSumAbsTimeDelta." TIMELINE_W, 15 /* [2m, 4m) */, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragTimeDelta." TIMELINE_W, 39 /* [2m, 4m) */, 1);
}
TEST_F(MediaControlsImplTest, TimelineMetricsDragBackAndForth) {
double duration = 540; // 9 minutes
LoadMediaWithDuration(duration);
EnsureSizing();
test::RunPendingTasks();
ASSERT_TRUE(IsElementVisible(*TimelineElement()));
DOMRect* timelineRect = TimelineTrackElement()->getBoundingClientRect();
ASSERT_LT(0, timelineRect->width());
EXPECT_EQ(0, MediaControls().MediaElement().currentTime());
float y = timelineRect->top() + timelineRect->height() / 2;
gfx::PointF trackTwoThirds(
timelineRect->left() + timelineRect->width() * 2 / 3, y);
gfx::PointF trackEnd(timelineRect->left() + timelineRect->width(), y);
gfx::PointF trackOneThird(
timelineRect->left() + timelineRect->width() * 1 / 3, y);
MouseDownAt(trackTwoThirds);
MouseMoveTo(trackEnd);
MouseMoveTo(trackOneThird);
MouseUpAt(trackOneThird);
EXPECT_LE(0.32 * duration, MediaControls().MediaElement().currentTime());
EXPECT_GE(0.34 * duration, MediaControls().MediaElement().currentTime());
GetHistogramTester().ExpectUniqueSample("Media.Timeline.SeekType." TIMELINE_W,
2 /* SeekType::kDragFromElsewhere */,
1);
GetHistogramTester().ExpectTotalCount(
"Media.Timeline.DragGestureDuration." TIMELINE_W, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragPercent." TIMELINE_W, 8 /* (-35.0%, -30.0%] */, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragSumAbsTimeDelta." TIMELINE_W, 17 /* [8m, 15m) */, 1);
GetHistogramTester().ExpectUniqueSample(
"Media.Timeline.DragTimeDelta." TIMELINE_W, 9 /* (-4m, -2m] */, 1);
}
TEST_F(MediaControlsImplTest, TimeIsCorrectlyFormatted) { TEST_F(MediaControlsImplTest, TimeIsCorrectlyFormatted) {
struct { struct {
double time; double time;
......
...@@ -8922,6 +8922,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -8922,6 +8922,9 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="MediaTimelineWidths" separator="."> <histogram_suffixes name="MediaTimelineWidths" separator=".">
<obsolete>
Deprecated as of 2020/10.
</obsolete>
<suffix name="32_47" label=""/> <suffix name="32_47" label=""/>
<suffix name="48_79" label=""/> <suffix name="48_79" label=""/>
<suffix name="80_127" label=""/> <suffix name="80_127" label=""/>
......
...@@ -3220,7 +3220,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -3220,7 +3220,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram> </histogram>
<histogram base="true" name="Media.Timeline.DragGestureDuration" units="ms" <histogram base="true" name="Media.Timeline.DragGestureDuration" units="ms"
expires_after="M88"> expires_after="2020-10-23">
<obsolete>
Deprecated as of 2020/10.
</obsolete>
<!-- Name completed by histogram_suffixes name="MediaTimelineWidths" --> <!-- Name completed by histogram_suffixes name="MediaTimelineWidths" -->
<owner>mlamouri@google.com</owner> <owner>mlamouri@google.com</owner>
...@@ -3233,7 +3236,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -3233,7 +3236,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram> </histogram>
<histogram base="true" name="Media.Timeline.DragPercent" <histogram base="true" name="Media.Timeline.DragPercent"
enum="MediaTimelinePercent" expires_after="M88"> enum="MediaTimelinePercent" expires_after="2020-10-23">
<obsolete>
Deprecated as of 2020/10.
</obsolete>
<!-- Name completed by histogram_suffixes name="MediaTimelineWidths" --> <!-- Name completed by histogram_suffixes name="MediaTimelineWidths" -->
<owner>mlamouri@google.com</owner> <owner>mlamouri@google.com</owner>
...@@ -3247,7 +3253,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -3247,7 +3253,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram> </histogram>
<histogram base="true" name="Media.Timeline.DragSumAbsTimeDelta" <histogram base="true" name="Media.Timeline.DragSumAbsTimeDelta"
enum="MediaTimelineAbsTimeDelta" expires_after="M88"> enum="MediaTimelineAbsTimeDelta" expires_after="2020-10-23">
<obsolete>
Deprecated as of 2020/10.
</obsolete>
<!-- Name completed by histogram_suffixes name="MediaTimelineWidths" --> <!-- Name completed by histogram_suffixes name="MediaTimelineWidths" -->
<owner>mlamouri@google.com</owner> <owner>mlamouri@google.com</owner>
...@@ -3265,7 +3274,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -3265,7 +3274,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram> </histogram>
<histogram base="true" name="Media.Timeline.DragTimeDelta" <histogram base="true" name="Media.Timeline.DragTimeDelta"
enum="MediaTimelineTimeDelta" expires_after="M88"> enum="MediaTimelineTimeDelta" expires_after="2020-10-23">
<obsolete>
Deprecated as of 2020/10.
</obsolete>
<!-- Name completed by histogram_suffixes name="MediaTimelineWidths" --> <!-- Name completed by histogram_suffixes name="MediaTimelineWidths" -->
<owner>mlamouri@google.com</owner> <owner>mlamouri@google.com</owner>
...@@ -3279,7 +3291,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -3279,7 +3291,10 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</histogram> </histogram>
<histogram base="true" name="Media.Timeline.SeekType" <histogram base="true" name="Media.Timeline.SeekType"
enum="MediaTimelineSeekType" expires_after="M88"> enum="MediaTimelineSeekType" expires_after="2020-10-23">
<obsolete>
Deprecated as of 2020/10.
</obsolete>
<!-- Name completed by histogram_suffixes name="MediaTimelineWidths" --> <!-- Name completed by histogram_suffixes name="MediaTimelineWidths" -->
<owner>mlamouri@google.com</owner> <owner>mlamouri@google.com</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