summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 23:06:59 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 23:06:59 +0000
commit9e9c869011d525480e1e463ceed357313356815e (patch)
treee21f999296a94dc8055d804d07518ecbcb465356 /media
parent97dc320a8fd7b25abbac5b35d6cc49111668416b (diff)
downloadchromium_src-9e9c869011d525480e1e463ceed357313356815e.zip
chromium_src-9e9c869011d525480e1e463ceed357313356815e.tar.gz
chromium_src-9e9c869011d525480e1e463ceed357313356815e.tar.bz2
Checking in media/base/mock_filters.h, a new set of mock filters based on gmock.
TEST=FFmpegDemuxer tests should continue to run BUG=none Review URL: http://codereview.chromium.org/147046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19078 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/mock_filters.h48
-rw-r--r--media/filters/ffmpeg_demuxer_unittest.cc7
-rw-r--r--media/media.gyp1
3 files changed, 52 insertions, 4 deletions
diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h
new file mode 100644
index 0000000..2a2b13c
--- /dev/null
+++ b/media/base/mock_filters.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2009 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.
+//
+// A new breed of mock media filters, this time using gmock! Feel free to add
+// actions if you need interesting side-effects (i.e., copying data to the
+// buffer passed into MockDataSource::Read()).
+//
+// Don't forget you can use StrictMock<> and NiceMock<> if you want the mock
+// filters to fail the test or do nothing when an unexpected method is called.
+// http://code.google.com/p/googlemock/wiki/CookBook#Nice_Mocks_and_Strict_Mocks
+
+#ifndef MEDIA_BASE_MOCK_FILTERS_H_
+#define MEDIA_BASE_MOCK_FILTERS_H_
+
+#include "media/base/filters.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace media {
+
+class MockDataSource : public DataSource {
+ public:
+ MockDataSource() {}
+
+ // MediaFilter implementation.
+ MOCK_METHOD0(Stop, void());
+ MOCK_METHOD1(SetPlaybackRate, void(float playback_rate));
+ MOCK_METHOD1(Seek, void(base::TimeDelta time));
+
+ // DataSource implementation.
+ MOCK_METHOD1(Initialize, bool(const std::string& url));
+ MOCK_METHOD0(media_format, const MediaFormat&());
+ MOCK_METHOD2(Read, size_t(uint8* data, size_t size));
+ MOCK_METHOD1(GetPosition, bool(int64* position_out));
+ MOCK_METHOD1(SetPosition, bool(int64 position));
+ MOCK_METHOD1(GetSize, bool(int64* size_out));
+ MOCK_METHOD0(IsSeekable, bool());
+
+ protected:
+ virtual ~MockDataSource() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(MockDataSource);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_MOCK_FILTERS_H_
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index 2690fc4..faa08ef 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -10,7 +10,7 @@
#include "media/base/filters.h"
#include "media/base/mock_ffmpeg.h"
#include "media/base/mock_filter_host.h"
-#include "media/base/mock_media_filters.h"
+#include "media/base/mock_filters.h"
#include "media/base/mock_reader.h"
#include "media/filters/ffmpeg_common.h"
#include "media/filters/ffmpeg_demuxer.h"
@@ -73,8 +73,7 @@ class FFmpegDemuxerTest : public testing::Test {
// Prepare a filter host and data source for the demuxer.
pipeline_.reset(new MockPipeline());
filter_host_.reset(new MockFilterHost<Demuxer>(pipeline_.get(), demuxer_));
- old_mocks::MockFilterConfig config;
- data_source_ = new old_mocks::MockDataSource(&config);
+ data_source_ = new StrictMock<MockDataSource>();
// Initialize FFmpeg fixtures.
memset(&format_context_, 0, sizeof(format_context_));
@@ -149,7 +148,7 @@ class FFmpegDemuxerTest : public testing::Test {
scoped_refptr<FFmpegDemuxer> demuxer_;
scoped_ptr<MockPipeline> pipeline_;
scoped_ptr<MockFilterHost<Demuxer> > filter_host_;
- scoped_refptr<old_mocks::MockDataSource> data_source_;
+ scoped_refptr<StrictMock<MockDataSource> > data_source_;
// FFmpeg fixtures.
AVFormatContext format_context_;
diff --git a/media/media.gyp b/media/media.gyp
index e752b0b..2947683 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -152,6 +152,7 @@
'base/mock_ffmpeg.cc',
'base/mock_ffmpeg.h',
'base/mock_filter_host.h',
+ 'base/mock_filters.h',
'base/mock_media_filters.h',
'base/mock_pipeline.h',
'base/mock_reader.h',