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

Unified Diff: media/gpu/avda_codec_allocator_unittest.cc

Issue 2540393002: media: AVDACodecAllocator now fails if threads don't start (Closed)
Patch Set: blah Created 4 years 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 | « media/gpu/avda_codec_allocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/avda_codec_allocator_unittest.cc
diff --git a/media/gpu/avda_codec_allocator_unittest.cc b/media/gpu/avda_codec_allocator_unittest.cc
index 5d4d1be19395b899cfdf5f39da407e9f2231fb74..8c066f214f0cc94c78d96f14b6152655433d7930 100644
--- a/media/gpu/avda_codec_allocator_unittest.cc
+++ b/media/gpu/avda_codec_allocator_unittest.cc
@@ -136,7 +136,7 @@ class AVDACodecAllocatorTest : public testing::Test {
allocator_, task_type));
}
- TaskType TaskTypeForAllocation() {
+ base::Optional<TaskType> TaskTypeForAllocation() {
return PostAndWait(FROM_HERE,
base::Bind(&AVDACodecAllocator::TaskTypeForAllocation,
base::Unretained(allocator_)));
@@ -185,26 +185,26 @@ class AVDACodecAllocatorTest : public testing::Test {
};
TEST_F(AVDACodecAllocatorTest, ThreadsStartWhenClientsStart) {
- ASSERT_FALSE(IsThreadRunning(TaskType::AUTO_CODEC));
- ASSERT_FALSE(IsThreadRunning(TaskType::SW_CODEC));
- ASSERT_TRUE(StartThread(avda1_));
- // Assert that the AUTO_CODEC thread is started. The other might not be.
- ASSERT_TRUE(IsThreadRunning(TaskType::AUTO_CODEC));
+ ASSERT_FALSE(IsThreadRunning(AUTO_CODEC));
+ ASSERT_FALSE(IsThreadRunning(SW_CODEC));
+ StartThread(avda1_);
+ ASSERT_TRUE(IsThreadRunning(AUTO_CODEC));
+ ASSERT_TRUE(IsThreadRunning(SW_CODEC));
}
TEST_F(AVDACodecAllocatorTest, ThreadsStopAfterAllClientsStop) {
StartThread(avda1_);
StartThread(avda2_);
StopThread(avda1_);
- ASSERT_TRUE(IsThreadRunning(TaskType::AUTO_CODEC));
+ ASSERT_TRUE(IsThreadRunning(AUTO_CODEC));
StopThread(avda2_);
- ASSERT_FALSE(IsThreadRunning(TaskType::AUTO_CODEC));
- // Note the SW_CODEC thread might still be running.
+ ASSERT_FALSE(IsThreadRunning(AUTO_CODEC));
+ ASSERT_FALSE(IsThreadRunning(SW_CODEC));
}
TEST_F(AVDACodecAllocatorTest, TestHangThread) {
StartThread(avda1_);
- ASSERT_EQ(TaskType::AUTO_CODEC, TaskTypeForAllocation());
+ ASSERT_EQ(AUTO_CODEC, TaskTypeForAllocation().value());
// Hang the AUTO_CODEC thread.
base::WaitableEvent about_to_wait_event(
@@ -213,7 +213,7 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) {
base::WaitableEvent wait_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
- TaskRunnerFor(TaskType::AUTO_CODEC)
+ TaskRunnerFor(AUTO_CODEC)
->PostTask(FROM_HERE, base::Bind(&WaitUntilRestarted,
&about_to_wait_event, &wait_event));
// Wait until the task starts, so that |allocator_| starts the hang timer.
@@ -221,24 +221,21 @@ TEST_F(AVDACodecAllocatorTest, TestHangThread) {
// Verify that we've failed over after a long time has passed.
tick_clock_.Advance(base::TimeDelta::FromSeconds(1));
- // Note that this should return the SW codec task type even if that thread
- // failed to start. TaskRunnerFor() will return the current thread in that
- // case too.
- ASSERT_EQ(TaskType::SW_CODEC, TaskTypeForAllocation());
+ ASSERT_EQ(SW_CODEC, TaskTypeForAllocation().value());
// Un-hang the thread and wait for it to let another task run. This will
// notify |allocator_| that the thread is no longer hung.
base::WaitableEvent done_waiting_event(
base::WaitableEvent::ResetPolicy::MANUAL,
base::WaitableEvent::InitialState::NOT_SIGNALED);
- TaskRunnerFor(TaskType::AUTO_CODEC)
+ TaskRunnerFor(AUTO_CODEC)
->PostTask(FROM_HERE,
base::Bind(&SignalImmediately, &done_waiting_event));
wait_event.Signal();
done_waiting_event.Wait();
// Verify that we've un-failed over.
- ASSERT_EQ(TaskType::AUTO_CODEC, TaskTypeForAllocation());
+ ASSERT_EQ(AUTO_CODEC, TaskTypeForAllocation().value());
}
TEST_F(AVDACodecAllocatorTest, AllocatingASurfaceTextureAlwaysSucceeds) {
« no previous file with comments | « media/gpu/avda_codec_allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698