Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/debug/stack_trace.h" | |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| 10 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 11 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 12 #include "base/timer.h" | 13 #include "base/timer.h" |
| 13 #include "media/base/data_buffer.h" | 14 #include "media/base/data_buffer.h" |
| 14 #include "media/base/gmock_callback_support.h" | 15 #include "media/base/gmock_callback_support.h" |
| 15 #include "media/base/limits.h" | 16 #include "media/base/limits.h" |
| 16 #include "media/base/mock_filters.h" | 17 #include "media/base/mock_filters.h" |
| 17 #include "media/base/test_helpers.h" | 18 #include "media/base/test_helpers.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 // We expect the video size to be set. | 105 // We expect the video size to be set. |
| 105 EXPECT_CALL(*this, OnNaturalSizeChanged(kNaturalSize)); | 106 EXPECT_CALL(*this, OnNaturalSizeChanged(kNaturalSize)); |
| 106 | 107 |
| 107 // Start prerolling. | 108 // Start prerolling. |
| 108 QueuePrerollFrames(0); | 109 QueuePrerollFrames(0); |
| 109 Preroll(0, PIPELINE_OK); | 110 Preroll(0, PIPELINE_OK); |
| 110 } | 111 } |
| 111 | 112 |
| 112 void InitializeRenderer(PipelineStatus expected) { | 113 void InitializeRenderer(PipelineStatus expected) { |
| 113 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); | 114 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); |
| 115 WaitableMessageLoopEvent event; | |
| 116 CallInitialize(event.GetPipelineStatusCB()); | |
| 117 event.RunAndWaitForStatus(expected); | |
| 118 } | |
| 119 | |
| 120 void CallInitialize(const PipelineStatusCB& status_cb) { | |
| 114 VideoRendererBase::VideoDecoderList decoders; | 121 VideoRendererBase::VideoDecoderList decoders; |
| 115 decoders.push_back(decoder_); | 122 decoders.push_back(decoder_); |
| 116 | |
| 117 WaitableMessageLoopEvent event; | |
| 118 renderer_->Initialize( | 123 renderer_->Initialize( |
| 119 demuxer_stream_, | 124 demuxer_stream_, |
| 120 decoders, | 125 decoders, |
| 121 event.GetPipelineStatusCB(), | 126 status_cb, |
| 122 base::Bind(&MockStatisticsCB::OnStatistics, | 127 base::Bind(&MockStatisticsCB::OnStatistics, |
| 123 base::Unretained(&statistics_cb_object_)), | 128 base::Unretained(&statistics_cb_object_)), |
| 124 base::Bind(&VideoRendererBaseTest::OnTimeUpdate, | 129 base::Bind(&VideoRendererBaseTest::OnTimeUpdate, |
| 125 base::Unretained(this)), | 130 base::Unretained(this)), |
| 126 base::Bind(&VideoRendererBaseTest::OnNaturalSizeChanged, | 131 base::Bind(&VideoRendererBaseTest::OnNaturalSizeChanged, |
| 127 base::Unretained(this)), | 132 base::Unretained(this)), |
| 128 ended_event_.GetClosure(), | 133 ended_event_.GetClosure(), |
| 129 error_event_.GetPipelineStatusCB(), | 134 error_event_.GetPipelineStatusCB(), |
| 130 base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)), | 135 base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)), |
| 131 base::Bind(&VideoRendererBaseTest::GetDuration, | 136 base::Bind(&VideoRendererBaseTest::GetDuration, |
| 132 base::Unretained(this))); | 137 base::Unretained(this))); |
| 133 event.RunAndWaitForStatus(expected); | |
| 134 } | 138 } |
| 135 | 139 |
| 136 void Play() { | 140 void Play() { |
| 137 SCOPED_TRACE("Play()"); | 141 SCOPED_TRACE("Play()"); |
| 138 WaitableMessageLoopEvent event; | 142 WaitableMessageLoopEvent event; |
| 139 renderer_->Play(event.GetClosure()); | 143 renderer_->Play(event.GetClosure()); |
| 140 event.RunAndWait(); | 144 event.RunAndWait(); |
| 141 } | 145 } |
| 142 | 146 |
| 143 void Preroll(int timestamp_ms, PipelineStatus expected) { | 147 void Preroll(int timestamp_ms, PipelineStatus expected) { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 | 365 |
| 362 DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest); | 366 DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest); |
| 363 }; | 367 }; |
| 364 | 368 |
| 365 TEST_F(VideoRendererBaseTest, Initialize) { | 369 TEST_F(VideoRendererBaseTest, Initialize) { |
| 366 Initialize(); | 370 Initialize(); |
| 367 EXPECT_EQ(0, GetCurrentTimestampInMs()); | 371 EXPECT_EQ(0, GetCurrentTimestampInMs()); |
| 368 Shutdown(); | 372 Shutdown(); |
| 369 } | 373 } |
| 370 | 374 |
| 375 static void ExpectNotCalled(PipelineStatus) { | |
| 376 base::debug::StackTrace stack; | |
| 377 ADD_FAILURE() << "Expected callback not to be called\n" << stack.ToString(); | |
|
scherkus (not reviewing)
2013/02/20 08:26:11
I did this to get the stack trace of the callback
| |
| 378 } | |
| 379 | |
|
acolwell GONE FROM CHROMIUM
2013/02/20 17:01:14
You should add a test that allows the renderer to
scherkus (not reviewing)
2013/02/21 20:43:54
Done.
| |
| 380 TEST_F(VideoRendererBaseTest, InitializeAndStop) { | |
| 381 EXPECT_CALL(*decoder_, Initialize(_, _, _)) | |
| 382 .WillOnce(RunCallback<1>(PIPELINE_OK)); | |
| 383 CallInitialize(base::Bind(&ExpectNotCalled)); | |
| 384 Stop(); | |
| 385 | |
| 386 // ~VideoRendererBase() will CHECK() if we left anything initialized. | |
| 387 } | |
| 388 | |
| 389 TEST_F(VideoRendererBaseTest, FlushAndStop) { | |
| 390 Initialize(); | |
| 391 Pause(); | |
| 392 renderer_->Flush(base::Bind(&ExpectNotCalled, PIPELINE_OK)); | |
| 393 Stop(); | |
| 394 | |
| 395 // ~VideoRendererBase() will CHECK() if we left anything initialized. | |
| 396 } | |
| 397 | |
| 371 TEST_F(VideoRendererBaseTest, Play) { | 398 TEST_F(VideoRendererBaseTest, Play) { |
| 372 Initialize(); | 399 Initialize(); |
| 373 Play(); | 400 Play(); |
| 374 Shutdown(); | 401 Shutdown(); |
| 375 } | 402 } |
| 376 | 403 |
| 377 TEST_F(VideoRendererBaseTest, EndOfStream_DefaultFrameDuration) { | 404 TEST_F(VideoRendererBaseTest, EndOfStream_DefaultFrameDuration) { |
| 378 Initialize(); | 405 Initialize(); |
| 379 Play(); | 406 Play(); |
| 380 | 407 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 InSequence s; | 634 InSequence s; |
| 608 | 635 |
| 609 EXPECT_CALL(*decoder_, Initialize(_, _, _)) | 636 EXPECT_CALL(*decoder_, Initialize(_, _, _)) |
| 610 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); | 637 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); |
| 611 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); | 638 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); |
| 612 | 639 |
| 613 Stop(); | 640 Stop(); |
| 614 } | 641 } |
| 615 | 642 |
| 616 } // namespace media | 643 } // namespace media |
| OLD | NEW |