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

Side by Side Diff: media/filters/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: Created 5 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 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(OnWaitingForEncryptionKey, 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));
107 108
108 if (start_status == PIPELINE_OK && audio_stream_) { 109 if (start_status == PIPELINE_OK && audio_stream_) {
109 EXPECT_CALL(*audio_renderer_, GetTimeSource()) 110 EXPECT_CALL(*audio_renderer_, GetTimeSource())
110 .WillOnce(Return(&time_source_)); 111 .WillOnce(Return(&time_source_));
111 } 112 }
112 113
113 renderer_impl_->Initialize( 114 renderer_impl_->Initialize(
114 demuxer_.get(), 115 demuxer_.get(), base::Bind(&CallbackHelper::OnInitialize,
115 base::Bind(&CallbackHelper::OnInitialize, 116 base::Unretained(&callbacks_)),
116 base::Unretained(&callbacks_)),
117 base::Bind(&CallbackHelper::OnUpdateStatistics, 117 base::Bind(&CallbackHelper::OnUpdateStatistics,
118 base::Unretained(&callbacks_)), 118 base::Unretained(&callbacks_)),
119 base::Bind(&CallbackHelper::OnBufferingStateChange, 119 base::Bind(&CallbackHelper::OnBufferingStateChange,
120 base::Unretained(&callbacks_)), 120 base::Unretained(&callbacks_)),
121 base::Bind(&CallbackHelper::OnVideoFramePaint, 121 base::Bind(&CallbackHelper::OnVideoFramePaint,
122 base::Unretained(&callbacks_)), 122 base::Unretained(&callbacks_)),
123 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), 123 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)),
124 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_))); 124 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)),
125 base::Bind(&CallbackHelper::OnWaitingForEncryptionKey,
126 base::Unretained(&callbacks_)));
125 base::RunLoop().RunUntilIdle(); 127 base::RunLoop().RunUntilIdle();
126 } 128 }
127 129
128 void CreateAudioStream() { 130 void CreateAudioStream() {
129 audio_stream_ = CreateStream(DemuxerStream::AUDIO); 131 audio_stream_ = CreateStream(DemuxerStream::AUDIO);
130 streams_.push_back(audio_stream_.get()); 132 streams_.push_back(audio_stream_.get());
131 EXPECT_CALL(*demuxer_, GetStream(DemuxerStream::AUDIO)) 133 EXPECT_CALL(*demuxer_, GetStream(DemuxerStream::AUDIO))
132 .WillRepeatedly(Return(audio_stream_.get())); 134 .WillRepeatedly(Return(audio_stream_.get()));
133 } 135 }
134 136
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 audio_error_cb_.Run(PIPELINE_ERROR_DECODE); 428 audio_error_cb_.Run(PIPELINE_ERROR_DECODE);
427 base::RunLoop().RunUntilIdle(); 429 base::RunLoop().RunUntilIdle();
428 } 430 }
429 431
430 TEST_F(RendererImplTest, ErrorDuringInitialize) { 432 TEST_F(RendererImplTest, ErrorDuringInitialize) {
431 CreateAudioAndVideoStream(); 433 CreateAudioAndVideoStream();
432 SetAudioRendererInitializeExpectations(PIPELINE_OK); 434 SetAudioRendererInitializeExpectations(PIPELINE_OK);
433 435
434 // Force an audio error to occur during video renderer initialization. 436 // Force an audio error to occur during video renderer initialization.
435 EXPECT_CALL(*video_renderer_, 437 EXPECT_CALL(*video_renderer_,
436 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _)) 438 Initialize(video_stream_.get(), _, _, _, _, _, _, _, _, _))
437 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE), 439 .WillOnce(DoAll(AudioError(&audio_error_cb_, PIPELINE_ERROR_DECODE),
438 SaveArg<4>(&video_buffering_state_cb_), 440 SaveArg<4>(&video_buffering_state_cb_),
439 SaveArg<6>(&video_ended_cb_), 441 SaveArg<6>(&video_ended_cb_),
440 RunCallback<1>(PIPELINE_OK))); 442 RunCallback<1>(PIPELINE_OK)));
441 443
442 InitializeAndExpect(PIPELINE_ERROR_DECODE); 444 InitializeAndExpect(PIPELINE_ERROR_DECODE);
443 } 445 }
444 446
445 } // namespace media 447 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698