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

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

Issue 12342020: Merge 184048 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
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 | Annotate | Revision Log
« no previous file with comments | « media/filters/video_renderer_base.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // We expect the video size to be set. 108 // We expect the video size to be set.
108 EXPECT_CALL(*this, OnNaturalSizeChanged(kNaturalSize)); 109 EXPECT_CALL(*this, OnNaturalSizeChanged(kNaturalSize));
109 110
110 // Start prerolling. 111 // Start prerolling.
111 QueuePrerollFrames(0); 112 QueuePrerollFrames(0);
112 Preroll(0, PIPELINE_OK); 113 Preroll(0, PIPELINE_OK);
113 } 114 }
114 115
115 void InitializeRenderer(PipelineStatus expected) { 116 void InitializeRenderer(PipelineStatus expected) {
116 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); 117 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected));
118 WaitableMessageLoopEvent event;
119 CallInitialize(event.GetPipelineStatusCB());
120 event.RunAndWaitForStatus(expected);
121 }
122
123 void CallInitialize(const PipelineStatusCB& status_cb) {
117 VideoRendererBase::VideoDecoderList decoders; 124 VideoRendererBase::VideoDecoderList decoders;
118 decoders.push_back(decoder_); 125 decoders.push_back(decoder_);
119
120 WaitableMessageLoopEvent event;
121 renderer_->Initialize( 126 renderer_->Initialize(
122 demuxer_stream_, 127 demuxer_stream_,
123 decoders, 128 decoders,
124 event.GetPipelineStatusCB(), 129 status_cb,
125 base::Bind(&MockStatisticsCB::OnStatistics, 130 base::Bind(&MockStatisticsCB::OnStatistics,
126 base::Unretained(&statistics_cb_object_)), 131 base::Unretained(&statistics_cb_object_)),
127 base::Bind(&VideoRendererBaseTest::OnTimeUpdate, 132 base::Bind(&VideoRendererBaseTest::OnTimeUpdate,
128 base::Unretained(this)), 133 base::Unretained(this)),
129 base::Bind(&VideoRendererBaseTest::OnNaturalSizeChanged, 134 base::Bind(&VideoRendererBaseTest::OnNaturalSizeChanged,
130 base::Unretained(this)), 135 base::Unretained(this)),
131 ended_event_.GetClosure(), 136 ended_event_.GetClosure(),
132 error_event_.GetPipelineStatusCB(), 137 error_event_.GetPipelineStatusCB(),
133 base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)), 138 base::Bind(&VideoRendererBaseTest::GetTime, base::Unretained(this)),
134 base::Bind(&VideoRendererBaseTest::GetDuration, 139 base::Bind(&VideoRendererBaseTest::GetDuration,
135 base::Unretained(this))); 140 base::Unretained(this)));
136 event.RunAndWaitForStatus(expected);
137 } 141 }
138 142
139 void Play() { 143 void Play() {
140 SCOPED_TRACE("Play()"); 144 SCOPED_TRACE("Play()");
141 WaitableMessageLoopEvent event; 145 WaitableMessageLoopEvent event;
142 renderer_->Play(event.GetClosure()); 146 renderer_->Play(event.GetClosure());
143 event.RunAndWait(); 147 event.RunAndWait();
144 } 148 }
145 149
146 void Preroll(int timestamp_ms, PipelineStatus expected) { 150 void Preroll(int timestamp_ms, PipelineStatus expected) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 353
350 // Run during FrameRequested() to unblock WaitForPendingRead(). 354 // Run during FrameRequested() to unblock WaitForPendingRead().
351 base::Closure wait_for_pending_read_cb_; 355 base::Closure wait_for_pending_read_cb_;
352 356
353 std::deque<std::pair< 357 std::deque<std::pair<
354 VideoDecoder::Status, scoped_refptr<VideoFrame> > > decode_results_; 358 VideoDecoder::Status, scoped_refptr<VideoFrame> > > decode_results_;
355 359
356 DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest); 360 DISALLOW_COPY_AND_ASSIGN(VideoRendererBaseTest);
357 }; 361 };
358 362
363 TEST_F(VideoRendererBaseTest, DoNothing) {
364 // Test that creation and deletion doesn't depend on calls to Initialize()
365 // and/or Stop().
366 }
367
368 TEST_F(VideoRendererBaseTest, StopWithoutInitialize) {
369 Stop();
370 }
371
359 TEST_F(VideoRendererBaseTest, Initialize) { 372 TEST_F(VideoRendererBaseTest, Initialize) {
360 Initialize(); 373 Initialize();
361 EXPECT_EQ(0, GetCurrentTimestampInMs()); 374 EXPECT_EQ(0, GetCurrentTimestampInMs());
362 Shutdown(); 375 Shutdown();
363 } 376 }
364 377
378 static void ExpectNotCalled(PipelineStatus) {
379 base::debug::StackTrace stack;
380 ADD_FAILURE() << "Expected callback not to be called\n" << stack.ToString();
381 }
382
383 TEST_F(VideoRendererBaseTest, StopWhileInitializing) {
384 EXPECT_CALL(*decoder_, Initialize(_, _, _))
385 .WillOnce(RunCallback<1>(PIPELINE_OK));
386 CallInitialize(base::Bind(&ExpectNotCalled));
387 Stop();
388
389 // ~VideoRendererBase() will CHECK() if we left anything initialized.
390 }
391
392 TEST_F(VideoRendererBaseTest, StopWhileFlushing) {
393 Initialize();
394 Pause();
395 renderer_->Flush(base::Bind(&ExpectNotCalled, PIPELINE_OK));
396 Stop();
397
398 // ~VideoRendererBase() will CHECK() if we left anything initialized.
399 }
400
365 TEST_F(VideoRendererBaseTest, Play) { 401 TEST_F(VideoRendererBaseTest, Play) {
366 Initialize(); 402 Initialize();
367 Play(); 403 Play();
368 Shutdown(); 404 Shutdown();
369 } 405 }
370 406
371 TEST_F(VideoRendererBaseTest, EndOfStream_DefaultFrameDuration) { 407 TEST_F(VideoRendererBaseTest, EndOfStream_DefaultFrameDuration) {
372 Initialize(); 408 Initialize();
373 Play(); 409 Play();
374 410
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 InSequence s; 647 InSequence s;
612 648
613 EXPECT_CALL(*decoder_, Initialize(_, _, _)) 649 EXPECT_CALL(*decoder_, Initialize(_, _, _))
614 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED)); 650 .WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED));
615 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED); 651 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED);
616 652
617 Stop(); 653 Stop();
618 } 654 }
619 655
620 } // namespace media 656 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/video_renderer_base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698