summaryrefslogtreecommitdiffstats
path: root/media/base/pipeline_impl_unittest.cc
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 01:26:40 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 01:26:40 +0000
commitcef6492128ea70329523cbcf5d4c204660090857 (patch)
tree7386081bed04bb489d9e19fa64f8090ff4bfb6a4 /media/base/pipeline_impl_unittest.cc
parentb02c01713a168403f65d5193ad6934d761c7fbaa (diff)
downloadchromium_src-cef6492128ea70329523cbcf5d4c204660090857.zip
chromium_src-cef6492128ea70329523cbcf5d4c204660090857.tar.gz
chromium_src-cef6492128ea70329523cbcf5d4c204660090857.tar.bz2
Adding callback support to media filter Initialize() and Seek().
Also includes unit tests for AudioRendererBase and VideoRendererBase. I had to rollback my first attempt at this change. Original review: http://codereview.chromium.org/155469 BUG=16014,16031 TEST=media_unittests, layout tests Review URL: http://codereview.chromium.org/155608 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/pipeline_impl_unittest.cc')
-rw-r--r--media/base/pipeline_impl_unittest.cc71
1 files changed, 37 insertions, 34 deletions
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc
index b673cfb..d6bd285 100644
--- a/media/base/pipeline_impl_unittest.cc
+++ b/media/base/pipeline_impl_unittest.cc
@@ -14,7 +14,9 @@
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::DoAll;
+using ::testing::Invoke;
using ::testing::Mock;
+using ::testing::NotNull;
using ::testing::Return;
using ::testing::StrictMock;
@@ -63,9 +65,8 @@ class PipelineImplTest : public ::testing::Test {
protected:
// Sets up expectations to allow the data source to initialize.
void InitializeDataSource() {
- EXPECT_CALL(*mocks_->data_source(), Initialize(""))
- .WillOnce(DoAll(InitializationComplete(mocks_->data_source()),
- Return(true)));
+ EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->data_source(), SetPlaybackRate(0.0f));
EXPECT_CALL(*mocks_->data_source(), Stop());
}
@@ -73,9 +74,9 @@ class PipelineImplTest : public ::testing::Test {
// Sets up expectations to allow the demuxer to initialize.
typedef std::vector<MockDemuxerStream*> MockDemuxerStreamVector;
void InitializeDemuxer(MockDemuxerStreamVector* streams) {
- EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source()))
- .WillOnce(DoAll(InitializationComplete(mocks_->demuxer()),
- Return(true)));
+ EXPECT_CALL(*mocks_->demuxer(),
+ Initialize(mocks_->data_source(), NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams())
.WillRepeatedly(Return(streams->size()));
EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(0.0f));
@@ -91,36 +92,34 @@ class PipelineImplTest : public ::testing::Test {
// Sets up expectations to allow the video decoder to initialize.
void InitializeVideoDecoder(MockDemuxerStream* stream) {
- EXPECT_CALL(*mocks_->video_decoder(), Initialize(stream))
- .WillOnce(DoAll(InitializationComplete(mocks_->video_decoder()),
- Return(true)));
+ EXPECT_CALL(*mocks_->video_decoder(), Initialize(stream, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(0.0f));
EXPECT_CALL(*mocks_->video_decoder(), Stop());
}
// Sets up expectations to allow the audio decoder to initialize.
void InitializeAudioDecoder(MockDemuxerStream* stream) {
- EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream))
- .WillOnce(DoAll(InitializationComplete(mocks_->audio_decoder()),
- Return(true)));
+ EXPECT_CALL(*mocks_->audio_decoder(), Initialize(stream, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(0.0f));
EXPECT_CALL(*mocks_->audio_decoder(), Stop());
}
// Sets up expectations to allow the video renderer to initialize.
void InitializeVideoRenderer() {
- EXPECT_CALL(*mocks_->video_renderer(), Initialize(mocks_->video_decoder()))
- .WillOnce(DoAll(InitializationComplete(mocks_->video_renderer()),
- Return(true)));
+ EXPECT_CALL(*mocks_->video_renderer(),
+ Initialize(mocks_->video_decoder(), NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f));
EXPECT_CALL(*mocks_->video_renderer(), Stop());
}
// Sets up expectations to allow the audio renderer to initialize.
void InitializeAudioRenderer() {
- EXPECT_CALL(*mocks_->audio_renderer(), Initialize(mocks_->audio_decoder()))
- .WillOnce(DoAll(InitializationComplete(mocks_->audio_renderer()),
- Return(true)));
+ EXPECT_CALL(*mocks_->audio_renderer(),
+ Initialize(mocks_->audio_decoder(), NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f));
EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f));
EXPECT_CALL(*mocks_->audio_renderer(), Stop());
@@ -201,8 +200,8 @@ TEST_F(PipelineImplTest, NotStarted) {
}
TEST_F(PipelineImplTest, NeverInitializes) {
- EXPECT_CALL(*mocks_->data_source(), Initialize(""))
- .WillOnce(Return(true));
+ EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull()))
+ .WillOnce(Invoke(&DestroyFilterCallback));
EXPECT_CALL(*mocks_->data_source(), Stop());
// This test hangs during initialization by never calling
@@ -233,10 +232,10 @@ TEST_F(PipelineImplTest, RequiredFilterMissing) {
}
TEST_F(PipelineImplTest, URLNotFound) {
- EXPECT_CALL(*mocks_->data_source(), Initialize(""))
+ EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull()))
.WillOnce(DoAll(Error(mocks_->data_source(),
PIPELINE_ERROR_URL_NOT_FOUND),
- Return(false)));
+ Invoke(&RunFilterCallback)));
EXPECT_CALL(*mocks_->data_source(), Stop());
InitializePipeline();
@@ -247,14 +246,12 @@ TEST_F(PipelineImplTest, URLNotFound) {
TEST_F(PipelineImplTest, NoStreams) {
// Manually set these expecations because SetPlaybackRate() is not called if
// we cannot fully initialize the pipeline.
- EXPECT_CALL(*mocks_->data_source(), Initialize(""))
- .WillOnce(DoAll(InitializationComplete(mocks_->data_source()),
- Return(true)));
+ EXPECT_CALL(*mocks_->data_source(), Initialize("", NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->data_source(), Stop());
- EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source()))
- .WillOnce(DoAll(InitializationComplete(mocks_->demuxer()),
- Return(true)));
+ EXPECT_CALL(*mocks_->demuxer(), Initialize(mocks_->data_source(), NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
EXPECT_CALL(*mocks_->demuxer(), GetNumberOfStreams())
.WillRepeatedly(Return(0));
EXPECT_CALL(*mocks_->demuxer(), Stop());
@@ -341,12 +338,18 @@ TEST_F(PipelineImplTest, Seek) {
// Every filter should receive a call to Seek().
base::TimeDelta expected = base::TimeDelta::FromSeconds(2000);
- EXPECT_CALL(*mocks_->data_source(), Seek(expected));
- EXPECT_CALL(*mocks_->demuxer(), Seek(expected));
- EXPECT_CALL(*mocks_->audio_decoder(), Seek(expected));
- EXPECT_CALL(*mocks_->audio_renderer(), Seek(expected));
- EXPECT_CALL(*mocks_->video_decoder(), Seek(expected));
- EXPECT_CALL(*mocks_->video_renderer(), Seek(expected));
+ EXPECT_CALL(*mocks_->data_source(), Seek(expected, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
+ EXPECT_CALL(*mocks_->demuxer(), Seek(expected, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
+ EXPECT_CALL(*mocks_->audio_decoder(), Seek(expected, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
+ EXPECT_CALL(*mocks_->audio_renderer(), Seek(expected, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
+ EXPECT_CALL(*mocks_->video_decoder(), Seek(expected, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
+ EXPECT_CALL(*mocks_->video_renderer(), Seek(expected, NotNull()))
+ .WillOnce(Invoke(&RunFilterCallback));
// We expect a successful seek callback.
EXPECT_CALL(callbacks_, OnSeek());