| Index: media/filters/pipeline_integration_test.cc
|
| diff --git a/media/filters/pipeline_integration_test.cc b/media/filters/pipeline_integration_test.cc
|
| index caf570ec4f21c67a64021374856870ae22dcb1cc..079402efe870872d0cb3b1c8f1edc561e73979c1 100644
|
| --- a/media/filters/pipeline_integration_test.cc
|
| +++ b/media/filters/pipeline_integration_test.cc
|
| @@ -2,26 +2,11 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "media/filters/pipeline_integration_test_base.h"
|
| +
|
| #include "base/bind.h"
|
| -#include "base/message_loop.h"
|
| -#include "media/base/filter_collection.h"
|
| -#include "media/base/media_log.h"
|
| -#include "media/base/message_loop_factory_impl.h"
|
| -#include "media/base/pipeline.h"
|
| #include "media/base/test_data_util.h"
|
| -#include "media/filters/chunk_demuxer.h"
|
| #include "media/filters/chunk_demuxer_client.h"
|
| -#include "media/filters/chunk_demuxer_factory.h"
|
| -#include "media/filters/ffmpeg_audio_decoder.h"
|
| -#include "media/filters/ffmpeg_demuxer_factory.h"
|
| -#include "media/filters/ffmpeg_video_decoder.h"
|
| -#include "media/filters/file_data_source.h"
|
| -#include "media/filters/null_audio_renderer.h"
|
| -#include "media/filters/video_renderer_base.h"
|
| -#include "testing/gmock/include/gmock/gmock.h"
|
| -#include "testing/gtest/include/gtest/gtest.h"
|
| -
|
| -using ::testing::AnyNumber;
|
|
|
| namespace media {
|
|
|
| @@ -90,160 +75,8 @@ class MockMediaSource : public ChunkDemuxerClient {
|
| scoped_refptr<ChunkDemuxer> chunk_demuxer_;
|
| };
|
|
|
| -// Integration tests for Pipeline. Real demuxers, real decoders, and
|
| -// base renderer implementations are used to verify pipeline functionality. The
|
| -// renderers used in these tests rely heavily on the AudioRendererBase &
|
| -// VideoRendererBase implementations which contain a majority of the code used
|
| -// in the real AudioRendererImpl & SkCanvasVideoRenderer implementations used in
|
| -// the browser. The renderers in this test don't actually write data to a
|
| -// display or audio device. Both of these devices are simulated since they have
|
| -// little effect on verifying pipeline behavior and allow tests to run faster
|
| -// than real-time.
|
| -class PipelineIntegrationTest : public testing::Test {
|
| +class PipelineIntegrationTest : public PipelineIntegrationTestBase {
|
| public:
|
| - PipelineIntegrationTest()
|
| - : message_loop_factory_(new MessageLoopFactoryImpl()),
|
| - pipeline_(new Pipeline(&message_loop_, new MediaLog())),
|
| - ended_(false),
|
| - pipeline_status_(PIPELINE_OK) {
|
| - EXPECT_CALL(*this, OnVideoRendererPaint()).Times(AnyNumber());
|
| - EXPECT_CALL(*this, OnSetOpaque(true)).Times(AnyNumber());
|
| - }
|
| -
|
| - virtual ~PipelineIntegrationTest() {
|
| - if (!pipeline_->IsRunning())
|
| - return;
|
| -
|
| - Stop();
|
| - }
|
| -
|
| - void OnStatusCallback(PipelineStatus expected_status,
|
| - PipelineStatus status) {
|
| - EXPECT_EQ(status, expected_status);
|
| - pipeline_status_ = status;
|
| - message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
|
| - }
|
| -
|
| - PipelineStatusCB QuitOnStatusCB(PipelineStatus expected_status) {
|
| - return base::Bind(&PipelineIntegrationTest::OnStatusCallback,
|
| - base::Unretained(this),
|
| - expected_status);
|
| - }
|
| -
|
| - void OnEnded(PipelineStatus status) {
|
| - DCHECK_EQ(status, PIPELINE_OK);
|
| - DCHECK(!ended_);
|
| - ended_ = true;
|
| - message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
|
| - }
|
| -
|
| - bool WaitUntilOnEnded() {
|
| - if (ended_)
|
| - return (pipeline_status_ == PIPELINE_OK);
|
| - message_loop_.Run();
|
| - EXPECT_TRUE(ended_);
|
| - return ended_ && (pipeline_status_ == PIPELINE_OK);
|
| - }
|
| -
|
| - void OnError(PipelineStatus status) {
|
| - DCHECK_NE(status, PIPELINE_OK);
|
| - pipeline_status_ = status;
|
| - message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure());
|
| - }
|
| -
|
| - bool Start(const std::string& url, PipelineStatus expected_status) {
|
| - pipeline_->Start(
|
| - CreateFilterCollection(url),
|
| - url,
|
| - base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
|
| - base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
|
| - NetworkEventCB(),
|
| - QuitOnStatusCB(expected_status));
|
| - message_loop_.Run();
|
| - return (pipeline_status_ == PIPELINE_OK);
|
| - }
|
| -
|
| - void Play() {
|
| - pipeline_->SetPlaybackRate(1);
|
| - }
|
| -
|
| - void Pause() {
|
| - pipeline_->SetPlaybackRate(0);
|
| - }
|
| -
|
| - bool Seek(base::TimeDelta seek_time) {
|
| - ended_ = false;
|
| -
|
| - pipeline_->Seek(seek_time, QuitOnStatusCB(PIPELINE_OK));
|
| - message_loop_.Run();
|
| - return (pipeline_status_ == PIPELINE_OK);
|
| - }
|
| -
|
| - void Stop() {
|
| - DCHECK(pipeline_->IsRunning());
|
| - pipeline_->Stop(QuitOnStatusCB(PIPELINE_OK));
|
| - message_loop_.Run();
|
| - }
|
| -
|
| - void QuitAfterCurrentTimeTask(const base::TimeDelta& quit_time) {
|
| - if (pipeline_->GetCurrentTime() >= quit_time ||
|
| - pipeline_status_ != PIPELINE_OK) {
|
| - message_loop_.Quit();
|
| - return;
|
| - }
|
| -
|
| - message_loop_.PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&PipelineIntegrationTest::QuitAfterCurrentTimeTask,
|
| - base::Unretained(this), quit_time),
|
| - 10);
|
| - }
|
| -
|
| - bool WaitUntilCurrentTimeIsAfter(const base::TimeDelta& wait_time) {
|
| - DCHECK(pipeline_->IsRunning());
|
| - DCHECK_GT(pipeline_->GetPlaybackRate(), 0);
|
| - DCHECK(wait_time <= pipeline_->GetMediaDuration());
|
| -
|
| - message_loop_.PostDelayedTask(
|
| - FROM_HERE,
|
| - base::Bind(&PipelineIntegrationTest::QuitAfterCurrentTimeTask,
|
| - base::Unretained(this),
|
| - wait_time),
|
| - 10);
|
| - message_loop_.Run();
|
| - return (pipeline_status_ == PIPELINE_OK);
|
| - }
|
| -
|
| - scoped_ptr<FilterCollection> CreateFilterCollection(const std::string& url) {
|
| - scoped_refptr<FileDataSource> data_source = new FileDataSource();
|
| - CHECK_EQ(PIPELINE_OK, data_source->Initialize(url));
|
| - return CreateFilterCollection(scoped_ptr<DemuxerFactory>(
|
| - new FFmpegDemuxerFactory(data_source, &message_loop_)));
|
| - }
|
| -
|
| - scoped_ptr<FilterCollection> CreateFilterCollection(
|
| - ChunkDemuxerClient* client) {
|
| - return CreateFilterCollection(scoped_ptr<DemuxerFactory>(
|
| - new ChunkDemuxerFactory(client)));
|
| - }
|
| -
|
| - scoped_ptr<FilterCollection> CreateFilterCollection(
|
| - scoped_ptr<DemuxerFactory> demuxer_factory) {
|
| - scoped_ptr<FilterCollection> collection(new FilterCollection());
|
| - collection->SetDemuxerFactory(demuxer_factory.Pass());
|
| - collection->AddAudioDecoder(new FFmpegAudioDecoder(
|
| - message_loop_factory_->GetMessageLoop("AudioDecoderThread")));
|
| - collection->AddVideoDecoder(new FFmpegVideoDecoder(
|
| - message_loop_factory_->GetMessageLoop("VideoDecoderThread")));
|
| - collection->AddVideoRenderer(new VideoRendererBase(
|
| - base::Bind(&PipelineIntegrationTest::OnVideoRendererPaint,
|
| - base::Unretained(this)),
|
| - base::Bind(&PipelineIntegrationTest::OnSetOpaque,
|
| - base::Unretained(this))));
|
| - collection->AddAudioRenderer(new NullAudioRenderer());
|
| - return collection.Pass();
|
| - }
|
| -
|
| // Verifies that seeking works properly for ChunkDemuxer when the
|
| // seek happens while there is a pending read on the ChunkDemuxer
|
| // and no data is available.
|
| @@ -281,17 +114,6 @@ class PipelineIntegrationTest : public testing::Test {
|
| Stop();
|
| return true;
|
| }
|
| -
|
| - protected:
|
| - MessageLoop message_loop_;
|
| - scoped_ptr<MessageLoopFactory> message_loop_factory_;
|
| - scoped_refptr<Pipeline> pipeline_;
|
| - bool ended_;
|
| - PipelineStatus pipeline_status_;
|
| -
|
| - private:
|
| - MOCK_METHOD0(OnVideoRendererPaint, void());
|
| - MOCK_METHOD1(OnSetOpaque, void(bool));
|
| };
|
|
|
|
|
|
|