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

Unified Diff: media/filters/ffmpeg_demuxer_unittest.cc

Issue 155469: Splitting media filter's Initialize() into Create() + callback and Seek() + callback. (Closed)
Patch Set: Fixed valgrind errors Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer_unittest.cc
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index 43b14c788b225d10a23ea6a0f344aa595fc21dce..18cec27434f0b62d035ea59272472f2494157afe 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -133,7 +133,8 @@ class FFmpegDemuxerTest : public testing::Test {
InitializeDemuxerMocks();
// We expect a successful initialization.
- EXPECT_CALL(host_, InitializationComplete());
+ EXPECT_CALL(callback_, OnFilterCallback());
+ EXPECT_CALL(callback_, OnCallbackDestroyed());
// Since we ignore data streams, the duration should be equal to the longest
// supported stream's duration (audio, in this case).
@@ -141,7 +142,7 @@ class FFmpegDemuxerTest : public testing::Test {
base::TimeDelta::FromMicroseconds(kDurations[AV_STREAM_AUDIO]);
EXPECT_CALL(host_, SetDuration(expected_duration));
- EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
+ demuxer_->Initialize(data_source_.get(), callback_.NewCallback());
message_loop_.RunAllPending();
}
@@ -150,6 +151,7 @@ class FFmpegDemuxerTest : public testing::Test {
scoped_refptr<FFmpegDemuxer> demuxer_;
scoped_refptr<StrictMock<MockDataSource> > data_source_;
StrictMock<MockFilterHost> host_;
+ StrictMock<MockFilterCallback> callback_;
MessageLoop message_loop_;
// FFmpeg fixtures.
@@ -196,8 +198,10 @@ TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) {
EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL))
.WillOnce(Return(-1));
EXPECT_CALL(host_, Error(DEMUXER_ERROR_COULD_NOT_OPEN));
+ EXPECT_CALL(callback_, OnFilterCallback());
+ EXPECT_CALL(callback_, OnCallbackDestroyed());
- EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
+ demuxer_->Initialize(data_source_.get(), callback_.NewCallback());
message_loop_.RunAllPending();
}
@@ -209,8 +213,10 @@ TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) {
.WillOnce(Return(AVERROR_IO));
EXPECT_CALL(*MockFFmpeg::get(), AVCloseInputFile(&format_context_));
EXPECT_CALL(host_, Error(DEMUXER_ERROR_COULD_NOT_PARSE));
+ EXPECT_CALL(callback_, OnFilterCallback());
+ EXPECT_CALL(callback_, OnCallbackDestroyed());
- EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
+ demuxer_->Initialize(data_source_.get(), callback_.NewCallback());
message_loop_.RunAllPending();
}
@@ -221,9 +227,11 @@ TEST_F(FFmpegDemuxerTest, Initialize_NoStreams) {
InitializeDemuxerMocks();
}
EXPECT_CALL(host_, Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS));
+ EXPECT_CALL(callback_, OnFilterCallback());
+ EXPECT_CALL(callback_, OnCallbackDestroyed());
format_context_.nb_streams = 0;
- EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
+ demuxer_->Initialize(data_source_.get(), callback_.NewCallback());
message_loop_.RunAllPending();
}
@@ -234,10 +242,12 @@ TEST_F(FFmpegDemuxerTest, Initialize_DataStreamOnly) {
InitializeDemuxerMocks();
}
EXPECT_CALL(host_, Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS));
+ EXPECT_CALL(callback_, OnFilterCallback());
+ EXPECT_CALL(callback_, OnCallbackDestroyed());
EXPECT_EQ(format_context_.streams[0], &streams_[AV_STREAM_DATA]);
format_context_.nb_streams = 1;
- EXPECT_TRUE(demuxer_->Initialize(data_source_.get()));
+ demuxer_->Initialize(data_source_.get(), callback_.NewCallback());
message_loop_.RunAllPending();
}
@@ -446,6 +456,11 @@ TEST_F(FFmpegDemuxerTest, Seek) {
EXPECT_CALL(*MockFFmpeg::get(),
AVSeekFrame(&format_context_, -1, kExpectedTimestamp, kExpectedFlags))
.WillOnce(Return(0));
+
+ // ...then our callback will be executed...
+ StrictMock<MockFilterCallback> seek_callback;
+ EXPECT_CALL(seek_callback, OnFilterCallback());
+ EXPECT_CALL(seek_callback, OnCallbackDestroyed());
EXPECT_CALL(*MockFFmpeg::get(), CheckPoint(2));
// ...followed by two audio packet reads we'll trigger...
@@ -483,7 +498,8 @@ TEST_F(FFmpegDemuxerTest, Seek) {
MockFFmpeg::get()->CheckPoint(1);
// Now issue a simple forward seek, which should discard queued packets.
- demuxer_->Seek(base::TimeDelta::FromMicroseconds(kExpectedTimestamp));
+ demuxer_->Seek(base::TimeDelta::FromMicroseconds(kExpectedTimestamp),
+ seek_callback.NewCallback());
message_loop_.RunAllPending();
MockFFmpeg::get()->CheckPoint(2);
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | media/filters/ffmpeg_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698