Commit e2d67812 authored by John Rummell's avatar John Rummell Committed by Commit Bot

Fix DCHECK to not fire on initialize failure

Also add some new tests to verify Initialize() failures.

BUG=883620
TEST=new tests pass

Change-Id: I8ed3ca04b37fcdca4b9c9c3483b1d7c696bf232a
Reviewed-on: https://chromium-review.googlesource.com/c/1336059Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608122}
parent ca0515b5
...@@ -269,7 +269,7 @@ void MojoVideoDecoderService::Reset(ResetCallback callback) { ...@@ -269,7 +269,7 @@ void MojoVideoDecoderService::Reset(ResetCallback callback) {
void MojoVideoDecoderService::OnDecoderInitialized(bool success) { void MojoVideoDecoderService::OnDecoderInitialized(bool success) {
DVLOG(1) << __func__; DVLOG(1) << __func__;
DCHECK(decoder_); DCHECK(!success || decoder_);
DCHECK(init_cb_); DCHECK(init_cb_);
TRACE_EVENT_ASYNC_END1("media", kInitializeTraceName, this, "success", TRACE_EVENT_ASYNC_END1("media", kInitializeTraceName, this, "success",
success); success);
......
...@@ -325,6 +325,32 @@ TEST_F(MojoVideoDecoderIntegrationTest, Initialize) { ...@@ -325,6 +325,32 @@ TEST_F(MojoVideoDecoderIntegrationTest, Initialize) {
EXPECT_EQ(client_->GetMaxDecodeRequests(), kMaxDecodeRequests); EXPECT_EQ(client_->GetMaxDecodeRequests(), kMaxDecodeRequests);
} }
TEST_F(MojoVideoDecoderIntegrationTest, InitializeFailNoDecoder) {
CreateClient();
StrictMock<base::MockCallback<VideoDecoder::InitCB>> init_cb;
EXPECT_CALL(init_cb, Run(false));
// Clear |decoder_| so that Initialize() should fail.
decoder_.reset();
client_->Initialize(TestVideoConfig::NormalH264(), false, nullptr,
init_cb.Get(), output_cb_.Get(), base::NullCallback());
RunUntilIdle();
}
TEST_F(MojoVideoDecoderIntegrationTest, InitializeFailNoCdm) {
CreateClient();
StrictMock<base::MockCallback<VideoDecoder::InitCB>> init_cb;
EXPECT_CALL(init_cb, Run(false));
// CdmContext* (3rd parameter) is not provided but the VideoDecoderConfig
// specifies encrypted video, so Initialize() should fail.
client_->Initialize(TestVideoConfig::NormalEncrypted(), false, nullptr,
init_cb.Get(), output_cb_.Get(), base::NullCallback());
RunUntilIdle();
}
TEST_F(MojoVideoDecoderIntegrationTest, MediaLogIsProxied) { TEST_F(MojoVideoDecoderIntegrationTest, MediaLogIsProxied) {
ASSERT_TRUE(Initialize()); ASSERT_TRUE(Initialize());
EXPECT_MEDIA_LOG_ON(client_media_log_, HasSubstr("\"test\"")); EXPECT_MEDIA_LOG_ON(client_media_log_, HasSubstr("\"test\""));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment