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

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

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