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

Side by Side Diff: media/filters/video_renderer_base_unittest.cc

Issue 12324005: Fix crash in VideoRendererBase::ThreadMain(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@git-svn
Patch Set: Created 7 years, 10 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 unified diff | Download patch
OLDNEW
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
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 359
356 // Run during FrameRequested() to unblock WaitForPendingRead(). 360 // Run during FrameRequested() to unblock WaitForPendingRead().
357 base::Closure wait_for_pending_read_cb_; 361 base::Closure wait_for_pending_read_cb_;
358 362
359 std::deque<std::pair< 363 std::deque<std::pair<
360 VideoDecoder::Status, scoped_refptr<VideoFrame> > > decode_results_; 364 VideoDecoder::Status, scoped_refptr<VideoFrame> > > decode_results_;
361 365
362 DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest); 366 DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest);
363 }; 367 };
364 368
369 TEST_F(VideoRendererBaseTest, DoNothing) {}
acolwell GONE FROM CHROMIUM 2013/02/21 21:07:16 nit: Add comment indicating why we have a DoNothin
scherkus (not reviewing) 2013/02/22 01:45:49 Done.
370
371 TEST_F(VideoRendererBaseTest, Stop) {
acolwell GONE FROM CHROMIUM 2013/02/21 21:07:16 nit: s/Stop/StopBeforeInitialize ?
scherkus (not reviewing) 2013/02/22 01:45:49 Settled on StopWithoutInitialize ("before" makes m
372 Stop();
373 }
374
365 TEST_F(VideoRendererBaseTest, Initialize) { 375 TEST_F(VideoRendererBaseTest, Initialize) {
366 Initialize(); 376 Initialize();
367 EXPECT_EQ(0, GetCurrentTimestampInMs()); 377 EXPECT_EQ(0, GetCurrentTimestampInMs());
368 Shutdown(); 378 Shutdown();
369 } 379 }
370 380
381 static void ExpectNotCalled(PipelineStatus) {
382 base::debug::StackTrace stack;
383 ADD_FAILURE() << "Expected callback not to be called\n" << stack.ToString();
384 }
385
386 TEST_F(VideoRendererBaseTest, InitializeAndStop) {
acolwell GONE FROM CHROMIUM 2013/02/21 21:07:16 nit: s/InitializeAndStop/StopWhileInitializing ?
scherkus (not reviewing) 2013/02/22 01:45:49 Done.
387 EXPECT_CALL(*decoder_, Initialize(_, _, _))
388 .WillOnce(RunCallback<1>(PIPELINE_OK));
389 CallInitialize(base::Bind(&ExpectNotCalled));
390 Stop();
391
392 // ~VideoRendererBase() will CHECK() if we left anything initialized.
393 }
394
395 TEST_F(VideoRendererBaseTest, FlushAndStop) {
acolwell GONE FROM CHROMIUM 2013/02/21 21:07:16 nit: s/FlushAndStop/StopWhileFlushing ?
scherkus (not reviewing) 2013/02/22 01:45:49 Done.
396 Initialize();
397 Pause();
398 renderer_->Flush(base::Bind(&ExpectNotCalled, PIPELINE_OK));
399 Stop();
400
401 // ~VideoRendererBase() will CHECK() if we left anything initialized.
402 }
403
371 TEST_F(VideoRendererBaseTest, Play) { 404 TEST_F(VideoRendererBaseTest, Play) {
372 Initialize(); 405 Initialize();
373 Play(); 406 Play();
374 Shutdown(); 407 Shutdown();
375 } 408 }
376 409
377 TEST_F(VideoRendererBaseTest, EndOfStream_DefaultFrameDuration) { 410 TEST_F(VideoRendererBaseTest, EndOfStream_DefaultFrameDuration) {
378 Initialize(); 411 Initialize();
379 Play(); 412 Play();
380 413
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 InSequence s; 640 InSequence s;
608 641
609 EXPECT_CALL(*decoder_, Initialize(_, _, _)) 642 EXPECT_CALL(*decoder_, Initialize(_, _, _))
610 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); 643 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED));
611 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); 644 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED);
612 645
613 Stop(); 646 Stop();
614 } 647 }
615 648
616 } // namespace media 649 } // namespace media
OLDNEW
« media/filters/video_renderer_base.cc ('K') | « media/filters/video_renderer_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698