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

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

Issue 2655723002: [Video, Android] Pause video only players ignoring duration and keyframes (Closed)
Patch Set: Created 3 years, 10 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 730
731 // Audible video. 731 // Audible video.
732 SetMetadata(true, true); 732 SetMetadata(true, true);
733 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 733 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
734 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 734 EXPECT_FALSE(ShouldDisableVideoWhenHidden());
735 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 735 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
736 736
737 // Video only (pausing is enabled on Android). 737 // Video only (pausing is enabled on Android).
738 SetMetadata(false, true); 738 SetMetadata(false, true);
739 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 739 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
740 EXPECT_FALSE(ShouldDisableVideoWhenHidden());
740 #if defined(OS_ANDROID) 741 #if defined(OS_ANDROID)
741 EXPECT_TRUE(ShouldPauseVideoWhenHidden()); 742 EXPECT_TRUE(ShouldPauseVideoWhenHidden());
743
744 // On Android, the duration and keyframe distance don't matter for video-only.
745 SetDuration(base::TimeDelta::FromSeconds(5));
746 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
747 EXPECT_TRUE(ShouldPauseVideoWhenHidden());
748
749 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100));
750 SetDuration(base::TimeDelta::FromSeconds(300));
751 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
752 EXPECT_TRUE(ShouldPauseVideoWhenHidden());
753
754 // Restore average keyframe distance.
755 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5));
742 #else 756 #else
743 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 757 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
744 #endif 758 #endif
745 EXPECT_FALSE(ShouldDisableVideoWhenHidden());
746 759
747 // Audio only. 760 // Audio only.
748 SetMetadata(true, false); 761 SetMetadata(true, false);
749 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); 762 EXPECT_FALSE(IsBackgroundOptimizationCandidate());
750 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 763 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
751 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 764 EXPECT_FALSE(ShouldDisableVideoWhenHidden());
752 765
753 // Duration is shorter than max video keyframe distance. 766 // Duration is shorter than max video keyframe distance.
754 SetDuration(base::TimeDelta::FromSeconds(5)); 767 SetDuration(base::TimeDelta::FromSeconds(5));
755 SetMetadata(true, true); 768 SetMetadata(true, true);
756 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 769 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
757 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 770 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
758 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 771 EXPECT_FALSE(ShouldDisableVideoWhenHidden());
759 772
760 // Average keyframe distance is too big. 773 // Average keyframe distance is too big.
761 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); 774 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100));
762 SetDuration(base::TimeDelta::FromSeconds(300)); 775 SetDuration(base::TimeDelta::FromSeconds(300));
763 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); 776 EXPECT_FALSE(IsBackgroundOptimizationCandidate());
764 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 777 EXPECT_FALSE(ShouldPauseVideoWhenHidden());
765 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 778 EXPECT_FALSE(ShouldDisableVideoWhenHidden());
766 } 779 }
767 780
768 } // namespace media 781 } // 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