Skip to content

Commit

Permalink
Add unit tests for RuntimeScheduler::cancelTask
Browse files Browse the repository at this point in the history
Summary:
Changelog: [internal]

Add unit tests for RuntimeScheduler::cancelTask

Reviewed By: JoshuaGross

Differential Revision: D27764482

fbshipit-source-id: 3833e49dd49865be4126bc5c3eb95a40d04bba99
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Apr 15, 2021
1 parent 4c1fd97 commit 8f3ffcf
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,23 @@ TEST_F(RuntimeSchedulerTest, scheduleTwoTasksWithDifferentPriorities) {
EXPECT_EQ(stubQueue_->size(), 0);
}

TEST_F(RuntimeSchedulerTest, cancelTask) {
bool didRunTask = false;
auto callback =
createHostFunctionFromLambda([&didRunTask]() { didRunTask = true; });

auto task = runtimeScheduler_->scheduleTask(
SchedulerPriority::NormalPriority, std::move(callback));

EXPECT_FALSE(didRunTask);
EXPECT_EQ(stubQueue_->size(), 1);

runtimeScheduler_->cancelTask(task);

stubQueue_->tick();

EXPECT_FALSE(didRunTask);
EXPECT_EQ(stubQueue_->size(), 0);
}

} // namespace facebook::react

0 comments on commit 8f3ffcf

Please sign in to comment.