aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qmltyperegistrar/foreign/foreign.pro1
-rw-r--r--tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro7
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/Required.qml6
-rw-r--r--tests/auto/qml/qqmlapplicationengine/data/requiredViolation.qml3
-rw-r--r--tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp18
-rw-r--r--tests/auto/qml/qqmldelegatemodel/data/removeFromGroup.qml45
-rw-r--r--tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro2
-rw-r--r--tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp15
-rw-r--r--tests/auto/qml/qqmlecmascript/data/generatorCrashNewProperty.qml20
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp16
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp33
-rw-r--r--tests/auto/qml/qqmllanguage/data/Tab1.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/bareInline.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp28
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp10
15 files changed, 219 insertions, 3 deletions
diff --git a/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro b/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
index 87521eac43..006439b58a 100644
--- a/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
+++ b/tests/auto/qml/qmltyperegistrar/foreign/foreign.pro
@@ -2,7 +2,6 @@ TEMPLATE = lib
QT = core
macos:CONFIG -= app_bundle
-CONFIG -= debug_and_release_target
SOURCES = foreign.cpp
HEADERS = foreign.h
diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
index fe21b122c2..3589743f0c 100644
--- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
+++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.pro
@@ -17,4 +17,9 @@ QML_IMPORT_NAME = QmlTypeRegistrarTest
QML_IMPORT_VERSION = 1.0
INCLUDEPATH += foreign
-LIBS += -Lforeign -lforeign
+debug_and_release {
+ CONFIG(release, debug|release): LIBS += -Lforeign/release -lforeign
+ else: LIBS += -Lforeign/debug -lforeign
+} else {
+ LIBS += -Lforeign -lforeign
+}
diff --git a/tests/auto/qml/qqmlapplicationengine/data/Required.qml b/tests/auto/qml/qqmlapplicationengine/data/Required.qml
new file mode 100644
index 0000000000..acf4a00ce6
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/Required.qml
@@ -0,0 +1,6 @@
+import QtQml 2.15
+
+QtObject
+{
+ required property int foo
+}
diff --git a/tests/auto/qml/qqmlapplicationengine/data/requiredViolation.qml b/tests/auto/qml/qqmlapplicationengine/data/requiredViolation.qml
new file mode 100644
index 0000000000..c5de4661a9
--- /dev/null
+++ b/tests/auto/qml/qqmlapplicationengine/data/requiredViolation.qml
@@ -0,0 +1,3 @@
+import QtQml 2.15
+
+Required {}
diff --git a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
index f636e527c3..4306c7b8ca 100644
--- a/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
+++ b/tests/auto/qml/qqmlapplicationengine/tst_qqmlapplicationengine.cpp
@@ -56,6 +56,7 @@ private slots:
void translationChange();
void setInitialProperties();
void failureToLoadTriggersWarningSignal();
+ void errorWhileCreating();
private:
QString buildDir;
@@ -333,6 +334,23 @@ void tst_qqmlapplicationengine::failureToLoadTriggersWarningSignal()
QTRY_COMPARE(warningObserver.count(), 1);
}
+void tst_qqmlapplicationengine::errorWhileCreating()
+{
+ auto url = testFileUrl("requiredViolation.qml");
+ QQmlApplicationEngine test;
+ QSignalSpy observer(&test, &QQmlApplicationEngine::objectCreated);
+
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlApplicationEngine failed to create component");
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, qPrintable(QStringLiteral("%1:5:5: Required property foo was not initialized").arg(testFileUrl("Required.qml").toString())));
+
+ test.load(url);
+
+ QTRY_COMPARE(observer.count(), 1);
+ QList<QVariant> args = observer.takeFirst();
+ QVERIFY(args.at(0).isNull());
+ QCOMPARE(args.at(1).toUrl(), url);
+}
+
QTEST_MAIN(tst_qqmlapplicationengine)
#include "tst_qqmlapplicationengine.moc"
diff --git a/tests/auto/qml/qqmldelegatemodel/data/removeFromGroup.qml b/tests/auto/qml/qqmldelegatemodel/data/removeFromGroup.qml
new file mode 100644
index 0000000000..4ae1a8aacc
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/data/removeFromGroup.qml
@@ -0,0 +1,45 @@
+import QtQuick 2.8
+import QtQml.Models 2.1
+
+Item {
+ id: root
+ width: 200
+ height: 200
+
+ DelegateModel {
+ id: visualModel
+ model: ListModel {
+ id: myLM
+ ListElement {
+ name: "Apple"
+ }
+ ListElement {
+ name: "Banana"
+ }
+ ListElement {
+ name: "Orange"
+ }
+ }
+ filterOnGroup: "selected"
+ groups: [
+ DelegateModelGroup {
+ name: "selected"
+ includeByDefault: true
+ }
+ ]
+ delegate: Text {
+ Component.onCompleted: {
+ if (index === 1) {
+ DelegateModel.inSelected = false
+ }
+ }
+ text: index + ": " + model.name
+ }
+ }
+
+ // Needs an actual ListView in order for the DelegateModel to instantiate all items
+ ListView {
+ model: visualModel
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro b/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro
index 7fdd3ab5f1..fbd72f6a44 100644
--- a/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro
+++ b/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro
@@ -2,7 +2,7 @@ CONFIG += testcase
TARGET = tst_qqmldelegatemodel
macos:CONFIG -= app_bundle
-QT += qml testlib core-private qml-private qmlmodels-private
+QT += qml quick testlib core-private qml-private qmlmodels-private
SOURCES += tst_qqmldelegatemodel.cpp
diff --git a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
index 87f42c0c8a..71550a50f3 100644
--- a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
+++ b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
@@ -29,6 +29,8 @@
#include <QtTest/qtest.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQmlModels/private/qqmldelegatemodel_p.h>
+#include <QtQuick/qquickview.h>
+#include <QtQuick/qquickitem.h>
#include "../../shared/util.h"
@@ -42,6 +44,7 @@ public:
private slots:
void valueWithoutCallingObjectFirst_data();
void valueWithoutCallingObjectFirst();
+ void filterOnGroup_removeWhenCompleted();
};
class AbstractItemModel : public QAbstractItemModel
@@ -134,6 +137,18 @@ void tst_QQmlDelegateModel::valueWithoutCallingObjectFirst()
QCOMPARE(model->variantValue(index, role), expectedValue);
}
+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);
+ QTest::qWaitFor([=]{ return model->count() == 2; } );
+}
+
QTEST_MAIN(tst_QQmlDelegateModel)
#include "tst_qqmldelegatemodel.moc"
diff --git a/tests/auto/qml/qqmlecmascript/data/generatorCrashNewProperty.qml b/tests/auto/qml/qqmlecmascript/data/generatorCrashNewProperty.qml
new file mode 100644
index 0000000000..f775b4c613
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/generatorCrashNewProperty.qml
@@ -0,0 +1,20 @@
+// QTBUG-91491
+import QtQml 2.15
+
+QtObject {
+ property int a: 42
+ property int b: 0
+ property int c: 0
+
+ function f(myfunc) {
+ let gen = myfunc();
+ gen["u"] = 0 // Adding members to the generator used to cause crashes when calling next()
+ c = gen.next().value
+ }
+
+ function refreshA() {
+ f(function*() { b = 12; return a });
+ }
+
+ Component.onCompleted: refreshA();
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 9198d3bebf..3c3a2a7a99 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -239,6 +239,7 @@ private slots:
void eval();
void function();
void topLevelGeneratorFunction();
+ void generatorCrashNewProperty();
void qtbug_10696();
void qtbug_11606();
void qtbug_11600();
@@ -6489,6 +6490,21 @@ void tst_qqmlecmascript::topLevelGeneratorFunction()
QCOMPARE(it.property("next").callWithInstance(it).property("value").toInt(), 1);
}
+// QTBUG-91491
+void tst_qqmlecmascript::generatorCrashNewProperty()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("generatorCrashNewProperty.qml"));
+
+ QScopedPointer<QObject> o(component.create());
+
+ QVERIFY2(o != nullptr, qPrintable(component.errorString()));
+
+ QCOMPARE(o->property("a").toInt(), 42);
+ QCOMPARE(o->property("b").toInt(), 12);
+ QCOMPARE(o->property("c").toInt(), 42);
+}
+
// Test the "Qt.include" method
void tst_qqmlecmascript::include()
{
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
index 549aae8c2b..25adf4f31d 100644
--- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -71,6 +71,7 @@ private slots:
void contextDelete();
void garbageCollection();
void requiredProperties();
+ void deleteInSetInitialState();
private:
QQmlIncubationController controller;
@@ -1213,6 +1214,38 @@ void tst_qqmlincubator::requiredProperties()
}
}
+class DeletingIncubator : public QQmlIncubator
+{
+
+
+ // QQmlIncubator interface
+protected:
+ void statusChanged(Status) override
+ {
+
+ }
+ void setInitialState(QObject *obj) override
+ {
+ delete obj;
+ clear();
+ }
+};
+
+void tst_qqmlincubator::deleteInSetInitialState()
+{
+ QQmlComponent component(&engine, testFileUrl("requiredProperty.qml"));
+ QVERIFY(component.isReady());
+ // forceCompletion immediately after creating an asynchronous object completes it
+ DeletingIncubator incubator;
+ incubator.setInitialProperties({{"requiredProperty", 42}});
+ QVERIFY(incubator.isNull());
+ component.create(incubator);
+ QVERIFY(incubator.isLoading());
+ incubator.forceCompletion(); // no crash
+ QVERIFY(incubator.isNull());
+ QCOMPARE(incubator.object(), nullptr); // object was deleted
+}
+
QTEST_MAIN(tst_qqmlincubator)
#include "tst_qqmlincubator.moc"
diff --git a/tests/auto/qml/qqmllanguage/data/Tab1.qml b/tests/auto/qml/qqmllanguage/data/Tab1.qml
new file mode 100644
index 0000000000..e1cd6d8c34
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/Tab1.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.15
+
+Item {
+ component LeftTab: Item {
+ }
+
+ component RightTab: Item {
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/bareInline.qml b/tests/auto/qml/qqmllanguage/data/bareInline.qml
new file mode 100644
index 0000000000..cb79021250
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/bareInline.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.9
+
+Item {
+ width: 800
+ height: 600
+ visible: true
+
+ Tab1.RightTab {}
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index e247a139ec..de8b2ef7eb 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -48,6 +48,7 @@
#include <private/qqmlscriptstring_p.h>
#include <private/qqmlvmemetaobject_p.h>
#include <private/qqmlcomponent_p.h>
+#include <private/qqmltype_p_p.h>
#include "testtypes.h"
#include "testhttpserver.h"
@@ -331,6 +332,7 @@ private slots:
void arrayToContainer();
void qualifiedScopeInCustomParser();
void accessNullPointerPropertyCache();
+ void bareInlineComponent();
private:
QQmlEngine engine;
@@ -5813,6 +5815,32 @@ void tst_qqmllanguage::accessNullPointerPropertyCache()
QVERIFY(!obj.isNull());
}
+void tst_qqmllanguage::bareInlineComponent()
+{
+ QQmlEngine engine;
+
+ QQmlComponent c(&engine, testFileUrl("bareInline.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> o(c.create());
+ QVERIFY(!o.isNull());
+
+ QQmlMetaType::freeUnusedTypesAndCaches();
+
+ bool tab1Found = false;
+ const auto types = QQmlMetaType::qmlTypes();
+ for (const QQmlType &type : types) {
+ if (type.elementName() == QStringLiteral("Tab1")) {
+ QVERIFY(type.module().isEmpty());
+ tab1Found = true;
+ const auto ics = type.priv()->objectIdToICType;
+ QVERIFY(ics.size() > 0);
+ for (const QQmlType &ic : ics)
+ QVERIFY(ic.containingType() == type);
+ }
+ }
+ QVERIFY(tab1Found);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 8a96fc52c5..5363cc8fcb 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -164,6 +164,8 @@ private slots:
void nestedQQmlPropertyMap();
void underscorePropertyChangeHandler();
+
+ void signalExpressionWithoutObject();
private:
QQmlEngine engine;
};
@@ -2210,6 +2212,14 @@ void tst_qqmlproperty::underscorePropertyChangeHandler()
QVERIFY(changeHandler.isSignalProperty());
}
+void tst_qqmlproperty::signalExpressionWithoutObject()
+{
+ QQmlProperty invalid;
+ QQmlPropertyPrivate::setSignalExpression(invalid, nullptr);
+ QQmlBoundSignalExpression *expr = QQmlPropertyPrivate::signalExpression(invalid);
+ QVERIFY(!expr);
+}
+
QTEST_MAIN(tst_qqmlproperty)
#include "tst_qqmlproperty.moc"