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

Side by Side Diff: media/renderers/video_renderer_impl_unittest.cc

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « media/renderers/audio_renderer_impl_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/debug/stack_trace.h" 10 #include "base/debug/stack_trace.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 void InitializeWithLowDelay(bool low_delay) { 91 void InitializeWithLowDelay(bool low_delay) {
92 // Monitor decodes from the decoder. 92 // Monitor decodes from the decoder.
93 EXPECT_CALL(*decoder_, Decode(_, _)) 93 EXPECT_CALL(*decoder_, Decode(_, _))
94 .WillRepeatedly(Invoke(this, &VideoRendererImplTest::DecodeRequested)); 94 .WillRepeatedly(Invoke(this, &VideoRendererImplTest::DecodeRequested));
95 95
96 EXPECT_CALL(*decoder_, Reset(_)) 96 EXPECT_CALL(*decoder_, Reset(_))
97 .WillRepeatedly(Invoke(this, &VideoRendererImplTest::FlushRequested)); 97 .WillRepeatedly(Invoke(this, &VideoRendererImplTest::FlushRequested));
98 98
99 // Initialize, we shouldn't have any reads. 99 // Initialize, we shouldn't have any reads.
100 InitializeRenderer(PIPELINE_OK, low_delay); 100 InitializeRenderer(low_delay, true);
101 } 101 }
102 102
103 void InitializeRenderer(PipelineStatus expected, bool low_delay) { 103 void InitializeRenderer(bool low_delay, bool expect_to_success) {
104 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); 104 SCOPED_TRACE(
105 base::StringPrintf("InitializeRenderer(%d)", expect_to_success));
105 WaitableMessageLoopEvent event; 106 WaitableMessageLoopEvent event;
106 CallInitialize(event.GetPipelineStatusCB(), low_delay, expected); 107 CallInitialize(event.GetPipelineStatusCB(), low_delay, expect_to_success);
107 event.RunAndWaitForStatus(expected); 108 event.RunAndWaitForStatus(expect_to_success ? PIPELINE_OK
109 : DECODER_ERROR_NOT_SUPPORTED);
108 } 110 }
109 111
110 void CallInitialize(const PipelineStatusCB& status_cb, 112 void CallInitialize(const PipelineStatusCB& status_cb,
111 bool low_delay, 113 bool low_delay,
112 PipelineStatus decoder_status) { 114 bool expect_to_success) {
113 if (low_delay) 115 if (low_delay)
114 demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE); 116 demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE);
115 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) 117 EXPECT_CALL(*decoder_, Initialize(_, _, _, _))
116 .WillOnce( 118 .WillOnce(
117 DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(decoder_status))); 119 DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(expect_to_success)));
118 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); 120 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
119 renderer_->Initialize( 121 renderer_->Initialize(
120 &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(), 122 &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(),
121 base::Bind(&VideoRendererImplTest::OnStatisticsUpdate, 123 base::Bind(&VideoRendererImplTest::OnStatisticsUpdate,
122 base::Unretained(this)), 124 base::Unretained(this)),
123 base::Bind(&StrictMock<MockCB>::BufferingStateChange, 125 base::Bind(&StrictMock<MockCB>::BufferingStateChange,
124 base::Unretained(&mock_cb_)), 126 base::Unretained(&mock_cb_)),
125 ended_event_.GetClosure(), error_event_.GetPipelineStatusCB(), 127 ended_event_.GetClosure(), error_event_.GetPipelineStatusCB(),
126 base::Bind(&WallClockTimeSource::GetWallClockTimes, 128 base::Bind(&WallClockTimeSource::GetWallClockTimes,
127 base::Unretained(&time_source_)), 129 base::Unretained(&time_source_)),
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); 525 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH));
524 StartPlayingFrom(0); 526 StartPlayingFrom(0);
525 527
526 // Check that there is an outstanding Read() request. 528 // Check that there is an outstanding Read() request.
527 EXPECT_TRUE(IsReadPending()); 529 EXPECT_TRUE(IsReadPending());
528 530
529 Destroy(); 531 Destroy();
530 } 532 }
531 533
532 TEST_P(VideoRendererImplTest, VideoDecoder_InitFailure) { 534 TEST_P(VideoRendererImplTest, VideoDecoder_InitFailure) {
533 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED, false); 535 InitializeRenderer(false, false);
534 Destroy(); 536 Destroy();
535 } 537 }
536 538
537 TEST_P(VideoRendererImplTest, Underflow) { 539 TEST_P(VideoRendererImplTest, Underflow) {
538 Initialize(); 540 Initialize();
539 QueueFrames("0 30 60 90"); 541 QueueFrames("0 30 60 90");
540 542
541 { 543 {
542 WaitableMessageLoopEvent event; 544 WaitableMessageLoopEvent event;
543 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); 545 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0)));
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 } 717 }
716 718
717 INSTANTIATE_TEST_CASE_P(OldVideoRenderer, 719 INSTANTIATE_TEST_CASE_P(OldVideoRenderer,
718 VideoRendererImplTest, 720 VideoRendererImplTest,
719 testing::Values(false)); 721 testing::Values(false));
720 INSTANTIATE_TEST_CASE_P(NewVideoRenderer, 722 INSTANTIATE_TEST_CASE_P(NewVideoRenderer,
721 VideoRendererImplTest, 723 VideoRendererImplTest,
722 testing::Values(true)); 724 testing::Values(true));
723 725
724 } // namespace media 726 } // namespace media
OLDNEW
« no previous file with comments | « media/renderers/audio_renderer_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698