aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qqmldelegatemodel/data/ImageToggle.qml21
-rw-r--r--tests/auto/qml/qqmldelegatemodel/data/contextAccessedByHandler.qml31
-rw-r--r--tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp22
-rw-r--r--tests/auto/qml/qqmlecmascript/data/generatorCallsGC.qml13
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp10
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtbug_89822.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/qtbug_89822.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp7
-rw-r--r--tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml54
9 files changed, 167 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmldelegatemodel/data/ImageToggle.qml b/tests/auto/qml/qqmldelegatemodel/data/ImageToggle.qml
new file mode 100644
index 0000000000..fa154b25f3
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/data/ImageToggle.qml
@@ -0,0 +1,21 @@
+import QtQuick 2.0
+
+Item {
+ property var isSelected: null
+ property string source
+ implicitWidth: 16
+ implicitHeight: 16
+
+ onSourceChanged: {
+ updateImageSource()
+ }
+
+ onIsSelectedChanged: {
+ updateImageSource()
+ }
+
+ function updateImageSource() {
+ let result = isSelected ? source + "_selected_dark.png" : source + "_active_dark.png"
+ }
+
+}
diff --git a/tests/auto/qml/qqmldelegatemodel/data/contextAccessedByHandler.qml b/tests/auto/qml/qqmldelegatemodel/data/contextAccessedByHandler.qml
new file mode 100644
index 0000000000..46d7524527
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/data/contextAccessedByHandler.qml
@@ -0,0 +1,31 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ width: 640
+ height: 480
+ property bool works: myView.currentItem.okay
+
+ ListView {
+ id: myView
+ model: myModel
+ anchors.fill: parent
+ delegate: Row {
+ property alias okay: image.isSelected
+ ImageToggle {
+ id: image
+ source: "glyph_16_arrow_patch"
+ isSelected: model.age < 6
+ }
+ Text {
+ text: "age:" + model.age + " selected:" + image.isSelected
+ }
+ }
+ }
+
+ ListModel {
+ id: myModel
+ ListElement { type: "Cat"; age: 3; }
+ ListElement { type: "Dog"; age: 2; }
+ }
+}
diff --git a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
index 9bc359d243..35f1e2c94d 100644
--- a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+++ b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
@@ -46,6 +46,7 @@ private slots:
void valueWithoutCallingObjectFirst();
void filterOnGroup_removeWhenCompleted();
void qtbug_86017();
+ void contextAccessedByHandler();
};
class AbstractItemModel : public QAbstractItemModel
@@ -164,6 +165,27 @@ void tst_QQmlDelegateModel::qtbug_86017()
QCOMPARE(model->filterGroup(), "selected");
}
+void tst_QQmlDelegateModel::filterOnGroup_removeWhenCompleted()
+{
+ QQuickView view(testFileUrl("removeFromGroup.qml"));
+ QCOMPARE(view.status(), QQuickView::Ready);
+ view.show();
+ QQuickItem *root = view.rootObject();
+ QVERIFY(root);
+ QQmlDelegateModel *model = root->findChild<QQmlDelegateModel*>();
+ QVERIFY(model);
+ QVERIFY(QTest::qWaitFor([=]{ return model->count() == 2; }));
+}
+
+void tst_QQmlDelegateModel::contextAccessedByHandler()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("contextAccessedByHandler.qml"));
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(root, qPrintable(component.errorString()));
+ QVERIFY(root->property("works").toBool());
+}
+
QTEST_MAIN(tst_QQmlDelegateModel)
#include "tst_qqmldelegatemodel.moc"
diff --git a/tests/auto/qml/qqmlecmascript/data/generatorCallsGC.qml b/tests/auto/qml/qqmlecmascript/data/generatorCallsGC.qml
new file mode 100644
index 0000000000..7fe366cac8
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/generatorCallsGC.qml
@@ -0,0 +1,13 @@
+import QtQml 2.15
+
+QtObject {
+ function test_generator_gc() {
+ ((function*() { gc() })()).next();
+ ((function*() { gc() })()).next();
+ ((function*() { gc() })()).next();
+ ((function*() { gc() })()).next();
+ }
+
+ Component.onCompleted: () => test_generator_gc()
+
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 3c3a2a7a99..7da1b2c500 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -240,6 +240,7 @@ private slots:
void function();
void topLevelGeneratorFunction();
void generatorCrashNewProperty();
+ void generatorCallsGC();
void qtbug_10696();
void qtbug_11606();
void qtbug_11600();
@@ -6505,6 +6506,15 @@ void tst_qqmlecmascript::generatorCrashNewProperty()
QCOMPARE(o->property("c").toInt(), 42);
}
+void tst_qqmlecmascript::generatorCallsGC()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("generatorCallsGC.qml"));
+
+ QScopedPointer<QObject> o(component.create()); // should not crash
+ QVERIFY2(o != nullptr, qPrintable(component.errorString()));
+}
+
// Test the "Qt.include" method
void tst_qqmlecmascript::include()
{
diff --git a/tests/auto/qml/qqmllanguage/data/qtbug_89822.errors.txt b/tests/auto/qml/qqmllanguage/data/qtbug_89822.errors.txt
new file mode 100644
index 0000000000..d69122ef8b
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/qtbug_89822.errors.txt
@@ -0,0 +1 @@
+6:40:Invalid alias target
diff --git a/tests/auto/qml/qqmllanguage/data/qtbug_89822.qml b/tests/auto/qml/qqmllanguage/data/qtbug_89822.qml
new file mode 100644
index 0000000000..17602ca4b9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/qtbug_89822.qml
@@ -0,0 +1,8 @@
+import QtQml 2.0
+
+QtObject {
+ id: root
+ readonly property QtObject test: QtObject { property int subproperty: 3}
+ readonly property alias testAlias: root.test.subproperty
+}
+
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index 94ecd6862a..31bf30c57c 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -146,6 +146,7 @@ private slots:
void aliasProperties();
void aliasPropertiesAndSignals();
void aliasPropertyChangeSignals();
+ void qtbug_89822();
void componentCompositeType();
void i18n();
void i18n_data();
@@ -2232,6 +2233,12 @@ void tst_qqmllanguage::aliasPropertiesAndSignals()
QCOMPARE(o->property("test").toBool(), true);
}
+void tst_qqmllanguage::qtbug_89822()
+{
+ QQmlComponent component(&engine, testFileUrl("qtbug_89822.qml"));
+ VERIFY_ERRORS("qtbug_89822.errors.txt");
+}
+
// Test that the root element in a composite type can be a Component
void tst_qqmllanguage::componentCompositeType()
{
diff --git a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml
index aa26956922..09f1d472b7 100644
--- a/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml
+++ b/tests/auto/qml/qqmlvaluetypes/data/matrix4x4_invokables.qml
@@ -10,6 +10,59 @@ Item {
property variant v2: Qt.vector3d(1,2,3)
property real factor: 2.23
+ function testTransformation() {
+ let m = Qt.matrix4x4();
+
+ m.scale(1, 2, 4);
+ if (m !== Qt.matrix4x4(1, 0, 0, 0,
+ 0, 2, 0, 0,
+ 0, 0, 4, 0,
+ 0, 0, 0, 1))
+ return false;
+ m.scale(Qt.vector3d(-8, -4, -2));
+ if (m !== Qt.matrix4x4(-8, 0, 0, 0,
+ 0,-8, 0, 0,
+ 0, 0, -8, 0,
+ 0, 0, 0, 1))
+ return false;
+ m.scale(-1 / 8);
+ if (m !== Qt.matrix4x4())
+ return false;
+
+ m.rotate(180, Qt.vector3d(1, 0, 0));
+ if (m !== Qt.matrix4x4(1, 0, 0, 0,
+ 0, -1, 0, 0,
+ 0, 0, -1, 0,
+ 0, 0, 0, 1))
+ return false;
+ m.rotate(180, Qt.vector3d(0, 1, 0));
+ if (m !== Qt.matrix4x4(-1, 0, 0, 0,
+ 0, -1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1))
+ return false;
+ m.rotate(180, Qt.vector3d(0, 0, 1));
+ if (m !== Qt.matrix4x4())
+ return false;
+
+ m.translate(Qt.vector3d(1, 2, 4));
+ if (m !== Qt.matrix4x4(1, 0, 0, 1,
+ 0, 1, 0, 2,
+ 0, 0, 1, 4,
+ 0, 0, 0, 1))
+ return false;
+
+ m = Qt.matrix4x4();
+ m.lookAt(Qt.vector3d(1, 2, 4), Qt.vector3d(1, 2, 0), Qt.vector3d(0, 1, 0));
+ if (m !== Qt.matrix4x4(1, 0, 0, -1,
+ 0, 1, 0, -2,
+ 0, 0, 1, -4,
+ 0, 0, 0, 1))
+ return false;
+
+ return true;
+ }
+
Component.onCompleted: {
success = true;
if (m1.times(m2) != Qt.matrix4x4(26, 26, 26, 26, 52, 52, 52, 52, 78, 78, 78, 78, 104, 104, 104, 104)) success = false;
@@ -27,5 +80,6 @@ Item {
if (m1.transposed() != Qt.matrix4x4(1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4)) success = false;
if (m1.fuzzyEquals(m2)) success = false;
if (!m1.fuzzyEquals(m2, 10)) success = false;
+ if (!testTransformation()) success = false;
}
}