1616
1717#include < QtCore/QScopedPointer>
1818#include < QtCore/QEventLoop>
19+ #include < QtCore/QFile>
20+ #include < QtCore/QTimer>
1921
2022#include < QtScript/QScriptContext>
2123#include < QtScript/QScriptEngine>
@@ -70,6 +72,13 @@ void TrikScriptRunnerTest::runFromFile(const QString &fileName)
7072 run (fileContents);
7173}
7274
75+ void TrikScriptRunnerTest::wait (int msec)
76+ {
77+ QEventLoop waitingLoop;
78+ QTimer::singleShot (msec, &waitingLoop, SLOT (quit ()));
79+ waitingLoop.exec ();
80+ }
81+
7382TEST_F (TrikScriptRunnerTest, sanityCheck)
7483{
7584 run (" 1 + 1" );
@@ -79,3 +88,23 @@ TEST_F(TrikScriptRunnerTest, fileTest)
7988{
8089 runFromFile (" file-test.js" );
8190}
91+
92+ TEST_F (TrikScriptRunnerTest, asyncSystemTest)
93+ {
94+ QFile testFile (" test" );
95+ testFile.remove ();
96+ ASSERT_FALSE (testFile.exists ());
97+ runFromFile (" async-system-test.js" );
98+ ASSERT_FALSE (testFile.exists ());
99+ wait (2100 );
100+ ASSERT_TRUE (testFile.exists ());
101+ }
102+
103+ TEST_F (TrikScriptRunnerTest, syncSystemTest)
104+ {
105+ QFile testFile (" test" );
106+ testFile.remove ();
107+ ASSERT_FALSE (testFile.exists ());
108+ runFromFile (" sync-system-test.js" );
109+ ASSERT_TRUE (testFile.exists ());
110+ }
0 commit comments