diff options
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/mock_filter_host.cc | 13 | ||||
-rw-r--r-- | media/base/mock_filter_host.h | 5 | ||||
-rw-r--r-- | media/base/mock_filters.cc | 64 | ||||
-rw-r--r-- | media/base/mock_filters.h | 64 | ||||
-rw-r--r-- | media/base/mock_task.cc | 22 | ||||
-rw-r--r-- | media/base/mock_task.h | 17 |
6 files changed, 127 insertions, 58 deletions
diff --git a/media/base/mock_filter_host.cc b/media/base/mock_filter_host.cc new file mode 100644 index 0000000..9c5e184 --- /dev/null +++ b/media/base/mock_filter_host.cc @@ -0,0 +1,13 @@ +// Copyright (c) 2011 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. + +#include "media/base/mock_filter_host.h" + +namespace media { + +MockFilterHost::MockFilterHost() {} + +MockFilterHost::~MockFilterHost() {} + +} // namespace media diff --git a/media/base/mock_filter_host.h b/media/base/mock_filter_host.h index 9043854..aecc3f6 100644 --- a/media/base/mock_filter_host.h +++ b/media/base/mock_filter_host.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. // @@ -19,7 +19,8 @@ namespace media { class MockFilterHost : public FilterHost { public: - MockFilterHost() {} + MockFilterHost(); + virtual ~MockFilterHost(); // FilterHost implementation. MOCK_METHOD0(InitializationComplete, void()); diff --git a/media/base/mock_filters.cc b/media/base/mock_filters.cc index f2110ff..3347016 100644 --- a/media/base/mock_filters.cc +++ b/media/base/mock_filters.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -6,6 +6,68 @@ namespace media { +MockFilterCallback::MockFilterCallback() {} + +MockFilterCallback::~MockFilterCallback() {} + +FilterCallback* MockFilterCallback::NewCallback() { + return new CallbackImpl(this); +} + +MockDataSource::MockDataSource() {} + +MockDataSource::~MockDataSource() {} + +MockDemuxer::MockDemuxer() {} + +MockDemuxer::~MockDemuxer() {} + +MockDemuxerStream::MockDemuxerStream() {} + +MockDemuxerStream::~MockDemuxerStream() {} + +MockVideoDecoder::MockVideoDecoder() {} + +MockVideoDecoder::~MockVideoDecoder() {} + +MockAudioDecoder::MockAudioDecoder() {} + +MockAudioDecoder::~MockAudioDecoder() {} + +MockVideoRenderer::MockVideoRenderer() {} + +MockVideoRenderer::~MockVideoRenderer() {} + +MockAudioRenderer::MockAudioRenderer() {} + +MockAudioRenderer::~MockAudioRenderer() {} + +MockFilterCollection::MockFilterCollection() + : data_source_(new MockDataSource()), + demuxer_(new MockDemuxer()), + video_decoder_(new MockVideoDecoder()), + audio_decoder_(new MockAudioDecoder()), + video_renderer_(new MockVideoRenderer()), + audio_renderer_(new MockAudioRenderer()) { +} + +MockFilterCollection::~MockFilterCollection() {} + +FilterCollection* MockFilterCollection::filter_collection( + bool include_data_source) const { + FilterCollection* collection = new FilterCollection(); + + if (include_data_source) { + collection->AddDataSource(data_source_); + } + collection->AddDemuxer(demuxer_); + collection->AddVideoDecoder(video_decoder_); + collection->AddAudioDecoder(audio_decoder_); + collection->AddVideoRenderer(video_renderer_); + collection->AddAudioRenderer(audio_renderer_); + return collection; +} + void RunFilterCallback(::testing::Unused, FilterCallback* callback) { callback->Run(); delete callback; diff --git a/media/base/mock_filters.h b/media/base/mock_filters.h index 3b1deb3..5b5677b 100644 --- a/media/base/mock_filters.h +++ b/media/base/mock_filters.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. // @@ -50,8 +50,8 @@ class Destroyable : public MockClass { // gmock will track the number of times the methods are executed. class MockFilterCallback { public: - MockFilterCallback() {} - virtual ~MockFilterCallback() {} + MockFilterCallback(); + virtual ~MockFilterCallback(); MOCK_METHOD0(OnCallbackDestroyed, void()); MOCK_METHOD0(OnFilterCallback, void()); @@ -60,9 +60,7 @@ class MockFilterCallback { // call OnFilterCallback() when executed and OnCallbackDestroyed() when // destroyed. Clients should use NiceMock<> or StrictMock<> depending on the // test. - FilterCallback* NewCallback() { - return new CallbackImpl(this); - } + FilterCallback* NewCallback(); private: // Private implementation of CallbackRunner used to trigger expectations on @@ -92,7 +90,7 @@ class MockFilterCallback { class MockDataSource : public DataSource { public: - MockDataSource() {} + MockDataSource(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -111,7 +109,7 @@ class MockDataSource : public DataSource { MOCK_METHOD0(IsStreaming, bool()); protected: - virtual ~MockDataSource() {} + virtual ~MockDataSource(); private: DISALLOW_COPY_AND_ASSIGN(MockDataSource); @@ -119,7 +117,7 @@ class MockDataSource : public DataSource { class MockDemuxer : public Demuxer { public: - MockDemuxer() {} + MockDemuxer(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -134,7 +132,7 @@ class MockDemuxer : public Demuxer { MOCK_METHOD1(GetStream, scoped_refptr<DemuxerStream>(int stream_id)); protected: - virtual ~MockDemuxer() {} + virtual ~MockDemuxer(); private: DISALLOW_COPY_AND_ASSIGN(MockDemuxer); @@ -142,7 +140,7 @@ class MockDemuxer : public Demuxer { class MockDemuxerStream : public DemuxerStream { public: - MockDemuxerStream() {} + MockDemuxerStream(); // DemuxerStream implementation. MOCK_METHOD0(media_format, const MediaFormat&()); @@ -151,7 +149,7 @@ class MockDemuxerStream : public DemuxerStream { MOCK_METHOD0(EnableBitstreamConverter, void()); protected: - virtual ~MockDemuxerStream() {} + virtual ~MockDemuxerStream(); private: MediaFormat media_format_; @@ -161,7 +159,7 @@ class MockDemuxerStream : public DemuxerStream { class MockVideoDecoder : public VideoDecoder { public: - MockVideoDecoder() {} + MockVideoDecoder(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -182,7 +180,7 @@ class MockVideoDecoder : public VideoDecoder { } protected: - virtual ~MockVideoDecoder() {} + virtual ~MockVideoDecoder(); private: DISALLOW_COPY_AND_ASSIGN(MockVideoDecoder); @@ -190,7 +188,7 @@ class MockVideoDecoder : public VideoDecoder { class MockAudioDecoder : public AudioDecoder { public: - MockAudioDecoder() {} + MockAudioDecoder(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -210,7 +208,7 @@ class MockAudioDecoder : public AudioDecoder { } protected: - virtual ~MockAudioDecoder() {} + virtual ~MockAudioDecoder(); private: DISALLOW_COPY_AND_ASSIGN(MockAudioDecoder); @@ -218,7 +216,7 @@ class MockAudioDecoder : public AudioDecoder { class MockVideoRenderer : public VideoRenderer { public: - MockVideoRenderer() {} + MockVideoRenderer(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -233,7 +231,7 @@ class MockVideoRenderer : public VideoRenderer { MOCK_METHOD1(ConsumeVideoFrame, void(scoped_refptr<VideoFrame> frame)); protected: - virtual ~MockVideoRenderer() {} + virtual ~MockVideoRenderer(); private: DISALLOW_COPY_AND_ASSIGN(MockVideoRenderer); @@ -241,7 +239,7 @@ class MockVideoRenderer : public VideoRenderer { class MockAudioRenderer : public AudioRenderer { public: - MockAudioRenderer() {} + MockAudioRenderer(); // Filter implementation. MOCK_METHOD1(Stop, void(FilterCallback* callback)); @@ -256,7 +254,7 @@ class MockAudioRenderer : public AudioRenderer { MOCK_METHOD1(SetVolume, void(float volume)); protected: - virtual ~MockAudioRenderer() {} + virtual ~MockAudioRenderer(); private: DISALLOW_COPY_AND_ASSIGN(MockAudioRenderer); @@ -266,16 +264,8 @@ class MockAudioRenderer : public AudioRenderer { // expectations on the filters and then pass the collection into a pipeline. class MockFilterCollection { public: - MockFilterCollection() - : data_source_(new MockDataSource()), - demuxer_(new MockDemuxer()), - video_decoder_(new MockVideoDecoder()), - audio_decoder_(new MockAudioDecoder()), - video_renderer_(new MockVideoRenderer()), - audio_renderer_(new MockAudioRenderer()) { - } - - virtual ~MockFilterCollection() {} + MockFilterCollection(); + virtual ~MockFilterCollection(); // Mock accessors. MockDataSource* data_source() const { return data_source_; } @@ -289,19 +279,7 @@ class MockFilterCollection { return filter_collection(true); } - FilterCollection* filter_collection(bool include_data_source) const { - FilterCollection* collection = new FilterCollection(); - - if (include_data_source) { - collection->AddDataSource(data_source_); - } - collection->AddDemuxer(demuxer_); - collection->AddVideoDecoder(video_decoder_); - collection->AddAudioDecoder(audio_decoder_); - collection->AddVideoRenderer(video_renderer_); - collection->AddAudioRenderer(audio_renderer_); - return collection; - } + FilterCollection* filter_collection(bool include_data_source) const; private: scoped_refptr<MockDataSource> data_source_; diff --git a/media/base/mock_task.cc b/media/base/mock_task.cc new file mode 100644 index 0000000..f9f8823 --- /dev/null +++ b/media/base/mock_task.cc @@ -0,0 +1,22 @@ +// Copyright (c) 2011 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. + +#include "media/base/mock_task.h" + +namespace media { + +TaskMocker::TaskMocker() + : outstanding_tasks_(0) { +} + +TaskMocker::~TaskMocker() { + CHECK(outstanding_tasks_ == 0) + << "If outstanding_tasks_ is not zero, tasks have been leaked."; +} + +Task* TaskMocker::CreateTask() { + return new CountingTask(this); +} + +} // namespace media diff --git a/media/base/mock_task.h b/media/base/mock_task.h index cb6e0de..6d418a1 100644 --- a/media/base/mock_task.h +++ b/media/base/mock_task.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -63,17 +63,10 @@ ACTION(InvokeRunnable) { class TaskMocker { public: - TaskMocker() - : outstanding_tasks_(0) { - } - ~TaskMocker() { - CHECK(outstanding_tasks_ == 0) - << "If outstanding_tasks_ is not zero, tasks have been leaked."; - } - - Task* CreateTask() { - return new CountingTask(this); - } + TaskMocker(); + ~TaskMocker(); + + Task* CreateTask(); MOCK_METHOD0(Run, void()); |