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

Side by Side Diff: media/blink/webmediaplayer_impl_unittest.cc

Issue 2741083002: Disable pausing background video-only players on desktop. (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 859
860 // There's no optimization criteria for video only on Android. 860 // There's no optimization criteria for video only on Android.
861 bool matches_requirements = 861 bool matches_requirements =
862 IsAndroid() || 862 IsAndroid() ||
863 ((GetDurationSec() < GetAverageKeyframeDistanceSec()) || 863 ((GetDurationSec() < GetAverageKeyframeDistanceSec()) ||
864 (GetAverageKeyframeDistanceSec() < 10)); 864 (GetAverageKeyframeDistanceSec() < 10));
865 EXPECT_EQ(matches_requirements, IsBackgroundOptimizationCandidate()); 865 EXPECT_EQ(matches_requirements, IsBackgroundOptimizationCandidate());
866 866
867 // Video is always paused when suspension is on and only if matches the 867 // Video is always paused when suspension is on and only if matches the
868 // optimization criteria if the optimization is on. 868 // optimization criteria if the optimization is on.
869 #if defined(OS_ANDROID)
869 bool should_pause = IsMediaSuspendOn() || 870 bool should_pause = IsMediaSuspendOn() ||
870 (IsBackgroundOptimizationOn() && matches_requirements); 871 (IsBackgroundOptimizationOn() && matches_requirements);
871 EXPECT_EQ(should_pause, ShouldPauseVideoWhenHidden()); 872 EXPECT_EQ(should_pause, ShouldPauseVideoWhenHidden());
873 #else
874 // TODO(avayvod): Revert after merging into 58 so we keep getting data on the
875 // background video pause behavior on desktop. See https://crbug.com/699106.
876 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
877 #endif
872 } 878 }
873 879
874 TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, AudioVideo) { 880 TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, AudioVideo) {
875 SetMetadata(true, true); 881 SetMetadata(true, true);
876 882
877 // Optimization requirements are the same for all platforms. 883 // Optimization requirements are the same for all platforms.
878 bool matches_requirements = 884 bool matches_requirements =
879 (GetDurationSec() < GetAverageKeyframeDistanceSec()) || 885 (GetDurationSec() < GetAverageKeyframeDistanceSec()) ||
880 (GetAverageKeyframeDistanceSec() < 10); 886 (GetAverageKeyframeDistanceSec() < 10);
881 887
882 EXPECT_EQ(matches_requirements, IsBackgroundOptimizationCandidate()); 888 EXPECT_EQ(matches_requirements, IsBackgroundOptimizationCandidate());
883 EXPECT_EQ(IsBackgroundOptimizationOn() && matches_requirements, 889 EXPECT_EQ(IsBackgroundOptimizationOn() && matches_requirements,
884 ShouldDisableVideoWhenHidden()); 890 ShouldDisableVideoWhenHidden());
885 891
886 // Only pause audible videos on Android if both media suspend and resume 892 // Only pause audible videos if both media suspend and resume
887 // background videos is on. On Desktop 893 // background videos is on.
894 #if defined(OS_ANDROID)
888 EXPECT_EQ(IsMediaSuspendOn() && IsResumeBackgroundVideoEnabled(), 895 EXPECT_EQ(IsMediaSuspendOn() && IsResumeBackgroundVideoEnabled(),
889 ShouldPauseVideoWhenHidden()); 896 ShouldPauseVideoWhenHidden());
897 #else
898 // TODO(avayvod): Revert after merging into 58 so we keep getting data on the
899 // background video pause behavior on desktop. See https://crbug.com/699106.
900 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
901 #endif
890 } 902 }
891 903
892 INSTANTIATE_TEST_CASE_P(BackgroundBehaviorTestInstances, 904 INSTANTIATE_TEST_CASE_P(BackgroundBehaviorTestInstances,
893 WebMediaPlayerImplBackgroundBehaviorTest, 905 WebMediaPlayerImplBackgroundBehaviorTest,
894 ::testing::Combine(::testing::Bool(), 906 ::testing::Combine(::testing::Bool(),
895 ::testing::Bool(), 907 ::testing::Bool(),
896 ::testing::Values(5, 300), 908 ::testing::Values(5, 300),
897 ::testing::Values(5, 100), 909 ::testing::Values(5, 100),
898 ::testing::Bool())); 910 ::testing::Bool()));
899 911
900 } // namespace media 912 } // namespace media
OLDNEW
« 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