Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: media/blink/webmediaplayer_impl_unittest.cc

Issue 2818013002: [Media] Add a feature flag to pause bg video only players. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl_unittest.cc
diff --git a/media/blink/webmediaplayer_impl_unittest.cc b/media/blink/webmediaplayer_impl_unittest.cc
index 6a2a291cf3b29bee856aaff274edb80d1db2ce74..0d4e6f87e5afbe066c5e73f6a562803e78337fa5 100644
--- a/media/blink/webmediaplayer_impl_unittest.cc
+++ b/media/blink/webmediaplayer_impl_unittest.cc
@@ -809,7 +809,7 @@ TEST_F(WebMediaPlayerImplTest, BackgroundIdlePauseTimerDependsOnAudio) {
class WebMediaPlayerImplBackgroundBehaviorTest
: public WebMediaPlayerImplTest,
public ::testing::WithParamInterface<
- std::tuple<bool, bool, int, int, bool, bool>> {
+ std::tuple<bool, bool, int, int, bool, bool, bool>> {
public:
// Indices of the tuple parameters.
static const int kIsMediaSuspendEnabled = 0;
@@ -818,6 +818,7 @@ class WebMediaPlayerImplBackgroundBehaviorTest
static const int kAverageKeyframeDistanceSec = 3;
static const int kIsResumeBackgroundVideoEnabled = 4;
static const int kIsMediaSource = 5;
+ static const int kIsBackgroundPauseEnabled = 6;
void SetUp() override {
WebMediaPlayerImplTest::SetUp();
@@ -832,6 +833,16 @@ class WebMediaPlayerImplBackgroundBehaviorTest
disabled_features += kBackgroundVideoTrackOptimization.name;
}
+ if (IsBackgroundPauseOn()) {
+ if (!enabled_features.empty())
+ enabled_features += ",";
+ enabled_features += kBackgroundVideoPauseOptimization.name;
+ } else {
+ if (!disabled_features.empty())
+ disabled_features += ",";
+ disabled_features += kBackgroundVideoPauseOptimization.name;
+ }
+
if (IsResumeBackgroundVideoEnabled()) {
if (!enabled_features.empty())
enabled_features += ",";
@@ -876,6 +887,10 @@ class WebMediaPlayerImplBackgroundBehaviorTest
return std::get<kIsResumeBackgroundVideoEnabled>(GetParam());
}
+ bool IsBackgroundPauseOn() {
+ return std::get<kIsBackgroundPauseEnabled>(GetParam());
+ }
+
int GetDurationSec() const { return std::get<kDurationSec>(GetParam()); }
int GetAverageKeyframeDistanceSec() const {
@@ -938,8 +953,8 @@ TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, VideoOnly) {
// Video is always paused when suspension is on and only if matches the
// optimization criteria if the optimization is on.
- bool should_pause = IsMediaSuspendOn() ||
- (IsBackgroundOptimizationOn() && matches_requirements);
+ bool should_pause =
+ IsMediaSuspendOn() || (IsBackgroundPauseOn() && matches_requirements);
EXPECT_EQ(should_pause, ShouldPauseVideoWhenHidden());
}
@@ -955,8 +970,8 @@ TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, AudioVideo) {
EXPECT_EQ(IsBackgroundOptimizationOn() && matches_requirements,
ShouldDisableVideoWhenHidden());
- // Only pause audible videos on Android if both media suspend and resume
- // background videos is on. On Desktop
+ // Only pause audible videos if both media suspend and resume background
+ // videos is on. Both are on by default on Android and off on desktop.
EXPECT_EQ(IsMediaSuspendOn() && IsResumeBackgroundVideoEnabled(),
ShouldPauseVideoWhenHidden());
}
@@ -968,6 +983,7 @@ INSTANTIATE_TEST_CASE_P(BackgroundBehaviorTestInstances,
::testing::Values(5, 300),
::testing::Values(5, 100),
::testing::Bool(),
+ ::testing::Bool(),
::testing::Bool()));
} // namespace media
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698