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

Side by Side Diff: content/renderer/media/media_recorder_handler_unittest.cc

Issue 2633623002: MediaRecorder: handle libwebm::Segment::AddFrame() errors and wire up to Blink (Closed)
Patch Set: I can haz moar testing? Created 3 years, 11 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 | « content/renderer/media/media_recorder_handler.cc ('k') | media/muxers/webm_muxer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 void AddTracks() { 111 void AddTracks() {
112 // Avoid issues with non-parameterized tests by calling this outside of ctr. 112 // Avoid issues with non-parameterized tests by calling this outside of ctr.
113 if (GetParam().has_video) 113 if (GetParam().has_video)
114 registry_.AddVideoTrack(kTestVideoTrackId); 114 registry_.AddVideoTrack(kTestVideoTrackId);
115 if (GetParam().has_audio) 115 if (GetParam().has_audio)
116 registry_.AddAudioTrack(kTestAudioTrackId); 116 registry_.AddAudioTrack(kTestAudioTrackId);
117 } 117 }
118 118
119 void ForceOneErrorInWebmMuxer() {
120 media_recorder_handler_->webm_muxer_->ForceOneLibWebmErrorForTesting();
121 }
122
119 std::unique_ptr<media::AudioBus> NextAudioBus() { 123 std::unique_ptr<media::AudioBus> NextAudioBus() {
120 std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create( 124 std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create(
121 kTestAudioChannels, 125 kTestAudioChannels,
122 kTestAudioSampleRate * kTestAudioBufferDurationMs / 1000)); 126 kTestAudioSampleRate * kTestAudioBufferDurationMs / 1000));
123 audio_source_.OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0, 127 audio_source_.OnMoreData(base::TimeDelta(), base::TimeTicks::Now(), 0,
124 bus.get()); 128 bus.get());
125 return bus; 129 return bus;
126 } 130 }
127 131
128 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks 132 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 run_loop.Run(); 336 run_loop.Run();
333 } 337 }
334 338
335 media_recorder_handler_->stop(); 339 media_recorder_handler_->stop();
336 340
337 // Expect a last call on destruction, with size 0 and |lastInSlice| true. 341 // Expect a last call on destruction, with size 0 and |lastInSlice| true.
338 EXPECT_CALL(*this, writeData(nullptr, 0, true, _)).Times(1); 342 EXPECT_CALL(*this, writeData(nullptr, 0, true, _)).Times(1);
339 media_recorder_handler_.reset(); 343 media_recorder_handler_.reset();
340 } 344 }
341 345
346 // Starts up recording and forces a WebmMuxer's libwebm error.
347 TEST_P(MediaRecorderHandlerTest, WebmMuxerErrorWhileEncoding) {
348 // Video-only test: Audio would be very similar.
349 if (GetParam().has_audio)
350 return;
351
352 AddTracks();
353
354 const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type));
355 const WebString codecs(base::UTF8ToUTF16(GetParam().codecs));
356 EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(),
357 mime_type, codecs, 0, 0));
358 EXPECT_TRUE(media_recorder_handler_->start(0));
359
360 InSequence s;
361 const scoped_refptr<media::VideoFrame> video_frame =
362 media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80));
363
364 {
365 const size_t kEncodedSizeThreshold = 16;
366 base::RunLoop run_loop;
367 base::Closure quit_closure = run_loop.QuitClosure();
368 EXPECT_CALL(*this, writeData(_, _, _, _)).Times(AtLeast(1));
369 EXPECT_CALL(*this, writeData(_, Gt(kEncodedSizeThreshold), _, _))
370 .Times(1)
371 .WillOnce(RunClosure(quit_closure));
372
373 OnVideoFrameForTesting(video_frame);
374 run_loop.Run();
375 }
376
377 ForceOneErrorInWebmMuxer();
378
379 {
380 base::RunLoop run_loop;
381 base::Closure quit_closure = run_loop.QuitClosure();
382 EXPECT_CALL(*this, writeData(_, _, _, _)).Times(0);
383 EXPECT_CALL(*this, onError(_)).Times(1).WillOnce(RunClosure(quit_closure));
384
385 OnVideoFrameForTesting(video_frame);
386 run_loop.Run();
387 }
388
389
390 // Expect a last call on destruction, with size 0 and |lastInSlice| true.
391 EXPECT_CALL(*this, writeData(nullptr, 0, true, _)).Times(1);
392 media_recorder_handler_.reset();
393 }
394
342 } // namespace content 395 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_recorder_handler.cc ('k') | media/muxers/webm_muxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698