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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 EXPECT_CALL(delegate_, DidPlay(_, true, true, false, _)); | 773 EXPECT_CALL(delegate_, DidPlay(_, true, true, false, _)); |
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 | 780 |
775 SetMetadata(true, true); | 781 SetMetadata(true, true); |
776 SetBackgroundVideoOptimization(true); | 782 SetBackgroundVideoOptimization(true); |
| 783 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5)); |
777 EXPECT_TRUE(ShouldDisableVideoWhenHidden()); | 784 EXPECT_TRUE(ShouldDisableVideoWhenHidden()); |
778 | 785 |
779 SetMetadata(true, true); | |
780 SetBackgroundVideoOptimization(false); | 786 SetBackgroundVideoOptimization(false); |
781 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 787 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
782 | 788 |
| 789 SetBackgroundVideoOptimization(true); |
| 790 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); |
| 791 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
| 792 |
| 793 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(5)); |
783 SetMetadata(false, true); | 794 SetMetadata(false, true); |
784 SetBackgroundVideoOptimization(true); | |
785 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 795 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
786 | 796 |
787 SetMetadata(true, false); | 797 SetMetadata(true, false); |
788 SetBackgroundVideoOptimization(true); | |
789 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 798 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
790 } | 799 } |
791 | 800 |
792 } // namespace media | 801 } // namespace media |
OLD | NEW |