| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 MOCK_METHOD1(OnStart, void(PipelineStatus)); | 48 MOCK_METHOD1(OnStart, void(PipelineStatus)); |
| 49 MOCK_METHOD1(OnSeek, void(PipelineStatus)); | 49 MOCK_METHOD1(OnSeek, void(PipelineStatus)); |
| 50 MOCK_METHOD1(OnStop, void(PipelineStatus)); | 50 MOCK_METHOD1(OnStop, void(PipelineStatus)); |
| 51 MOCK_METHOD1(OnEnded, void(PipelineStatus)); | 51 MOCK_METHOD1(OnEnded, void(PipelineStatus)); |
| 52 MOCK_METHOD1(OnError, void(PipelineStatus)); | 52 MOCK_METHOD1(OnError, void(PipelineStatus)); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); | 55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Run |cb| w/ OK status. | |
| 59 static void RunPipelineStatusOKCB(const PipelineStatusCB& cb) { | |
| 60 cb.Run(PIPELINE_OK); | |
| 61 } | |
| 62 | |
| 63 // TODO(scherkus): even though some filters are initialized on separate | 58 // TODO(scherkus): even though some filters are initialized on separate |
| 64 // threads these test aren't flaky... why? It's because filters' Initialize() | 59 // threads these test aren't flaky... why? It's because filters' Initialize() |
| 65 // is executed on |message_loop_| and the mock filters instantly call | 60 // is executed on |message_loop_| and the mock filters instantly call |
| 66 // InitializationComplete(), which keeps the pipeline humming along. If | 61 // InitializationComplete(), which keeps the pipeline humming along. If |
| 67 // either filters don't call InitializationComplete() immediately or filter | 62 // either filters don't call InitializationComplete() immediately or filter |
| 68 // initialization is moved to a separate thread this test will become flaky. | 63 // initialization is moved to a separate thread this test will become flaky. |
| 69 class PipelineTest : public ::testing::Test { | 64 class PipelineTest : public ::testing::Test { |
| 70 public: | 65 public: |
| 71 PipelineTest() | 66 PipelineTest() |
| 72 : pipeline_(new Pipeline(&message_loop_, new MediaLog())) { | 67 : pipeline_(new Pipeline(&message_loop_, new MediaLog())) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 86 if (!pipeline_->IsRunning()) { | 81 if (!pipeline_->IsRunning()) { |
| 87 return; | 82 return; |
| 88 } | 83 } |
| 89 | 84 |
| 90 // Expect a stop callback if we were started. | 85 // Expect a stop callback if we were started. |
| 91 EXPECT_CALL(callbacks_, OnStop(PIPELINE_OK)); | 86 EXPECT_CALL(callbacks_, OnStop(PIPELINE_OK)); |
| 92 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, | 87 pipeline_->Stop(base::Bind(&CallbackHelper::OnStop, |
| 93 base::Unretained(&callbacks_))); | 88 base::Unretained(&callbacks_))); |
| 94 message_loop_.RunAllPending(); | 89 message_loop_.RunAllPending(); |
| 95 | 90 |
| 91 pipeline_ = NULL; |
| 96 mocks_.reset(); | 92 mocks_.reset(); |
| 97 } | 93 } |
| 98 | 94 |
| 99 protected: | 95 protected: |
| 100 // Sets up expectations to allow the demuxer to initialize. | 96 // Sets up expectations to allow the demuxer to initialize. |
| 101 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; | 97 typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector; |
| 102 void InitializeDemuxer(MockDemuxerStreamVector* streams, | 98 void InitializeDemuxer(MockDemuxerStreamVector* streams, |
| 103 const base::TimeDelta& duration) { | 99 const base::TimeDelta& duration) { |
| 100 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)) |
| 101 .WillOnce(Invoke(&RunPipelineStatusCB)); |
| 104 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration( | 102 mocks_->demuxer()->SetTotalAndBufferedBytesAndDuration( |
| 105 kTotalBytes, kBufferedBytes, duration); | 103 kTotalBytes, kBufferedBytes, duration); |
| 106 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); | 104 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f)); |
| 107 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) | 105 EXPECT_CALL(*mocks_->demuxer(), Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 108 .WillOnce(Invoke(&RunPipelineStatusCB)); | 106 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
| 109 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 107 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 110 .WillOnce(Invoke(&RunStopFilterCallback)); | 108 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 111 | 109 |
| 112 // Configure the demuxer to return the streams. | 110 // Configure the demuxer to return the streams. |
| 113 for (size_t i = 0; i < streams->size(); ++i) { | 111 for (size_t i = 0; i < streams->size(); ++i) { |
| 114 scoped_refptr<DemuxerStream> stream((*streams)[i]); | 112 scoped_refptr<DemuxerStream> stream((*streams)[i]); |
| 115 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) | 113 EXPECT_CALL(*mocks_->demuxer(), GetStream(stream->type())) |
| 116 .WillRepeatedly(Return(stream)); | 114 .WillRepeatedly(Return(stream)); |
| 117 } | 115 } |
| 118 } | 116 } |
| 119 | 117 |
| 120 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { | 118 StrictMock<MockDemuxerStream>* CreateStream(DemuxerStream::Type type) { |
| 121 StrictMock<MockDemuxerStream>* stream = | 119 StrictMock<MockDemuxerStream>* stream = |
| 122 new StrictMock<MockDemuxerStream>(); | 120 new StrictMock<MockDemuxerStream>(); |
| 123 EXPECT_CALL(*stream, type()) | 121 EXPECT_CALL(*stream, type()) |
| 124 .WillRepeatedly(Return(type)); | 122 .WillRepeatedly(Return(type)); |
| 125 return stream; | 123 return stream; |
| 126 } | 124 } |
| 127 | 125 |
| 128 // Sets up expectations to allow the video decoder to initialize. | 126 // Sets up expectations to allow the video decoder to initialize. |
| 129 void InitializeVideoDecoder(MockDemuxerStream* stream) { | 127 void InitializeVideoDecoder(MockDemuxerStream* stream) { |
| 130 EXPECT_CALL(*mocks_->video_decoder(), | 128 EXPECT_CALL(*mocks_->video_decoder(), |
| 131 Initialize(stream, _, _)) | 129 Initialize(stream, _, _)) |
| 132 .WillOnce(WithArg<1>(Invoke(&RunPipelineStatusOKCB))); | 130 .WillOnce(Invoke(&RunPipelineStatusCB3)); |
| 133 } | 131 } |
| 134 | 132 |
| 135 // Sets up expectations to allow the audio decoder to initialize. | 133 // Sets up expectations to allow the audio decoder to initialize. |
| 136 void InitializeAudioDecoder(const scoped_refptr<DemuxerStream>& stream) { | 134 void InitializeAudioDecoder(const scoped_refptr<DemuxerStream>& stream) { |
| 137 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _)) | 135 EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, _, _)) |
| 138 .WillOnce(Invoke(&RunPipelineStatusCB3)); | 136 .WillOnce(Invoke(&RunPipelineStatusCB3)); |
| 139 } | 137 } |
| 140 | 138 |
| 141 // Sets up expectations to allow the video renderer to initialize. | 139 // Sets up expectations to allow the video renderer to initialize. |
| 142 void InitializeVideoRenderer() { | 140 void InitializeVideoRenderer() { |
| 143 EXPECT_CALL(*mocks_->video_renderer(), Initialize( | 141 EXPECT_CALL(*mocks_->video_renderer(), Initialize( |
| 144 scoped_refptr<VideoDecoder>(mocks_->video_decoder()), _, _, _)) | 142 scoped_refptr<VideoDecoder>(mocks_->video_decoder()), _, _, _)) |
| 145 .WillOnce(Invoke(&RunPipelineStatusCB4)); | 143 .WillOnce(Invoke(&RunPipelineStatusCB4)); |
| 146 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 144 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 147 EXPECT_CALL(*mocks_->video_renderer(), | 145 EXPECT_CALL(*mocks_->video_renderer(), |
| 148 Seek(mocks_->demuxer()->GetStartTime(), _)) | 146 Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 149 .WillOnce(Invoke(&RunPipelineStatusCB)); | 147 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
| 150 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) | 148 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
| 151 .WillOnce(Invoke(&RunStopFilterCallback)); | 149 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 152 } | 150 } |
| 153 | 151 |
| 154 // Sets up expectations to allow the audio renderer to initialize. | 152 // Sets up expectations to allow the audio renderer to initialize. |
| 155 void InitializeAudioRenderer(bool disable_after_init_cb = false) { | 153 void InitializeAudioRenderer(bool disable_after_init_cb = false) { |
| 156 if (disable_after_init_cb) { | 154 if (disable_after_init_cb) { |
| 157 EXPECT_CALL(*mocks_->audio_renderer(), Initialize( | 155 EXPECT_CALL(*mocks_->audio_renderer(), Initialize( |
| 158 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _)) | 156 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _)) |
| 159 .WillOnce(DoAll(Invoke(&RunPipelineStatusCB4), | 157 .WillOnce(DoAll(Invoke(&RunPipelineStatusCB4), |
| 160 DisableAudioRenderer(mocks_->audio_renderer()))); | 158 DisableAudioRenderer(mocks_->audio_renderer()))); |
| 161 } else { | 159 } else { |
| 162 EXPECT_CALL(*mocks_->audio_renderer(), Initialize( | 160 EXPECT_CALL(*mocks_->audio_renderer(), Initialize( |
| 163 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _)) | 161 scoped_refptr<AudioDecoder>(mocks_->audio_decoder()), _, _, _)) |
| 164 .WillOnce(Invoke(&RunPipelineStatusCB4)); | 162 .WillOnce(Invoke(&RunPipelineStatusCB4)); |
| 165 } | 163 } |
| 166 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 164 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 167 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 165 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 168 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) | 166 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) |
| 169 .WillOnce(Invoke(&RunPipelineStatusCB)); | 167 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
| 170 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 168 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 171 .WillOnce(Invoke(&RunStopFilterCallback)); | 169 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 172 } | 170 } |
| 173 | 171 |
| 174 // Sets up expectations on the callback and initializes the pipeline. Called | 172 // Sets up expectations on the callback and initializes the pipeline. Called |
| 175 // after tests have set expectations any filters they wish to use. | 173 // after tests have set expectations any filters they wish to use. |
| 176 void InitializePipeline() { | |
| 177 InitializePipeline(PIPELINE_OK); | |
| 178 } | |
| 179 // Most tests can expect the |filter_collection|'s |build_status| to get | |
| 180 // reflected in |Start()|'s argument. | |
| 181 void InitializePipeline(PipelineStatus start_status) { | 174 void InitializePipeline(PipelineStatus start_status) { |
| 182 InitializePipeline(start_status, start_status); | |
| 183 } | |
| 184 // But some tests require different statuses in build & Start. | |
| 185 void InitializePipeline(PipelineStatus build_status, | |
| 186 PipelineStatus start_status) { | |
| 187 // Expect an initialization callback. | |
| 188 EXPECT_CALL(callbacks_, OnStart(start_status)); | 175 EXPECT_CALL(callbacks_, OnStart(start_status)); |
| 189 | 176 |
| 190 pipeline_->Start( | 177 pipeline_->Start( |
| 191 mocks_->filter_collection(true, true, true, build_status).Pass(), | 178 mocks_->Create().Pass(), |
| 192 "", | |
| 193 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 179 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 194 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 180 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 195 NetworkEventCB(), | 181 NetworkEventCB(), |
| 196 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | 182 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
| 197 | |
| 198 message_loop_.RunAllPending(); | 183 message_loop_.RunAllPending(); |
| 199 } | 184 } |
| 200 | 185 |
| 201 void CreateAudioStream() { | 186 void CreateAudioStream() { |
| 202 audio_stream_ = CreateStream(DemuxerStream::AUDIO); | 187 audio_stream_ = CreateStream(DemuxerStream::AUDIO); |
| 203 } | 188 } |
| 204 | 189 |
| 205 void CreateVideoStream() { | 190 void CreateVideoStream() { |
| 206 video_stream_ = CreateStream(DemuxerStream::VIDEO); | 191 video_stream_ = CreateStream(DemuxerStream::VIDEO); |
| 207 } | 192 } |
| 208 | 193 |
| 209 MockDemuxerStream* audio_stream() { | 194 MockDemuxerStream* audio_stream() { |
| 210 return audio_stream_; | 195 return audio_stream_; |
| 211 } | 196 } |
| 212 | 197 |
| 213 MockDemuxerStream* video_stream() { | 198 MockDemuxerStream* video_stream() { |
| 214 return video_stream_; | 199 return video_stream_; |
| 215 } | 200 } |
| 216 | 201 |
| 217 void ExpectSeek(const base::TimeDelta& seek_time) { | 202 void ExpectSeek(const base::TimeDelta& seek_time) { |
| 218 // Every filter should receive a call to Seek(). | 203 // Every filter should receive a call to Seek(). |
| 219 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) | 204 EXPECT_CALL(*mocks_->demuxer(), Seek(seek_time, _)) |
| 220 .WillOnce(Invoke(&RunPipelineStatusCB)); | 205 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
| 221 | 206 |
| 222 if (audio_stream_) { | 207 if (audio_stream_) { |
| 223 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _)) | 208 EXPECT_CALL(*mocks_->audio_renderer(), Seek(seek_time, _)) |
| 224 .WillOnce(Invoke(&RunPipelineStatusCB)); | 209 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
| 225 } | 210 } |
| 226 | 211 |
| 227 if (video_stream_) { | 212 if (video_stream_) { |
| 228 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _)) | 213 EXPECT_CALL(*mocks_->video_renderer(), Seek(seek_time, _)) |
| 229 .WillOnce(Invoke(&RunPipelineStatusCB)); | 214 .WillOnce(Invoke(&RunPipelineStatusCB2)); |
| 230 } | 215 } |
| 231 | 216 |
| 232 // We expect a successful seek callback. | 217 // We expect a successful seek callback. |
| 233 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); | 218 EXPECT_CALL(callbacks_, OnSeek(PIPELINE_OK)); |
| 234 } | 219 } |
| 235 | 220 |
| 236 void DoSeek(const base::TimeDelta& seek_time) { | 221 void DoSeek(const base::TimeDelta& seek_time) { |
| 237 pipeline_->Seek(seek_time, | 222 pipeline_->Seek(seek_time, |
| 238 base::Bind(&CallbackHelper::OnSeek, | 223 base::Bind(&CallbackHelper::OnSeek, |
| 239 base::Unretained(&callbacks_))); | 224 base::Unretained(&callbacks_))); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 EXPECT_EQ(0, pipeline_->GetTotalBytes()); | 273 EXPECT_EQ(0, pipeline_->GetTotalBytes()); |
| 289 | 274 |
| 290 // Should always get set to zero. | 275 // Should always get set to zero. |
| 291 gfx::Size size(1, 1); | 276 gfx::Size size(1, 1); |
| 292 pipeline_->GetNaturalVideoSize(&size); | 277 pipeline_->GetNaturalVideoSize(&size); |
| 293 EXPECT_EQ(0, size.width()); | 278 EXPECT_EQ(0, size.width()); |
| 294 EXPECT_EQ(0, size.height()); | 279 EXPECT_EQ(0, size.height()); |
| 295 } | 280 } |
| 296 | 281 |
| 297 TEST_F(PipelineTest, NeverInitializes) { | 282 TEST_F(PipelineTest, NeverInitializes) { |
| 283 // Don't execute the callback passed into Initialize(). |
| 284 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)); |
| 285 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 286 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 287 |
| 298 // This test hangs during initialization by never calling | 288 // This test hangs during initialization by never calling |
| 299 // InitializationComplete(). StrictMock<> will ensure that the callback is | 289 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 300 // never executed. | 290 // never executed. |
| 301 pipeline_->Start( | 291 pipeline_->Start( |
| 302 mocks_->filter_collection(false, false, true, PIPELINE_OK).Pass(), | 292 mocks_->Create().Pass(), |
| 303 "", | |
| 304 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 293 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 305 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 294 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 306 NetworkEventCB(), | 295 NetworkEventCB(), |
| 307 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | 296 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
| 308 message_loop_.RunAllPending(); | 297 message_loop_.RunAllPending(); |
| 309 | 298 |
| 310 EXPECT_FALSE(pipeline_->IsInitialized()); | 299 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 311 | 300 |
| 312 // Because our callback will get executed when the test tears down, we'll | 301 // Because our callback will get executed when the test tears down, we'll |
| 313 // verify that nothing has been called, then set our expectation for the call | 302 // verify that nothing has been called, then set our expectation for the call |
| 314 // made during tear down. | 303 // made during tear down. |
| 315 Mock::VerifyAndClear(&callbacks_); | 304 Mock::VerifyAndClear(&callbacks_); |
| 316 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); | 305 EXPECT_CALL(callbacks_, OnStart(PIPELINE_OK)); |
| 317 } | 306 } |
| 318 | 307 |
| 319 TEST_F(PipelineTest, RequiredFilterMissing) { | 308 TEST_F(PipelineTest, RequiredFilterMissing) { |
| 309 // TODO(acolwell,fischman): See TODO in URLNotFound below. |
| 310 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
| 320 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); | 311 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); |
| 321 | 312 |
| 322 // Sets up expectations on the callback and initializes the pipeline. Called | 313 // Create a filter collection with missing filter. |
| 323 // after tests have set expectations any filters they wish to use. | 314 scoped_ptr<FilterCollection> collection(mocks_->Create()); |
| 324 // Expect an initialization callback. | 315 collection->SetDemuxer(NULL); |
| 325 EXPECT_CALL(callbacks_, OnStart(PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); | |
| 326 | 316 |
| 327 // Create a filter collection with missing filter. | |
| 328 scoped_ptr<FilterCollection> collection(mocks_->filter_collection( | |
| 329 false, true, true, PIPELINE_ERROR_REQUIRED_FILTER_MISSING)); | |
| 330 pipeline_->Start( | 317 pipeline_->Start( |
| 331 collection.Pass(), | 318 collection.Pass(), |
| 332 "", | 319 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 333 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 320 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 334 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 321 NetworkEventCB(), |
| 335 NetworkEventCB(), | 322 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
| 336 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | |
| 337 message_loop_.RunAllPending(); | 323 message_loop_.RunAllPending(); |
| 338 | 324 |
| 339 EXPECT_FALSE(pipeline_->IsInitialized()); | 325 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 340 } | 326 } |
| 341 | 327 |
| 342 TEST_F(PipelineTest, URLNotFound) { | 328 TEST_F(PipelineTest, URLNotFound) { |
| 343 // TODO(acolwell,fischman): Since OnStart() is getting called with an error | 329 // TODO(acolwell,fischman): Since OnStart() is getting called with an error |
| 344 // code already, OnError() doesn't also need to get called. Fix the pipeline | 330 // code already, OnError() doesn't also need to get called. Fix the pipeline |
| 345 // (and it's consumers!) so that OnError doesn't need to be called after | 331 // (and it's consumers!) so that OnError doesn't need to be called after |
| 346 // another callback has already reported the error. Same applies to NoStreams | 332 // another callback has already reported the error. Same applies to NoStreams |
| 347 // below. | 333 // below. |
| 348 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_URL_NOT_FOUND)); | 334 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_URL_NOT_FOUND)); |
| 335 |
| 336 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)) |
| 337 .WillOnce(RunPipelineStatusCBWithError( |
| 338 PIPELINE_ERROR_URL_NOT_FOUND)); |
| 339 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 340 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 341 |
| 349 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); | 342 InitializePipeline(PIPELINE_ERROR_URL_NOT_FOUND); |
| 350 EXPECT_FALSE(pipeline_->IsInitialized()); | 343 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 351 } | 344 } |
| 352 | 345 |
| 353 TEST_F(PipelineTest, NoStreams) { | 346 TEST_F(PipelineTest, NoStreams) { |
| 354 // Manually set these expectations because SetPlaybackRate() is not called if | |
| 355 // we cannot fully initialize the pipeline. | |
| 356 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | |
| 357 .WillOnce(Invoke(&RunStopFilterCallback)); | |
| 358 // TODO(acolwell,fischman): see TODO in URLNotFound above. | 347 // TODO(acolwell,fischman): see TODO in URLNotFound above. |
| 359 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_COULD_NOT_RENDER)); | 348 EXPECT_CALL(callbacks_, OnError(PIPELINE_ERROR_COULD_NOT_RENDER)); |
| 360 | 349 |
| 361 InitializePipeline(PIPELINE_OK, PIPELINE_ERROR_COULD_NOT_RENDER); | 350 EXPECT_CALL(*mocks_->demuxer(), Initialize(_)) |
| 351 .WillOnce(Invoke(&RunPipelineStatusCB)); |
| 352 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 353 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 354 |
| 355 InitializePipeline(PIPELINE_ERROR_COULD_NOT_RENDER); |
| 362 EXPECT_FALSE(pipeline_->IsInitialized()); | 356 EXPECT_FALSE(pipeline_->IsInitialized()); |
| 363 } | 357 } |
| 364 | 358 |
| 365 TEST_F(PipelineTest, AudioStream) { | 359 TEST_F(PipelineTest, AudioStream) { |
| 366 CreateAudioStream(); | 360 CreateAudioStream(); |
| 367 MockDemuxerStreamVector streams; | 361 MockDemuxerStreamVector streams; |
| 368 streams.push_back(audio_stream()); | 362 streams.push_back(audio_stream()); |
| 369 | 363 |
| 370 InitializeDemuxer(&streams, base::TimeDelta()); | 364 InitializeDemuxer(&streams, base::TimeDelta()); |
| 371 InitializeAudioDecoder(audio_stream()); | 365 InitializeAudioDecoder(audio_stream()); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 877 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 884 } | 878 } |
| 885 | 879 |
| 886 // Test that different-thread, some-delay callback (the expected common case) | 880 // Test that different-thread, some-delay callback (the expected common case) |
| 887 // works correctly. | 881 // works correctly. |
| 888 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 882 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 889 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 883 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 890 } | 884 } |
| 891 | 885 |
| 892 } // namespace media | 886 } // namespace media |
| OLD | NEW |