OLD | NEW |
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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 } else { | 256 } else { |
257 scoped_feature_list_.InitAndDisableFeature( | 257 scoped_feature_list_.InitAndDisableFeature( |
258 kBackgroundVideoTrackOptimization); | 258 kBackgroundVideoTrackOptimization); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 bool ShouldDisableVideoWhenHidden() const { | 262 bool ShouldDisableVideoWhenHidden() const { |
263 return wmpi_->ShouldDisableVideoWhenHidden(); | 263 return wmpi_->ShouldDisableVideoWhenHidden(); |
264 } | 264 } |
265 | 265 |
| 266 void SetVideoKeyframeDistanceAverage(base::TimeDelta value) { |
| 267 PipelineStatistics statistics; |
| 268 statistics.video_keyframe_distance_average = value; |
| 269 wmpi_->SetPipelineStatisticsForTest(statistics); |
| 270 } |
| 271 |
266 // "Renderer" thread. | 272 // "Renderer" thread. |
267 base::MessageLoop message_loop_; | 273 base::MessageLoop message_loop_; |
268 | 274 |
269 // "Media" thread. This is necessary because WMPI destruction waits on a | 275 // "Media" thread. This is necessary because WMPI destruction waits on a |
270 // WaitableEvent. | 276 // WaitableEvent. |
271 base::Thread media_thread_; | 277 base::Thread media_thread_; |
272 | 278 |
273 // Blink state. | 279 // Blink state. |
274 blink::WebFrameClient web_frame_client_; | 280 blink::WebFrameClient web_frame_client_; |
275 blink::WebView* web_view_; | 281 blink::WebView* web_view_; |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 client_.set_is_autoplaying_muted(false); | 774 client_.set_is_autoplaying_muted(false); |
769 wmpi_->setVolume(1.0); | 775 wmpi_->setVolume(1.0); |
770 } | 776 } |
771 | 777 |
772 TEST_F(WebMediaPlayerImplTest, ShouldDisableVideoWhenHidden) { | 778 TEST_F(WebMediaPlayerImplTest, ShouldDisableVideoWhenHidden) { |
773 InitializeWebMediaPlayerImpl(); | 779 InitializeWebMediaPlayerImpl(); |
774 EXPECT_CALL(delegate_, IsHidden()).WillRepeatedly(Return(true)); | 780 EXPECT_CALL(delegate_, IsHidden()).WillRepeatedly(Return(true)); |
775 SetBackgroundVideoOptimization(true); | 781 SetBackgroundVideoOptimization(true); |
776 | 782 |
777 SetMetadata(true, true); | 783 SetMetadata(true, true); |
| 784 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5)); |
778 EXPECT_TRUE(ShouldDisableVideoWhenHidden()); | 785 EXPECT_TRUE(ShouldDisableVideoWhenHidden()); |
779 | 786 |
780 SetMetadata(false, true); | 787 SetMetadata(false, true); |
781 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 788 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
782 | 789 |
783 SetMetadata(true, false); | 790 SetMetadata(true, false); |
784 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 791 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
| 792 |
| 793 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); |
| 794 SetMetadata(true, true); |
| 795 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
785 } | 796 } |
786 | 797 |
787 TEST_F(WebMediaPlayerImplTest, ShouldDisableVideoWhenHiddenFeatureDisabled) { | 798 TEST_F(WebMediaPlayerImplTest, ShouldDisableVideoWhenHiddenFeatureDisabled) { |
788 InitializeWebMediaPlayerImpl(); | 799 InitializeWebMediaPlayerImpl(); |
789 EXPECT_CALL(delegate_, IsHidden()).WillRepeatedly(Return(true)); | 800 EXPECT_CALL(delegate_, IsHidden()).WillRepeatedly(Return(true)); |
790 SetBackgroundVideoOptimization(false); | 801 SetBackgroundVideoOptimization(false); |
791 | 802 |
792 SetMetadata(true, true); | 803 SetMetadata(true, true); |
793 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 804 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
794 } | 805 } |
795 | 806 |
796 } // namespace media | 807 } // namespace media |
OLD | NEW |