aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlengine
diff options
context:
space:
mode:
authorMatthew Vogt <matthew.vogt@nokia.com>2012-05-21 13:40:22 +1000
committerQt by Nokia <qt-info@nokia.com>2012-05-21 11:22:43 +0200
commitf16f4c3b78eb0138b2dca455f702b9335eb03f40 (patch)
tree323af783bc8cc4c132d6e6b8e24c207dae67b0b8 /tests/auto/qml/qqmlengine
parent65500896a05344bdfd5fcbfa9a6456f48cd4e4a4 (diff)
Ensure repeated compilation does not fail
Failure could result from the allocation of an address previously used for the same class. The test is repeated for a surprisingly large count of repetitions to increase the chance of this occurring. Change-Id: I045902c50021f23adbbd61fccf41b9c38657387a Reviewed-by: Chris Adams <christopher.adams@nokia.com>
Diffstat (limited to 'tests/auto/qml/qqmlengine')
-rw-r--r--tests/auto/qml/qqmlengine/data/failedCompilation.1.qml4
-rw-r--r--tests/auto/qml/qqmlengine/data/repeatedCompilation.qml9
-rw-r--r--tests/auto/qml/qqmlengine/tst_qqmlengine.cpp43
3 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/data/failedCompilation.1.qml b/tests/auto/qml/qqmlengine/data/failedCompilation.1.qml
new file mode 100644
index 0000000000..0bd3cd0254
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/data/failedCompilation.1.qml
@@ -0,0 +1,4 @@
+// No imports - intentional
+
+Item {
+}
diff --git a/tests/auto/qml/qqmlengine/data/repeatedCompilation.qml b/tests/auto/qml/qqmlengine/data/repeatedCompilation.qml
new file mode 100644
index 0000000000..797381e54c
--- /dev/null
+++ b/tests/auto/qml/qqmlengine/data/repeatedCompilation.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+VMEExtendVMEComponent {
+ property bool success: false
+
+ Component.onCompleted: {
+ success = (foo == 'bar') && (bar == 'baz')
+ }
+}
diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
index 727635ee2c..85c32d8118 100644
--- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
+++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp
@@ -69,6 +69,9 @@ private slots:
void clearComponentCache();
void trimComponentCache();
void trimComponentCache_data();
+ void repeatedCompilation();
+ void failedCompilation();
+ void failedCompilation_data();
void outputWarningsToStandardError();
void objectOwnership();
void multipleEngines();
@@ -372,6 +375,46 @@ void tst_qqmlengine::trimComponentCache_data()
QTest::newRow("ScriptComponent") << "testScriptComponent.qml";
}
+void tst_qqmlengine::repeatedCompilation()
+{
+ QQmlEngine engine;
+
+ for (int i = 0; i < 100; ++i) {
+ engine.collectGarbage();
+ engine.trimComponentCache();
+
+ QQmlComponent component(&engine, testFileUrl("repeatedCompilation.qml"));
+ QVERIFY(component.isReady());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object != 0);
+ QCOMPARE(object->property("success").toBool(), true);
+ }
+}
+
+void tst_qqmlengine::failedCompilation()
+{
+ QFETCH(QString, file);
+
+ QQmlEngine engine;
+
+ QQmlComponent component(&engine, testFileUrl(file));
+ QVERIFY(!component.isReady());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object == 0);
+
+ engine.collectGarbage();
+ engine.trimComponentCache();
+ engine.clearComponentCache();
+}
+
+void tst_qqmlengine::failedCompilation_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QTest::newRow("Invalid URL") << "failedCompilation.does.not.exist.qml";
+ QTest::newRow("Invalid content") << "failedCompilation.1.qml";
+}
+
static QStringList warnings;
static void msgHandler(QtMsgType, const char *warning)
{