summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-07-16 11:56:20 +0200
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-07-27 12:38:21 +0300
commit54ae74b4f82bb4660dbd75a8d276ad0ddb1100a4 (patch)
treefb67feed20a668e3971c5e7a74b14a23a14bf24c /tests
parentf076870bf254ea152cb186133c7ba7a3b6578119 (diff)
Fix memory leak of the data model.
Change-Id: Ibc92b6615399963b8ba01b5288624e4ed9674138 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/scion/tst_scion.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/auto/scion/tst_scion.cpp b/tests/auto/scion/tst_scion.cpp
index 9b1d0f9..88f3d4d 100644
--- a/tests/auto/scion/tst_scion.cpp
+++ b/tests/auto/scion/tst_scion.cpp
@@ -21,6 +21,7 @@
#include <QScxml/scxmlparser.h>
#include <QScxml/ecmascriptdatamodel.h>
+#include <QScxml/nulldatamodel.h>
#include "scxml/scion.h"
#include "scxml/compiled_tests.h"
@@ -226,15 +227,26 @@ void TestScion::dynamic()
QVERIFY(parser.errors().isEmpty());
scxmlFile.close();
- auto table = parser.instantiateStateMachine();
- if (table == nullptr && testStatus == TestFails) {
+ QScopedPointer<StateTable> table(parser.instantiateStateMachine());
+ if (table == Q_NULLPTR && testStatus == TestFails) {
QEXPECT_FAIL("", "This is expected to fail", Abort);
}
- QVERIFY(table != nullptr);
+ QVERIFY(table != Q_NULLPTR);
+ switch (parser.dataModel()) {
+ case ScxmlParser::NullDataModel:
+ table->setDataModel(new NullDataModel(table.data()));
+ break;
+ case ScxmlParser::EcmaScriptDataModel:
+ table->setDataModel(new EcmaScriptDataModel(table.data()));
+ break;
+ default:
+ QFAIL("Unknown datamodel");
+ }
if (testStatus == TestFails)
QEXPECT_FAIL("", "This is expected to fail", Abort);
- QVERIFY(runTest(table, testDescription.object()));
+ QVERIFY(runTest(table.data(), testDescription.object()));
+ delete table->dataModel();
}
static QStringList getStates(const QJsonObject &obj, const QString &key)
@@ -272,7 +284,7 @@ void TestScion::compiled()
auto testDescription = QJsonDocument::fromJson(jsonFile.readAll());
jsonFile.close();
- auto table = creator();
+ QScopedPointer<Scxml::StateTable> table(creator());
if (table == Q_NULLPTR && testStatus == TestFails) {
QEXPECT_FAIL("", "This is expected to fail", Abort);
}
@@ -280,7 +292,7 @@ void TestScion::compiled()
if (testStatus == TestFails)
QEXPECT_FAIL("", "This is expected to fail", Abort);
- QVERIFY(runTest(table, testDescription.object()));
+ QVERIFY(runTest(table.data(), testDescription.object()));
}
static bool verifyStates(StateTable *stateMachine, const QJsonObject &stateDescription, const QString &key, int counter)