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

Side by Side Diff: media/filters/chunk_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/chunk_demuxer.cc ('k') | media/filters/ffmpeg_audio_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 "base/bind.h" 5 #include "base/bind.h"
6 #include "media/base/audio_decoder_config.h" 6 #include "media/base/audio_decoder_config.h"
7 #include "media/base/decoder_buffer.h" 7 #include "media/base/decoder_buffer.h"
8 #include "media/base/mock_callback.h" 8 #include "media/base/mock_callback.h"
9 #include "media/base/mock_demuxer_host.h" 9 #include "media/base/mock_demuxer_host.h"
10 #include "media/base/test_data_util.h" 10 #include "media/base/test_data_util.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 } 66 }
67 67
68 MATCHER_P(HasTimestamp, timestamp_in_ms, "") { 68 MATCHER_P(HasTimestamp, timestamp_in_ms, "") {
69 return arg && !arg->IsEndOfStream() && 69 return arg && !arg->IsEndOfStream() &&
70 arg->GetTimestamp().InMilliseconds() == timestamp_in_ms; 70 arg->GetTimestamp().InMilliseconds() == timestamp_in_ms;
71 } 71 }
72 72
73 static void OnReadDone(const base::TimeDelta& expected_time, 73 static void OnReadDone(const base::TimeDelta& expected_time,
74 bool* called, 74 bool* called,
75 DemuxerStream::Status status,
75 const scoped_refptr<DecoderBuffer>& buffer) { 76 const scoped_refptr<DecoderBuffer>& buffer) {
77 EXPECT_EQ(status, DemuxerStream::kOk);
76 EXPECT_EQ(expected_time, buffer->GetTimestamp()); 78 EXPECT_EQ(expected_time, buffer->GetTimestamp());
77 *called = true; 79 *called = true;
78 } 80 }
79 81
80 static void OnReadDone_EOSExpected(bool* called, 82 static void OnReadDone_EOSExpected(bool* called,
83 DemuxerStream::Status status,
81 const scoped_refptr<DecoderBuffer>& buffer) { 84 const scoped_refptr<DecoderBuffer>& buffer) {
85 EXPECT_EQ(status, DemuxerStream::kOk);
82 EXPECT_TRUE(buffer->IsEndOfStream()); 86 EXPECT_TRUE(buffer->IsEndOfStream());
83 *called = true; 87 *called = true;
84 } 88 }
85 89
86 class MockChunkDemuxerClient : public ChunkDemuxerClient { 90 class MockChunkDemuxerClient : public ChunkDemuxerClient {
87 public: 91 public:
88 MockChunkDemuxerClient() {} 92 MockChunkDemuxerClient() {}
89 virtual ~MockChunkDemuxerClient() {} 93 virtual ~MockChunkDemuxerClient() {}
90 94
91 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer)); 95 MOCK_METHOD1(DemuxerOpened, void(ChunkDemuxer* demuxer));
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 std::stringstream ss; 514 std::stringstream ss;
511 ss << "{ "; 515 ss << "{ ";
512 for (size_t i = 0; i < r.size(); ++i) { 516 for (size_t i = 0; i < r.size(); ++i) {
513 ss << "[" << r.start(i).InMilliseconds() << "," 517 ss << "[" << r.start(i).InMilliseconds() << ","
514 << r.end(i).InMilliseconds() << ") "; 518 << r.end(i).InMilliseconds() << ") ";
515 } 519 }
516 ss << "}"; 520 ss << "}";
517 EXPECT_EQ(ss.str(), expected); 521 EXPECT_EQ(ss.str(), expected);
518 } 522 }
519 523
520 MOCK_METHOD1(ReadDone, void(const scoped_refptr<DecoderBuffer>&)); 524 MOCK_METHOD2(ReadDone, void(DemuxerStream::Status status,
525 const scoped_refptr<DecoderBuffer>&));
521 526
522 void ExpectRead(DemuxerStream* stream, int64 timestamp_in_ms) { 527 void ExpectRead(DemuxerStream* stream, int64 timestamp_in_ms) {
523 EXPECT_CALL(*this, ReadDone(HasTimestamp(timestamp_in_ms))); 528 EXPECT_CALL(*this, ReadDone(DemuxerStream::kOk,
529 HasTimestamp(timestamp_in_ms)));
524 stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone, 530 stream->Read(base::Bind(&ChunkDemuxerTest::ReadDone,
525 base::Unretained(this))); 531 base::Unretained(this)));
526 } 532 }
527 533
528 MOCK_METHOD1(Checkpoint, void(int id)); 534 MOCK_METHOD1(Checkpoint, void(int id));
529 535
530 struct BufferTimestamps { 536 struct BufferTimestamps {
531 int video_time_ms; 537 int video_time_ms;
532 int audio_time_ms; 538 int audio_time_ms;
533 }; 539 };
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 964
959 // Check to see if |audio_read_done_| and |video_read_done_| variables 965 // Check to see if |audio_read_done_| and |video_read_done_| variables
960 // match |expected|. 966 // match |expected|.
961 void CheckIfReadDonesWereCalled(bool expected) { 967 void CheckIfReadDonesWereCalled(bool expected) {
962 EXPECT_EQ(expected, audio_read_done_); 968 EXPECT_EQ(expected, audio_read_done_);
963 EXPECT_EQ(expected, video_read_done_); 969 EXPECT_EQ(expected, video_read_done_);
964 } 970 }
965 971
966 private: 972 private:
967 static void OnEndOfStreamReadDone( 973 static void OnEndOfStreamReadDone(
968 bool* called, const scoped_refptr<DecoderBuffer>& buffer) { 974 bool* called,
975 DemuxerStream::Status status,
976 const scoped_refptr<DecoderBuffer>& buffer) {
977 EXPECT_EQ(status, DemuxerStream::kOk);
969 EXPECT_TRUE(buffer->IsEndOfStream()); 978 EXPECT_TRUE(buffer->IsEndOfStream());
970 *called = true; 979 *called = true;
971 } 980 }
972 981
973 scoped_refptr<Demuxer> demuxer_; 982 scoped_refptr<Demuxer> demuxer_;
974 bool audio_read_done_; 983 bool audio_read_done_;
975 bool video_read_done_; 984 bool video_read_done_;
976 985
977 DISALLOW_COPY_AND_ASSIGN(EndOfStreamHelper); 986 DISALLOW_COPY_AND_ASSIGN(EndOfStreamHelper);
978 }; 987 };
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 1795
1787 GenerateExpectedReads(0, 4, audio, video); 1796 GenerateExpectedReads(0, 4, audio, video);
1788 GenerateExpectedReads(46, 66, 5, audio, video); 1797 GenerateExpectedReads(46, 66, 5, audio, video);
1789 1798
1790 EndOfStreamHelper end_of_stream_helper(demuxer_); 1799 EndOfStreamHelper end_of_stream_helper(demuxer_);
1791 end_of_stream_helper.RequestReads(); 1800 end_of_stream_helper.RequestReads();
1792 end_of_stream_helper.CheckIfReadDonesWereCalled(true); 1801 end_of_stream_helper.CheckIfReadDonesWereCalled(true);
1793 } 1802 }
1794 1803
1795 } // namespace media 1804 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.cc ('k') | media/filters/ffmpeg_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698