Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 10669022: Add status parameter to DemuxerStream::ReadCB (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/ffmpeg_video_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 21 matching lines...) Expand all
32 using ::testing::_; 32 using ::testing::_;
33 33
34 namespace media { 34 namespace media {
35 35
36 MATCHER(IsEndOfStreamBuffer, 36 MATCHER(IsEndOfStreamBuffer,
37 std::string(negation ? "isn't" : "is") + " end of stream") { 37 std::string(negation ? "isn't" : "is") + " end of stream") {
38 return arg->IsEndOfStream(); 38 return arg->IsEndOfStream();
39 } 39 }
40 40
41 static void EosOnReadDone(bool* got_eos_buffer, 41 static void EosOnReadDone(bool* got_eos_buffer,
42 DemuxerStream::Status status,
42 const scoped_refptr<DecoderBuffer>& buffer) { 43 const scoped_refptr<DecoderBuffer>& buffer) {
44 EXPECT_EQ(status, DemuxerStream::kOk);
43 if (buffer->IsEndOfStream()) { 45 if (buffer->IsEndOfStream()) {
44 *got_eos_buffer = true; 46 *got_eos_buffer = true;
45 EXPECT_TRUE(!buffer->GetData()); 47 EXPECT_TRUE(!buffer->GetData());
46 EXPECT_EQ(buffer->GetDataSize(), 0); 48 EXPECT_EQ(buffer->GetDataSize(), 0);
47 return; 49 return;
48 } 50 }
49 51
50 EXPECT_TRUE(buffer->GetData()); 52 EXPECT_TRUE(buffer->GetData());
51 EXPECT_GT(buffer->GetDataSize(), 0); 53 EXPECT_GT(buffer->GetDataSize(), 0);
52 *got_eos_buffer = false; 54 *got_eos_buffer = false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 message_loop_.RunAllPending(); 96 message_loop_.RunAllPending();
95 } 97 }
96 98
97 MOCK_METHOD2(OnReadDoneCalled, void(int, int64)); 99 MOCK_METHOD2(OnReadDoneCalled, void(int, int64));
98 100
99 // Verifies that |buffer| has a specific |size| and |timestamp|. 101 // Verifies that |buffer| has a specific |size| and |timestamp|.
100 // |location| simply indicates where the call to this function was made. 102 // |location| simply indicates where the call to this function was made.
101 // This makes it easier to track down where test failures occur. 103 // This makes it easier to track down where test failures occur.
102 void OnReadDone(const tracked_objects::Location& location, 104 void OnReadDone(const tracked_objects::Location& location,
103 int size, int64 timestampInMicroseconds, 105 int size, int64 timestampInMicroseconds,
106 DemuxerStream::Status status,
104 const scoped_refptr<DecoderBuffer>& buffer) { 107 const scoped_refptr<DecoderBuffer>& buffer) {
105 std::string location_str; 108 std::string location_str;
106 location.Write(true, false, &location_str); 109 location.Write(true, false, &location_str);
107 location_str += "\n"; 110 location_str += "\n";
108 SCOPED_TRACE(location_str); 111 SCOPED_TRACE(location_str);
112 EXPECT_EQ(status, DemuxerStream::kOk);
109 OnReadDoneCalled(size, timestampInMicroseconds); 113 OnReadDoneCalled(size, timestampInMicroseconds);
110 EXPECT_TRUE(buffer.get() != NULL); 114 EXPECT_TRUE(buffer.get() != NULL);
111 EXPECT_EQ(size, buffer->GetDataSize()); 115 EXPECT_EQ(size, buffer->GetDataSize());
112 EXPECT_EQ(base::TimeDelta::FromMicroseconds(timestampInMicroseconds), 116 EXPECT_EQ(base::TimeDelta::FromMicroseconds(timestampInMicroseconds),
113 buffer->GetTimestamp()); 117 buffer->GetTimestamp());
114 } 118 }
115 119
116 DemuxerStream::ReadCB NewReadCB(const tracked_objects::Location& location, 120 DemuxerStream::ReadCB NewReadCB(const tracked_objects::Location& location,
117 int size, int64 timestampInMicroseconds) { 121 int size, int64 timestampInMicroseconds) {
118 EXPECT_CALL(*this, OnReadDoneCalled(size, timestampInMicroseconds)); 122 EXPECT_CALL(*this, OnReadDoneCalled(size, timestampInMicroseconds));
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 message_loop_.RunAllPending(); 408 message_loop_.RunAllPending();
405 } 409 }
406 410
407 // A mocked callback specialization for calling Read(). Since RunWithParams() 411 // A mocked callback specialization for calling Read(). Since RunWithParams()
408 // is mocked we don't need to pass in object or method pointers. 412 // is mocked we don't need to pass in object or method pointers.
409 class MockReadCB : public base::RefCountedThreadSafe<MockReadCB> { 413 class MockReadCB : public base::RefCountedThreadSafe<MockReadCB> {
410 public: 414 public:
411 MockReadCB() {} 415 MockReadCB() {}
412 416
413 MOCK_METHOD0(OnDelete, void()); 417 MOCK_METHOD0(OnDelete, void());
414 MOCK_METHOD1(Run, void(const scoped_refptr<DecoderBuffer>& buffer)); 418 MOCK_METHOD2(Run, void(DemuxerStream::Status status,
419 const scoped_refptr<DecoderBuffer>& buffer));
415 420
416 protected: 421 protected:
417 virtual ~MockReadCB() { 422 virtual ~MockReadCB() {
418 OnDelete(); 423 OnDelete();
419 } 424 }
420 425
421 private: 426 private:
422 friend class base::RefCountedThreadSafe<MockReadCB>; 427 friend class base::RefCountedThreadSafe<MockReadCB>;
423 428
424 DISALLOW_COPY_AND_ASSIGN(MockReadCB); 429 DISALLOW_COPY_AND_ASSIGN(MockReadCB);
(...skipping 14 matching lines...) Expand all
439 444
440 // Expect all calls in sequence. 445 // Expect all calls in sequence.
441 InSequence s; 446 InSequence s;
442 447
443 // Create our mocked callback. The Callback created by base::Bind() will take 448 // Create our mocked callback. The Callback created by base::Bind() will take
444 // ownership of this pointer. 449 // ownership of this pointer.
445 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>(); 450 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>();
446 451
447 // The callback should be immediately deleted. We'll use a checkpoint to 452 // The callback should be immediately deleted. We'll use a checkpoint to
448 // verify that it has indeed been deleted. 453 // verify that it has indeed been deleted.
449 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer())); 454 EXPECT_CALL(*callback, Run(DemuxerStream::kOk, IsEndOfStreamBuffer()));
450 EXPECT_CALL(*callback, OnDelete()); 455 EXPECT_CALL(*callback, OnDelete());
451 EXPECT_CALL(*this, CheckPoint(1)); 456 EXPECT_CALL(*this, CheckPoint(1));
452 457
453 // Attempt the read... 458 // Attempt the read...
454 audio->Read(base::Bind(&MockReadCB::Run, callback)); 459 audio->Read(base::Bind(&MockReadCB::Run, callback));
455 460
456 message_loop_.RunAllPending(); 461 message_loop_.RunAllPending();
457 462
458 // ...and verify that |callback| was deleted. 463 // ...and verify that |callback| was deleted.
459 CheckPoint(1); 464 CheckPoint(1);
(...skipping 19 matching lines...) Expand all
479 484
480 // Expect all calls in sequence. 485 // Expect all calls in sequence.
481 InSequence s; 486 InSequence s;
482 487
483 // Create our mocked callback. The Callback created by base::Bind() will take 488 // Create our mocked callback. The Callback created by base::Bind() will take
484 // ownership of this pointer. 489 // ownership of this pointer.
485 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>(); 490 StrictMock<MockReadCB>* callback = new StrictMock<MockReadCB>();
486 491
487 // The callback should be immediately deleted. We'll use a checkpoint to 492 // The callback should be immediately deleted. We'll use a checkpoint to
488 // verify that it has indeed been deleted. 493 // verify that it has indeed been deleted.
489 EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer())); 494 EXPECT_CALL(*callback, Run(DemuxerStream::kOk, IsEndOfStreamBuffer()));
490 EXPECT_CALL(*callback, OnDelete()); 495 EXPECT_CALL(*callback, OnDelete());
491 EXPECT_CALL(*this, CheckPoint(1)); 496 EXPECT_CALL(*this, CheckPoint(1));
492 497
493 // Release the reference to the demuxer. This should also destroy it. 498 // Release the reference to the demuxer. This should also destroy it.
494 demuxer_ = NULL; 499 demuxer_ = NULL;
495 // |audio| now has a demuxer_ pointer to invalid memory. 500 // |audio| now has a demuxer_ pointer to invalid memory.
496 501
497 // Attempt the read... 502 // Attempt the read...
498 audio->Read(base::Bind(&MockReadCB::Run, callback)); 503 audio->Read(base::Bind(&MockReadCB::Run, callback));
499 504
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 TEST_F(FFmpegDemuxerTest, UnsupportedVideoSupportedAudioDemux) { 721 TEST_F(FFmpegDemuxerTest, UnsupportedVideoSupportedAudioDemux) {
717 CreateDemuxer("vorbis_audio_wmv_video.mkv"); 722 CreateDemuxer("vorbis_audio_wmv_video.mkv");
718 InitializeDemuxer(); 723 InitializeDemuxer();
719 724
720 // Ensure the expected streams are present. 725 // Ensure the expected streams are present.
721 EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::VIDEO)); 726 EXPECT_FALSE(demuxer_->GetStream(DemuxerStream::VIDEO));
722 EXPECT_TRUE(demuxer_->GetStream(DemuxerStream::AUDIO)); 727 EXPECT_TRUE(demuxer_->GetStream(DemuxerStream::AUDIO));
723 } 728 }
724 729
725 } // namespace media 730 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/ffmpeg_video_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698