aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-11-18 16:15:01 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2019-11-25 15:34:40 +0100
commitf1f395b37da163bce2dc3b5fc4e298bb4f56a3e7 (patch)
tree9ce2ba89a86ed754a8ecb8f52181770853e21a08 /tests
parentba494aaa24defe1401f621b791891e696b308756 (diff)
parent0ee087f5a5edd7d1aa39fd15e0dc85985320c09a (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/quit.js4
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/data/quitInJS.qml41
-rw-r--r--tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp48
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp1
-rw-r--r--tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml7
-rw-r--r--tests/auto/qml/qmlcachegen/qmlcachegen.pro3
-rw-r--r--tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp10
-rw-r--r--tests/auto/qml/qmllint/data/esmodule.mjs2
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
-rw-r--r--tests/auto/qml/qmlmin/tst_qmlmin.cpp1
-rw-r--r--tests/auto/qml/qmlplugindump/data/dumper/Imports/Derived.qml6
-rw-r--r--tests/auto/qml/qmlplugindump/data/dumper/Imports/imports.pro2
-rw-r--r--tests/auto/qml/qmlplugindump/data/dumper/Imports/plugins.qmltypes10
-rw-r--r--tests/auto/qml/qmlplugindump/data/dumper/Imports/qmldir1
-rw-r--r--tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml14
-rw-r--r--tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp11
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp25
-rw-r--r--tests/auto/qml/qqmldelegatemodel/data/abstractItemModel.qml37
-rw-r--r--tests/auto/qml/qqmldelegatemodel/data/integerModel.qml35
-rw-r--r--tests/auto/qml/qqmldelegatemodel/data/listModel.qml45
-rw-r--r--tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro13
-rw-r--r--tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp139
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp8
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp21
-rw-r--r--tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp66
-rw-r--r--tests/auto/qml/qqmlitemmodels/qtestmodel.h2
-rw-r--r--tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml5
-rw-r--r--tests/auto/qml/qqmllanguage/data/SelfReference.qml8
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.14.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.18.errors.txt1
-rw-r--r--tests/auto/qml/qqmllanguage/data/alias.18.qml9
-rw-r--r--tests/auto/qml/qqmllanguage/data/fuzzed.2.qmlbin404 -> 404 bytes
-rw-r--r--tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/fuzzed.3.qmlbin0 -> 4777 bytes
-rw-r--r--tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml7
-rw-r--r--tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir1
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp93
-rw-r--r--tests/auto/qml/qqmlproperty/data/interfaceBinding.qml27
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp100
-rw-r--r--tests/auto/qml/qqmltablemodel/qqmltablemodel.pro2
-rw-r--r--tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp28
-rw-r--r--tests/auto/qml/qqmltypeloader/data/declarativeCppType.qml6
-rw-r--r--tests/auto/qml/qqmltypeloader/declarativetesttype.h44
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp21
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.pro8
-rw-r--r--tests/auto/quick/qquickanimatedsprite/data/finishBehavior.qml18
-rw-r--r--tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp63
-rw-r--r--tests/auto/quick/qquickdrag/tst_qquickdrag.cpp25
-rw-r--r--tests/auto/quick/qquickitem/data/setParentInWindowChange.qml12
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp8
-rw-r--r--tests/auto/quick/qquickitem2/tst_qquickitem.cpp6
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml54
-rw-r--r--tests/auto/quick/qquickloader/data/CacheClearTest.qml4
-rw-r--r--tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml20
-rw-r--r--tests/auto/quick/qquickloader/tst_qquickloader.cpp5
-rw-r--r--tests/auto/quick/qquicktext/data/lineLayout.qml9
-rw-r--r--tests/auto/quick/qquicktext/data/lineLayoutImplicitWidth.qml80
-rw-r--r--tests/auto/quick/qquicktext/tst_qquicktext.cpp56
-rw-r--r--tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp24
-rw-r--r--tests/auto/quick/qquicktextinput/data/qtbug77841.qml22
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp42
-rw-r--r--tests/auto/quick/quick.pro2
64 files changed, 1286 insertions, 83 deletions
diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/quit.js b/tests/auto/qml/debugger/qqmldebugjs/data/quit.js
new file mode 100644
index 0000000000..1a45fd5538
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/quit.js
@@ -0,0 +1,4 @@
+function quit() {
+ console.log("hit");
+ Qt.quit();
+}
diff --git a/tests/auto/qml/debugger/qqmldebugjs/data/quitInJS.qml b/tests/auto/qml/debugger/qqmldebugjs/data/quitInJS.qml
new file mode 100644
index 0000000000..6e4183100b
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmldebugjs/data/quitInJS.qml
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "quit.js" as Quit;
+
+//DO NOT CHANGE
+
+Item {
+ Timer {
+ running: true
+ triggeredOnStart: true
+ onTriggered: Quit.quit();
+ }
+}
+
diff --git a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
index 255d679b1b..5b6c43bc0c 100644
--- a/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
+++ b/tests/auto/qml/debugger/qqmldebugjs/tst_qqmldebugjs.cpp
@@ -58,6 +58,8 @@ const char *ONCOMPLETED_QMLFILE = "oncompleted.qml";
const char *CREATECOMPONENT_QMLFILE = "createComponent.qml";
const char *CONDITION_QMLFILE = "condition.qml";
const char *QUIT_QMLFILE = "quit.qml";
+const char *QUITINJS_QMLFILE = "quitInJS.qml";
+const char *QUIT_JSFILE = "quit.js";
const char *CHANGEBREAKPOINT_QMLFILE = "changeBreakpoint.qml";
const char *STEPACTION_QMLFILE = "stepAction.qml";
const char *BREAKPOINTRELOCATION_QMLFILE = "breakpointRelocation.qml";
@@ -109,8 +111,10 @@ private slots:
void setBreakpointInScriptOnOptimizedBinding();
void setBreakpointInScriptWithCondition_data() { targetData(); }
void setBreakpointInScriptWithCondition();
- void setBreakpointInScriptThatQuits_data() { targetData(); }
+ void setBreakpointInScriptThatQuits_data() { targetData(); };
void setBreakpointInScriptThatQuits();
+ void setBreakpointInJavaScript_data();
+ void setBreakpointInJavaScript();
void setBreakpointWhenAttaching();
void clearBreakpoint_data() { targetData(); }
@@ -450,6 +454,48 @@ void tst_QQmlDebugJS::setBreakpointInScriptThatQuits()
QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
}
+void tst_QQmlDebugJS::setBreakpointInJavaScript_data()
+{
+ QTest::addColumn<bool>("qmlscene");
+ QTest::addColumn<bool>("seedCache");
+ QTest::newRow("custom / immediate") << false << false;
+ QTest::newRow("qmlscene / immediate") << true << false;
+ QTest::newRow("custom / seeded") << false << true;
+ QTest::newRow("qmlscene / seeded") << true << true;
+}
+
+void tst_QQmlDebugJS::setBreakpointInJavaScript()
+{
+ QFETCH(bool, qmlscene);
+ QFETCH(bool, seedCache);
+
+ if (seedCache) { // Make sure there is a qmlc file that the engine should _not_ laod.
+ QProcess process;
+ process.start(QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmlscene",
+ { testFile(QUITINJS_QMLFILE) });
+ QTRY_COMPARE(process.state(), QProcess::NotRunning);
+ }
+
+ QCOMPARE(init(qmlscene, QUITINJS_QMLFILE), ConnectSuccess);
+
+ const int sourceLine = 2;
+
+ m_client->setBreakpoint(QLatin1String(QUIT_JSFILE), sourceLine, -1, true);
+ m_client->connect();
+ QVERIFY(waitForClientSignal(SIGNAL(stopped())));
+
+ const QJsonObject body = m_client->response().body.toObject();
+
+ QCOMPARE(body.value("sourceLine").toInt(), sourceLine);
+ QCOMPARE(QFileInfo(body.value("script").toObject().value("name").toString()).fileName(),
+ QLatin1String(QUIT_JSFILE));
+
+ m_client->continueDebugging(QV4DebugClient::Continue);
+
+ QVERIFY(m_process->waitForFinished());
+ QCOMPARE(m_process->exitStatus(), QProcess::NormalExit);
+}
+
void tst_QQmlDebugJS::setBreakpointWhenAttaching()
{
int sourceLine = 35;
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 1c895eb793..f1ff396d4f 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -4888,6 +4888,7 @@ void tst_QJSEngine::interrupt_data()
QTest::addRow("labeled continue / %s", mode) << i << "a: while (true) { for (;;) { continue a; } }";
QTest::addRow("labeled break / %s", mode) << i << "while (true) { a: for (;;) { break a; } }";
QTest::addRow("tail call / %s", mode) << i << "'use strict';\nfunction x() { return x(); }; x();";
+ QTest::addRow("huge array join / %s", mode) << i << "Array(1E9)|1";
}
}
diff --git a/tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml b/tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml
new file mode 100644
index 0000000000..2128a54d81
--- /dev/null
+++ b/tests/auto/qml/qmlcachegen/data/parameterAdjustment.qml
@@ -0,0 +1,7 @@
+import QtQml 2.12
+
+QtObject {
+ signal testSignal(string a, int b, string c, bool d, bool e, real f, real g, bool h, int i, int j, string k, int l, string m, string n)
+ onTestSignal: {}
+ Component.onCompleted: testSignal("a", 1, "b", true, true, 0.1, 0.1, true, 1, 1, "a", 1, "a", "a")
+}
diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
index 1a334b68ce..452bd7d04a 100644
--- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro
+++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro
@@ -17,7 +17,8 @@ RESOURCES += \
data/jsmoduleimport.qml \
data/script.mjs \
data/module.mjs \
- data/utils.mjs
+ data/utils.mjs \
+ data/parameterAdjustment.qml
workerscripts_test.files = \
data/worker.js \
diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
index 5d87c319f3..f940f9c476 100644
--- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
+++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp
@@ -73,6 +73,8 @@ private slots:
void reproducibleCache_data();
void reproducibleCache();
+
+ void parameterAdjustment();
};
// A wrapper around QQmlComponent to ensure the temporary reference counts
@@ -664,6 +666,14 @@ void tst_qmlcachegen::reproducibleCache()
QCOMPARE(contents1, contents2);
}
+void tst_qmlcachegen::parameterAdjustment()
+{
+ QQmlEngine engine;
+ CleanlyLoadingComponent component(&engine, QUrl("qrc:///data/parameterAdjustment.qml"));
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull()); // Doesn't crash
+}
+
QTEST_GUILESS_MAIN(tst_qmlcachegen)
#include "tst_qmlcachegen.moc"
diff --git a/tests/auto/qml/qmllint/data/esmodule.mjs b/tests/auto/qml/qmllint/data/esmodule.mjs
new file mode 100644
index 0000000000..50a53be2b1
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/esmodule.mjs
@@ -0,0 +1,2 @@
+
+export function test() { console.log("hello world"); }
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 04f554ac48..e3c297fa0f 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -158,6 +158,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("catchIdentifier") << QStringLiteral("catchIdentifierNoWarning.qml");
QTest::newRow("qmldirAndQmltypes") << QStringLiteral("qmldirAndQmltypes.qml");
QTest::newRow("forLoop") << QStringLiteral("forLoop.qml");
+ QTest::newRow("esmodule") << QStringLiteral("esmodule.mjs");
}
void TestQmllint::cleanQmlCode()
diff --git a/tests/auto/qml/qmlmin/tst_qmlmin.cpp b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
index 79a73299a4..e7498a8583 100644
--- a/tests/auto/qml/qmlmin/tst_qmlmin.cpp
+++ b/tests/auto/qml/qmlmin/tst_qmlmin.cpp
@@ -130,6 +130,7 @@ void tst_qmlmin::initTestCase()
invalidFiles << "tests/auto/qml/qjsengine/script/com/trolltech/syntaxerror/__init__.js";
invalidFiles << "tests/auto/qml/debugger/qqmlpreview/data/broken.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.2.qml";
+ invalidFiles << "tests/auto/qml/qqmllanguage/data/fuzzed.3.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.2.qml";
invalidFiles << "tests/auto/qml/qqmllanguage/data/requiredProperties.3.qml";
// generatorFunction.qml is not invalid per se, but the minifier cannot handle yield statements
diff --git a/tests/auto/qml/qmlplugindump/data/dumper/Imports/Derived.qml b/tests/auto/qml/qmlplugindump/data/dumper/Imports/Derived.qml
new file mode 100644
index 0000000000..2f0ac401d7
--- /dev/null
+++ b/tests/auto/qml/qmlplugindump/data/dumper/Imports/Derived.qml
@@ -0,0 +1,6 @@
+pragma Singleton
+import dumper.Imports 1.0
+
+Imports {
+ property int something: 2
+}
diff --git a/tests/auto/qml/qmlplugindump/data/dumper/Imports/imports.pro b/tests/auto/qml/qmlplugindump/data/dumper/Imports/imports.pro
index d20ea967ea..b4bd9baf5b 100644
--- a/tests/auto/qml/qmlplugindump/data/dumper/Imports/imports.pro
+++ b/tests/auto/qml/qmlplugindump/data/dumper/Imports/imports.pro
@@ -17,7 +17,7 @@ HEADERS += \
imports.h
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
- cp.files = qmldir plugins.qmltypes CompositeImports.qml
+ cp.files = qmldir plugins.qmltypes CompositeImports.qml Derived.qml
cp.path = $$OUT_PWD
COPIES += cp
}
diff --git a/tests/auto/qml/qmlplugindump/data/dumper/Imports/plugins.qmltypes b/tests/auto/qml/qmlplugindump/data/dumper/Imports/plugins.qmltypes
index 937dd60a9e..fb13928ba0 100644
--- a/tests/auto/qml/qmlplugindump/data/dumper/Imports/plugins.qmltypes
+++ b/tests/auto/qml/qmlplugindump/data/dumper/Imports/plugins.qmltypes
@@ -14,4 +14,14 @@ Module {
exports: ["dumper.Imports/Imports 1.0"]
exportMetaObjectRevisions: [0]
}
+ Component {
+ prototype: "Imports"
+ name: "dumper.Imports/Derived 1.0"
+ exports: ["dumper.Imports/Derived 1.0"]
+ exportMetaObjectRevisions: [0]
+ isComposite: true
+ isCreatable: false
+ isSingleton: true
+ Property { name: "something"; type: "int" }
+ }
}
diff --git a/tests/auto/qml/qmlplugindump/data/dumper/Imports/qmldir b/tests/auto/qml/qmlplugindump/data/dumper/Imports/qmldir
index c9058a7f95..f84fca1d75 100644
--- a/tests/auto/qml/qmlplugindump/data/dumper/Imports/qmldir
+++ b/tests/auto/qml/qmlplugindump/data/dumper/Imports/qmldir
@@ -1,3 +1,4 @@
module dumper.Imports
plugin Imports
CompositeImports 1.0 CompositeImports.qml
+singleton Derived 1.0 Derived.qml
diff --git a/tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml b/tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml
new file mode 100644
index 0000000000..366dbf0464
--- /dev/null
+++ b/tests/auto/qml/qqmlbinding/data/nanPropertyToInt.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.11
+
+Item {
+ visible: true
+ width: 320
+ height: 200
+ property int val: other.val
+
+ Rectangle {
+ id: other
+ anchors.fill: parent;
+ property int val: undefined / 2
+ }
+}
diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
index 2c2d311ff7..2610402455 100644
--- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
+++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp
@@ -56,6 +56,7 @@ private slots:
void bindingOverwriting();
void bindToQmlComponent();
void bindingDoesNoWeirdConversion();
+ void bindNaNToInt();
private:
QQmlEngine engine;
@@ -398,6 +399,16 @@ void tst_qqmlbinding::bindingDoesNoWeirdConversion()
QVERIFY(colorLabel);
}
+//QTBUG-72442
+void tst_qqmlbinding::bindNaNToInt()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("nanPropertyToInt.qml"));
+ QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create()));
+
+ QVERIFY(item != nullptr);
+ QCOMPARE(item->property("val").toInt(), 0);
+}
QTEST_MAIN(tst_qqmlbinding)
#include "tst_qqmlbinding.moc"
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index d9cb6673df..6754f22049 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -895,16 +895,27 @@ void tst_qqmlcontext::contextObjectHierarchy()
void tst_qqmlcontext::destroyContextProperty()
{
- QQmlEngine engine;
- QQmlContext context(&engine);
-
+ QScopedPointer<QQmlContext> context;
+ QScopedPointer<QObject> objectThatOutlivesEngine(new QObject);
{
- QObject object;
- context.setContextProperty(QLatin1String("a"), &object);
- QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), &object);
+ QQmlEngine engine;
+ context.reset(new QQmlContext(&engine));
+
+ {
+ QObject object;
+ context->setContextProperty(QLatin1String("a"), &object);
+ QCOMPARE(qvariant_cast<QObject *>(context->contextProperty(QLatin1String("a"))), &object);
+ }
+
+ QCOMPARE(qvariant_cast<QObject *>(context->contextProperty(QLatin1String("a"))), nullptr);
+ context->setContextProperty(QLatin1String("b"), objectThatOutlivesEngine.data());
}
- QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), nullptr);
+ // dropDestroyedObject() should not crash, even if the engine is gone.
+ objectThatOutlivesEngine.reset();
+
+ // We're not allowed to call context->contextProperty("b") anymore.
+ // TODO: Or are we?
}
QTEST_MAIN(tst_qqmlcontext)
diff --git a/tests/auto/qml/qqmldelegatemodel/data/abstractItemModel.qml b/tests/auto/qml/qqmldelegatemodel/data/abstractItemModel.qml
new file mode 100644
index 0000000000..01ebfd8e1e
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/data/abstractItemModel.qml
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml.Models 2.15
+import QtQuick 2.15
+
+import Test 1.0
+
+DelegateModel {
+ model: AbstractItemModel {}
+ delegate: Item {}
+}
diff --git a/tests/auto/qml/qqmldelegatemodel/data/integerModel.qml b/tests/auto/qml/qqmldelegatemodel/data/integerModel.qml
new file mode 100644
index 0000000000..f6cd886e09
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/data/integerModel.qml
@@ -0,0 +1,35 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml.Models 2.15
+import QtQuick 2.15
+
+DelegateModel {
+ model: 100
+ delegate: Item {}
+}
diff --git a/tests/auto/qml/qqmldelegatemodel/data/listModel.qml b/tests/auto/qml/qqmldelegatemodel/data/listModel.qml
new file mode 100644
index 0000000000..1ee8bcac72
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/data/listModel.qml
@@ -0,0 +1,45 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQml.Models 2.15
+import QtQuick 2.15
+
+DelegateModel {
+ model: ListModel {
+ ListElement {
+ name: "Item 0"
+ }
+ ListElement {
+ name: "Item 1"
+ }
+ ListElement {
+ name: "Item 2"
+ }
+ }
+ delegate: Item {}
+}
diff --git a/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro b/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro
new file mode 100644
index 0000000000..7fdd3ab5f1
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/qqmldelegatemodel.pro
@@ -0,0 +1,13 @@
+CONFIG += testcase
+TARGET = tst_qqmldelegatemodel
+macos:CONFIG -= app_bundle
+
+QT += qml testlib core-private qml-private qmlmodels-private
+
+SOURCES += tst_qqmldelegatemodel.cpp
+
+include (../../shared/util.pri)
+
+TESTDATA = data/*
+
+OTHER_FILES += data/*
diff --git a/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
new file mode 100644
index 0000000000..87f42c0c8a
--- /dev/null
+++ b/tests/auto/qml/qqmldelegatemodel/tst_qqmldelegatemodel.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/qtest.h>
+#include <QtQml/qqmlcomponent.h>
+#include <QtQmlModels/private/qqmldelegatemodel_p.h>
+
+#include "../../shared/util.h"
+
+class tst_QQmlDelegateModel : public QQmlDataTest
+{
+ Q_OBJECT
+
+public:
+ tst_QQmlDelegateModel();
+
+private slots:
+ void valueWithoutCallingObjectFirst_data();
+ void valueWithoutCallingObjectFirst();
+};
+
+class AbstractItemModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ AbstractItemModel()
+ {
+ for (int i = 0; i < 3; ++i)
+ mValues.append(QString::fromLatin1("Item %1").arg(i));
+ }
+
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override
+ {
+ if (parent.isValid())
+ return QModelIndex();
+
+ return createIndex(row, column);
+ }
+
+ QModelIndex parent(const QModelIndex &) const override
+ {
+ return QModelIndex();
+ }
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override
+ {
+ if (parent.isValid())
+ return 0;
+
+ return mValues.count();
+ }
+
+ int columnCount(const QModelIndex &parent) const override
+ {
+ if (parent.isValid())
+ return 0;
+
+ return 1;
+ }
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
+ {
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ return mValues.at(index.row());
+ }
+
+private:
+ QVector<QString> mValues;
+};
+
+tst_QQmlDelegateModel::tst_QQmlDelegateModel()
+{
+ qmlRegisterType<AbstractItemModel>("Test", 1, 0, "AbstractItemModel");
+}
+
+void tst_QQmlDelegateModel::valueWithoutCallingObjectFirst_data()
+{
+ QTest::addColumn<QUrl>("qmlFileUrl");
+ QTest::addColumn<int>("index");
+ QTest::addColumn<QString>("role");
+ QTest::addColumn<QVariant>("expectedValue");
+
+ QTest::addRow("integer") << testFileUrl("integerModel.qml")
+ << 50 << QString::fromLatin1("modelData") << QVariant(50);
+ QTest::addRow("ListModel") << testFileUrl("listModel.qml")
+ << 1 << QString::fromLatin1("name") << QVariant(QLatin1String("Item 1"));
+ QTest::addRow("QAbstractItemModel") << testFileUrl("abstractItemModel.qml")
+ << 1 << QString::fromLatin1("display") << QVariant(QLatin1String("Item 1"));
+}
+
+// Tests that it's possible to call variantValue() without creating
+// costly delegate items first via object().
+void tst_QQmlDelegateModel::valueWithoutCallingObjectFirst()
+{
+ QFETCH(const QUrl, qmlFileUrl);
+ QFETCH(const int, index);
+ QFETCH(const QString, role);
+ QFETCH(const QVariant, expectedValue);
+
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(qmlFileUrl);
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY2(root, qPrintable(component.errorString()));
+ QQmlDelegateModel *model = qobject_cast<QQmlDelegateModel*>(root.data());
+ QVERIFY(model);
+ QCOMPARE(model->variantValue(index, role), expectedValue);
+}
+
+QTEST_MAIN(tst_QQmlDelegateModel)
+
+#include "tst_qqmldelegatemodel.moc"
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index f4de83eb87..a002658fee 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -5737,7 +5737,7 @@ void tst_qqmlecmascript::sequenceConversionRead()
QVERIFY(seq != nullptr);
// we haven't registered QList<NonRegisteredType> as a sequence type.
- QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QList<NonRegisteredType>' for property 'MySequenceConversionObject::typeListProperty'");
+ QString warningOne = QLatin1String("QMetaProperty::read: Unable to handle unregistered datatype 'QVector<NonRegisteredType>' for property 'MySequenceConversionObject::typeListProperty'");
QString warningTwo = qmlFile.toString() + QLatin1String(":18: TypeError: Cannot read property 'length' of undefined");
QTest::ignoreMessage(QtWarningMsg, warningOne.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, warningTwo.toLatin1().constData());
@@ -5747,7 +5747,7 @@ void tst_qqmlecmascript::sequenceConversionRead()
// QList<NonRegisteredType> has not been registered as a sequence type.
QCOMPARE(object->property("pointListLength").toInt(), 0);
QVERIFY(!object->property("pointList").isValid());
- QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QList<NonRegisteredType>' for property 'MySequenceConversionObject::typeListProperty'");
+ QTest::ignoreMessage(QtWarningMsg, "QMetaProperty::read: Unable to handle unregistered datatype 'QVector<NonRegisteredType>' for property 'MySequenceConversionObject::typeListProperty'");
QQmlProperty seqProp(seq, "typeListProperty", &engine);
QVERIFY(!seqProp.read().isValid()); // not a valid/known sequence type
@@ -5790,7 +5790,7 @@ void tst_qqmlecmascript::sequenceConversionWrite()
QVERIFY(seq != nullptr);
// we haven't registered QList<QPoint> as a sequence type, so writing shouldn't work.
- QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QJSValue to QList<QPoint>");
+ QString warningOne = qmlFile.toString() + QLatin1String(":16: Error: Cannot assign QJSValue to QVector<QPoint>");
QTest::ignoreMessage(QtWarningMsg, warningOne.toLatin1().constData());
QMetaObject::invokeMethod(object, "performTest");
@@ -5904,7 +5904,7 @@ void tst_qqmlecmascript::sequenceConversionBindings()
{
QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
- QString warning = QString(QLatin1String("%1:17:9: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
+ QString warning = QString(QLatin1String("%1:17:9: Unable to assign QVector<int> to QVector<bool>")).arg(qmlFile.toString());
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QQmlComponent component(&engine, qmlFile);
QObject *object = component.create();
diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
index ca1e52ad2c..9c865b3f73 100644
--- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
+++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp
@@ -32,6 +32,7 @@
#include <QtQuick/qquickview.h>
#include <QtQuick/qquickitem.h>
#include <private/qqmlimport_p.h>
+#include <private/qqmlengine_p.h>
#include "../../shared/util.h"
class tst_QQmlImport : public QQmlDataTest
@@ -46,6 +47,7 @@ private slots:
void completeQmldirPaths();
void interceptQmldir();
void singletonVersionResolution();
+ void removeDynamicPlugin();
void cleanup();
};
@@ -260,6 +262,25 @@ void tst_QQmlImport::singletonVersionResolution()
}
}
+void tst_QQmlImport::removeDynamicPlugin()
+{
+ qmlClearTypeRegistrations();
+ QQmlEngine engine;
+ {
+ // Load something that adds a dynamic plugin
+ QQmlComponent component(&engine);
+ component.setData(QByteArray("import QtTest 1.0; TestResult{}"), QUrl());
+ QVERIFY(component.isReady());
+ }
+ QQmlImportDatabase *imports = &QQmlEnginePrivate::get(&engine)->importDatabase;
+ const QStringList &plugins = imports->dynamicPlugins();
+ QVERIFY(!plugins.isEmpty());
+ for (const QString &plugin : plugins)
+ QVERIFY(imports->removeDynamicPlugin(plugin));
+ QVERIFY(imports->dynamicPlugins().isEmpty());
+ qmlClearTypeRegistrations();
+}
+
QTEST_MAIN(tst_QQmlImport)
diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
index 756b3b1d7c..549aae8c2b 100644
--- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
+++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp
@@ -149,7 +149,7 @@ void tst_qqmlincubator::objectDeleted()
QVERIFY(!SelfRegisteringType::me());
while (SelfRegisteringOuterType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -157,14 +157,14 @@ void tst_qqmlincubator::objectDeleted()
QVERIFY(incubator.isLoading());
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
delete SelfRegisteringType::me();
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -205,7 +205,7 @@ void tst_qqmlincubator::clear()
component.create(incubator);
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -224,7 +224,7 @@ void tst_qqmlincubator::clear()
component.create(incubator);
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -318,7 +318,7 @@ void tst_qqmlincubator::forceCompletion()
QVERIFY(incubator.isLoading());
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -377,7 +377,7 @@ void tst_qqmlincubator::setInitialState()
MyIncubator incubator(QQmlIncubator::Asynchronous);
component.create(incubator);
QVERIFY(incubator.isLoading());
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
QVERIFY(incubator.isReady());
QVERIFY(incubator.object());
@@ -414,7 +414,7 @@ void tst_qqmlincubator::clearDuringCompletion()
QVERIFY(!CompletionRegisteringType::me());
while (CompletionRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -453,7 +453,7 @@ void tst_qqmlincubator::objectDeletionAfterInit()
component.create(incubator);
while (!incubator.obj && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -552,7 +552,7 @@ void tst_qqmlincubator::statusChanged()
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -574,7 +574,7 @@ void tst_qqmlincubator::statusChanged()
QCOMPARE(incubator.statuses.at(0), int(QQmlIncubator::Loading));
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -622,7 +622,7 @@ void tst_qqmlincubator::asynchronousIfNested()
QVERIFY(incubator.isLoading());
QVERIFY(!SelfRegisteringType::me());
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -635,7 +635,7 @@ void tst_qqmlincubator::asynchronousIfNested()
while (nested.isLoading()) {
QVERIFY(incubator.isLoading());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -643,7 +643,7 @@ void tst_qqmlincubator::asynchronousIfNested()
QVERIFY(incubator.isLoading());
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -742,7 +742,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNested()
QVERIFY(!SelfRegisteringType::me());
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -779,7 +779,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNested()
QVERIFY(incubator1.isLoading());
QVERIFY(incubator2.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -792,14 +792,14 @@ void tst_qqmlincubator::chainedAsynchronousIfNested()
QVERIFY(incubator1.isReady());
QVERIFY(incubator2.isLoading());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
QVERIFY(incubator1.isReady());
QVERIFY(incubator2.isReady());
if (incubator.isLoading()) {
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -856,7 +856,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
QVERIFY(!SelfRegisteringType::me());
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -876,7 +876,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
QVERIFY(incubator2.isNull());
QVERIFY(incubator3.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -891,7 +891,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
QVERIFY(incubator2.isNull());
QVERIFY(incubator3.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -906,7 +906,7 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
QVERIFY(incubator2.isLoading());
QVERIFY(incubator3.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -921,12 +921,12 @@ void tst_qqmlincubator::chainedAsynchronousIfNestedOnCompleted()
QVERIFY(incubator2.isReady());
QVERIFY(incubator3.isLoading());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -984,7 +984,7 @@ void tst_qqmlincubator::chainedAsynchronousClear()
QVERIFY(!SelfRegisteringType::me());
while (SelfRegisteringType::me() == nullptr && incubator.isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -1004,7 +1004,7 @@ void tst_qqmlincubator::chainedAsynchronousClear()
QVERIFY(incubator2.isNull());
QVERIFY(incubator3.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -1019,7 +1019,7 @@ void tst_qqmlincubator::chainedAsynchronousClear()
QVERIFY(incubator2.isNull());
QVERIFY(incubator3.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -1034,7 +1034,7 @@ void tst_qqmlincubator::chainedAsynchronousClear()
QVERIFY(incubator2.isLoading());
QVERIFY(incubator3.isNull());
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -1078,7 +1078,7 @@ void tst_qqmlincubator::selfDelete()
#define DELETE_TEST(status, mode) { \
bool done = false; \
component.create(*(new MyIncubator(&done, status, mode))); \
- bool True = true; \
+ std::atomic<bool> True{true}; \
controller.incubateWhile(&True); \
QVERIFY(done == true); \
}
@@ -1107,7 +1107,7 @@ void tst_qqmlincubator::selfDelete()
QVERIFY(!SelfRegisteringType::me());
while (SelfRegisteringType::me() == nullptr && incubator->isLoading()) {
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
@@ -1121,7 +1121,7 @@ void tst_qqmlincubator::selfDelete()
delete SelfRegisteringType::me();
{
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
}
@@ -1142,7 +1142,7 @@ void tst_qqmlincubator::contextDelete()
delete context;
{
- bool b = false;
+ std::atomic<bool> b{false};
controller.incubateWhile(&b);
}
}
@@ -1155,7 +1155,7 @@ void tst_qqmlincubator::garbageCollection()
engine.collectGarbage();
- bool b = true;
+ std::atomic<bool> b{true};
controller.incubateWhile(&b);
// verify incubation completed (the incubator was not prematurely collected)
diff --git a/tests/auto/qml/qqmlitemmodels/qtestmodel.h b/tests/auto/qml/qqmlitemmodels/qtestmodel.h
index 6a022b3135..de42253708 100644
--- a/tests/auto/qml/qqmlitemmodels/qtestmodel.h
+++ b/tests/auto/qml/qqmlitemmodels/qtestmodel.h
@@ -31,6 +31,8 @@
#include <QtCore/qabstractitemmodel.h>
+#include <limits.h>
+
class TestModel: public QAbstractItemModel
{
Q_OBJECT
diff --git a/tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt
new file mode 100644
index 0000000000..dfd077941e
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.errors.txt
@@ -0,0 +1 @@
+3:29:SelfInstantiation is instantiated recursively
diff --git a/tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml
new file mode 100644
index 0000000000..b2e4e453a0
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/SelfInstantiation.qml
@@ -0,0 +1,5 @@
+import QtQml 2.0
+QtObject {
+ property QtObject self: SelfInstantiation {
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/SelfReference.qml b/tests/auto/qml/qqmllanguage/data/SelfReference.qml
new file mode 100644
index 0000000000..129a171d77
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/SelfReference.qml
@@ -0,0 +1,8 @@
+import QtQml 2.0
+QtObject {
+ property SelfReference self
+ signal blah(selfParam: SelfReference)
+ function returnSelf() : SelfReference {
+ return this;
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/alias.14.errors.txt b/tests/auto/qml/qqmllanguage/data/alias.14.errors.txt
deleted file mode 100644
index 90a3ea4317..0000000000
--- a/tests/auto/qml/qqmllanguage/data/alias.14.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-10:34:References to other aliases within the same object are not supported at the moment
diff --git a/tests/auto/qml/qqmllanguage/data/alias.18.errors.txt b/tests/auto/qml/qqmllanguage/data/alias.18.errors.txt
new file mode 100644
index 0000000000..dda3e7a174
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/alias.18.errors.txt
@@ -0,0 +1 @@
+7:24:Duplicate alias name
diff --git a/tests/auto/qml/qqmllanguage/data/alias.18.qml b/tests/auto/qml/qqmllanguage/data/alias.18.qml
new file mode 100644
index 0000000000..a9be937975
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/alias.18.qml
@@ -0,0 +1,9 @@
+import QtQml 2.14
+
+QtObject {
+ id: root
+ property QtObject o1: QtObject {
+ property alias a: root
+ property alias a: root
+ }
+}
diff --git a/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml b/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml
index e726f6783c..f164ec98ea 100644
--- a/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml
+++ b/tests/auto/qml/qqmllanguage/data/fuzzed.2.qml
Binary files differ
diff --git a/tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt b/tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt
new file mode 100644
index 0000000000..da17dc5599
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/fuzzed.3.errors.txt
@@ -0,0 +1,2 @@
+3:2:Unexpected token `version number'
+1:1:Expected a qualified name id or a string literal
diff --git a/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml b/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml
new file mode 100644
index 0000000000..6861ebf8a9
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/fuzzed.3.qml
Binary files differ
diff --git a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
index 043f714636..887d87b9fb 100644
--- a/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/objectValueTypeProperty.errors.txt
@@ -1 +1 @@
-4:18:Can not assign value of type "MyTypeObject" to property "x", expecting "int"
+4:18:Cannot assign value of type "MyTypeObject" to property "x", expecting "int"
diff --git a/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml
new file mode 100644
index 0000000000..f70a3b1fea
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/TestSingleton.qml
@@ -0,0 +1,7 @@
+import QtQml 2.0
+import selfreferencingsingletonmodule 1.0
+pragma Singleton
+QtObject {
+ property SelfReferencingSingleton self
+ property int dummy: 42
+}
diff --git a/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir
new file mode 100644
index 0000000000..617861b00b
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/selfreferencingsingletonmodule/qmldir
@@ -0,0 +1 @@
+singleton SelfReferencingSingleton 1.0 TestSingleton.qml
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index e2032c3b86..7fff982cde 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -306,6 +306,9 @@ private slots:
void extendedForeignTypes();
+ void selfReference();
+ void selfReferencingSingleton();
+
private:
QQmlEngine engine;
QStringList defaultImportPathList;
@@ -624,12 +627,15 @@ void tst_qqmllanguage::errors_data()
QTest::newRow("fuzzed.1") << "fuzzed.1.qml" << "fuzzed.1.errors.txt" << false;
QTest::newRow("fuzzed.2") << "fuzzed.2.qml" << "fuzzed.2.errors.txt" << false;
+ QTest::newRow("fuzzed.3") << "fuzzed.3.qml" << "fuzzed.3.errors.txt" << false;
QTest::newRow("bareQmlImport") << "bareQmlImport.qml" << "bareQmlImport.errors.txt" << false;
QTest::newRow("typeAnnotations.2") << "typeAnnotations.2.qml" << "typeAnnotations.2.errors.txt" << false;
QTest::newRow("propertyUnknownType") << "propertyUnknownType.qml" << "propertyUnknownType.errors.txt" << false;
+
+ QTest::newRow("selfInstantiation") << "SelfInstantiation.qml" << "SelfInstantiation.errors.txt" << false;
}
void tst_qqmllanguage::errors()
@@ -1955,7 +1961,6 @@ void tst_qqmllanguage::aliasProperties()
// "Nested" aliases within an object that require iterative resolution
{
- // This is known to fail at the moment.
QQmlComponent component(&engine, testFileUrl("alias.14.qml"));
VERIFY_ERRORS(0);
@@ -2054,6 +2059,11 @@ void tst_qqmllanguage::aliasProperties()
auto text = myText->property("text").toString();
QCOMPARE(text, "alias:\n20");
}
+
+ {
+ QQmlComponent component(&engine, testFileUrl("alias.18.qml"));
+ VERIFY_ERRORS("alias.18.errors.txt");
+ }
}
// QTBUG-13374 Test that alias properties and signals can coexist
@@ -4728,11 +4738,13 @@ static void beginDeferredOnce(QQmlEnginePrivate *enginePriv,
typedef QMultiHash<int, const QV4::CompiledData::Binding *> QV4PropertyBindingHash;
auto it = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.second);
auto last = std::reverse_iterator<QV4PropertyBindingHash::iterator>(range.first);
+ state->creator->beginPopulateDeferred(deferData->context);
while (it != last) {
- if (!state->creator->populateDeferredBinding(property, deferData, *it))
- state->errors << state->creator->errors;
+ state->creator->populateDeferredBinding(property, deferData->deferredIdx, *it);
++it;
}
+ state->creator->finalizePopulateDeferred();
+ state->errors << state->creator->errors;
deferredState->constructionStates += state;
@@ -4957,24 +4969,24 @@ void tst_qqmllanguage::instanceof_data()
// assert that basic types don't convert to QObject
QTest::newRow("1 instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
- << QVariant("TypeError: Type error");
+ << QVariant(false);
QTest::newRow("true instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
- << QVariant("TypeError: Type error");
+ << QVariant(false);
QTest::newRow("\"foobar\" instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
- << QVariant("TypeError: Type error");
+ << QVariant(false);
// assert that Managed don't either
QTest::newRow("new String(\"foobar\") instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
- << QVariant("TypeError: Type error");
+ << QVariant(false);
QTest::newRow("new Object() instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
- << QVariant("TypeError: Type error");
+ << QVariant(false);
QTest::newRow("new Date() instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
- << QVariant("TypeError: Type error");
+ << QVariant(false);
// test that simple QtQml comparisons work
QTest::newRow("qtobjectInstance instanceof QtObject")
@@ -5274,6 +5286,69 @@ void tst_qqmllanguage::extendedForeignTypes()
QCOMPARE(o->property("foreignExtendedObjectName").toString(), QLatin1String("foreignExtended"));
}
+void tst_qqmllanguage::selfReference()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("SelfReference.qml"));
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+
+ QQmlComponentPrivate *componentPrivate = QQmlComponentPrivate::get(&component);
+ auto compilationUnit = componentPrivate->compilationUnit;
+ QVERIFY(compilationUnit);
+
+ const QMetaObject *metaObject = o->metaObject();
+ QMetaProperty selfProperty = metaObject->property(metaObject->indexOfProperty("self"));
+ QCOMPARE(selfProperty.userType(), compilationUnit->metaTypeId);
+
+ QByteArray typeName = selfProperty.typeName();
+ QVERIFY(typeName.endsWith('*'));
+ typeName = typeName.chopped(1);
+ QCOMPARE(typeName, metaObject->className());
+
+ QMetaMethod selfFunction = metaObject->method(metaObject->indexOfMethod("returnSelf()"));
+ QVERIFY(selfFunction.isValid());
+ QCOMPARE(selfFunction.returnType(), compilationUnit->metaTypeId);
+
+ QMetaMethod selfSignal;
+
+ for (int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i) {
+ QMetaMethod method = metaObject->method(i);
+ if (method.isValid() && method.name().startsWith("blah")) {
+ selfSignal = method;
+ break;
+ }
+ }
+
+ QVERIFY(selfSignal.isValid());
+ QCOMPARE(selfSignal.parameterCount(), 1);
+ QCOMPARE(selfSignal.parameterType(0), compilationUnit->metaTypeId);
+}
+
+void tst_qqmllanguage::selfReferencingSingleton()
+{
+ QQmlEngine engine;
+ engine.addImportPath(dataDirectory());
+
+ QPointer<QObject> singletonPointer;
+ {
+ QQmlComponent component(&engine);
+ component.setData(QByteArray(R"(import QtQml 2.0
+ import selfreferencingsingletonmodule 1.0
+ QtObject {
+ property SelfReferencingSingleton singletonPointer: SelfReferencingSingleton
+ })"), QUrl());
+ VERIFY_ERRORS(0);
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o.isNull());
+ singletonPointer = o->property("singletonPointer").value<QObject*>();
+ }
+
+ QVERIFY(!singletonPointer.isNull());
+ QCOMPARE(singletonPointer->property("dummy").toInt(), 42);
+}
+
QTEST_MAIN(tst_qqmllanguage)
#include "tst_qqmllanguage.moc"
diff --git a/tests/auto/qml/qqmlproperty/data/interfaceBinding.qml b/tests/auto/qml/qqmlproperty/data/interfaceBinding.qml
new file mode 100644
index 0000000000..4e72a75f42
--- /dev/null
+++ b/tests/auto/qml/qqmlproperty/data/interfaceBinding.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.12
+import io.qt.bugreports 1.0
+Item {
+ InterfaceConsumer {
+ objectName: "a1"
+ i: A {
+ property int i: 42
+ }
+ }
+
+ InterfaceConsumer {
+ objectName: "a2"
+ property A a: A {
+ property int i: 43
+ }
+ i: a
+ }
+
+ InterfaceConsumer {
+ objectName: "a3"
+ property A a: A {
+ id : aa
+ property int i: 44
+ }
+ i: aa
+ }
+}
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 1a5927fa74..f039ccc110 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -40,6 +40,8 @@
#endif
#include <QtCore/private/qobject_p.h>
#include "../../shared/util.h"
+#include "qobject.h"
+#include <QtQml/QQmlPropertyMap>
#include <QDebug>
class MyQmlObject : public QObject
@@ -148,6 +150,7 @@ private slots:
void readOnlyDynamicProperties();
void aliasToIdWithMatchingQmlFileNameOnCaseInsensitiveFileSystem();
void nullPropertyBinding();
+ void interfaceBinding();
void floatToStringPrecision_data();
void floatToStringPrecision();
@@ -155,6 +158,8 @@ private slots:
void copy();
void bindingToAlias();
+
+ void nestedQQmlPropertyMap();
private:
QQmlEngine engine;
};
@@ -2083,6 +2088,83 @@ void tst_qqmlproperty::nullPropertyBinding()
QMetaObject::invokeMethod(root.get(), "tog");
}
+struct Interface {
+};
+
+QT_BEGIN_NAMESPACE
+#define MyInterface_iid "io.qt.bugreports.Interface"
+Q_DECLARE_INTERFACE(Interface, MyInterface_iid);
+QT_END_NAMESPACE
+
+class A : public QObject, Interface {
+ Q_OBJECT
+ Q_INTERFACES(Interface)
+};
+
+class B : public QObject, Interface {
+ Q_OBJECT
+ Q_INTERFACES(Interface)
+};
+
+class C : public QObject {
+ Q_OBJECT
+};
+
+class InterfaceConsumer : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(Interface* i READ interface WRITE setInterface NOTIFY interfaceChanged)
+ Q_PROPERTY(int testValue READ testValue NOTIFY testValueChanged)
+
+
+public:
+
+ Interface* interface() const
+ {
+ return m_interface;
+ }
+ void setInterface(Interface* interface)
+ {
+ QObject* object = reinterpret_cast<QObject*>(interface);
+ m_testValue = object->property("i").toInt();
+ emit testValueChanged();
+ if (m_interface == interface)
+ return;
+
+ m_interface = interface;
+ emit interfaceChanged();
+ }
+
+ int testValue() {
+ return m_testValue;
+ }
+
+signals:
+ void interfaceChanged();
+ void testValueChanged();
+
+private:
+ Interface* m_interface = nullptr;
+ int m_testValue = 0;
+};
+void tst_qqmlproperty::interfaceBinding()
+{
+
+ qmlRegisterInterface<Interface>("Interface");
+ qmlRegisterType<A>("io.qt.bugreports", 1, 0, "A");
+ qmlRegisterType<B>("io.qt.bugreports", 1, 0, "B");
+ qmlRegisterType<C>("io.qt.bugreports", 1, 0, "C");
+ qmlRegisterType<InterfaceConsumer>("io.qt.bugreports", 1, 0, "InterfaceConsumer");
+
+ const QUrl url = testFileUrl("interfaceBinding.qml");
+ QQmlEngine engine;
+ QQmlComponent component(&engine, url);
+ QScopedPointer<QObject> root(component.create());
+ QVERIFY(root);
+ QCOMPARE(root->findChild<QObject*>("a1")->property("testValue").toInt(), 42);
+ QCOMPARE(root->findChild<QObject*>("a2")->property("testValue").toInt(), 43);
+ QCOMPARE(root->findChild<QObject*>("a3")->property("testValue").toInt(), 44);
+}
+
void tst_qqmlproperty::floatToStringPrecision_data()
{
QTest::addColumn<QString>("propertyName");
@@ -2139,6 +2221,24 @@ void tst_qqmlproperty::bindingToAlias()
QVERIFY(!o.isNull());
}
+void tst_qqmlproperty::nestedQQmlPropertyMap()
+{
+ QQmlPropertyMap mainPropertyMap;
+ QQmlPropertyMap nestedPropertyMap;
+ QQmlPropertyMap deeplyNestedPropertyMap;
+
+ mainPropertyMap.insert("nesting1", QVariant::fromValue(&nestedPropertyMap));
+ nestedPropertyMap.insert("value", 42);
+ nestedPropertyMap.insert("nesting2", QVariant::fromValue(&deeplyNestedPropertyMap));
+ deeplyNestedPropertyMap.insert("value", "success");
+
+ QQmlProperty value{&mainPropertyMap, "nesting1.value"};
+ QCOMPARE(value.read().toInt(), 42);
+
+ QQmlProperty success{&mainPropertyMap, "nesting1.nesting2.value"};
+ QCOMPARE(success.read().toString(), QLatin1String("success"));
+}
+
QTEST_MAIN(tst_qqmlproperty)
#include "tst_qqmlproperty.moc"
diff --git a/tests/auto/qml/qqmltablemodel/qqmltablemodel.pro b/tests/auto/qml/qqmltablemodel/qqmltablemodel.pro
index 9d298dfdf2..11b11132aa 100644
--- a/tests/auto/qml/qqmltablemodel/qqmltablemodel.pro
+++ b/tests/auto/qml/qqmltablemodel/qqmltablemodel.pro
@@ -7,4 +7,4 @@ include (../../shared/util.pri)
TESTDATA = data/*
-QT += core gui qml-private qml quick-private quick testlib qmlmodels-private
+QT += core gui qml-private qml quick-private quick testlib
diff --git a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
index d913bcdf9a..5457597df3 100644
--- a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
+++ b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
@@ -29,8 +29,8 @@
#include <QtTest/qtest.h>
#include <QtTest/qsignalspy.h>
#include <QtCore/qregularexpression.h>
+#include <QtCore/qabstractitemmodel.h>
#include <QtQml/private/qqmlengine_p.h>
-#include <QtQmlModels/private/qqmltablemodel_p.h>
#include <QtQml/qqmlcomponent.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
@@ -68,7 +68,7 @@ void tst_QQmlTableModel::appendRemoveRow()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel") .value<QAbstractTableModel *>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -213,7 +213,7 @@ void tst_QQmlTableModel::appendRowToEmptyModel()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 0);
QCOMPARE(model->columnCount(), 2);
@@ -248,7 +248,7 @@ void tst_QQmlTableModel::clear()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -287,7 +287,7 @@ void tst_QQmlTableModel::getRow()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -318,7 +318,7 @@ void tst_QQmlTableModel::insertRow()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -474,7 +474,7 @@ void tst_QQmlTableModel::moveRow()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->columnCount(), 2);
QCOMPARE(model->rowCount(), 2);
@@ -602,7 +602,7 @@ void tst_QQmlTableModel::setRow()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->columnCount(), 2);
QCOMPARE(model->rowCount(), 2);
@@ -762,7 +762,7 @@ void tst_QQmlTableModel::setDataThroughDelegate()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -825,7 +825,7 @@ void tst_QQmlTableModel::setRowsImperatively()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 0);
QCOMPARE(model->columnCount(), 2);
@@ -862,7 +862,7 @@ void tst_QQmlTableModel::setRowsMultipleTimes()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("testModel").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -919,7 +919,7 @@ void tst_QQmlTableModel::dataAndEditing()
view.show();
QVERIFY(QTest::qWaitForWindowActive(&view));
- QQmlTableModel *model = view.rootObject()->property("model").value<QQmlTableModel*>();
+ auto *model = view.rootObject()->property("model").value<QAbstractTableModel*>();
QVERIFY(model);
const QHash<int, QByteArray> roleNames = model->roleNames();
@@ -939,7 +939,7 @@ void tst_QQmlTableModel::omitTableModelColumnIndex()
QQmlComponent component(&engine, testFileUrl("omitTableModelColumnIndex.qml"));
QCOMPARE(component.status(), QQmlComponent::Ready);
- QScopedPointer<QQmlTableModel> model(qobject_cast<QQmlTableModel*>(component.create()));
+ QScopedPointer<QAbstractTableModel> model(qobject_cast<QAbstractTableModel*>(component.create()));
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
@@ -963,7 +963,7 @@ void tst_QQmlTableModel::complexRow()
QCOMPARE(tableView->rows(), 2);
QCOMPARE(tableView->columns(), 2);
- QQmlTableModel *model = tableView->model().value<QQmlTableModel*>();
+ auto *model = tableView->model().value<QAbstractTableModel*>();
QVERIFY(model);
QCOMPARE(model->rowCount(), 2);
QCOMPARE(model->columnCount(), 2);
diff --git a/tests/auto/qml/qqmltypeloader/data/declarativeCppType.qml b/tests/auto/qml/qqmltypeloader/data/declarativeCppType.qml
new file mode 100644
index 0000000000..9061f3beb5
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/declarativeCppType.qml
@@ -0,0 +1,6 @@
+import QtQml 2.0
+import declarative.import.for.typeloader.test 3.2
+
+DeclarativeTestType {
+ objectName: "ddddd"
+}
diff --git a/tests/auto/qml/qqmltypeloader/declarativetesttype.h b/tests/auto/qml/qqmltypeloader/declarativetesttype.h
new file mode 100644
index 0000000000..a21cdcfd1d
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/declarativetesttype.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DECLARATIVETESTTYPE_H
+#define DECLARATIVETESTTYPE_H
+
+#include <QObject>
+#include <qqml.h>
+
+class DeclarativeTestType : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+
+public:
+ explicit DeclarativeTestType(QObject *parent = nullptr) : QObject(parent) {}
+};
+
+#endif // DECLARATIVETESTTYPE_H
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 07f67c7843..d529600723 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -61,7 +61,7 @@ private slots:
void qrcRootPathUrl();
void implicitImport();
void compositeSingletonCycle();
-
+ void declarativeCppType();
private:
void checkSingleton(const QString & dataDirectory);
};
@@ -100,6 +100,8 @@ void tst_QQMLTypeLoader::trimCache()
{
QQmlEngine engine;
QQmlTypeLoader &loader = QQmlEnginePrivate::get(&engine)->typeLoader;
+ QVector<QQmlTypeData *> releaseLater;
+ QVector<QV4::ExecutableCompilationUnit *> releaseCompilationUnitLater;
for (int i = 0; i < 256; ++i) {
QUrl url = testFileUrl("trim_cache.qml");
url.setQuery(QString::number(i));
@@ -112,8 +114,10 @@ void tst_QQMLTypeLoader::trimCache()
// QQmlTypeData or its compiledData() should prevent the trimming.
if (i % 10 == 0) {
// keep ref on data, don't add ref on data->compiledData()
+ releaseLater.append(data);
} else if (i % 5 == 0) {
data->compilationUnit()->addref();
+ releaseCompilationUnitLater.append(data->compilationUnit());
data->release();
} else {
data->release();
@@ -129,6 +133,12 @@ void tst_QQMLTypeLoader::trimCache()
QVERIFY(!loader.isTypeLoaded(url));
// The cache is free to keep the others.
}
+
+ for (auto *data : qAsConst(releaseCompilationUnitLater))
+ data->release();
+
+ for (auto *data : qAsConst(releaseLater))
+ data->release();
}
void tst_QQMLTypeLoader::trimCache2()
@@ -557,6 +567,15 @@ void tst_QQMLTypeLoader::compositeSingletonCycle()
QCOMPARE(qvariant_cast<QColor>(object->property("color")), QColorConstants::Black);
}
+void tst_QQMLTypeLoader::declarativeCppType()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("declarativeCppType.qml"));
+ QCOMPARE(component.status(), QQmlComponent::Ready);
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+}
+
QTEST_MAIN(tst_QQMLTypeLoader)
#include "tst_qqmltypeloader.moc"
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.pro b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.pro
index 743f7cf3ac..c868474b5b 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.pro
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.pro
@@ -1,4 +1,4 @@
-CONFIG += testcase
+CONFIG += testcase qmltypes
TARGET = tst_qqmltypeloader
QT += qml testlib qml-private quick
macx:CONFIG -= app_bundle
@@ -8,7 +8,11 @@ SOURCES += \
../../shared/testhttpserver.cpp
HEADERS += \
- ../../shared/testhttpserver.h
+ ../../shared/testhttpserver.h \
+ declarativetesttype.h
+
+QML_IMPORT_VERSION = 3.2
+QML_IMPORT_NAME = "declarative.import.for.typeloader.test"
include (../../shared/util.pri)
diff --git a/tests/auto/quick/qquickanimatedsprite/data/finishBehavior.qml b/tests/auto/quick/qquickanimatedsprite/data/finishBehavior.qml
new file mode 100644
index 0000000000..13a0ef4622
--- /dev/null
+++ b/tests/auto/quick/qquickanimatedsprite/data/finishBehavior.qml
@@ -0,0 +1,18 @@
+import QtQuick 2.15
+
+Rectangle {
+ color: "black"
+ width: 320
+ height: 320
+
+ AnimatedSprite {
+ objectName: "sprite"
+ loops: 1
+ source: "squarefacesprite.png"
+ frameCount: 6
+ frameDuration: 64
+ width: 160
+ height: 160
+ finishBehavior: AnimatedSprite.FinishAtFinalFrame
+ }
+}
diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
index d2bbf9e6b1..9f616c56e2 100644
--- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
+++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp
@@ -49,6 +49,7 @@ private slots:
void initTestCase();
void test_properties();
void test_runningChangedSignal();
+ void test_startStop();
void test_frameChangedSignal();
void test_largeAnimation_data();
void test_largeAnimation();
@@ -56,6 +57,7 @@ private slots:
void test_changeSourceToSmallerImgKeepingBigFrameSize();
void test_infiniteLoops();
void test_implicitSize();
+ void test_finishBehavior();
};
void tst_qquickanimatedsprite::initTestCase()
@@ -118,6 +120,42 @@ void tst_qquickanimatedsprite::test_runningChangedSignal()
QCOMPARE(finishedSpy.count(), 1);
}
+void tst_qquickanimatedsprite::test_startStop()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+
+ window->setSource(testFileUrl("runningChange.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QVERIFY(window->rootObject());
+ QQuickAnimatedSprite* sprite = window->rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
+ QVERIFY(sprite);
+
+ QVERIFY(!sprite->running());
+
+ QSignalSpy runningChangedSpy(sprite, SIGNAL(runningChanged(bool)));
+ QSignalSpy finishedSpy(sprite, SIGNAL(finished()));
+ QVERIFY(finishedSpy.isValid());
+
+ sprite->start();
+ QVERIFY(sprite->running());
+ QTRY_COMPARE(runningChangedSpy.count(), 1);
+ QCOMPARE(finishedSpy.count(), 0);
+ sprite->stop();
+ QVERIFY(!sprite->running());
+ QTRY_COMPARE(runningChangedSpy.count(), 2);
+ QCOMPARE(finishedSpy.count(), 0);
+
+ sprite->setCurrentFrame(2);
+ sprite->start();
+ QVERIFY(sprite->running());
+ QCOMPARE(sprite->currentFrame(), 0);
+ QTRY_VERIFY(sprite->currentFrame() > 0);
+ sprite->stop();
+ QVERIFY(!sprite->running());
+}
+
template <typename T>
static bool isWithinRange(T min, T value, T max)
{
@@ -391,6 +429,31 @@ void tst_qquickanimatedsprite::test_infiniteLoops()
QCOMPARE(finishedSpy.count(), 0);
}
+void tst_qquickanimatedsprite::test_finishBehavior()
+{
+ QQuickView window;
+ window.setSource(testFileUrl("finishBehavior.qml"));
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QVERIFY(window.rootObject());
+
+ QQuickAnimatedSprite* sprite = window.rootObject()->findChild<QQuickAnimatedSprite*>("sprite");
+ QVERIFY(sprite);
+
+ QTRY_VERIFY(sprite->running());
+
+ // correctly stops at last frame
+ QSignalSpy finishedSpy(sprite, SIGNAL(finished()));
+ QVERIFY(finishedSpy.wait(2000));
+ QCOMPARE(sprite->running(), false);
+ QCOMPARE(sprite->currentFrame(), 5);
+
+ // correctly starts a second time
+ sprite->start();
+ QTRY_VERIFY(sprite->running());
+ QTRY_COMPARE(sprite->currentFrame(), 5);
+}
+
QTEST_MAIN(tst_qquickanimatedsprite)
#include "tst_qquickanimatedsprite.moc"
diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
index ee43e5e06a..f1288c2dbe 100644
--- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
+++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp
@@ -143,6 +143,7 @@ private slots:
void source();
void recursion_data();
void recursion();
+ void noCrashWithImageProvider();
private:
QQmlEngine engine;
@@ -1279,6 +1280,30 @@ void tst_QQuickDrag::recursion()
}
}
+void tst_QQuickDrag::noCrashWithImageProvider()
+{
+ // QTBUG-72045
+ QQmlComponent component(&engine);
+ component.setData(
+ R"(
+ import QtQuick 2.9
+ Item {
+ Rectangle {
+ id: item
+ width: 50
+ height: 50
+ anchors.centerIn: parent
+ color: "orange"
+ Component.onCompleted: {
+ item.Drag.imageSource = "image://kill/me"
+ }
+ }
+ })", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QQuickItem *item = qobject_cast<QQuickItem *>(object.data());
+ QVERIFY(item);
+}
+
QTEST_MAIN(tst_QQuickDrag)
diff --git a/tests/auto/quick/qquickitem/data/setParentInWindowChange.qml b/tests/auto/quick/qquickitem/data/setParentInWindowChange.qml
new file mode 100644
index 0000000000..d68b7adb72
--- /dev/null
+++ b/tests/auto/quick/qquickitem/data/setParentInWindowChange.qml
@@ -0,0 +1,12 @@
+import QtQuick 2.12
+
+Rectangle {
+ width: 800
+ height: 600
+ Item {
+ id: it
+ onWindowChanged: () => it.parent = newParent
+ }
+
+ Item { id: newParent }
+}
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index b6e40d5117..8aab13e095 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -197,6 +197,8 @@ private slots:
void qtBug60123();
#endif
+ void setParentCalledInOnWindowChanged();
+
private:
enum PaintOrderOp {
@@ -2146,6 +2148,12 @@ void tst_qquickitem::qtBug60123()
activateWindowAndTestPress(&window);
}
#endif
+void tst_qquickitem::setParentCalledInOnWindowChanged()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("setParentInWindowChange.qml"));
+ QVERIFY(ensureFocus(&view)); // should not crash
+}
QTEST_MAIN(tst_qquickitem)
diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
index 399535cfa6..607cf91bfe 100644
--- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp
@@ -76,8 +76,10 @@ private slots:
void qtbug_50516_2();
void keys();
+#if QT_CONFIG(shortcut)
void standardKeys_data();
void standardKeys();
+#endif
void keysProcessingOrder();
void keysim();
void keysForward();
@@ -1429,6 +1431,8 @@ void tst_QQuickItem::keys()
delete testObject;
}
+#if QT_CONFIG(shortcut)
+
Q_DECLARE_METATYPE(QEvent::Type);
Q_DECLARE_METATYPE(QKeySequence::StandardKey);
@@ -1487,6 +1491,8 @@ void tst_QQuickItem::standardKeys()
QCOMPARE(item->property("released").toBool(), released);
}
+#endif // QT_CONFIG(shortcut)
+
void tst_QQuickItem::keysProcessingOrder()
{
QQuickView *window = new QQuickView(nullptr);
diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
index 49838c4fd5..e8b3960486 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml
@@ -1019,5 +1019,59 @@ Item {
waitForRendering(layout);
verify(layout.children[1].visible == false);
}
+
+
+
+ Component {
+ id: gridlayout_propertyChanges_Component
+ GridLayout {
+ columns: 1
+ property alias spy : signalSpy
+ SignalSpy {
+ id: signalSpy
+ target: parent
+ }
+ }
+ }
+
+ Component {
+ id: rowlayout_propertyChanges_Component
+ RowLayout {
+ property alias spy : signalSpy
+ SignalSpy {
+ id: signalSpy
+ target: parent
+ }
+ }
+ }
+
+ function test_propertyChanges_data()
+ {
+ let data = [
+ { tag: "columnSpacing", value: 9 },
+ { tag: "rowSpacing", value: 9 },
+ { tag: "columns", value: 2 },
+ { tag: "rows", value: 2 },
+ { tag: "flow", value: GridLayout.TopToBottom},
+ { tag: "layoutDirection", value: Qt.RightToLeft },
+ { tag: "spacing", value: 9 }
+ ]
+ return data
+ }
+
+ function test_propertyChanges(data)
+ {
+ var propName = data.tag
+ var layout = createTemporaryObject(propName === "spacing"
+ ? rowlayout_propertyChanges_Component
+ : gridlayout_propertyChanges_Component
+ , container)
+
+ layout.spy.signalName = propName + "Changed"
+ verify(layout.spy.valid)
+
+ layout[propName] = data.value
+ compare(layout.spy.count, 1)
+ }
}
}
diff --git a/tests/auto/quick/qquickloader/data/CacheClearTest.qml b/tests/auto/quick/qquickloader/data/CacheClearTest.qml
new file mode 100644
index 0000000000..acab79f96e
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/CacheClearTest.qml
@@ -0,0 +1,4 @@
+import QtQml 2.12
+QtObject {
+ property int i: 42
+}
diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml
new file mode 100644
index 0000000000..ddc874d14c
--- /dev/null
+++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml
@@ -0,0 +1,20 @@
+import QtQuick 2.0
+
+Item {
+ id: root
+ property int oldi: 0
+ property int i: 0
+
+ Loader {
+ id: loader
+ objectName: "loader"
+ active: true
+ }
+
+ Component.onCompleted: {
+ loader.setSource("CacheClearTest.qml", {i: 12})
+ root.oldi = loader.item.i
+ loader.setSource("CacheClearTest.qml")
+ root.i = loader.item.i // should be 42
+ }
+}
diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
index da923d4d41..e05b7ae9ce 100644
--- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp
+++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp
@@ -691,6 +691,11 @@ void tst_QQuickLoader::initialPropertyValues_data()
<< (QStringList() << QString(testFileUrl("RequiredPropertyValuesComponent.qml").toString() + QLatin1String(":6:5: Required property s was not initialized")))
<< (QStringList() << "i" << "s")
<< (QVariantList() << 0 << QLatin1String(""));
+
+ QTest::newRow("source url changed, previously initial properties are discared") << testFileUrl("initialPropertyValues.11.qml")
+ << QStringList()
+ << (QStringList() << "oldi" << "i")
+ << (QVariantList() << 12 << 42);
}
void tst_QQuickLoader::initialPropertyValues()
diff --git a/tests/auto/quick/qquicktext/data/lineLayout.qml b/tests/auto/quick/qquicktext/data/lineLayout.qml
index cb2474791e..5a980de7da 100644
--- a/tests/auto/quick/qquicktext/data/lineLayout.qml
+++ b/tests/auto/quick/qquicktext/data/lineLayout.qml
@@ -14,6 +14,9 @@ Rectangle {
textFormat: Text.StyledText
focus: true
+ property int lastLineNumber: -1
+ property bool receivedMultipleLastLines
+
text: "<b>Lorem ipsum</b> dolor sit amet, consectetur adipiscing elit. Integer at ante dui. Sed eu egestas est.
<br/><p><i>Maecenas nec libero leo. Sed ac leo eget ipsum ultricies viverra sit amet eu orci. Praesent et tortor risus, viverra accumsan sapien. Sed faucibus eleifend lectus, sed euismod urna porta eu. Aenean ultricies lectus ut orci dictum quis convallis nisi ultrices. Nunc elit mi, iaculis a porttitor rutrum, venenatis malesuada nisi. Suspendisse turpis quam, euismod non imperdiet et, rutrum nec ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam semper tristique metus eu sodales. Integer eget risus ipsum. Quisque ut risus ut nulla tristique volutpat at sit amet nisl. Aliquam pulvinar auctor diam nec bibendum.</i><br/><p>Quisque luctus sapien id arcu volutpat pharetra. Praesent pretium imperdiet euismod. Integer fringilla rhoncus condimentum. Quisque sit amet ornare nulla. Cras sapien augue, sagittis a dictum id, suscipit et nunc. Cras vitae augue in enim elementum venenatis sed nec risus. Sed nisi quam, mollis quis auctor ac, vestibulum in neque. Vivamus eu justo risus. Suspendisse vel mollis est. Vestibulum gravida interdum mi, in molestie neque gravida in. Donec nibh odio, mattis facilisis vulputate et, scelerisque ut felis. Sed ornare eros nec odio aliquam eu varius augue adipiscing. Vivamus sit amet massa dapibus sapien pulvinar consectetur a sit amet felis. Cras non mi id libero dictum iaculis id dignissim eros. Praesent eget enim dui, sed bibendum neque. Ut interdum nisl id leo malesuada ornare. Pellentesque id nisl eu odio volutpat posuere et at massa. Pellentesque nec lorem justo. Integer sem urna, pharetra sed sagittis vitae, condimentum ac felis. Ut vitae sapien ac tortor adipiscing pharetra. Cras tristique urna tempus ante volutpat eleifend non eu ligula. Mauris sodales nisl et lorem tristique sodales. Mauris arcu orci, vehicula semper cursus ac, dapibus ut mi."
@@ -30,6 +33,12 @@ Rectangle {
line.x = line.width * 2 + 60
line.height = 20
}
+
+ // Save last line number, it is important to do this after setting the width
+ if (line.isLast) {
+ receivedMultipleLastLines = (lastLineNumber !== -1) && (lastLineNumber !== line.number)
+ lastLineNumber = line.number
+ }
}
}
}
diff --git a/tests/auto/quick/qquicktext/data/lineLayoutImplicitWidth.qml b/tests/auto/quick/qquicktext/data/lineLayoutImplicitWidth.qml
new file mode 100644
index 0000000000..de5ca616b8
--- /dev/null
+++ b/tests/auto/quick/qquicktext/data/lineLayoutImplicitWidth.qml
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Jolla Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: main
+ width: 800; height: 600
+
+ property real off: 0
+
+ Text {
+ id: myText
+ objectName: "myText"
+ wrapMode: Text.WordWrap
+ font.pixelSize: 14
+ textFormat: Text.PlainText
+ focus: true
+ anchors.fill: parent
+
+ // The autotest will retrieve these so that it can verify them
+ property var lineImplicitWidths: []
+
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam quis ante tristique, fermentum magna at, varius lacus. Donec elementum orci sit amet ligula efficitur, eget sodales orci porttitor. Etiam laoreet tellus quis nisi mollis lacinia. Cras vitae nisl sed nunc semper blandit. Duis egestas commodo lacus non congue. Fusce quis rhoncus urna. And magna arcu, sodales vitae nunc vel, rutrum hendrerit magna. Nullam imperdiet porttitor sem at euismod. Morbi faucibus libero sit amet vestibulum aliquam. Duis consectetur lacinia malesuada. Sed quis ante dui. Name dignissim faucibus felis. Quisque dapibus aliquam ante, eu cursus elit dictum in. Mauris placerat efficitur rutrum."
+
+ onLineLaidOut: {
+ var n = line.number
+
+ // Save information about the line so the autotest can retrieve it
+ lineImplicitWidths[n] = line.implicitWidth
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
index e62db81d27..06ce730091 100644
--- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp
+++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp
@@ -30,6 +30,7 @@
#include <QTextDocument>
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlcomponent.h>
+#include <QtQml/qjsvalue.h>
#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickmousearea_p.h>
#include <QtQuickTest/QtQuickTest>
@@ -119,6 +120,7 @@ private slots:
void lineLaidOut();
void lineLaidOutRelayout();
void lineLaidOutHAlign();
+ void lineLaidOutImplicitWidth();
void imgTagsBaseUrl_data();
void imgTagsBaseUrl();
@@ -2871,6 +2873,13 @@ void tst_qquicktext::lineLaidOut()
QCOMPARE(r.height(), qreal(20));
}
}
+
+ // Ensure that isLast was correctly emitted
+ int lastLineNumber = myText->property("lastLineNumber").toInt();
+ QCOMPARE(lastLineNumber, myText->lineCount() - 1);
+ // Ensure that only one line was considered last (after changing its width)
+ bool receivedMultipleLastLines = myText->property("receivedMultipleLastLines").toBool();
+ QVERIFY(!receivedMultipleLastLines);
}
void tst_qquicktext::lineLaidOutRelayout()
@@ -2975,6 +2984,53 @@ void tst_qquicktext::imgTagsBaseUrl_data()
<< 181.;
}
+void tst_qquicktext::lineLaidOutImplicitWidth()
+{
+ QScopedPointer<QQuickView> window(createView(testFile("lineLayoutImplicitWidth.qml")));
+
+ QQuickText *myText = window->rootObject()->findChild<QQuickText*>("myText");
+ QVERIFY(myText != nullptr);
+
+ QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(myText);
+ QVERIFY(textPrivate != nullptr);
+
+ // Retrieve the saved implicitWidth values of each rendered line
+ QVariant widthsProperty = myText->property("lineImplicitWidths");
+ QVERIFY(!widthsProperty.isNull());
+ QVERIFY(widthsProperty.isValid());
+ QVERIFY(widthsProperty.canConvert<QJSValue>());
+ QJSValue widthsValue = widthsProperty.value<QJSValue>();
+ QVERIFY(widthsValue.isArray());
+ int lineCount = widthsValue.property("length").toInt();
+ QVERIFY(lineCount > 0);
+
+ // Create the same text layout by hand
+ // Note that this approach needs additional processing for styled text,
+ // so we only use it for plain text here.
+ QTextLayout layout;
+ layout.setCacheEnabled(true);
+ layout.setText(myText->text());
+ layout.setTextOption(textPrivate->layout.textOption());
+ layout.setFont(myText->font());
+ layout.beginLayout();
+ for (QTextLine line = layout.createLine(); line.isValid(); line = layout.createLine()) {
+ line.setLineWidth(myText->width());
+ }
+ layout.endLayout();
+
+ // Line count of the just created layout should match the rendered text
+ QCOMPARE(lineCount, layout.lineCount());
+
+ // Go through each line and verify that the values emitted by lineLaidOut are correct
+ for (int i = 0; i < layout.lineCount(); ++i) {
+ qreal implicitWidth = widthsValue.property(i).toNumber();
+ QVERIFY(implicitWidth > 0);
+
+ QTextLine line = layout.lineAt(i);
+ QCOMPARE(implicitWidth, line.naturalTextWidth());
+ }
+}
+
static QUrl substituteTestServerUrl(const QUrl &serverUrl, const QUrl &testUrl)
{
QUrl result = testUrl;
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
index facd63027e..d03441e052 100644
--- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
+++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp
@@ -131,8 +131,10 @@ private slots:
void mouseSelectionMode_accessors();
void selectByMouse();
void selectByKeyboard();
+#if QT_CONFIG(shortcut)
void keyboardSelection_data();
void keyboardSelection();
+#endif
void renderType();
void inputMethodHints();
@@ -190,16 +192,19 @@ private slots:
void insert();
void remove_data();
void remove();
-
+#if QT_CONFIG(shortcut)
void keySequence_data();
void keySequence();
+#endif
void undo_data();
void undo();
void redo_data();
void redo();
+#if QT_CONFIG(shortcut)
void undo_keypressevents_data();
void undo_keypressevents();
+#endif
void clear();
void baseUrl();
@@ -217,7 +222,9 @@ private slots:
private:
void simulateKeys(QWindow *window, const QList<Key> &keys);
+#if QT_CONFIG(shortcut)
void simulateKeys(QWindow *window, const QKeySequence &sequence);
+#endif
void simulateKey(QWindow *, int key, Qt::KeyboardModifiers modifiers = nullptr);
@@ -260,6 +267,8 @@ void tst_qquicktextedit::simulateKeys(QWindow *window, const QList<Key> &keys)
}
}
+#if QT_CONFIG(shortcut)
+
void tst_qquicktextedit::simulateKeys(QWindow *window, const QKeySequence &sequence)
{
for (int i = 0; i < sequence.count(); ++i) {
@@ -277,6 +286,8 @@ QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
return keys;
}
+#endif // QT_CONFIG(shortcut)
+
template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
{
for (int i = 0; i < N - 1; ++i) {
@@ -2307,6 +2318,8 @@ void tst_qquicktextedit::selectByKeyboard()
QCOMPARE(spy.at(2).at(0).toBool(), false);
}
+#if QT_CONFIG(shortcut)
+
Q_DECLARE_METATYPE(QKeySequence::StandardKey)
void tst_qquicktextedit::keyboardSelection_data()
@@ -2391,6 +2404,8 @@ void tst_qquicktextedit::keyboardSelection()
QCOMPARE(edit->selectedText(), selectedText);
}
+#endif // QT_CONFIG(shortcut)
+
void tst_qquicktextedit::renderType()
{
QQmlComponent component(&engine);
@@ -4820,6 +4835,7 @@ void tst_qquicktextedit::remove()
QVERIFY(cursorPositionSpy.count() > 0);
}
+#if QT_CONFIG(shortcut)
void tst_qquicktextedit::keySequence_data()
{
@@ -4984,6 +5000,8 @@ void tst_qquicktextedit::keySequence()
QCOMPARE(textEdit->selectedText(), selectedText);
}
+#endif // QT_CONFIG(shortcut)
+
#define NORMAL 0
#define REPLACE_UNTIL_END 1
@@ -5257,6 +5275,8 @@ void tst_qquicktextedit::redo()
QCOMPARE(spy.count(), 2);
}
+#if QT_CONFIG(shortcut)
+
void tst_qquicktextedit::undo_keypressevents_data()
{
QTest::addColumn<KeyList>("keys");
@@ -5450,6 +5470,8 @@ void tst_qquicktextedit::undo_keypressevents()
QVERIFY(textEdit->text().isEmpty());
}
+#endif // QT_CONFIG(shortcut)
+
void tst_qquicktextedit::clear()
{
QString componentStr = "import QtQuick 2.0\nTextEdit { focus: true }";
diff --git a/tests/auto/quick/qquicktextinput/data/qtbug77841.qml b/tests/auto/quick/qquicktextinput/data/qtbug77841.qml
new file mode 100644
index 0000000000..ebb43a8f82
--- /dev/null
+++ b/tests/auto/quick/qquicktextinput/data/qtbug77841.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.12
+
+Item {
+ id: root
+ width: 600
+ height: 300
+
+ TextInput {
+ id: qwe
+ objectName: "qwe"
+ width: 500
+ height: 100
+ font.pixelSize: 50
+ text: "123456"
+ focus: true
+ }
+
+ Component.onCompleted: {
+ qwe.insert(0, "***")
+ qwe.remove(0, 3)
+ }
+}
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index ed2d535fda..1d12121a6f 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -146,7 +146,7 @@ private slots:
void cursorRectangle();
void navigation();
void navigation_RTL();
-#if QT_CONFIG(clipboard)
+#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void copyAndPaste();
void copyAndPasteKeySequence();
void canPasteEmpty();
@@ -181,15 +181,19 @@ private slots:
void remove_data();
void remove();
+#if QT_CONFIG(shortcut)
void keySequence_data();
void keySequence();
+#endif
void undo_data();
void undo();
void redo_data();
void redo();
+#if QT_CONFIG(shortcut)
void undo_keypressevents_data();
void undo_keypressevents();
+#endif
void clear();
void backspaceSurrogatePairs();
@@ -230,12 +234,15 @@ private slots:
void padding();
void QTBUG_51115_readOnlyResetsSelection();
+ void QTBUG_77814_InsertRemoveNoSelection();
private:
void simulateKey(QWindow *, int key);
void simulateKeys(QWindow *window, const QList<Key> &keys);
+#if QT_CONFIG(shortcut)
void simulateKeys(QWindow *window, const QKeySequence &sequence);
+#endif
QQmlEngine engine;
QStringList standard;
@@ -263,6 +270,8 @@ void tst_qquicktextinput::simulateKeys(QWindow *window, const QList<Key> &keys)
}
}
+#if QT_CONFIG(shortcut)
+
void tst_qquicktextinput::simulateKeys(QWindow *window, const QKeySequence &sequence)
{
for (int i = 0; i < sequence.count(); ++i) {
@@ -280,6 +289,8 @@ QList<Key> &operator <<(QList<Key> &keys, const QKeySequence &sequence)
return keys;
}
+#endif // QT_CONFIG(shortcut)
+
template <int N> QList<Key> &operator <<(QList<Key> &keys, const char (&characters)[N])
{
for (int i = 0; i < N - 1; ++i) {
@@ -2585,7 +2596,7 @@ void tst_qquicktextinput::navigation_RTL()
QVERIFY(input->hasActiveFocus());
}
-#if QT_CONFIG(clipboard)
+#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::copyAndPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -2683,7 +2694,7 @@ void tst_qquicktextinput::copyAndPaste()
}
#endif
-#if QT_CONFIG(clipboard)
+#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::copyAndPasteKeySequence()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -2751,7 +2762,7 @@ void tst_qquicktextinput::copyAndPasteKeySequence()
}
#endif
-#if QT_CONFIG(clipboard)
+#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::canPasteEmpty()
{
QGuiApplication::clipboard()->clear();
@@ -2767,7 +2778,7 @@ void tst_qquicktextinput::canPasteEmpty()
}
#endif
-#if QT_CONFIG(clipboard)
+#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::canPaste()
{
QGuiApplication::clipboard()->setText("Some text");
@@ -2783,7 +2794,7 @@ void tst_qquicktextinput::canPaste()
}
#endif
-#if QT_CONFIG(clipboard)
+#if QT_CONFIG(clipboard) && QT_CONFIG(shortcut)
void tst_qquicktextinput::middleClickPaste()
{
if (!PlatformQuirks::isClipboardAvailable())
@@ -5097,6 +5108,7 @@ void tst_qquicktextinput::remove()
QVERIFY(cursorPositionSpy.count() > 0);
}
+#if QT_CONFIG(shortcut)
void tst_qquicktextinput::keySequence_data()
{
QTest::addColumn<QString>("text");
@@ -5282,6 +5294,8 @@ void tst_qquicktextinput::keySequence()
QCOMPARE(textInput->selectedText(), selectedText);
}
+#endif // QT_CONFIG(shortcut)
+
#define NORMAL 0
#define REPLACE_UNTIL_END 1
@@ -5555,6 +5569,8 @@ void tst_qquicktextinput::redo()
QCOMPARE(spy.count(), 2);
}
+#if QT_CONFIG(shortcut)
+
void tst_qquicktextinput::undo_keypressevents_data()
{
QTest::addColumn<KeyList>("keys");
@@ -5859,6 +5875,8 @@ void tst_qquicktextinput::undo_keypressevents()
QVERIFY(textInput->text().isEmpty());
}
+#endif // QT_CONFIG(shortcut)
+
void tst_qquicktextinput::clear()
{
QString componentStr = "import QtQuick 2.0\nTextInput { focus: true }";
@@ -7003,6 +7021,18 @@ void tst_qquicktextinput::QTBUG_51115_readOnlyResetsSelection()
QCOMPARE(obj->selectedText(), QString());
}
+void tst_qquicktextinput::QTBUG_77814_InsertRemoveNoSelection()
+{
+ QQuickView view;
+ view.setSource(testFileUrl("qtbug77841.qml"));
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QQuickTextInput *textInput = view.rootObject()->findChild<QQuickTextInput*>("qwe");
+ QVERIFY(textInput);
+
+ QCOMPARE(textInput->selectedText(), QString());
+}
+
QTEST_MAIN(tst_qquicktextinput)
#include "tst_qquicktextinput.moc"
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index b6ffdc0f7e..9ab7119903 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -96,6 +96,8 @@ boot2qt: QUICKTESTS -= qquickgridview qquicklistview qquicktableview qquickposit
!qtConfig(accessibility):QUICKTESTS -= qquickaccessible
+!qtConfig(shortcut):QUICKTESTS -= qquickshortcut
+
qtConfig(private_tests) {
SUBDIRS += $$PRIVATETESTS
SUBDIRS += $$QUICKTESTS