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

Unified Diff: media/base/pipeline_impl_unittest.cc

Issue 155469: Splitting media filter's Initialize() into Create() + callback and Seek() + callback. (Closed)
Patch Set: Fixed valgrind errors 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/pipeline_impl.cc ('k') | media/filters/audio_renderer_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline_impl_unittest.cc
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc
index 1fb50562e292604db3ef59249cdb850393aebdc2..50ffec7544aeb4f2a3f3d5110f05ef1d5bd2322e 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());
@@ -128,7 +127,7 @@ class PipelineImplTest : public ::testing::Test {
// Sets up expectations on the callback and initializes the pipeline. Called
// afters tests have set expectations any filters they wish to use.
- void InitializePipeline( ) {
+ void InitializePipeline() {
// Expect an initialization callback.
EXPECT_CALL(callbacks_, OnStart());
pipeline_.Start(mocks_, "",
@@ -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());
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/filters/audio_renderer_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698