| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 // | 4 // |
| 5 // TODO(ajwong): This whole file is deprecated in favor or gmock style mocks. | 5 // TODO(ajwong): This whole file is deprecated in favor or gmock style mocks. |
| 6 // The deprecated classes have been moved into the old_mocks to avoid colliding | 6 // The deprecated classes have been moved into the old_mocks to avoid colliding |
| 7 // with the newer mock classes. Once all the unittests have been migrated, this | 7 // with the newer mock classes. Once all the unittests have been migrated, this |
| 8 // should be deleted. | 8 // should be deleted. |
| 9 | 9 |
| 10 #ifndef MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ | 10 #ifndef MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 virtual void Seek(base::TimeDelta time) { | 99 virtual void Seek(base::TimeDelta time) { |
| 100 seek_time_ = time; | 100 seek_time_ = time; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Implementation of DataSource. | 103 // Implementation of DataSource. |
| 104 virtual bool Initialize(const std::string& url) { | 104 virtual bool Initialize(const std::string& url) { |
| 105 media_format_.SetAsString(MediaFormat::kMimeType, | 105 media_format_.SetAsString(MediaFormat::kMimeType, |
| 106 mime_type::kApplicationOctetStream); | 106 mime_type::kApplicationOctetStream); |
| 107 media_format_.SetAsString(MediaFormat::kURL, url); | 107 media_format_.SetAsString(MediaFormat::kURL, url); |
| 108 host_->SetTotalBytes(config_->media_total_bytes); | 108 host()->SetTotalBytes(config_->media_total_bytes); |
| 109 switch (config_->data_source_behavior) { | 109 switch (config_->data_source_behavior) { |
| 110 case MOCK_DATA_SOURCE_NORMAL_INIT: | 110 case MOCK_DATA_SOURCE_NORMAL_INIT: |
| 111 host_->InitializationComplete(); | 111 host()->InitializationComplete(); |
| 112 return true; | 112 return true; |
| 113 case MOCK_DATA_SOURCE_NEVER_INIT: | 113 case MOCK_DATA_SOURCE_NEVER_INIT: |
| 114 return true; | 114 return true; |
| 115 case MOCK_DATA_SOURCE_URL_ERROR_IN_INIT: | 115 case MOCK_DATA_SOURCE_URL_ERROR_IN_INIT: |
| 116 host_->Error(PIPELINE_ERROR_URL_NOT_FOUND); | 116 host()->Error(PIPELINE_ERROR_URL_NOT_FOUND); |
| 117 return false; | 117 return false; |
| 118 case MOCK_DATA_SOURCE_INIT_RETURN_FALSE: | 118 case MOCK_DATA_SOURCE_INIT_RETURN_FALSE: |
| 119 return false; | 119 return false; |
| 120 default: | 120 default: |
| 121 NOTREACHED(); | 121 NOTREACHED(); |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual const MediaFormat& media_format() { | 126 virtual const MediaFormat& media_format() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 // Implementation of MediaFilter. | 228 // Implementation of MediaFilter. |
| 229 virtual void Stop() {} | 229 virtual void Stop() {} |
| 230 | 230 |
| 231 virtual void Seek(base::TimeDelta time) { | 231 virtual void Seek(base::TimeDelta time) { |
| 232 seek_time_ = time; | 232 seek_time_ = time; |
| 233 } | 233 } |
| 234 | 234 |
| 235 // Implementation of Demuxer. | 235 // Implementation of Demuxer. |
| 236 virtual bool Initialize(DataSource* data_source) { | 236 virtual bool Initialize(DataSource* data_source) { |
| 237 host_->InitializationComplete(); | 237 host()->InitializationComplete(); |
| 238 return true; | 238 return true; |
| 239 } | 239 } |
| 240 | 240 |
| 241 virtual size_t GetNumberOfStreams() { | 241 virtual size_t GetNumberOfStreams() { |
| 242 size_t num_streams = 0; | 242 size_t num_streams = 0; |
| 243 if (config_->has_audio) { | 243 if (config_->has_audio) { |
| 244 ++num_streams; | 244 ++num_streams; |
| 245 } | 245 } |
| 246 if (config_->has_video) { | 246 if (config_->has_video) { |
| 247 ++num_streams; | 247 ++num_streams; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 292 |
| 293 // Implementation of MediaFilter. | 293 // Implementation of MediaFilter. |
| 294 virtual void Stop() {} | 294 virtual void Stop() {} |
| 295 | 295 |
| 296 virtual void Seek(base::TimeDelta time) { | 296 virtual void Seek(base::TimeDelta time) { |
| 297 seek_time_ = time; | 297 seek_time_ = time; |
| 298 } | 298 } |
| 299 | 299 |
| 300 // Implementation of AudioDecoder. | 300 // Implementation of AudioDecoder. |
| 301 virtual bool Initialize(DemuxerStream* stream) { | 301 virtual bool Initialize(DemuxerStream* stream) { |
| 302 host_->InitializationComplete(); | 302 host()->InitializationComplete(); |
| 303 return true; | 303 return true; |
| 304 } | 304 } |
| 305 | 305 |
| 306 virtual const MediaFormat& media_format() { | 306 virtual const MediaFormat& media_format() { |
| 307 return media_format_; | 307 return media_format_; |
| 308 } | 308 } |
| 309 | 309 |
| 310 virtual void Read(Callback1<Buffer*>::Type* callback) { | 310 virtual void Read(Callback1<Buffer*>::Type* callback) { |
| 311 // TODO(ralphl): implement mock read. | 311 // TODO(ralphl): implement mock read. |
| 312 NOTREACHED(); | 312 NOTREACHED(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 331 | 331 |
| 332 // Implementation of MediaFilter. | 332 // Implementation of MediaFilter. |
| 333 virtual void Stop() {} | 333 virtual void Stop() {} |
| 334 | 334 |
| 335 virtual void Seek(base::TimeDelta time) { | 335 virtual void Seek(base::TimeDelta time) { |
| 336 seek_time_ = time; | 336 seek_time_ = time; |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Implementation of AudioRenderer. | 339 // Implementation of AudioRenderer. |
| 340 virtual bool Initialize(AudioDecoder* decoder) { | 340 virtual bool Initialize(AudioDecoder* decoder) { |
| 341 host_->InitializationComplete(); | 341 host()->InitializationComplete(); |
| 342 return true; | 342 return true; |
| 343 } | 343 } |
| 344 | 344 |
| 345 virtual void SetVolume(float volume) {} | 345 virtual void SetVolume(float volume) {} |
| 346 | 346 |
| 347 // Mock accessors. | 347 // Mock accessors. |
| 348 const base::TimeDelta& seek_time() const { return seek_time_; } | 348 const base::TimeDelta& seek_time() const { return seek_time_; } |
| 349 | 349 |
| 350 private: | 350 private: |
| 351 virtual ~MockAudioRenderer() {} | 351 virtual ~MockAudioRenderer() {} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 // Implementation of MediaFilter. | 398 // Implementation of MediaFilter. |
| 399 virtual void Stop() {} | 399 virtual void Stop() {} |
| 400 | 400 |
| 401 virtual void Seek(base::TimeDelta time) { | 401 virtual void Seek(base::TimeDelta time) { |
| 402 seek_time_ = time; | 402 seek_time_ = time; |
| 403 } | 403 } |
| 404 | 404 |
| 405 // Implementation of VideoDecoder. | 405 // Implementation of VideoDecoder. |
| 406 virtual bool Initialize(DemuxerStream* stream) { | 406 virtual bool Initialize(DemuxerStream* stream) { |
| 407 host_->InitializationComplete(); | 407 host()->InitializationComplete(); |
| 408 return true; | 408 return true; |
| 409 } | 409 } |
| 410 | 410 |
| 411 virtual const MediaFormat& media_format() { | 411 virtual const MediaFormat& media_format() { |
| 412 return media_format_; | 412 return media_format_; |
| 413 } | 413 } |
| 414 | 414 |
| 415 virtual void Read(Callback1<VideoFrame*>::Type* callback) { | 415 virtual void Read(Callback1<VideoFrame*>::Type* callback) { |
| 416 DoRead(callback); | 416 DoRead(callback); |
| 417 } | 417 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 429 // formats as needed. | 429 // formats as needed. |
| 430 EXPECT_EQ(config_->video_surface_format, VideoSurface::YV12); | 430 EXPECT_EQ(config_->video_surface_format, VideoSurface::YV12); |
| 431 scoped_refptr<VideoFrame> frame; | 431 scoped_refptr<VideoFrame> frame; |
| 432 VideoFrameImpl::CreateFrame(config_->video_surface_format, | 432 VideoFrameImpl::CreateFrame(config_->video_surface_format, |
| 433 config_->video_width, | 433 config_->video_width, |
| 434 config_->video_height, | 434 config_->video_height, |
| 435 mock_frame_time_, | 435 mock_frame_time_, |
| 436 config_->frame_duration, | 436 config_->frame_duration, |
| 437 &frame); | 437 &frame); |
| 438 if (!frame) { | 438 if (!frame) { |
| 439 host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY); | 439 host()->Error(PIPELINE_ERROR_OUT_OF_MEMORY); |
| 440 ADD_FAILURE(); | 440 ADD_FAILURE(); |
| 441 } else { | 441 } else { |
| 442 mock_frame_time_ += config_->frame_duration; | 442 mock_frame_time_ += config_->frame_duration; |
| 443 if (mock_frame_time_ >= config_->media_duration) { | 443 if (mock_frame_time_ >= config_->media_duration) { |
| 444 VideoFrameImpl::CreateEmptyFrame(&frame); | 444 VideoFrameImpl::CreateEmptyFrame(&frame); |
| 445 } else { | 445 } else { |
| 446 InitializeYV12Frame(frame, (mock_frame_time_.InSecondsF() / | 446 InitializeYV12Frame(frame, (mock_frame_time_.InSecondsF() / |
| 447 config_->media_duration.InSecondsF())); | 447 config_->media_duration.InSecondsF())); |
| 448 } | 448 } |
| 449 callback->Run(frame); | 449 callback->Run(frame); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 468 | 468 |
| 469 // Implementation of MediaFilter. | 469 // Implementation of MediaFilter. |
| 470 virtual void Stop() {} | 470 virtual void Stop() {} |
| 471 | 471 |
| 472 virtual void Seek(base::TimeDelta time) { | 472 virtual void Seek(base::TimeDelta time) { |
| 473 seek_time_ = time; | 473 seek_time_ = time; |
| 474 } | 474 } |
| 475 | 475 |
| 476 // Implementation of VideoRenderer. | 476 // Implementation of VideoRenderer. |
| 477 virtual bool Initialize(VideoDecoder* decoder) { | 477 virtual bool Initialize(VideoDecoder* decoder) { |
| 478 host_->SetVideoSize(config_->video_width, config_->video_height); | 478 host()->SetVideoSize(config_->video_width, config_->video_height); |
| 479 host_->InitializationComplete(); | 479 host()->InitializationComplete(); |
| 480 return true; | 480 return true; |
| 481 } | 481 } |
| 482 | 482 |
| 483 // Mock accessors. | 483 // Mock accessors. |
| 484 const base::TimeDelta& seek_time() const { return seek_time_; } | 484 const base::TimeDelta& seek_time() const { return seek_time_; } |
| 485 | 485 |
| 486 private: | 486 private: |
| 487 virtual ~MockVideoRenderer() {} | 487 virtual ~MockVideoRenderer() {} |
| 488 | 488 |
| 489 base::TimeDelta seek_time_; | 489 base::TimeDelta seek_time_; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 bool waiting_for_callback_; | 647 bool waiting_for_callback_; |
| 648 | 648 |
| 649 DISALLOW_COPY_AND_ASSIGN(InitializationHelper); | 649 DISALLOW_COPY_AND_ASSIGN(InitializationHelper); |
| 650 }; | 650 }; |
| 651 | 651 |
| 652 } // namespace old_mocks | 652 } // namespace old_mocks |
| 653 | 653 |
| 654 } // namespace media | 654 } // namespace media |
| 655 | 655 |
| 656 #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ | 656 #endif // MEDIA_BASE_MOCK_MEDIA_FILTERS_H_ |
| OLD | NEW |