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

Unified Diff: media/base/pipeline_unittest.cc

Issue 511323003: media: Remove FilterCollection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase & fix player_x11 Created 6 years, 4 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
Index: media/base/pipeline_unittest.cc
diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc
index c064df4c3c130635380f33bd05fccbfa86ef25e0..772a5c5f58c4cdd49d6b2290057ffc65dbfe8b59 100644
--- a/media/base/pipeline_unittest.cc
+++ b/media/base/pipeline_unittest.cc
@@ -5,6 +5,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/test/simple_test_tick_clock.h"
@@ -13,6 +14,7 @@
#include "media/base/fake_text_track_stream.h"
#include "media/base/gmock_callback_support.h"
#include "media/base/media_log.h"
+#include "media/base/media_switches.h"
#include "media/base/mock_filters.h"
#include "media/base/pipeline.h"
#include "media/base/test_helpers.h"
@@ -86,21 +88,9 @@ class PipelineTest : public ::testing::Test {
PipelineTest()
: pipeline_(new Pipeline(message_loop_.message_loop_proxy(),
new MediaLog())),
- filter_collection_(new FilterCollection()),
- demuxer_(new StrictMock<MockDemuxer>()) {
- filter_collection_->SetDemuxer(demuxer_.get());
-
- renderer_ = new StrictMock<MockRenderer>();
- scoped_ptr<Renderer> renderer(renderer_);
- filter_collection_->SetRenderer(renderer.Pass());
-
- text_renderer_ = new TextRenderer(
- message_loop_.message_loop_proxy(),
- base::Bind(&PipelineTest::OnAddTextTrack,
- base::Unretained(this)));
- scoped_ptr<TextRenderer> text_renderer(text_renderer_);
- filter_collection_->SetTextRenderer(text_renderer.Pass());
-
+ demuxer_(new StrictMock<MockDemuxer>()),
+ scoped_renderer_(new StrictMock<MockRenderer>()),
+ renderer_(scoped_renderer_.get()) {
// SetDemuxerExpectations() adds overriding expectations for expected
// non-NULL streams.
DemuxerStream* null_pointer = NULL;
@@ -137,6 +127,12 @@ class PipelineTest : public ::testing::Test {
message_loop_.RunUntilIdle();
}
+ // Test implementation.
+ virtual void SetUp() OVERRIDE {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
scherkus (not reviewing) 2014/08/28 18:48:22 IIRC this executes once per test typically we've
xhwang 2014/08/28 19:52:05 Done. But I actually searched run_all_unittests.c
scherkus (not reviewing) 2014/08/28 19:57:18 That's because we've launched features / enabled t
+ command_line->AppendSwitch(switches::kEnableInbandTextTracks);
+ }
+
void OnDemuxerError() {
// Cast because OnDemuxerError is private in Pipeline.
static_cast<DemuxerHost*>(pipeline_.get())
@@ -191,9 +187,24 @@ class PipelineTest : public ::testing::Test {
message_loop_.RunUntilIdle();
}
+ void StartPipeline() {
+ pipeline_->Start(
+ demuxer_.get(),
+ scoped_renderer_.PassAs<Renderer>(),
+ base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
+ base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
+ base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)),
+ base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)),
+ base::Bind(&CallbackHelper::OnBufferingStateChange,
+ base::Unretained(&callbacks_)),
+ base::Bind(&CallbackHelper::OnDurationChange,
+ base::Unretained(&callbacks_)),
+ base::Bind(&PipelineTest::OnAddTextTrack, base::Unretained(this)));
+ }
+
// Sets up expectations on the callback and initializes the pipeline. Called
// after tests have set expectations any filters they wish to use.
- void StartPipeline(PipelineStatus start_status) {
+ void StartPipelineAndExpect(PipelineStatus start_status) {
EXPECT_CALL(callbacks_, OnStart(start_status));
if (start_status == PIPELINE_OK) {
@@ -206,16 +217,7 @@ class PipelineTest : public ::testing::Test {
EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_ENOUGH));
}
- pipeline_->Start(
- filter_collection_.Pass(),
- base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnBufferingStateChange,
- base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnDurationChange,
- base::Unretained(&callbacks_)));
+ StartPipeline();
message_loop_.RunUntilIdle();
}
@@ -307,8 +309,8 @@ class PipelineTest : public ::testing::Test {
base::MessageLoop message_loop_;
scoped_ptr<Pipeline> pipeline_;
- scoped_ptr<FilterCollection> filter_collection_;
scoped_ptr<StrictMock<MockDemuxer> > demuxer_;
+ scoped_ptr<StrictMock<MockRenderer> > scoped_renderer_;
StrictMock<MockRenderer>* renderer_;
StrictMock<CallbackHelper> text_renderer_callbacks_;
TextRenderer* text_renderer_;
@@ -357,16 +359,7 @@ TEST_F(PipelineTest, NeverInitializes) {
// This test hangs during initialization by never calling
// InitializationComplete(). StrictMock<> will ensure that the callback is
// never executed.
- pipeline_->Start(
- filter_collection_.Pass(),
- base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnBufferingStateChange,
- base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnDurationChange,
- base::Unretained(&callbacks_)));
+ StartPipeline();
message_loop_.RunUntilIdle();
// Because our callback will get executed when the test tears down, we'll
@@ -390,17 +383,7 @@ TEST_F(PipelineTest, StartThenStopImmediately) {
.WillOnce(RunClosure<0>());
EXPECT_CALL(callbacks_, OnStart(_));
-
- pipeline_->Start(
- filter_collection_.Pass(),
- base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnBufferingStateChange,
- base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnDurationChange,
- base::Unretained(&callbacks_)));
+ StartPipeline();
// Expect a stop callback if we were started.
ExpectPipelineStopAndDestroyPipeline();
@@ -417,7 +400,7 @@ TEST_F(PipelineTest, DemuxerErrorDuringStop) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_CALL(*demuxer_, Stop(_))
.WillOnce(DoAll(InvokeWithoutArgs(this, &PipelineTest::OnDemuxerError),
@@ -435,7 +418,7 @@ TEST_F(PipelineTest, URLNotFound) {
EXPECT_CALL(*demuxer_, Stop(_))
.WillOnce(RunClosure<0>());
- StartPipeline(PIPELINE_ERROR_URL_NOT_FOUND);
+ StartPipelineAndExpect(PIPELINE_ERROR_URL_NOT_FOUND);
}
TEST_F(PipelineTest, NoStreams) {
@@ -444,7 +427,7 @@ TEST_F(PipelineTest, NoStreams) {
EXPECT_CALL(*demuxer_, Stop(_))
.WillOnce(RunClosure<0>());
- StartPipeline(PIPELINE_ERROR_COULD_NOT_RENDER);
+ StartPipelineAndExpect(PIPELINE_ERROR_COULD_NOT_RENDER);
}
TEST_F(PipelineTest, AudioStream) {
@@ -455,7 +438,7 @@ TEST_F(PipelineTest, AudioStream) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_TRUE(metadata_.has_audio);
EXPECT_FALSE(metadata_.has_video);
}
@@ -468,7 +451,7 @@ TEST_F(PipelineTest, VideoStream) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_FALSE(metadata_.has_audio);
EXPECT_TRUE(metadata_.has_video);
}
@@ -483,7 +466,7 @@ TEST_F(PipelineTest, AudioVideoStream) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_TRUE(metadata_.has_audio);
EXPECT_TRUE(metadata_.has_video);
}
@@ -497,7 +480,7 @@ TEST_F(PipelineTest, VideoTextStream) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_FALSE(metadata_.has_audio);
EXPECT_TRUE(metadata_.has_video);
@@ -515,7 +498,7 @@ TEST_F(PipelineTest, VideoAudioTextStream) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_TRUE(metadata_.has_audio);
EXPECT_TRUE(metadata_.has_video);
@@ -534,7 +517,7 @@ TEST_F(PipelineTest, Seek) {
SetRendererExpectations();
// Initialize then seek!
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
// Every filter should receive a call to Seek().
base::TimeDelta expected = base::TimeDelta::FromSeconds(2000);
@@ -551,7 +534,7 @@ TEST_F(PipelineTest, SeekAfterError) {
SetRendererExpectations();
// Initialize then seek!
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_CALL(*demuxer_, Stop(_))
.WillOnce(RunClosure<0>());
@@ -580,7 +563,7 @@ TEST_F(PipelineTest, SetVolume) {
EXPECT_CALL(*renderer_, SetVolume(expected));
// Initialize then set volume!
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
pipeline_->SetVolume(expected);
}
@@ -593,7 +576,7 @@ TEST_F(PipelineTest, Properties) {
SetDemuxerExpectations(&streams, kDuration);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_EQ(kDuration.ToInternalValue(),
pipeline_->GetMediaDuration().ToInternalValue());
EXPECT_FALSE(pipeline_->DidLoadingProgress());
@@ -608,7 +591,7 @@ TEST_F(PipelineTest, GetBufferedTimeRanges) {
SetDemuxerExpectations(&streams, kDuration);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
EXPECT_EQ(0u, pipeline_->GetBufferedTimeRanges().size());
@@ -637,7 +620,7 @@ TEST_F(PipelineTest, EndedCallback) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
AddTextStream();
@@ -657,7 +640,7 @@ TEST_F(PipelineTest, ErrorDuringSeek) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
float playback_rate = 1.0f;
EXPECT_CALL(*renderer_, SetPlaybackRate(playback_rate));
@@ -709,7 +692,7 @@ TEST_F(PipelineTest, NoMessageDuringTearDownFromError) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
// Trigger additional requests on the pipeline during tear down from error.
base::Callback<void(PipelineStatus)> cb = base::Bind(
@@ -743,7 +726,7 @@ TEST_F(PipelineTest, DestroyAfterStop) {
streams.push_back(audio_stream());
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
ExpectDemuxerStop();
@@ -762,7 +745,7 @@ TEST_F(PipelineTest, Underflow) {
SetDemuxerExpectations(&streams);
SetRendererExpectations();
- StartPipeline(PIPELINE_OK);
+ StartPipelineAndExpect(PIPELINE_OK);
// Simulate underflow.
EXPECT_CALL(callbacks_, OnBufferingStateChange(BUFFERING_HAVE_NOTHING));
@@ -822,16 +805,7 @@ class PipelineTeardownTest : public PipelineTest {
SetInitializeExpectations(state, stop_or_error);
EXPECT_CALL(callbacks_, OnStart(expected_status));
- pipeline_->Start(
- filter_collection_.Pass(),
- base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnMetadata, base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnBufferingStateChange,
- base::Unretained(&callbacks_)),
- base::Bind(&CallbackHelper::OnDurationChange,
- base::Unretained(&callbacks_)));
+ StartPipeline();
message_loop_.RunUntilIdle();
}

Powered by Google App Engine
This is Rietveld 408576698