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

Unified Diff: media/base/mock_ffmpeg.cc

Issue 149423: Converted remaining tests to use gmock and deleted all old mocking code. (Closed)
Patch Set: Fix again 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/base/mock_ffmpeg.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/mock_ffmpeg.cc
diff --git a/media/base/mock_ffmpeg.cc b/media/base/mock_ffmpeg.cc
index 054f9961225f4bb32a72cd26943bc00fdfdc1ce6..562aff2ef42031536d2a29ec6d3ec446740fd02a 100644
--- a/media/base/mock_ffmpeg.cc
+++ b/media/base/mock_ffmpeg.cc
@@ -7,12 +7,36 @@
#include "base/logging.h"
#include "media/filters/ffmpeg_common.h"
+using ::testing::_;
+using ::testing::AtMost;
+using ::testing::DoAll;
+using ::testing::Return;
+using ::testing::SaveArg;
+
namespace media {
MockFFmpeg* MockFFmpeg::instance_ = NULL;
+URLProtocol* MockFFmpeg::protocol_ = NULL;
MockFFmpeg::MockFFmpeg()
: outstanding_packets_(0) {
+ // 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.
+ //
+ // TODO(scherkus): this feels gross and I need to think of a way to better
+ // inject/mock singletons.
+ if (!protocol_) {
+ EXPECT_CALL(*this, AVCodecInit())
+ .Times(AtMost(1))
+ .WillOnce(Return());
+ EXPECT_CALL(*this, AVRegisterProtocol(_))
+ .Times(AtMost(1))
+ .WillOnce(DoAll(SaveArg<0>(&protocol_), Return(0)));
+ EXPECT_CALL(*this, AVRegisterAll())
+ .Times(AtMost(1))
+ .WillOnce(Return());
+ }
}
MockFFmpeg::~MockFFmpeg() {
@@ -40,6 +64,11 @@ MockFFmpeg* MockFFmpeg::get() {
}
// static
+URLProtocol* MockFFmpeg::protocol() {
+ return protocol_;
+}
+
+// static
void MockFFmpeg::DestructPacket(AVPacket* packet) {
delete [] packet->data;
packet->data = NULL;
@@ -49,6 +78,18 @@ void MockFFmpeg::DestructPacket(AVPacket* packet) {
// FFmpeg stubs that delegate to the FFmpegMock instance.
extern "C" {
+void avcodec_init() {
+ media::MockFFmpeg::get()->AVCodecInit();
+}
+
+int av_register_protocol(URLProtocol* protocol) {
+ return media::MockFFmpeg::get()->AVRegisterProtocol(protocol);
+}
+
+void av_register_all() {
+ media::MockFFmpeg::get()->AVRegisterAll();
+}
+
AVCodec* avcodec_find_decoder(enum CodecID id) {
return media::MockFFmpeg::get()->AVCodecFindDecoder(id);
}
« no previous file with comments | « media/base/mock_ffmpeg.h ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698