Showing the changes to tests/script-engine/src/ScriptEngineTests.cpp (1 of 1 file). Show all
Unified · Split
| @@ -250,7 +250,25 @@ void ScriptEngineTests::testRaiseExceptionAndCatch() { · 249 unmodified lines | |||
| 250 | 250 | ||
| 251 | 251 | ||
| 252 | void ScriptEngineTests::testSignal() { | 252 | void ScriptEngineTests::testSignal() { |
| 253 | QString script = | ||
| 254 | "var count = 0;" | ||
| 255 | "Script.update.connect(function(deltaTime) {" | ||
| 256 | " count++;" | ||
| 257 | " print(deltaTime);" | ||
| 258 | " if (count >= 10) {" | ||
| 259 | " Script.stop(true);" | ||
| 260 | " }" | ||
| 261 | "});"; | ||
| 262 | |||
| 263 | QStringList printed; | ||
| 264 | auto sm = makeManager(script, "testSignal.js"); | ||
| 265 | |||
| 266 | connect(sm.get(), &ScriptManager::printedMessage, [&printed](const QString& message, const QString& engineName){ | ||
| 267 | printed.append(message); | ||
| 268 | }); | ||
| 253 | 269 | ||
| 270 | sm->run(); | ||
| 271 | QVERIFY(printed.length() >= 10); | ||
| 254 | } | 272 | } |
| 255 | 273 | ||
| 256 | 274 | ||