| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <deque> | 6 #include <deque> |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 message_loop_.RunAllPending(); | 436 message_loop_.RunAllPending(); |
| 437 } | 437 } |
| 438 | 438 |
| 439 // A mocked callback specialization for calling Read(). Since RunWithParams() | 439 // A mocked callback specialization for calling Read(). Since RunWithParams() |
| 440 // is mocked we don't need to pass in object or method pointers. | 440 // is mocked we don't need to pass in object or method pointers. |
| 441 class MockReadCB : public base::RefCountedThreadSafe<MockReadCB> { | 441 class MockReadCB : public base::RefCountedThreadSafe<MockReadCB> { |
| 442 public: | 442 public: |
| 443 MockReadCB() {} | 443 MockReadCB() {} |
| 444 | 444 |
| 445 MOCK_METHOD0(OnDelete, void()); | 445 MOCK_METHOD0(OnDelete, void()); |
| 446 MOCK_METHOD1(Run, void(const scoped_refptr<DecoderBuffer>& buffer)); | 446 MOCK_METHOD2(Run, void(DemuxerStream::Status status, |
| 447 const scoped_refptr<DecoderBuffer>& buffer)); |
| 447 | 448 |
| 448 protected: | 449 protected: |
| 449 virtual ~MockReadCB() { | 450 virtual ~MockReadCB() { |
| 450 OnDelete(); | 451 OnDelete(); |
| 451 } | 452 } |
| 452 | 453 |
| 453 private: | 454 private: |
| 454 friend class base::RefCountedThreadSafe<MockReadCB>; | 455 friend class base::RefCountedThreadSafe<MockReadCB>; |
| 455 | 456 |
| 456 DISALLOW_COPY_AND_ASSIGN(MockReadCB); | 457 DISALLOW_COPY_AND_ASSIGN(MockReadCB); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 471 | 472 |
| 472 // Expect all calls in sequence. | 473 // Expect all calls in sequence. |
| 473 InSequence s; | 474 InSequence s; |
| 474 | 475 |
| 475 // Create our mocked callback. The Callback created by base::Bind() will take | 476 // Create our mocked callback. The Callback created by base::Bind() will take |
| 476 // ownership of this pointer. | 477 // ownership of this pointer. |
| 477 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>(); | 478 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>(); |
| 478 | 479 |
| 479 // The callback should be immediately deleted. We'll use a checkpoint to | 480 // The callback should be immediately deleted. We'll use a checkpoint to |
| 480 // verify that it has indeed been deleted. | 481 // verify that it has indeed been deleted. |
| 481 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer())); | 482 EXPECT_CALL(*callback, Run(DemuxerStream::kOk, IsEndOfStreamBuffer())); |
| 482 EXPECT_CALL(*callback, OnDelete()); | 483 EXPECT_CALL(*callback, OnDelete()); |
| 483 EXPECT_CALL(*this, CheckPoint(1)); | 484 EXPECT_CALL(*this, CheckPoint(1)); |
| 484 | 485 |
| 485 // Attempt the read... | 486 // Attempt the read... |
| 486 audio->Read(base::Bind(&MockReadCB::Run, callback)); | 487 audio->Read(base::Bind(&MockReadCB::Run, callback)); |
| 487 | 488 |
| 488 message_loop_.RunAllPending(); | 489 message_loop_.RunAllPending(); |
| 489 | 490 |
| 490 // ...and verify that |callback| was deleted. | 491 // ...and verify that |callback| was deleted. |
| 491 CheckPoint(1); | 492 CheckPoint(1); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 511 | 512 |
| 512 // Expect all calls in sequence. | 513 // Expect all calls in sequence. |
| 513 InSequence s; | 514 InSequence s; |
| 514 | 515 |
| 515 // Create our mocked callback. The Callback created by base::Bind() will take | 516 // Create our mocked callback. The Callback created by base::Bind() will take |
| 516 // ownership of this pointer. | 517 // ownership of this pointer. |
| 517 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>(); | 518 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>(); |
| 518 | 519 |
| 519 // The callback should be immediately deleted. We'll use a checkpoint to | 520 // The callback should be immediately deleted. We'll use a checkpoint to |
| 520 // verify that it has indeed been deleted. | 521 // verify that it has indeed been deleted. |
| 521 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer())); | 522 EXPECT_CALL(*callback, Run(DemuxerStream::kOk, IsEndOfStreamBuffer())); |
| 522 EXPECT_CALL(*callback, OnDelete()); | 523 EXPECT_CALL(*callback, OnDelete()); |
| 523 EXPECT_CALL(*this, CheckPoint(1)); | 524 EXPECT_CALL(*this, CheckPoint(1)); |
| 524 | 525 |
| 525 // Release the reference to the demuxer. This should also destroy it. | 526 // Release the reference to the demuxer. This should also destroy it. |
| 526 demuxer_ = NULL; | 527 demuxer_ = NULL; |
| 527 // |audio| now has a demuxer_ pointer to invalid memory. | 528 // |audio| now has a demuxer_ pointer to invalid memory. |
| 528 | 529 |
| 529 // Attempt the read... | 530 // Attempt the read... |
| 530 audio->Read(base::Bind(&MockReadCB::Run, callback)); | 531 audio->Read(base::Bind(&MockReadCB::Run, callback)); |
| 531 | 532 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 TEST_F(FFmpegDemuxerTest, UnsupportedVideoSupportedAudioDemux) { | 775 TEST_F(FFmpegDemuxerTest, UnsupportedVideoSupportedAudioDemux) { |
| 775 CreateDemuxer("vorbis_audio_wmv_video.mkv"); | 776 CreateDemuxer("vorbis_audio_wmv_video.mkv"); |
| 776 InitializeDemuxer(); | 777 InitializeDemuxer(); |
| 777 | 778 |
| 778 // Ensure the expected streams are present. | 779 // Ensure the expected streams are present. |
| 779 EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::VIDEO)); | 780 EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::VIDEO)); |
| 780 EXPECT_TRUE(demuxer_->GetStream(DemuxerStream::AUDIO)); | 781 EXPECT_TRUE(demuxer_->GetStream(DemuxerStream::AUDIO)); |
| 781 } | 782 } |
| 782 | 783 |
| 783 } // namespace media | 784 } // namespace media |
| OLD | NEW |