| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 audio_renderer_(new StrictMock<MockAudioRenderer>()), | 61 audio_renderer_(new StrictMock<MockAudioRenderer>()), |
| 62 renderer_impl_( | 62 renderer_impl_( |
| 63 new RendererImpl(message_loop_.message_loop_proxy(), | 63 new RendererImpl(message_loop_.message_loop_proxy(), |
| 64 scoped_ptr<AudioRenderer>(audio_renderer_), | 64 scoped_ptr<AudioRenderer>(audio_renderer_), |
| 65 scoped_ptr<VideoRenderer>(video_renderer_))) { | 65 scoped_ptr<VideoRenderer>(video_renderer_))) { |
| 66 // SetDemuxerExpectations() adds overriding expectations for expected | 66 // SetDemuxerExpectations() adds overriding expectations for expected |
| 67 // non-NULL streams. | 67 // non-NULL streams. |
| 68 DemuxerStream* null_pointer = NULL; | 68 DemuxerStream* null_pointer = NULL; |
| 69 EXPECT_CALL(*demuxer_, GetStream(_)) | 69 EXPECT_CALL(*demuxer_, GetStream(_)) |
| 70 .WillRepeatedly(Return(null_pointer)); | 70 .WillRepeatedly(Return(null_pointer)); |
| 71 EXPECT_CALL(*demuxer_, GetLiveness()) | |
| 72 .WillRepeatedly(Return(Demuxer::LIVENESS_UNKNOWN)); | |
| 73 } | 71 } |
| 74 | 72 |
| 75 virtual ~RendererImplTest() { | 73 virtual ~RendererImplTest() { |
| 76 renderer_impl_.reset(); | 74 renderer_impl_.reset(); |
| 77 base::RunLoop().RunUntilIdle(); | 75 base::RunLoop().RunUntilIdle(); |
| 78 } | 76 } |
| 79 | 77 |
| 80 protected: | 78 protected: |
| 81 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 79 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 82 | 80 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 93 Initialize(audio_stream_.get(), _, _, _, _, _)) | 91 Initialize(audio_stream_.get(), _, _, _, _, _)) |
| 94 .WillOnce(DoAll(SaveArg<3>(&audio_buffering_state_cb_), | 92 .WillOnce(DoAll(SaveArg<3>(&audio_buffering_state_cb_), |
| 95 SaveArg<4>(&audio_ended_cb_), | 93 SaveArg<4>(&audio_ended_cb_), |
| 96 SaveArg<5>(&audio_error_cb_), | 94 SaveArg<5>(&audio_error_cb_), |
| 97 RunCallback<1>(status))); | 95 RunCallback<1>(status))); |
| 98 } | 96 } |
| 99 | 97 |
| 100 // Sets up expectations to allow the video renderer to initialize. | 98 // Sets up expectations to allow the video renderer to initialize. |
| 101 void SetVideoRendererInitializeExpectations(PipelineStatus status) { | 99 void SetVideoRendererInitializeExpectations(PipelineStatus status) { |
| 102 EXPECT_CALL(*video_renderer_, | 100 EXPECT_CALL(*video_renderer_, |
| 103 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) | 101 Initialize(video_stream_.get(), _, _, _, _, _, _, _)) |
| 104 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), | 102 .WillOnce(DoAll(SaveArg<3>(&video_buffering_state_cb_), |
| 105 SaveArg<6>(&video_ended_cb_), | 103 SaveArg<5>(&video_ended_cb_), |
| 106 RunCallback<2>(status))); | 104 RunCallback<1>(status))); |
| 107 } | 105 } |
| 108 | 106 |
| 109 void InitializeAndExpect(PipelineStatus start_status) { | 107 void InitializeAndExpect(PipelineStatus start_status) { |
| 110 if (start_status != PIPELINE_OK) | 108 if (start_status != PIPELINE_OK) |
| 111 EXPECT_CALL(callbacks_, OnError(start_status)); | 109 EXPECT_CALL(callbacks_, OnError(start_status)); |
| 112 | 110 |
| 113 EXPECT_CALL(callbacks_, OnInitialize()); | 111 EXPECT_CALL(callbacks_, OnInitialize()); |
| 114 | 112 |
| 115 if (start_status == PIPELINE_OK && audio_stream_) { | 113 if (start_status == PIPELINE_OK && audio_stream_) { |
| 116 EXPECT_CALL(*audio_renderer_, GetTimeSource()) | 114 EXPECT_CALL(*audio_renderer_, GetTimeSource()) |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); | 431 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); |
| 434 base::RunLoop().RunUntilIdle(); | 432 base::RunLoop().RunUntilIdle(); |
| 435 } | 433 } |
| 436 | 434 |
| 437 TEST_F(RendererImplTest, ErrorDuringInitialize) { | 435 TEST_F(RendererImplTest, ErrorDuringInitialize) { |
| 438 CreateAudioAndVideoStream(); | 436 CreateAudioAndVideoStream(); |
| 439 SetAudioRendererInitializeExpectations(PIPELINE_OK); | 437 SetAudioRendererInitializeExpectations(PIPELINE_OK); |
| 440 | 438 |
| 441 // Force an audio error to occur during video renderer initialization. | 439 // Force an audio error to occur during video renderer initialization. |
| 442 EXPECT_CALL(*video_renderer_, | 440 EXPECT_CALL(*video_renderer_, |
| 443 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) | 441 Initialize(video_stream_.get(), _, _, _, _, _, _, _)) |
| 444 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), | 442 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), |
| 445 SaveArg<4>(&video_buffering_state_cb_), | 443 SaveArg<3>(&video_buffering_state_cb_), |
| 446 SaveArg<6>(&video_ended_cb_), | 444 SaveArg<5>(&video_ended_cb_), |
| 447 RunCallback<2>(PIPELINE_OK))); | 445 RunCallback<1>(PIPELINE_OK))); |
| 448 | 446 |
| 449 InitializeAndExpect(PIPELINE_ERROR_DECODE); | 447 InitializeAndExpect(PIPELINE_ERROR_DECODE); |
| 450 } | 448 } |
| 451 | 449 |
| 452 } // namespace media | 450 } // namespace media |
| OLD | NEW |