diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-03-11 12:57:46 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-03-11 12:57:46 -0400 |
commit | 199907fa280cb3d1ea5a27dbe94e69df9256c101 (patch) | |
tree | d2f9dda3cc0cdff66b85d3247db3130edf36f973 /indra | |
parent | 4a8ea879fa62c0131985f625e940c5bc0b3fec46 (diff) |
Add llluamanager_test test exercising leap.WaitFor.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/tests/llluamanager_test.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/indra/newview/tests/llluamanager_test.cpp b/indra/newview/tests/llluamanager_test.cpp index 1c2be900d3..36b8bb046a 100644 --- a/indra/newview/tests/llluamanager_test.cpp +++ b/indra/newview/tests/llluamanager_test.cpp @@ -28,6 +28,7 @@ #include "lluri.h" #include "lluuid.h" #include "lua_function.h" +#include "lualistener.h" #include "stringize.h" class LLTestApp : public LLApp @@ -309,10 +310,44 @@ namespace tut set_test_name("test leap.lua"); const std::string lua( "-- test leap.lua\n" + "\n" "leap = require('leap')\n" + "\n" + "-- negative priority ensures catchall is always last\n" + "catchall = leap.WaitFor:new(-1, 'catchall')\n" + "function catchall:filter(pump, data)\n" + " return data\n" + "end\n" + "\n" + "-- but first, catch events with 'special' key\n" + "catch_special = leap.WaitFor:new(2, 'catch_special')\n" + "function catch_special:filter(pump, data)\n" + " return if data['special'] ~= nil then data else nil\n" + "end\n" + "\n" + "function drain(waitfor)\n" + " print(waitfor.name .. ' start')\n" + " for item in waitfor.wait, waitfor do\n" + " print(waitfor.name .. ' caught', item)\n" + " end\n" + " print(waitfor.name .. ' done')\n" + "end\n" + "\n" + "co_all = coroutine.create(drain)\n" + "co_special = coroutine.create(drain)\n" + "coroutine.resume(co_all, catchall)\n" + "coroutine.resume(co_special, catch_special)\n" + "\n" + "leap.process()\n" ); LuaState L; auto future = LLLUAmanager::startScriptLine(L, lua); + auto replyname{ L.obtainListener()->getReplyName() }; + auto& replypump{ LLEventPumps::instance().obtain(replyname) }; + replypump.post(llsd::map("special", "K")); + replypump.post(llsd::map("name", "not special")); + // tell leap.process() we're done + replypump.post(LLSD()); auto [count, result] = future.get(); ensure_equals("leap.lua: " + result.asString(), count, 0); } |