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

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

Issue 2658513003: [Cleanup] Rename Hidden to Background in WMPI.
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
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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 bool IsSuspended() { return wmpi_->pipeline_controller_.IsSuspended(); } 272 bool IsSuspended() { return wmpi_->pipeline_controller_.IsSuspended(); }
273 273
274 void AddBufferedRanges() { 274 void AddBufferedRanges() {
275 wmpi_->buffered_data_source_host_.AddBufferedByteRange(0, 1); 275 wmpi_->buffered_data_source_host_.AddBufferedByteRange(0, 1);
276 } 276 }
277 277
278 void SetDelegateState(WebMediaPlayerImpl::DelegateState state) { 278 void SetDelegateState(WebMediaPlayerImpl::DelegateState state) {
279 wmpi_->SetDelegateState(state, false); 279 wmpi_->SetDelegateState(state, false);
280 } 280 }
281 281
282 bool ShouldDisableVideoWhenHidden() const { 282 bool ShouldDisableVideoWhenBackground() const {
283 return wmpi_->ShouldDisableVideoWhenHidden(); 283 return wmpi_->ShouldDisableVideoWhenBackground();
284 } 284 }
285 285
286 bool ShouldPauseVideoWhenHidden() const { 286 bool ShouldPauseVideoWhenBackground() const {
287 return wmpi_->ShouldPauseVideoWhenHidden(); 287 return wmpi_->ShouldPauseVideoWhenBackground();
288 } 288 }
289 289
290 bool IsBackgroundOptimizationCandidate() const { 290 bool IsBackgroundOptimizationCandidate() const {
291 return wmpi_->IsBackgroundOptimizationCandidate(); 291 return wmpi_->IsBackgroundOptimizationCandidate();
292 } 292 }
293 293
294 void SetVideoKeyframeDistanceAverage(base::TimeDelta value) { 294 void SetVideoKeyframeDistanceAverage(base::TimeDelta value) {
295 PipelineStatistics statistics; 295 PipelineStatistics statistics;
296 statistics.video_keyframe_distance_average = value; 296 statistics.video_keyframe_distance_average = value;
297 wmpi_->SetPipelineStatisticsForTest(statistics); 297 wmpi_->SetPipelineStatisticsForTest(statistics);
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 TEST_F(WebMediaPlayerImplTest, BackgroundOptimizationsFeatureEnabled) { 682 TEST_F(WebMediaPlayerImplTest, BackgroundOptimizationsFeatureEnabled) {
683 base::test::ScopedFeatureList scoped_feature_list; 683 base::test::ScopedFeatureList scoped_feature_list;
684 scoped_feature_list.InitAndEnableFeature(kBackgroundVideoTrackOptimization); 684 scoped_feature_list.InitAndEnableFeature(kBackgroundVideoTrackOptimization);
685 InitializeWebMediaPlayerImpl(); 685 InitializeWebMediaPlayerImpl();
686 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5)); 686 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5));
687 SetDuration(base::TimeDelta::FromSeconds(300)); 687 SetDuration(base::TimeDelta::FromSeconds(300));
688 688
689 // Audible video. 689 // Audible video.
690 SetMetadata(true, true); 690 SetMetadata(true, true);
691 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 691 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
692 EXPECT_TRUE(ShouldDisableVideoWhenHidden()); 692 EXPECT_TRUE(ShouldDisableVideoWhenBackground());
693 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 693 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
694 694
695 // Video only. 695 // Video only.
696 SetMetadata(false, true); 696 SetMetadata(false, true);
697 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 697 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
698 EXPECT_TRUE(ShouldPauseVideoWhenHidden()); 698 EXPECT_TRUE(ShouldPauseVideoWhenBackground());
699 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 699 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
700 700
701 // Audio only. 701 // Audio only.
702 SetMetadata(true, false); 702 SetMetadata(true, false);
703 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); 703 EXPECT_FALSE(IsBackgroundOptimizationCandidate());
704 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 704 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
705 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 705 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
706 706
707 // Duration is shorter than max video keyframe distance. 707 // Duration is shorter than max video keyframe distance.
708 SetDuration(base::TimeDelta::FromSeconds(5)); 708 SetDuration(base::TimeDelta::FromSeconds(5));
709 SetMetadata(true, true); 709 SetMetadata(true, true);
710 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 710 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
711 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 711 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
712 EXPECT_TRUE(ShouldDisableVideoWhenHidden()); 712 EXPECT_TRUE(ShouldDisableVideoWhenBackground());
713 713
714 // Average keyframe distance is too big. 714 // Average keyframe distance is too big.
715 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); 715 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100));
716 SetDuration(base::TimeDelta::FromSeconds(300)); 716 SetDuration(base::TimeDelta::FromSeconds(300));
717 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); 717 EXPECT_FALSE(IsBackgroundOptimizationCandidate());
718 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 718 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
719 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 719 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
720 } 720 }
721 721
722 TEST_F(WebMediaPlayerImplTest, BackgroundOptimizationsFeatureDisabled) { 722 TEST_F(WebMediaPlayerImplTest, BackgroundOptimizationsFeatureDisabled) {
723 base::test::ScopedFeatureList scoped_feature_list; 723 base::test::ScopedFeatureList scoped_feature_list;
724 scoped_feature_list.InitAndDisableFeature(kBackgroundVideoTrackOptimization); 724 scoped_feature_list.InitAndDisableFeature(kBackgroundVideoTrackOptimization);
725 725
726 InitializeWebMediaPlayerImpl(); 726 InitializeWebMediaPlayerImpl();
727 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5)); 727 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5));
728 SetDuration(base::TimeDelta::FromSeconds(300)); 728 SetDuration(base::TimeDelta::FromSeconds(300));
729 729
730 // Audible video. 730 // Audible video.
731 SetMetadata(true, true); 731 SetMetadata(true, true);
732 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 732 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
733 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 733 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
734 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 734 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
735 735
736 // Video only (pausing is enabled on Android). 736 // Video only (pausing is enabled on Android).
737 SetMetadata(false, true); 737 SetMetadata(false, true);
738 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 738 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
739 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 739 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
740 #if defined(OS_ANDROID) 740 #if defined(OS_ANDROID)
741 EXPECT_TRUE(ShouldPauseVideoWhenHidden()); 741 EXPECT_TRUE(ShouldPauseVideoWhenBackground());
742 742
743 // On Android, the duration and keyframe distance don't matter for video-only. 743 // On Android, the duration and keyframe distance don't matter for video-only.
744 SetDuration(base::TimeDelta::FromSeconds(5)); 744 SetDuration(base::TimeDelta::FromSeconds(5));
745 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 745 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
746 EXPECT_TRUE(ShouldPauseVideoWhenHidden()); 746 EXPECT_TRUE(ShouldPauseVideoWhenBackground());
747 747
748 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); 748 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100));
749 SetDuration(base::TimeDelta::FromSeconds(300)); 749 SetDuration(base::TimeDelta::FromSeconds(300));
750 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 750 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
751 EXPECT_TRUE(ShouldPauseVideoWhenHidden()); 751 EXPECT_TRUE(ShouldPauseVideoWhenBackground());
752 752
753 // Restore average keyframe distance. 753 // Restore average keyframe distance.
754 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5)); 754 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5));
755 #else 755 #else
756 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 756 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
757 #endif 757 #endif
758 758
759 // Audio only. 759 // Audio only.
760 SetMetadata(true, false); 760 SetMetadata(true, false);
761 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); 761 EXPECT_FALSE(IsBackgroundOptimizationCandidate());
762 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 762 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
763 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 763 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
764 764
765 // Duration is shorter than max video keyframe distance. 765 // Duration is shorter than max video keyframe distance.
766 SetDuration(base::TimeDelta::FromSeconds(5)); 766 SetDuration(base::TimeDelta::FromSeconds(5));
767 SetMetadata(true, true); 767 SetMetadata(true, true);
768 EXPECT_TRUE(IsBackgroundOptimizationCandidate()); 768 EXPECT_TRUE(IsBackgroundOptimizationCandidate());
769 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 769 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
770 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 770 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
771 771
772 // Average keyframe distance is too big. 772 // Average keyframe distance is too big.
773 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); 773 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100));
774 SetDuration(base::TimeDelta::FromSeconds(300)); 774 SetDuration(base::TimeDelta::FromSeconds(300));
775 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); 775 EXPECT_FALSE(IsBackgroundOptimizationCandidate());
776 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); 776 EXPECT_FALSE(ShouldPauseVideoWhenBackground());
777 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); 777 EXPECT_FALSE(ShouldDisableVideoWhenBackground());
778 } 778 }
779 779
780 } // namespace media 780 } // namespace media
OLDNEW
« media/blink/webmediaplayer_impl.h ('K') | « media/blink/webmediaplayer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698