Commit f3081f74 authored by Xiaohan Wang's avatar Xiaohan Wang Committed by Commit Bot

media: Fix WebMediaPlayerImplTest.Encrypted test flakiness

The current test has a race condition that by the time MetaData is
reported (right after Demuxer initialization), the Renderer might not
have been initialized (which triggers the "waitingforkey" event, that
will trigger DidBlockPlaybackWaitingForKey().

This CL fixes the test so that Load() will wait for
DidBlockPlaybackWaitingForKey() to avoid this race condition.

Bug: 1021574
Test: Fix flaky test.
Change-Id: Icd3bdae9ceb2a5bb7791418e729e68e323ff74fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900158Reviewed-by: default avatarJohn Rummell <jrummell@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712709}
parent 34aa4a89
......@@ -1588,12 +1588,16 @@ TEST_F(WebMediaPlayerImplTest, Encrypted) {
// To avoid PreloadMetadataLazyLoad.
wmpi_->SetPreload(blink::WebMediaPlayer::kPreloadAuto);
EXPECT_CALL(encrypted_client_, DidBlockPlaybackWaitingForKey());
EXPECT_CALL(encrypted_client_, DidResumePlaybackBlockedForKey());
{
base::RunLoop run_loop;
EXPECT_CALL(encrypted_client_,
Encrypted(EmeInitDataType::WEBM, NotNull(), Gt(0u)));
LoadAndWaitForReadyState(kEncryptedVideoOnlyTestFile,
blink::WebMediaPlayer::kReadyStateHaveMetadata);
EXPECT_CALL(encrypted_client_, DidBlockPlaybackWaitingForKey());
EXPECT_CALL(encrypted_client_, DidResumePlaybackBlockedForKey())
.WillRepeatedly(RunClosure(run_loop.QuitClosure()));
Load(kEncryptedVideoOnlyTestFile);
run_loop.Run();
}
CreateCdm();
......@@ -1603,7 +1607,9 @@ TEST_F(WebMediaPlayerImplTest, Encrypted) {
.WillRepeatedly(Return(nullptr));
mock_cdm_context_.set_cdm_id(CdmContext::kInvalidCdmId);
// Wait for kNetworkStateFormatError caused by Renderer initialization error.
{
// Wait for kNetworkStateFormatError caused by Renderer initialization
// error.
base::RunLoop run_loop;
EXPECT_CALL(client_, NetworkStateChanged()).WillOnce(Invoke([&] {
if (wmpi_->GetNetworkState() ==
......@@ -1612,6 +1618,7 @@ TEST_F(WebMediaPlayerImplTest, Encrypted) {
}));
SetCdm();
run_loop.Run();
}
}
TEST_F(WebMediaPlayerImplTest, Waiting_NoDecryptionKey) {
......
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