diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/LibCore/TestLibCoreDeferredInvoke.cpp | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/Tests/LibCore/CMakeLists.txt b/Tests/LibCore/CMakeLists.txt index fee06664c7..5143662458 100644 --- a/Tests/LibCore/CMakeLists.txt +++ b/Tests/LibCore/CMakeLists.txt @@ -3,6 +3,7 @@ set( ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreArgsParser.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreFileWatcher.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreIODevice.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TestLibCoreDeferredInvoke.cpp ) foreach(source ${TEST_SOURCES}) diff --git a/Tests/LibCore/TestLibCoreDeferredInvoke.cpp b/Tests/LibCore/TestLibCoreDeferredInvoke.cpp new file mode 100644 index 0000000000..097d22ab5e --- /dev/null +++ b/Tests/LibCore/TestLibCoreDeferredInvoke.cpp @@ -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(); +} |