OLD | NEW |
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 Loading... |
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(low_delay, true); | 100 InitializeRenderer(PIPELINE_OK, low_delay); |
101 } | 101 } |
102 | 102 |
103 void InitializeRenderer(bool low_delay, bool expect_to_success) { | 103 void InitializeRenderer(PipelineStatus expected, bool low_delay) { |
104 SCOPED_TRACE( | 104 SCOPED_TRACE(base::StringPrintf("InitializeRenderer(%d)", expected)); |
105 base::StringPrintf("InitializeRenderer(%d)", expect_to_success)); | |
106 WaitableMessageLoopEvent event; | 105 WaitableMessageLoopEvent event; |
107 CallInitialize(event.GetPipelineStatusCB(), low_delay, expect_to_success); | 106 CallInitialize(event.GetPipelineStatusCB(), low_delay, expected); |
108 event.RunAndWaitForStatus(expect_to_success ? PIPELINE_OK | 107 event.RunAndWaitForStatus(expected); |
109 : DECODER_ERROR_NOT_SUPPORTED); | |
110 } | 108 } |
111 | 109 |
112 void CallInitialize(const PipelineStatusCB& status_cb, | 110 void CallInitialize(const PipelineStatusCB& status_cb, |
113 bool low_delay, | 111 bool low_delay, |
114 bool expect_to_success) { | 112 PipelineStatus decoder_status) { |
115 if (low_delay) | 113 if (low_delay) |
116 demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE); | 114 demuxer_stream_.set_liveness(DemuxerStream::LIVENESS_LIVE); |
117 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) | 115 EXPECT_CALL(*decoder_, Initialize(_, _, _, _)) |
118 .WillOnce( | 116 .WillOnce( |
119 DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(expect_to_success))); | 117 DoAll(SaveArg<3>(&output_cb_), RunCallback<2>(decoder_status))); |
120 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); | 118 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0); |
121 renderer_->Initialize( | 119 renderer_->Initialize( |
122 &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(), | 120 &demuxer_stream_, status_cb, media::SetDecryptorReadyCB(), |
123 base::Bind(&VideoRendererImplTest::OnStatisticsUpdate, | 121 base::Bind(&VideoRendererImplTest::OnStatisticsUpdate, |
124 base::Unretained(this)), | 122 base::Unretained(this)), |
125 base::Bind(&StrictMock<MockCB>::BufferingStateChange, | 123 base::Bind(&StrictMock<MockCB>::BufferingStateChange, |
126 base::Unretained(&mock_cb_)), | 124 base::Unretained(&mock_cb_)), |
127 ended_event_.GetClosure(), error_event_.GetPipelineStatusCB(), | 125 ended_event_.GetClosure(), error_event_.GetPipelineStatusCB(), |
128 base::Bind(&WallClockTimeSource::GetWallClockTimes, | 126 base::Bind(&WallClockTimeSource::GetWallClockTimes, |
129 base::Unretained(&time_source_)), | 127 base::Unretained(&time_source_)), |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 523 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
526 StartPlayingFrom(0); | 524 StartPlayingFrom(0); |
527 | 525 |
528 // Check that there is an outstanding Read() request. | 526 // Check that there is an outstanding Read() request. |
529 EXPECT_TRUE(IsReadPending()); | 527 EXPECT_TRUE(IsReadPending()); |
530 | 528 |
531 Destroy(); | 529 Destroy(); |
532 } | 530 } |
533 | 531 |
534 TEST_P(VideoRendererImplTest, VideoDecoder_InitFailure) { | 532 TEST_P(VideoRendererImplTest, VideoDecoder_InitFailure) { |
535 InitializeRenderer(false, false); | 533 InitializeRenderer(DECODER_ERROR_NOT_SUPPORTED, false); |
536 Destroy(); | 534 Destroy(); |
537 } | 535 } |
538 | 536 |
539 TEST_P(VideoRendererImplTest, Underflow) { | 537 TEST_P(VideoRendererImplTest, Underflow) { |
540 Initialize(); | 538 Initialize(); |
541 QueueFrames("0 30 60 90"); | 539 QueueFrames("0 30 60 90"); |
542 | 540 |
543 { | 541 { |
544 WaitableMessageLoopEvent event; | 542 WaitableMessageLoopEvent event; |
545 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); | 543 EXPECT_CALL(mock_cb_, FrameReceived(HasTimestamp(0))); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 715 } |
718 | 716 |
719 INSTANTIATE_TEST_CASE_P(OldVideoRenderer, | 717 INSTANTIATE_TEST_CASE_P(OldVideoRenderer, |
720 VideoRendererImplTest, | 718 VideoRendererImplTest, |
721 testing::Values(false)); | 719 testing::Values(false)); |
722 INSTANTIATE_TEST_CASE_P(NewVideoRenderer, | 720 INSTANTIATE_TEST_CASE_P(NewVideoRenderer, |
723 VideoRendererImplTest, | 721 VideoRendererImplTest, |
724 testing::Values(true)); | 722 testing::Values(true)); |
725 | 723 |
726 } // namespace media | 724 } // namespace media |
OLD | NEW |