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

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

Issue 935243002: Decryptors can report kNoKey to WebMediaPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android changes Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 CallbackHelper() {} 43 CallbackHelper() {}
44 virtual ~CallbackHelper() {} 44 virtual ~CallbackHelper() {}
45 45
46 MOCK_METHOD1(OnInitialize, void(PipelineStatus)); 46 MOCK_METHOD1(OnInitialize, void(PipelineStatus));
47 MOCK_METHOD0(OnFlushed, void()); 47 MOCK_METHOD0(OnFlushed, void());
48 MOCK_METHOD0(OnEnded, void()); 48 MOCK_METHOD0(OnEnded, void());
49 MOCK_METHOD1(OnError, void(PipelineStatus)); 49 MOCK_METHOD1(OnError, void(PipelineStatus));
50 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&)); 50 MOCK_METHOD1(OnUpdateStatistics, void(const PipelineStatistics&));
51 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState)); 51 MOCK_METHOD1(OnBufferingStateChange, void(BufferingState));
52 MOCK_METHOD1(OnVideoFramePaint, void(const scoped_refptr<VideoFrame>&)); 52 MOCK_METHOD1(OnVideoFramePaint, void(const scoped_refptr<VideoFrame>&));
53 MOCK_METHOD0(OnWaitingForDecryptionKey, void());
53 54
54 private: 55 private:
55 DISALLOW_COPY_AND_ASSIGN(CallbackHelper); 56 DISALLOW_COPY_AND_ASSIGN(CallbackHelper);
56 }; 57 };
57 58
58 RendererImplTest() 59 RendererImplTest()
59 : demuxer_(new StrictMock<MockDemuxer>()), 60 : demuxer_(new StrictMock<MockDemuxer>()),
60 video_renderer_(new StrictMock<MockVideoRenderer>()), 61 video_renderer_(new StrictMock<MockVideoRenderer>()),
61 audio_renderer_(new StrictMock<MockAudioRenderer>()), 62 audio_renderer_(new StrictMock<MockAudioRenderer>()),
62 renderer_impl_( 63 renderer_impl_(
(...skipping 18 matching lines...) Expand all
81 scoped_ptr<StrictMock<MockDemuxerStream> > CreateStream( 82 scoped_ptr<StrictMock<MockDemuxerStream> > CreateStream(
82 DemuxerStream::Type type) { 83 DemuxerStream::Type type) {
83 scoped_ptr<StrictMock<MockDemuxerStream> > stream( 84 scoped_ptr<StrictMock<MockDemuxerStream> > stream(
84 new StrictMock<MockDemuxerStream>(type)); 85 new StrictMock<MockDemuxerStream>(type));
85 return stream.Pass(); 86 return stream.Pass();
86 } 87 }
87 88
88 // Sets up expectations to allow the audio renderer to initialize. 89 // Sets up expectations to allow the audio renderer to initialize.
89 void SetAudioRendererInitializeExpectations(PipelineStatus status) { 90 void SetAudioRendererInitializeExpectations(PipelineStatus status) {
90 EXPECT_CALL(*audio_renderer_, 91 EXPECT_CALL(*audio_renderer_,
91 Initialize(audio_stream_.get(), _, _, _, _, _, _)) 92 Initialize(audio_stream_.get(), _, _, _, _, _, _, _))
92 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_), 93 .WillOnce(DoAll(SaveArg<4>(&audio_buffering_state_cb_),
93 SaveArg<5>(&audio_ended_cb_), 94 SaveArg<5>(&audio_ended_cb_),
94 SaveArg<6>(&audio_error_cb_), RunCallback<1>(status))); 95 SaveArg<6>(&audio_error_cb_), RunCallback<1>(status)));
95 } 96 }
96 97
97 // Sets up expectations to allow the video renderer to initialize. 98 // Sets up expectations to allow the video renderer to initialize.
98 void SetVideoRendererInitializeExpectations(PipelineStatus status) { 99 void SetVideoRendererInitializeExpectations(PipelineStatus status) {
99 EXPECT_CALL(*video_renderer_, 100 EXPECT_CALL(*video_renderer_,
100 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) 101 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _, _))
101 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_), 102 .WillOnce(DoAll(SaveArg<4>(&video_buffering_state_cb_),
102 SaveArg<6>(&video_ended_cb_), RunCallback<1>(status))); 103 SaveArg<6>(&video_ended_cb_), RunCallback<1>(status)));
103 } 104 }
104 105
105 void InitializeAndExpect(PipelineStatus start_status) { 106 void InitializeAndExpect(PipelineStatus start_status) {
106 EXPECT_CALL(callbacks_, OnInitialize(start_status)); 107 EXPECT_CALL(callbacks_, OnInitialize(start_status));
108 EXPECT_CALL(callbacks_, OnWaitingForDecryptionKey()).Times(0);
107 109
108 if (start_status == PIPELINE_OK && audio_stream_) { 110 if (start_status == PIPELINE_OK && audio_stream_) {
109 EXPECT_CALL(*audio_renderer_, GetTimeSource()) 111 EXPECT_CALL(*audio_renderer_, GetTimeSource())
110 .WillOnce(Return(&time_source_)); 112 .WillOnce(Return(&time_source_));
111 } 113 }
112 114
113 renderer_impl_->Initialize( 115 renderer_impl_->Initialize(
114 demuxer_.get(), 116 demuxer_.get(),
115 base::Bind(&CallbackHelper::OnInitialize, 117 base::Bind(&CallbackHelper::OnInitialize,
116 base::Unretained(&callbacks_)), 118 base::Unretained(&callbacks_)),
117 base::Bind(&CallbackHelper::OnUpdateStatistics, 119 base::Bind(&CallbackHelper::OnUpdateStatistics,
118 base::Unretained(&callbacks_)), 120 base::Unretained(&callbacks_)),
119 base::Bind(&CallbackHelper::OnBufferingStateChange, 121 base::Bind(&CallbackHelper::OnBufferingStateChange,
120 base::Unretained(&callbacks_)), 122 base::Unretained(&callbacks_)),
121 base::Bind(&CallbackHelper::OnVideoFramePaint, 123 base::Bind(&CallbackHelper::OnVideoFramePaint,
122 base::Unretained(&callbacks_)), 124 base::Unretained(&callbacks_)),
123 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 125 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
124 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_))); 126 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
127 base::Bind(&CallbackHelper::OnWaitingForDecryptionKey,
128 base::Unretained(&callbacks_)));
125 base::RunLoop().RunUntilIdle(); 129 base::RunLoop().RunUntilIdle();
126 } 130 }
127 131
128 void CreateAudioStream() { 132 void CreateAudioStream() {
129 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 133 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
130 streams_.push_back(audio_stream_.get()); 134 streams_.push_back(audio_stream_.get());
131 EXPECT_CALL(*demuxer_, GetStream(DemuxerStream::AUDIO)) 135 EXPECT_CALL(*demuxer_, GetStream(DemuxerStream::AUDIO))
132 .WillRepeatedly(Return(audio_stream_.get())); 136 .WillRepeatedly(Return(audio_stream_.get()));
133 } 137 }
134 138
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); 430 audio_error_cb_.Run(PIPELINE_ERROR_DECODE);
427 base::RunLoop().RunUntilIdle(); 431 base::RunLoop().RunUntilIdle();
428 } 432 }
429 433
430 TEST_F(RendererImplTest, ErrorDuringInitialize) { 434 TEST_F(RendererImplTest, ErrorDuringInitialize) {
431 CreateAudioAndVideoStream(); 435 CreateAudioAndVideoStream();
432 SetAudioRendererInitializeExpectations(PIPELINE_OK); 436 SetAudioRendererInitializeExpectations(PIPELINE_OK);
433 437
434 // Force an audio error to occur during video renderer initialization. 438 // Force an audio error to occur during video renderer initialization.
435 EXPECT_CALL(*video_renderer_, 439 EXPECT_CALL(*video_renderer_,
436 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) 440 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _, _))
437 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), 441 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE),
438 SaveArg<4>(&video_buffering_state_cb_), 442 SaveArg<4>(&video_buffering_state_cb_),
439 SaveArg<6>(&video_ended_cb_), 443 SaveArg<6>(&video_ended_cb_),
440 RunCallback<1>(PIPELINE_OK))); 444 RunCallback<1>(PIPELINE_OK)));
441 445
442 InitializeAndExpect(PIPELINE_ERROR_DECODE); 446 InitializeAndExpect(PIPELINE_ERROR_DECODE);
443 } 447 }
444 448
445 } // namespace media 449 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698