| Index: media/filters/video_renderer_base_unittest.cc
|
| ===================================================================
|
| --- media/filters/video_renderer_base_unittest.cc (revision 184723)
|
| +++ media/filters/video_renderer_base_unittest.cc (working copy)
|
| @@ -5,6 +5,7 @@
|
| #include "base/bind.h"
|
| #include "base/callback.h"
|
| #include "base/callback_helpers.h"
|
| +#include "base/debug/stack_trace.h"
|
| #include "base/message_loop.h"
|
| #include "base/stl_util.h"
|
| #include "base/stringprintf.h"
|
| @@ -114,14 +115,18 @@
|
|
|
| void InitializeRenderer(PipelineStatus expected) {
|
| SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected));
|
| + WaitableMessageLoopEvent event;
|
| + CallInitialize(event.GetPipelineStatusCB());
|
| + event.RunAndWaitForStatus(expected);
|
| + }
|
| +
|
| + void CallInitialize(const PipelineStatusCB& status_cb) {
|
| VideoRendererBase::VideoDecoderList decoders;
|
| decoders.push_back(decoder_);
|
| -
|
| - WaitableMessageLoopEvent event;
|
| renderer_->Initialize(
|
| demuxer_stream_,
|
| decoders,
|
| - event.GetPipelineStatusCB(),
|
| + status_cb,
|
| base::Bind(&MockStatisticsCB::OnStatistics,
|
| base::Unretained(&statistics_cb_object_)),
|
| base::Bind(&VideoRendererBaseTest::OnTimeUpdate,
|
| @@ -133,7 +138,6 @@
|
| base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)),
|
| base::Bind(&VideoRendererBaseTest::GetDuration,
|
| base::Unretained(this)));
|
| - event.RunAndWaitForStatus(expected);
|
| }
|
|
|
| void Play() {
|
| @@ -354,12 +358,44 @@
|
| DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest);
|
| };
|
|
|
| +TEST_F(VideoRendererBaseTest, DoNothing) {
|
| + // Test that creation and deletion doesn't depend on calls to Initialize()
|
| + // and/or Stop().
|
| +}
|
| +
|
| +TEST_F(VideoRendererBaseTest, StopWithoutInitialize) {
|
| + Stop();
|
| +}
|
| +
|
| TEST_F(VideoRendererBaseTest, Initialize) {
|
| Initialize();
|
| EXPECT_EQ(0, GetCurrentTimestampInMs());
|
| Shutdown();
|
| }
|
|
|
| +static void ExpectNotCalled(PipelineStatus) {
|
| + base::debug::StackTrace stack;
|
| + ADD_FAILURE() << "Expected callback not to be called\n" << stack.ToString();
|
| +}
|
| +
|
| +TEST_F(VideoRendererBaseTest, StopWhileInitializing) {
|
| + EXPECT_CALL(*decoder_, Initialize(_, _, _))
|
| + .WillOnce(RunCallback<1>(PIPELINE_OK));
|
| + CallInitialize(base::Bind(&ExpectNotCalled));
|
| + Stop();
|
| +
|
| + // ~VideoRendererBase() will CHECK() if we left anything initialized.
|
| +}
|
| +
|
| +TEST_F(VideoRendererBaseTest, StopWhileFlushing) {
|
| + Initialize();
|
| + Pause();
|
| + renderer_->Flush(base::Bind(&ExpectNotCalled, PIPELINE_OK));
|
| + Stop();
|
| +
|
| + // ~VideoRendererBase() will CHECK() if we left anything initialized.
|
| +}
|
| +
|
| TEST_F(VideoRendererBaseTest, Play) {
|
| Initialize();
|
| Play();
|
|
|