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

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

Issue 2738793002: Revert of 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)
870 bool should_pause = IsMediaSuspendOn() || 869 bool should_pause = IsMediaSuspendOn() ||
871 (IsBackgroundOptimizationOn() && matches_requirements); 870 (IsBackgroundOptimizationOn() && matches_requirements);
872 EXPECT_EQ(should_pause, ShouldPauseVideoWhenHidden()); 871 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
878 } 872 }
879 873
880 TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, AudioVideo) { 874 TEST_P(WebMediaPlayerImplBackgroundBehaviorTest, AudioVideo) {
881 SetMetadata(true, true); 875 SetMetadata(true, true);
882 876
883 // Optimization requirements are the same for all platforms. 877 // Optimization requirements are the same for all platforms.
884 bool matches_requirements = 878 bool matches_requirements =
885 (GetDurationSec() < GetAverageKeyframeDistanceSec()) || 879 (GetDurationSec() < GetAverageKeyframeDistanceSec()) ||
886 (GetAverageKeyframeDistanceSec() < 10); 880 (GetAverageKeyframeDistanceSec() < 10);
887 881
888 EXPECT_EQ(matches_requirements, IsBackgroundOptimizationCandidate()); 882 EXPECT_EQ(matches_requirements, IsBackgroundOptimizationCandidate());
889 EXPECT_EQ(IsBackgroundOptimizationOn() && matches_requirements, 883 EXPECT_EQ(IsBackgroundOptimizationOn() && matches_requirements,
890 ShouldDisableVideoWhenHidden()); 884 ShouldDisableVideoWhenHidden());
891 885
892 // Only pause audible videos if both media suspend and resume 886 // Only pause audible videos on Android if both media suspend and resume
893 // background videos is on. 887 // background videos is on. On Desktop
894 #if defined(OS_ANDROID)
895 EXPECT_EQ(IsMediaSuspendOn() && IsResumeBackgroundVideoEnabled(), 888 EXPECT_EQ(IsMediaSuspendOn() && IsResumeBackgroundVideoEnabled(),
896 ShouldPauseVideoWhenHidden()); 889 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
902 } 890 }
903 891
904 INSTANTIATE_TEST_CASE_P(BackgroundBehaviorTestInstances, 892 INSTANTIATE_TEST_CASE_P(BackgroundBehaviorTestInstances,
905 WebMediaPlayerImplBackgroundBehaviorTest, 893 WebMediaPlayerImplBackgroundBehaviorTest,
906 ::testing::Combine(::testing::Bool(), 894 ::testing::Combine(::testing::Bool(),
907 ::testing::Bool(), 895 ::testing::Bool(),
908 ::testing::Values(5, 300), 896 ::testing::Values(5, 300),
909 ::testing::Values(5, 100), 897 ::testing::Values(5, 100),
910 ::testing::Bool())); 898 ::testing::Bool()));
911 899
912 } // namespace media 900 } // 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