mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 15:17:45 +00:00
Tests: Add tests for Core::deferred_invoke
This commit is contained in:
parent
749f62860e
commit
b5a145b466
2 changed files with 26 additions and 0 deletions
|
@ -3,6 +3,7 @@ set(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreArgsParser.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreArgsParser.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreFileWatcher.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreFileWatcher.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreIODevice.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreIODevice.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreDeferredInvoke.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(source ${TEST_SOURCES})
|
foreach(source ${TEST_SOURCES})
|
||||||
|
|
25
Tests/LibCore/TestLibCoreDeferredInvoke.cpp
Normal file
25
Tests/LibCore/TestLibCoreDeferredInvoke.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <AK/Format.h>
|
||||||
|
#include <LibCore/EventLoop.h>
|
||||||
|
#include <LibCore/Timer.h>
|
||||||
|
#include <LibTest/TestCase.h>
|
||||||
|
|
||||||
|
TEST_CASE(deferred_invoke)
|
||||||
|
{
|
||||||
|
Core::EventLoop event_loop;
|
||||||
|
auto reaper = Core::Timer::create_single_shot(250, [] {
|
||||||
|
warnln("I waited for the deferred_invoke to happen, but it never did!");
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
|
});
|
||||||
|
|
||||||
|
Core::deferred_invoke([&event_loop] {
|
||||||
|
event_loop.quit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
event_loop.exec();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue