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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/media_recorder_handler_unittest.cc
diff --git a/content/renderer/media/media_recorder_handler_unittest.cc b/content/renderer/media/media_recorder_handler_unittest.cc
index 8f968d69dcb5f469d3befd4fc004a9612d85bf02..6d6d6d006d33c8433e2e74aca30924c2b738bcdb 100644
--- a/content/renderer/media/media_recorder_handler_unittest.cc
+++ b/content/renderer/media/media_recorder_handler_unittest.cc
@@ -116,6 +116,10 @@ class MediaRecorderHandlerTest : public TestWithParam<MediaRecorderTestParams>,
registry_.AddAudioTrack(kTestAudioTrackId);
}
+ void ForceOneErrorInWebmMuxer() {
+ media_recorder_handler_->webm_muxer_->ForceOneLibWebmErrorForTesting();
+ }
+
std::unique_ptr<media::AudioBus> NextAudioBus() {
std::unique_ptr<media::AudioBus> bus(media::AudioBus::Create(
kTestAudioChannels,
@@ -339,4 +343,53 @@ TEST_P(MediaRecorderHandlerTest, EncodeAudioFrames) {
media_recorder_handler_.reset();
}
+// Starts up recording and forces a WebmMuxer's libwebm error.
+TEST_P(MediaRecorderHandlerTest, WebmMuxerErrorWhileEncoding) {
+ // Video-only test: Audio would be very similar.
+ if (GetParam().has_audio)
+ return;
+
+ AddTracks();
+
+ const WebString mime_type(base::UTF8ToUTF16(GetParam().mime_type));
+ const WebString codecs(base::UTF8ToUTF16(GetParam().codecs));
+ EXPECT_TRUE(media_recorder_handler_->initialize(this, registry_.test_stream(),
+ mime_type, codecs, 0, 0));
+ EXPECT_TRUE(media_recorder_handler_->start(0));
+
+ InSequence s;
+ const scoped_refptr<media::VideoFrame> video_frame =
+ media::VideoFrame::CreateBlackFrame(gfx::Size(160, 80));
+
+ {
+ const size_t kEncodedSizeThreshold = 16;
+ base::RunLoop run_loop;
+ base::Closure quit_closure = run_loop.QuitClosure();
+ EXPECT_CALL(*this, writeData(_, _, _, _)).Times(AtLeast(1));
+ EXPECT_CALL(*this, writeData(_, Gt(kEncodedSizeThreshold), _, _))
+ .Times(1)
+ .WillOnce(RunClosure(quit_closure));
+
+ OnVideoFrameForTesting(video_frame);
+ run_loop.Run();
+ }
+
+ ForceOneErrorInWebmMuxer();
+
+ {
+ base::RunLoop run_loop;
+ base::Closure quit_closure = run_loop.QuitClosure();
+ EXPECT_CALL(*this, writeData(_, _, _, _)).Times(0);
+ EXPECT_CALL(*this, onError(_)).Times(1).WillOnce(RunClosure(quit_closure));
+
+ OnVideoFrameForTesting(video_frame);
+ run_loop.Run();
+ }
+
+
+ // Expect a last call on destruction, with size 0 and |lastInSlice| true.
+ EXPECT_CALL(*this, writeData(nullptr, 0, true, _)).Times(1);
+ media_recorder_handler_.reset();
+}
+
} // namespace content
« 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