summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 22:06:43 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 22:06:43 +0000
commit71893bf4539fe2d65cfc3fc2e0f532a31db9f76a (patch)
tree25967e4975c4673add7765fab145356a07b0be1f
parent7c4329e5a84ef883d5e3f116d8cb78a401b92b2b (diff)
downloadchromium_src-71893bf4539fe2d65cfc3fc2e0f532a31db9f76a.zip
chromium_src-71893bf4539fe2d65cfc3fc2e0f532a31db9f76a.tar.gz
chromium_src-71893bf4539fe2d65cfc3fc2e0f532a31db9f76a.tar.bz2
Revert 75444 - Move MockFFmpeg instance setting into the constructor/destructor.
Previously tests had to manually call MockFFmpeg::set() during test setup and teardown. Now that operation is handled automatically via scoping. BUG=72933 TEST=media_unittests Review URL: http://codereview.chromium.org/6539021 TBR=scherkus@chromium.org Review URL: http://codereview.chromium.org/6541037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75448 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/base/mock_ffmpeg.cc86
-rw-r--r--media/base/mock_ffmpeg.h5
-rw-r--r--media/filters/bitstream_converter_unittest.cc10
-rw-r--r--media/filters/ffmpeg_demuxer_unittest.cc96
-rw-r--r--media/filters/ffmpeg_glue_unittest.cc11
-rw-r--r--media/filters/ffmpeg_h264_bitstream_converter_unittest.cc1
-rw-r--r--media/filters/ffmpeg_video_decoder_unittest.cc6
-rw-r--r--media/media.gyp47
-rw-r--r--media/video/ffmpeg_video_decode_engine_unittest.cc40
9 files changed, 196 insertions, 106 deletions
diff --git a/media/base/mock_ffmpeg.cc b/media/base/mock_ffmpeg.cc
index 4a20563..f3aa552 100644
--- a/media/base/mock_ffmpeg.cc
+++ b/media/base/mock_ffmpeg.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -20,9 +20,6 @@ URLProtocol* MockFFmpeg::protocol_ = NULL;
MockFFmpeg::MockFFmpeg()
: outstanding_packets_(0) {
- CHECK(instance_ == NULL) << "Only a single MockFFmpeg instance can exist";
- instance_ = this;
-
// If we haven't assigned our static copy of URLProtocol, set up expectations
// to catch the URLProtocol registered when the singleton instance of
// FFmpegGlue is created.
@@ -43,13 +40,16 @@ MockFFmpeg::MockFFmpeg()
.Times(AtMost(1))
.WillOnce(Return());
}
+ // av_lockmgr_register() is also called from ~FFmpegLock(), so we expect
+ // it to be called at the end.
+ EXPECT_CALL(*this, AVRegisterLockManager(_))
+ .Times(AtMost(2))
+ .WillRepeatedly(Return(0));
}
MockFFmpeg::~MockFFmpeg() {
CHECK(!outstanding_packets_)
<< "MockFFmpeg destroyed with outstanding packets";
- CHECK(instance_);
- instance_ = NULL;
}
void MockFFmpeg::inc_outstanding_packets() {
@@ -62,6 +62,16 @@ void MockFFmpeg::dec_outstanding_packets() {
}
// static
+void MockFFmpeg::set(MockFFmpeg* instance) {
+ instance_ = instance;
+}
+
+// static
+MockFFmpeg* MockFFmpeg::get() {
+ return instance_;
+}
+
+// static
URLProtocol* MockFFmpeg::protocol() {
return protocol_;
}
@@ -76,57 +86,59 @@ void MockFFmpeg::DestructPacket(AVPacket* packet) {
// FFmpeg stubs that delegate to the FFmpegMock instance.
extern "C" {
void avcodec_init() {
- MockFFmpeg::get()->AVCodecInit();
+ media::MockFFmpeg::get()->AVCodecInit();
}
int av_register_protocol2(URLProtocol* protocol, int size) {
- return MockFFmpeg::get()->AVRegisterProtocol2(protocol, size);
+ return media::MockFFmpeg::get()->AVRegisterProtocol2(protocol, size);
}
void av_register_all() {
- MockFFmpeg::get()->AVRegisterAll();
+ media::MockFFmpeg::get()->AVRegisterAll();
}
int av_lockmgr_register(int (*cb)(void**, enum AVLockOp)) {
+ media::MockFFmpeg* mock = media::MockFFmpeg::get();
// Here |mock| may be NULL when this function is called from ~FFmpegGlue().
- if (MockFFmpeg::get()) {
- return MockFFmpeg::get()->AVRegisterLockManager(cb);
+ if (mock != NULL) {
+ return mock->AVRegisterLockManager(cb);
+ } else {
+ return 0;
}
- return 0;
}
AVCodec* avcodec_find_decoder(enum CodecID id) {
- return MockFFmpeg::get()->AVCodecFindDecoder(id);
+ return media::MockFFmpeg::get()->AVCodecFindDecoder(id);
}
int avcodec_open(AVCodecContext* avctx, AVCodec* codec) {
- return MockFFmpeg::get()->AVCodecOpen(avctx, codec);
+ return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec);
}
int avcodec_close(AVCodecContext* avctx) {
- return MockFFmpeg::get()->AVCodecClose(avctx);
+ return media::MockFFmpeg::get()->AVCodecClose(avctx);
}
int avcodec_thread_init(AVCodecContext* avctx, int threads) {
- return MockFFmpeg::get()->AVCodecThreadInit(avctx, threads);
+ return media::MockFFmpeg::get()->AVCodecThreadInit(avctx, threads);
}
void avcodec_flush_buffers(AVCodecContext* avctx) {
- return MockFFmpeg::get()->AVCodecFlushBuffers(avctx);
+ return media::MockFFmpeg::get()->AVCodecFlushBuffers(avctx);
}
AVFrame* avcodec_alloc_frame() {
- return MockFFmpeg::get()->AVCodecAllocFrame();
+ return media::MockFFmpeg::get()->AVCodecAllocFrame();
}
int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture,
int* got_picture_ptr, AVPacket* avpkt) {
- return MockFFmpeg::get()->
+ return media::MockFFmpeg::get()->
AVCodecDecodeVideo2(avctx, picture, got_picture_ptr, avpkt);
}
AVBitStreamFilterContext* av_bitstream_filter_init(const char* name) {
- return MockFFmpeg::get()->AVBitstreamFilterInit(name);
+ return media::MockFFmpeg::get()->AVBitstreamFilterInit(name);
}
int av_bitstream_filter_filter(AVBitStreamFilterContext* bsfc,
@@ -137,29 +149,29 @@ int av_bitstream_filter_filter(AVBitStreamFilterContext* bsfc,
const uint8_t* buf,
int buf_size,
int keyframe) {
- return MockFFmpeg::get()->
+ return media::MockFFmpeg::get()->
AVBitstreamFilterFilter(bsfc, avctx, args, poutbuf, poutbuf_size, buf,
buf_size, keyframe);
}
void av_bitstream_filter_close(AVBitStreamFilterContext* bsf) {
- return MockFFmpeg::get()->AVBitstreamFilterClose(bsf);
+ return media::MockFFmpeg::get()->AVBitstreamFilterClose(bsf);
}
int av_open_input_file(AVFormatContext** format, const char* filename,
AVInputFormat* input_format, int buffer_size,
AVFormatParameters* parameters) {
- return MockFFmpeg::get()->AVOpenInputFile(format, filename,
- input_format, buffer_size,
- parameters);
+ return media::MockFFmpeg::get()->AVOpenInputFile(format, filename,
+ input_format, buffer_size,
+ parameters);
}
void av_close_input_file(AVFormatContext* format) {
- MockFFmpeg::get()->AVCloseInputFile(format);
+ media::MockFFmpeg::get()->AVCloseInputFile(format);
}
int av_find_stream_info(AVFormatContext* format) {
- return MockFFmpeg::get()->AVFindStreamInfo(format);
+ return media::MockFFmpeg::get()->AVFindStreamInfo(format);
}
int64 av_rescale_q(int64 a, AVRational bq, AVRational cq) {
@@ -171,45 +183,45 @@ int64 av_rescale_q(int64 a, AVRational bq, AVRational cq) {
}
int av_read_frame(AVFormatContext* format, AVPacket* packet) {
- return MockFFmpeg::get()->AVReadFrame(format, packet);
+ return media::MockFFmpeg::get()->AVReadFrame(format, packet);
}
int av_seek_frame(AVFormatContext *format, int stream_index, int64_t timestamp,
int flags) {
- return MockFFmpeg::get()->AVSeekFrame(format, stream_index, timestamp,
- flags)
+ return media::MockFFmpeg::get()->AVSeekFrame(format, stream_index, timestamp,
+ flags);
}
void av_init_packet(AVPacket* pkt) {
- return MockFFmpeg::get()->AVInitPacket(pkt);
+ return media::MockFFmpeg::get()->AVInitPacket(pkt);
}
int av_new_packet(AVPacket* packet, int size) {
- return MockFFmpeg::get()->AVNewPacket(packet, size);
+ return media::MockFFmpeg::get()->AVNewPacket(packet, size);
}
void av_free_packet(AVPacket* packet) {
- MockFFmpeg::get()->AVFreePacket(packet);
+ media::MockFFmpeg::get()->AVFreePacket(packet);
}
void av_free(void* ptr) {
// Freeing NULL pointers are valid, but they aren't interesting from a mock
// perspective.
if (ptr) {
- MockFFmpeg::get()->AVFree(ptr);
+ media::MockFFmpeg::get()->AVFree(ptr);
}
}
int av_dup_packet(AVPacket* packet) {
- return MockFFmpeg::get()->AVDupPacket(packet);
+ return media::MockFFmpeg::get()->AVDupPacket(packet);
}
void av_log_set_level(int level) {
- MockFFmpeg::get()->AVLogSetLevel(level);
+ media::MockFFmpeg::get()->AVLogSetLevel(level);
}
void av_destruct_packet(AVPacket *pkt) {
- MockFFmpeg::get()->AVDestructPacket(pkt);
+ media::MockFFmpeg::get()->AVDestructPacket(pkt);
}
} // extern "C"
diff --git a/media/base/mock_ffmpeg.h b/media/base/mock_ffmpeg.h
index 89402fe..09daf03 100644
--- a/media/base/mock_ffmpeg.h
+++ b/media/base/mock_ffmpeg.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -65,7 +65,8 @@ class MockFFmpeg {
// Used for verifying check points during tests.
MOCK_METHOD1(CheckPoint, void(int id));
- // Returns the current MockFFmpeg instance.
+ // Setter/getter for the global instance of MockFFmpeg.
+ static void set(MockFFmpeg* instance);
static MockFFmpeg* get();
// Returns the URLProtocol registered by the FFmpegGlue singleton.
diff --git a/media/filters/bitstream_converter_unittest.cc b/media/filters/bitstream_converter_unittest.cc
index 6efb225..85ca34e 100644
--- a/media/filters/bitstream_converter_unittest.cc
+++ b/media/filters/bitstream_converter_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -23,6 +23,9 @@ namespace media {
class BitstreamConverterTest : public testing::Test {
protected:
BitstreamConverterTest() {
+ // Initialize MockFFmpeg.
+ MockFFmpeg::set(&mock_ffmpeg_);
+
memset(&test_stream_context_, 0, sizeof(test_stream_context_));
memset(&test_filter_, 0, sizeof(test_filter_));
memset(&test_packet_, 0, sizeof(test_packet_));
@@ -30,7 +33,10 @@ class BitstreamConverterTest : public testing::Test {
test_packet_.size = kTestSize1;
}
- virtual ~BitstreamConverterTest() {}
+ virtual ~BitstreamConverterTest() {
+ // Reset MockFFmpeg.
+ MockFFmpeg::set(NULL);
+ }
AVCodecContext test_stream_context_;
AVBitStreamFilterContext test_filter_;
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index c492493..aec72ea 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -105,6 +105,9 @@ class FFmpegDemuxerTest : public testing::Test {
streams_[i].time_base.den = 1 * base::Time::kMicrosecondsPerSecond;
streams_[i].time_base.num = 1;
}
+
+ // Initialize MockFFmpeg.
+ MockFFmpeg::set(&mock_ffmpeg_);
}
virtual ~FFmpegDemuxerTest() {
@@ -116,15 +119,18 @@ class FFmpegDemuxerTest : public testing::Test {
// Release the reference to the demuxer.
demuxer_ = NULL;
+
+ // Reset MockFFmpeg.
+ MockFFmpeg::set(NULL);
}
// Sets up MockFFmpeg to allow FFmpegDemuxer to successfully initialize.
void InitializeDemuxerMocks() {
- EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL))
+ EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL))
.WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0)));
- EXPECT_CALL(mock_ffmpeg_, AVFindStreamInfo(&format_context_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVFindStreamInfo(&format_context_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVCloseInputFile(&format_context_));
+ EXPECT_CALL(*MockFFmpeg::get(), AVCloseInputFile(&format_context_));
}
// Initializes both MockFFmpeg and FFmpegDemuxer.
@@ -173,7 +179,7 @@ const uint8* FFmpegDemuxerTest::kNullData = NULL;
TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) {
// Simulate av_open_input_file() failing.
- EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL))
+ EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL))
.WillOnce(Return(-1));
EXPECT_CALL(host_, SetError(DEMUXER_ERROR_COULD_NOT_OPEN));
@@ -183,11 +189,11 @@ TEST_F(FFmpegDemuxerTest, Initialize_OpenFails) {
TEST_F(FFmpegDemuxerTest, Initialize_ParseFails) {
// Simulate av_find_stream_info() failing.
- EXPECT_CALL(mock_ffmpeg_, AVOpenInputFile(_, _, NULL, 0, NULL))
+ EXPECT_CALL(*MockFFmpeg::get(), AVOpenInputFile(_, _, NULL, 0, NULL))
.WillOnce(DoAll(SetArgumentPointee<0>(&format_context_), Return(0)));
- EXPECT_CALL(mock_ffmpeg_, AVFindStreamInfo(&format_context_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVFindStreamInfo(&format_context_))
.WillOnce(Return(AVERROR_IO));
- EXPECT_CALL(mock_ffmpeg_, AVCloseInputFile(&format_context_));
+ EXPECT_CALL(*MockFFmpeg::get(), AVCloseInputFile(&format_context_));
EXPECT_CALL(host_, SetError(DEMUXER_ERROR_COULD_NOT_PARSE));
demuxer_->Initialize(data_source_.get(), NewExpectedCallback());
@@ -264,14 +270,14 @@ TEST_F(FFmpegDemuxerTest, Read_DiscardUninteresting) {
}
// Ignore all AVFreePacket() calls. We check this elsewhere.
- EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
+ EXPECT_CALL(*MockFFmpeg::get(), AVFreePacket(_)).Times(AnyNumber());
// The demuxer will read a data packet which will get immediately freed,
// followed by a read error to end the reading.
InSequence s;
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_DATA, kNullData, 0));
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(Return(AVERROR_IO));
// Attempt a read from the audio stream and run the message loop until done.
@@ -295,13 +301,13 @@ TEST_F(FFmpegDemuxerTest, Read_Audio) {
}
// Ignore all AVFreePacket() calls. We check this via valgrind.
- EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
+ EXPECT_CALL(*MockFFmpeg::get(), AVFreePacket(_)).Times(AnyNumber());
// The demuxer will read a data packet which will get immediately freed,
// followed by reading an audio packet...
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_AUDIO, kAudioData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
// Attempt a read from the audio stream and run the message loop until done.
@@ -327,12 +333,12 @@ TEST_F(FFmpegDemuxerTest, Read_Video) {
}
// Ignore all AVFreePacket() calls. We check this via valgrind.
- EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
+ EXPECT_CALL(*MockFFmpeg::get(), AVFreePacket(_)).Times(AnyNumber());
// Simulate a successful frame read.
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_VIDEO, kVideoData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
// Attempt a read from the video stream and run the message loop until done.
@@ -358,9 +364,9 @@ TEST_F(FFmpegDemuxerTest, Read_EndOfStream) {
}
// Ignore all AVFreePacket() calls. We check this via valgrind.
- EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
+ EXPECT_CALL(*MockFFmpeg::get(), AVFreePacket(_)).Times(AnyNumber());
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(Return(AVERROR_IO));
// We should now expect an end of stream buffer.
@@ -397,59 +403,59 @@ TEST_F(FFmpegDemuxerTest, Seek) {
const int64 kExpectedFlags = AVSEEK_FLAG_BACKWARD;
// Ignore all AVFreePacket() calls. We check this via valgrind.
- EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
+ EXPECT_CALL(*MockFFmpeg::get(), AVFreePacket(_)).Times(AnyNumber());
// Expect all calls in sequence.
InSequence s;
// First we'll read a video packet that causes two audio packets to be queued
// inside FFmpegDemuxer...
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_AUDIO, kAudioData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_AUDIO, kAudioData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_VIDEO, kVideoData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, CheckPoint(1));
+ EXPECT_CALL(*MockFFmpeg::get(), CheckPoint(1));
// ...then we'll expect a seek call...
- EXPECT_CALL(mock_ffmpeg_,
+ EXPECT_CALL(*MockFFmpeg::get(),
AVSeekFrame(&format_context_, -1, kExpectedTimestamp, kExpectedFlags))
.WillOnce(Return(0));
// ...then our callback will be executed...
FilterCallback* seek_callback = NewExpectedCallback();
- EXPECT_CALL(mock_ffmpeg_, CheckPoint(2));
+ EXPECT_CALL(*MockFFmpeg::get(), CheckPoint(2));
// ...followed by two audio packet reads we'll trigger...
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_AUDIO, kAudioData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_AUDIO, kAudioData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
// ...followed by two video packet reads...
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_VIDEO, kVideoData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_VIDEO, kVideoData, kDataSize));
- EXPECT_CALL(mock_ffmpeg_, AVDupPacket(_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVDupPacket(_))
.WillOnce(Return(0));
// ...and finally a sanity checkpoint to make sure everything was released.
- EXPECT_CALL(mock_ffmpeg_, CheckPoint(3));
+ EXPECT_CALL(*MockFFmpeg::get(), CheckPoint(3));
// Read a video packet and release it.
scoped_refptr<DemuxerStreamReader> reader(new DemuxerStreamReader());
@@ -464,13 +470,13 @@ TEST_F(FFmpegDemuxerTest, Seek) {
// Release the video packet and verify the other packets are still queued.
reader->Reset();
message_loop_.RunAllPending();
- mock_ffmpeg_.CheckPoint(1);
+ MockFFmpeg::get()->CheckPoint(1);
// Issue a simple forward seek, which should discard queued packets.
demuxer_->Seek(base::TimeDelta::FromMicroseconds(kExpectedTimestamp),
seek_callback);
message_loop_.RunAllPending();
- mock_ffmpeg_.CheckPoint(2);
+ MockFFmpeg::get()->CheckPoint(2);
// Audio read #1.
reader->Read(audio);
@@ -514,7 +520,7 @@ TEST_F(FFmpegDemuxerTest, Seek) {
// Manually release the last reference to the buffer and verify it was freed.
reader->Reset();
message_loop_.RunAllPending();
- mock_ffmpeg_.CheckPoint(3);
+ MockFFmpeg::get()->CheckPoint(3);
}
// A mocked callback specialization for calling Read(). Since RunWithParams()
@@ -562,14 +568,14 @@ TEST_F(FFmpegDemuxerTest, Stop) {
// The callback should be immediately deleted. We'll use a checkpoint to
// verify that it has indeed been deleted.
EXPECT_CALL(*callback, OnDelete());
- EXPECT_CALL(mock_ffmpeg_, CheckPoint(1));
+ EXPECT_CALL(*MockFFmpeg::get(), CheckPoint(1));
// Attempt the read...
audio->Read(callback.release());
message_loop_.RunAllPending();
// ...and verify that |callback| was deleted.
- mock_ffmpeg_.CheckPoint(1);
+ MockFFmpeg::get()->CheckPoint(1);
}
TEST_F(FFmpegDemuxerTest, DisableAudioStream) {
@@ -587,17 +593,17 @@ TEST_F(FFmpegDemuxerTest, DisableAudioStream) {
message_loop_.RunAllPending();
// Ignore all AVFreePacket() calls. We check this via valgrind.
- EXPECT_CALL(mock_ffmpeg_, AVFreePacket(_)).Times(AnyNumber());
+ EXPECT_CALL(*MockFFmpeg::get(), AVFreePacket(_)).Times(AnyNumber());
// Expect all calls in sequence.
InSequence s;
// The demuxer will read an audio packet which will get immediately freed.
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(CreatePacketNoCount(AV_STREAM_AUDIO, kNullData, 0));
// Then an end-of-stream packet is read.
- EXPECT_CALL(mock_ffmpeg_, AVReadFrame(&format_context_, _))
+ EXPECT_CALL(*MockFFmpeg::get(), AVReadFrame(&format_context_, _))
.WillOnce(Return(AVERROR_IO));
// Get our streams.
diff --git a/media/filters/ffmpeg_glue_unittest.cc b/media/filters/ffmpeg_glue_unittest.cc
index 3c09fcf..f823669 100644
--- a/media/filters/ffmpeg_glue_unittest.cc
+++ b/media/filters/ffmpeg_glue_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -36,9 +36,12 @@ class MockProtocol : public FFmpegURLProtocol {
class FFmpegGlueTest : public ::testing::Test {
public:
- FFmpegGlueTest() {}
+ FFmpegGlueTest() {
+ }
virtual void SetUp() {
+ MockFFmpeg::set(&mock_ffmpeg_);
+
// Singleton should initialize FFmpeg.
CHECK(FFmpegGlue::GetInstance());
@@ -47,6 +50,10 @@ class FFmpegGlueTest : public ::testing::Test {
CHECK(protocol_);
}
+ virtual void TearDown() {
+ MockFFmpeg::set(NULL);
+ }
+
// Helper to open a URLContext pointing to the given mocked protocol.
// Callers are expected to close the context at the end of their test.
virtual void OpenContext(MockProtocol* protocol, URLContext* context) {
diff --git a/media/filters/ffmpeg_h264_bitstream_converter_unittest.cc b/media/filters/ffmpeg_h264_bitstream_converter_unittest.cc
index 5799123..bf582f6 100644
--- a/media/filters/ffmpeg_h264_bitstream_converter_unittest.cc
+++ b/media/filters/ffmpeg_h264_bitstream_converter_unittest.cc
@@ -270,6 +270,7 @@ class FFmpegH264BitstreamConverterTest : public testing::Test {
FFmpegH264BitstreamConverterTest() {
// Set up the ffmpeg mock and use our local fake functions to do the
// actual implementation for packet allocation / freeing.
+ MockFFmpeg::set(&ffmpeg_mock_);
ON_CALL(ffmpeg_mock_, AVInitPacket(_))
.WillByDefault(Invoke(fake_av_init_packet));
ON_CALL(ffmpeg_mock_, AVNewPacket(_, _))
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index 95acdc4..da87170 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -156,6 +156,9 @@ class FFmpegVideoDecoderTest : public testing::Test {
stream_.r_frame_rate.den = 1;
buffer_ = new DataBuffer(1);
end_of_stream_buffer_ = new DataBuffer(0);
+
+ // Initialize MockFFmpeg.
+ MockFFmpeg::set(&mock_ffmpeg_);
}
virtual ~FFmpegVideoDecoderTest() {
@@ -169,6 +172,9 @@ class FFmpegVideoDecoderTest : public testing::Test {
// Finish up any remaining tasks.
message_loop_.RunAllPending();
+
+ // Reset MockFFmpeg.
+ MockFFmpeg::set(NULL);
}
void InitializeDecoderSuccessfully() {
diff --git a/media/media.gyp b/media/media.gyp
index 2e6e613..1b76aff 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -399,6 +399,53 @@
}],
],
}],
+ # media_unittests is failing like crazy on Windows. So disable all test
+ # cases. See bug: http://crbug.com/72790
+ ['OS=="win"', {
+ 'sources!': [
+ 'audio/audio_input_controller_unittest.cc',
+ 'audio/audio_input_unittest.cc',
+ 'audio/audio_output_controller_unittest.cc',
+ 'audio/audio_output_proxy_unittest.cc',
+ 'audio/audio_parameters_unittest.cc',
+ 'audio/audio_util_unittest.cc',
+ 'audio/fake_audio_input_stream_unittest.cc',
+ 'audio/linux/alsa_output_unittest.cc',
+ 'audio/mac/audio_output_mac_unittest.cc',
+ 'audio/simple_sources_unittest.cc',
+ 'audio/win/audio_output_win_unittest.cc',
+ 'base/composite_filter_unittest.cc',
+ 'base/clock_impl_unittest.cc',
+ 'base/data_buffer_unittest.cc',
+ 'base/djb2_unittest.cc',
+ 'base/filter_collection_unittest.cc',
+ 'base/h264_bitstream_converter_unittest.cc',
+ 'base/mock_ffmpeg.cc',
+ 'base/mock_ffmpeg.h',
+ 'base/mock_reader.h',
+ 'base/mock_task.cc',
+ 'base/mock_task.h',
+ 'base/pipeline_impl_unittest.cc',
+ 'base/pts_heap_unittest.cc',
+ 'base/seekable_buffer_unittest.cc',
+ 'base/state_matrix_unittest.cc',
+ 'base/video_frame_unittest.cc',
+ 'base/yuv_convert_unittest.cc',
+ 'filters/audio_renderer_algorithm_ola_unittest.cc',
+ 'filters/audio_renderer_base_unittest.cc',
+ 'filters/bitstream_converter_unittest.cc',
+ 'filters/decoder_base_unittest.cc',
+ 'filters/ffmpeg_demuxer_unittest.cc',
+ 'filters/ffmpeg_glue_unittest.cc',
+ 'filters/ffmpeg_h264_bitstream_converter_unittest.cc',
+ 'filters/ffmpeg_video_decoder_unittest.cc',
+ 'filters/file_data_source_unittest.cc',
+ 'filters/video_renderer_base_unittest.cc',
+ 'omx/mock_omx.cc',
+ 'omx/mock_omx.h',
+ 'video/ffmpeg_video_decode_engine_unittest.cc',
+ ],
+ }],
],
},
{
diff --git a/media/video/ffmpeg_video_decode_engine_unittest.cc b/media/video/ffmpeg_video_decode_engine_unittest.cc
index e3bea41..666e522 100644
--- a/media/video/ffmpeg_video_decode_engine_unittest.cc
+++ b/media/video/ffmpeg_video_decode_engine_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -68,6 +68,9 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
buffer_ = new DataBuffer(1);
+ // Initialize MockFFmpeg.
+ MockFFmpeg::set(&mock_ffmpeg_);
+
test_engine_.reset(new FFmpegVideoDecodeEngine());
test_engine_->SetCodecContextForTest(&codec_context_);
@@ -81,18 +84,19 @@ class FFmpegVideoDecodeEngineTest : public testing::Test,
~FFmpegVideoDecodeEngineTest() {
test_engine_.reset();
+ MockFFmpeg::set(NULL);
}
void Initialize() {
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(Return(&codec_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecThreadInit(&codec_context_, 2))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecOpen(&codec_context_, &codec_))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVFree(&yuv_frame_))
.Times(1);
config_.codec = kCodecH264;
@@ -162,11 +166,11 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
// Test avcodec_find_decoder() returning NULL.
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(ReturnNull());
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
- EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVFree(&yuv_frame_))
.Times(1);
config_.codec = kCodecH264;
@@ -182,13 +186,13 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
// Note There are 2 threads for FFmpeg-mt.
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) {
// Test avcodec_thread_init() failing.
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(Return(&codec_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecThreadInit(&codec_context_, 2))
.WillOnce(Return(-1));
- EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVFree(&yuv_frame_))
.Times(1);
config_.codec = kCodecH264;
@@ -203,15 +207,15 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_InitThreadFails) {
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
// Test avcodec_open() failing.
- EXPECT_CALL(mock_ffmpeg_, AVCodecFindDecoder(CODEC_ID_NONE))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecFindDecoder(CODEC_ID_NONE))
.WillOnce(Return(&codec_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecAllocFrame())
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecAllocFrame())
.WillOnce(Return(&yuv_frame_));
- EXPECT_CALL(mock_ffmpeg_, AVCodecThreadInit(&codec_context_, 2))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecThreadInit(&codec_context_, 2))
.WillOnce(Return(0));
- EXPECT_CALL(mock_ffmpeg_, AVCodecOpen(&codec_context_, &codec_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVCodecOpen(&codec_context_, &codec_))
.WillOnce(Return(-1));
- EXPECT_CALL(mock_ffmpeg_, AVFree(&yuv_frame_))
+ EXPECT_CALL(*MockFFmpeg::get(), AVFree(&yuv_frame_))
.Times(1);
config_.codec = kCodecH264;