aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-04-18 01:00:05 +0200
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-04-18 01:00:06 +0200
commitf0f01cc37910a6b1ca454a4374138d76cd09901a (patch)
tree1b112993e5b84f58541c7216d1fcc738271f0ab3 /tests/auto/qml/qqmlecmascript
parent7c3dad14d38aea0239e5e66c9018acdc0e6c0b55 (diff)
parent6069cc1cd1a6309cdffeb8bdd9c4035f33742228 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'tests/auto/qml/qqmlecmascript')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/bindingBoundFunctions.qml34
-rw-r--r--tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml14
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp25
3 files changed, 67 insertions, 6 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/bindingBoundFunctions.qml b/tests/auto/qml/qqmlecmascript/data/bindingBoundFunctions.qml
new file mode 100644
index 0000000000..8dbd2fd3d9
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/bindingBoundFunctions.qml
@@ -0,0 +1,34 @@
+import QtQuick 2.6
+
+QtObject {
+ property bool success: false
+ property var num: 100
+ property var simple: 0
+ property var complex: 0
+
+
+ Component.onCompleted: {
+ function s(x) {
+ return x
+ }
+ function c(x) {
+ return x + num
+ }
+
+ var bound = s.bind(undefined, 100)
+ simple = Qt.binding(bound)
+ if (simple != 100)
+ return;
+ var bound = c.bind(undefined, 100)
+ complex = Qt.binding(bound);
+
+ if (complex != 200)
+ return;
+ num = 0;
+ if (complex != 100)
+ return;
+
+ print("success!!!");
+ success = true;
+ }
+}
diff --git a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
index 5103168fd3..99c49ebf62 100644
--- a/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
+++ b/tests/auto/qml/qqmlecmascript/data/sequenceConversion.array.qml
@@ -10,6 +10,11 @@ Item {
objectName: "msco"
}
+ Component {
+ id: mscoComponent
+ MySequenceConversionObject { }
+ }
+
property bool success: false
property variant intList
@@ -252,4 +257,13 @@ Item {
if (testSequence.valueOf() == prevValueOf) referenceDeletion = false;
if (testSequence.length == prevLength) referenceDeletion = false;
}
+
+ function jsonConversion() {
+ success = true
+ var msco = mscoComponent.createObject()
+ if (JSON.stringify(msco.intListProperty) != "[1,2,3,4]") success = false;
+ if (JSON.stringify(msco.qrealListProperty) != "[1.1,2.2,3.3,4.4]") success = false;
+ if (JSON.stringify(msco.boolListProperty) != "[true,false,true,false]") success = false;
+ if (JSON.stringify(msco.stringListProperty) != "[\"first\",\"second\",\"third\",\"fourth\"]") success = false;
+ }
}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index d5a2456438..619780bcdd 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -289,6 +289,7 @@ private slots:
void withStatement();
void tryStatement();
void replaceBinding();
+ void bindingBoundFunctions();
void deleteRootObjectInCreation();
void onDestruction();
void onDestructionViaGC();
@@ -5562,17 +5563,18 @@ void tst_qqmlecmascript::sequenceConversionArray()
// ensure that in JS the returned sequences act just like normal JS Arrays.
QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
QQmlComponent component(&engine, qmlFile);
- QObject *object = component.create();
+ QScopedPointer<QObject> object(component.create());
QVERIFY(object != nullptr);
- QMetaObject::invokeMethod(object, "indexedAccess");
+ QMetaObject::invokeMethod(object.data(), "indexedAccess");
QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "arrayOperations");
+ QMetaObject::invokeMethod(object.data(), "arrayOperations");
QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "testEqualitySemantics");
+ QMetaObject::invokeMethod(object.data(), "testEqualitySemantics");
QVERIFY(object->property("success").toBool());
- QMetaObject::invokeMethod(object, "testReferenceDeletion");
+ QMetaObject::invokeMethod(object.data(), "testReferenceDeletion");
QCOMPARE(object->property("referenceDeletion").toBool(), true);
- delete object;
+ QMetaObject::invokeMethod(object.data(), "jsonConversion");
+ QVERIFY(object->property("success").toBool());
}
@@ -7246,6 +7248,17 @@ void tst_qqmlecmascript::replaceBinding()
delete obj;
}
+void tst_qqmlecmascript::bindingBoundFunctions()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("bindingBoundFunctions.qml"));
+ QObject *obj = c.create();
+ QVERIFY(obj != nullptr);
+
+ QVERIFY(obj->property("success").toBool());
+ delete obj;
+}
+
void tst_qqmlecmascript::deleteRootObjectInCreation()
{
{