aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml6
-rw-r--r--tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp26
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml b/tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml
new file mode 100644
index 0000000000..1aefdf0c42
--- /dev/null
+++ b/tests/auto/qml/qqmlexpression/data/expressionFromDataComponent.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+import Test 1.0
+TestObject {
+ scriptString: { return "success"; }
+}
+
diff --git a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
index 12cb2dce83..f53ef82891 100644
--- a/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
+++ b/tests/auto/qml/qqmlexpression/tst_qqmlexpression.cpp
@@ -47,6 +47,7 @@ public:
private slots:
void scriptString();
void syntaxError();
+ void expressionFromDataComponent();
};
class TestObject : public QObject
@@ -108,6 +109,31 @@ void tst_qqmlexpression::syntaxError()
QCOMPARE(v, QVariant());
}
+void tst_qqmlexpression::expressionFromDataComponent()
+{
+ qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
+
+ QQmlEngine engine;
+ QQmlComponent c(&engine);
+
+ QUrl url = testFileUrl("expressionFromDataComponent.qml");
+
+ {
+ QFile f(url.toLocalFile());
+ QVERIFY(f.open(QIODevice::ReadOnly));
+ c.setData(f.readAll(), url);
+ }
+
+ QScopedPointer<TestObject> object;
+ object.reset(qobject_cast<TestObject*>(c.create()));
+ Q_ASSERT(!object.isNull());
+
+ QQmlExpression expression(object->scriptString());
+ QVariant result = expression.evaluate();
+ QVERIFY(result.type() == QVariant::String);
+ QCOMPARE(result.toString(), QStringLiteral("success"));
+}
+
QTEST_MAIN(tst_qqmlexpression)
#include "tst_qqmlexpression.moc"