summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-08-30 13:31:09 +0000
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-02 03:47:47 +0430
commitb5a145b46677dd0853ffa65842a2a6cfe06ca061 (patch)
tree18d3ed4af8f5afc29f8ef8357c9b181b2e85ab8a
parent749f62860e4b8406c4059107bd2c2ba63119d3ce (diff)
downloadserenity-b5a145b46677dd0853ffa65842a2a6cfe06ca061.zip
Tests: Add tests for Core::deferred_invoke
-rw-r--r--Tests/LibCore/CMakeLists.txt1
-rw-r--r--Tests/LibCore/TestLibCoreDeferredInvoke.cpp25
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();
+}