Expect late delayed task is deleted.
Bug: None
Change-Id: I38d1c2f97504bf1e627723db7fb91368839a82d0
Reviewed-on: https://webrtc-review.googlesource.com/101401
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24811}
diff --git a/rtc_base/task_queue_unittest.cc b/rtc_base/task_queue_unittest.cc
index 21b91c4..cedf68e 100644
--- a/rtc_base/task_queue_unittest.cc
+++ b/rtc_base/task_queue_unittest.cc
@@ -175,12 +175,17 @@
TEST(TaskQueueTest, PostDelayedAfterDestruct) {
static const char kQueueName[] = "PostDelayedAfterDestruct";
- Event event(false, false);
+ Event run(false, false);
+ Event deleted(false, false);
{
TaskQueue queue(kQueueName);
- queue.PostDelayedTask(Bind(&CheckCurrent, &event, &queue), 100);
+ queue.PostDelayedTask(
+ rtc::NewClosure([&run] { run.Set(); }, [&deleted] { deleted.Set(); }),
+ 100);
}
- EXPECT_FALSE(event.Wait(200)); // Task should not run.
+ // Task might outlive the TaskQueue, but still should be deleted.
+ EXPECT_TRUE(deleted.Wait(200));
+ EXPECT_FALSE(run.Wait(0)); // and should not run.
}
TEST(TaskQueueTest, PostAndReply) {