From 96727d6e63ca927f3c7b68d4baa4fe672a4dcd0b Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Wed, 2 Apr 2025 20:49:49 +0530 Subject: Add events system for lua runtime to dispatch and register events --- spec/testUtils.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/testUtils.cpp') diff --git a/spec/testUtils.cpp b/spec/testUtils.cpp index cea7a3d..8f348bd 100644 --- a/spec/testUtils.cpp +++ b/spec/testUtils.cpp @@ -1,3 +1,4 @@ +#include "LuaRuntime.hpp" #include #include #include @@ -22,3 +23,14 @@ int run_all_tests() { get_qtest_registry().clear(); return exit_code; } + +bool wait_for_lua_to_be_true(QString lua_code) { + return QTest::qWaitFor([&lua_code]() { + auto &lua = LuaRuntime::instance(); + QSignalSpy evaluation_completed_spy(&lua, + &LuaRuntime::evaluation_completed); + lua.evaluate(lua_code); + evaluation_completed_spy.wait(); + return evaluation_completed_spy.first().first().toBool(); + }); +} -- cgit v1.3.1