Commit e38550ec authored by Francois Doray's avatar Francois Doray Committed by Commit Bot

Remove usage of ScopedTaskScheduler from ffmpeg_demuxer_unittest.cc.

ScopedTaskScheduler is deprecated.

Bug: 708584
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I583be368ed89cdc687078bd8b72fcf2edf240afa
Reviewed-on: https://chromium-review.googlesource.com/586912Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Commit-Queue: Francois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491786}
parent ad928ca5
......@@ -19,7 +19,7 @@
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_task_scheduler.h"
#include "base/test/scoped_task_environment.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "media/base/decrypt_config.h"
......@@ -85,8 +85,10 @@ void OnStreamStatusChanged(base::WaitableEvent* event,
event->Signal();
}
void CheckStreamStatusNotifications(MediaResource* media_resource,
FFmpegDemuxerStream* stream) {
void CheckStreamStatusNotifications(
MediaResource* media_resource,
FFmpegDemuxerStream* stream,
base::test::ScopedTaskEnvironment* scoped_task_environment) {
base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
......@@ -95,12 +97,12 @@ void CheckStreamStatusNotifications(MediaResource* media_resource,
base::Bind(&OnStreamStatusChanged, base::Unretained(&event)));
stream->SetEnabled(false, base::TimeDelta());
base::RunLoop().RunUntilIdle();
scoped_task_environment->RunUntilIdle();
ASSERT_TRUE(event.IsSignaled());
event.Reset();
stream->SetEnabled(true, base::TimeDelta());
base::RunLoop().RunUntilIdle();
scoped_task_environment->RunUntilIdle();
ASSERT_TRUE(event.IsSignaled());
}
......@@ -146,7 +148,7 @@ class FFmpegDemuxerTest : public testing::Test {
if (demuxer_)
demuxer_->Stop();
demuxer_.reset();
base::RunLoop().RunUntilIdle();
scoped_task_environment_.RunUntilIdle();
data_source_.reset();
}
......@@ -294,7 +296,7 @@ class FFmpegDemuxerTest : public testing::Test {
// Fixture members.
base::test::ScopedTaskScheduler task_scheduler_;
base::test::ScopedTaskEnvironment scoped_task_environment_;
// TODO(wolenetz): Consider expanding MediaLog verification coverage here
// using StrictMock<MockMediaLog> for all FFmpegDemuxerTests. See
......@@ -528,10 +530,12 @@ TEST_F(FFmpegDemuxerTest, AbortPendingReads) {
audio->Read(NewReadCB(FROM_HERE, 29, 0, true, DemuxerStream::kAborted));
demuxer_->AbortPendingReads();
base::RunLoop().Run();
scoped_task_environment_.RunUntilIdle();
// Additional reads should also be aborted (until a Seek()).
audio->Read(NewReadCB(FROM_HERE, 29, 0, true, DemuxerStream::kAborted));
base::RunLoop().Run();
scoped_task_environment_.RunUntilIdle();
// Ensure blocking thread has completed outstanding work.
demuxer_->Stop();
......@@ -555,6 +559,7 @@ TEST_F(FFmpegDemuxerTest, Read_Audio) {
audio->Read(NewReadCB(FROM_HERE, 27, 3000, true));
base::RunLoop().Run();
scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(166866, demuxer_->GetMemoryUsage());
}
......@@ -572,6 +577,7 @@ TEST_F(FFmpegDemuxerTest, Read_Video) {
video->Read(NewReadCB(FROM_HERE, 1057, 33000, false));
base::RunLoop().Run();
scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(148778, demuxer_->GetMemoryUsage());
}
......@@ -1145,7 +1151,8 @@ TEST_F(FFmpegDemuxerTest, Stop) {
// Attempt the read...
audio->Read(callback.Get());
base::RunLoop().RunUntilIdle();
scoped_task_environment_.RunUntilIdle();
;
// Don't let the test call Stop() again.
demuxer_.reset();
......@@ -1730,8 +1737,10 @@ TEST_F(FFmpegDemuxerTest, StreamStatusNotifications) {
EXPECT_NE(nullptr, video_stream);
// Verify stream status notifications delivery without pending read first.
CheckStreamStatusNotifications(demuxer_.get(), audio_stream);
CheckStreamStatusNotifications(demuxer_.get(), video_stream);
CheckStreamStatusNotifications(demuxer_.get(), audio_stream,
&scoped_task_environment_);
CheckStreamStatusNotifications(demuxer_.get(), video_stream,
&scoped_task_environment_);
// Verify that stream notifications are delivered properly when stream status
// changes with a pending read. Call FlushBuffers before reading, to ensure
......@@ -1739,10 +1748,12 @@ TEST_F(FFmpegDemuxerTest, StreamStatusNotifications) {
// ensuring that status changes occur while an async read is pending.
audio_stream->FlushBuffers();
audio_stream->Read(base::Bind(&media::OnReadDone_ExpectEos));
CheckStreamStatusNotifications(demuxer_.get(), audio_stream);
CheckStreamStatusNotifications(demuxer_.get(), audio_stream,
&scoped_task_environment_);
video_stream->FlushBuffers();
video_stream->Read(base::Bind(&media::OnReadDone_ExpectEos));
CheckStreamStatusNotifications(demuxer_.get(), video_stream);
CheckStreamStatusNotifications(demuxer_.get(), video_stream,
&scoped_task_environment_);
}
TEST_F(FFmpegDemuxerTest, MultitrackMemoryUsage) {
......@@ -1757,6 +1768,7 @@ TEST_F(FFmpegDemuxerTest, MultitrackMemoryUsage) {
// shouldn't be too high.
audio->Read(NewReadCB(FROM_HERE, 304, 0, true));
base::RunLoop().Run();
scoped_task_environment_.RunUntilIdle();
EXPECT_EQ(22134, demuxer_->GetMemoryUsage());
// Now enable all demuxer streams in the file and perform another read, this
......@@ -1768,6 +1780,7 @@ TEST_F(FFmpegDemuxerTest, MultitrackMemoryUsage) {
audio->Read(NewReadCB(FROM_HERE, 166, 21000, true));
base::RunLoop().Run();
scoped_task_environment_.RunUntilIdle();
// With newly enabled demuxer streams the amount of memory used by the demuxer
// is much higher.
EXPECT_EQ(156011, demuxer_->GetMemoryUsage());
......
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