diff options
Diffstat (limited to 'tests/auto')
75 files changed, 1302 insertions, 357 deletions
diff --git a/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml b/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml index de105916a7..61599adc09 100644 --- a/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml +++ b/tests/auto/particles/qquickparticlesystem/data/crashaffectors.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2017 reMarkable A/S -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp index 584bd10151..441f8c113f 100644 --- a/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp +++ b/tests/auto/qml/debugger/qv4debugger/tst_qv4debugger.cpp @@ -46,7 +46,7 @@ using namespace QV4; using namespace QV4::Debugging; -typedef QV4::ReturnedValue (*InjectedFunction)(QV4::CallContext*); +typedef void (*InjectedFunction)(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData); Q_DECLARE_METATYPE(InjectedFunction) static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) @@ -438,11 +438,11 @@ void tst_qv4debugger::addBreakPointWhilePaused() QCOMPARE(state.lineNumber, 2); } -static QV4::ReturnedValue someCall(QV4::CallContext *ctx) +static void someCall(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *) { - static_cast<QV4Debugger *>(ctx->d()->engine->debugger()) + static_cast<QV4Debugger *>(scope.engine->debugger()) ->removeBreakPoint("removeBreakPointForNextInstruction", 2); - return QV4::Encode::undefined(); + RETURN_UNDEFINED(); } void tst_qv4debugger::removeBreakPointForNextInstruction() diff --git a/tests/auto/qml/ecmascripttests/test262.py b/tests/auto/qml/ecmascripttests/test262.py index 99f029cffd..9f0a7c1dee 100755 --- a/tests/auto/qml/ecmascripttests/test262.py +++ b/tests/auto/qml/ecmascripttests/test262.py @@ -569,6 +569,7 @@ def Main(): #logging.basicConfig(level=logging.DEBUG) os.environ["TZ"] = "PST8PDT" os.environ["LANG"] = "en_US.UTF-8" + os.environ["LC_TIME"] = "en_US.UTF-8" parser = BuildOptions() (options, args) = parser.parse_args() ValidateOptions(options) diff --git a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp index 5d7009e7c8..880e254543 100644 --- a/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp +++ b/tests/auto/qml/ecmascripttests/tst_ecmascripttests.cpp @@ -44,7 +44,7 @@ void tst_EcmaScriptTests::runTests_data() QTest::addColumn<QString>("qmljsParameter"); QTest::newRow("jit") << QStringLiteral("--jit"); - // Not passing yet: QTest::newRow("interpreter") << QStringLiteral("--interpret"); + QTest::newRow("interpreter") << QStringLiteral("--interpret"); } void tst_EcmaScriptTests::runTests() diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 59566ad927..12a8bd3829 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -7,6 +7,7 @@ PUBLICTESTS += \ parserstress \ qjsvalueiterator \ qjsonbinding \ + qqmlfile \ !boot2qt { PUBLICTESTS += \ diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index b7e616a050..1f80ff46d0 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -43,6 +43,7 @@ private slots: void loadGeneratedFile(); void translationExpressionSupport(); + void signalHandlerParameters(); }; // A wrapper around QQmlComponent to ensure the temporary reference counts @@ -158,6 +159,41 @@ void tst_qmlcachegen::translationExpressionSupport() QCOMPARE(obj->property("text").toString(), QString("All Ok")); } +void tst_qmlcachegen::signalHandlerParameters() +{ + QTemporaryDir tempDir; + QVERIFY(tempDir.isValid()); + + const auto writeTempFile = [&tempDir](const QString &fileName, const char *contents) { + QFile f(tempDir.path() + '/' + fileName); + const bool ok = f.open(QIODevice::WriteOnly | QIODevice::Truncate); + Q_ASSERT(ok); + f.write(contents); + return f.fileName(); + }; + + const QString testFilePath = writeTempFile("test.qml", "import QtQml 2.0\n" + "QtObject {\n" + " property real result: 0\n" + " signal testMe(real value);\n" + " onTestMe: result = value;\n" + " function runTest() { testMe(42); }\n" + "}"); + + QVERIFY(generateCache(testFilePath)); + + const QString cacheFilePath = testFilePath + QLatin1Char('c'); + QVERIFY(QFile::exists(cacheFilePath)); + QVERIFY(QFile::remove(testFilePath)); + + QQmlEngine engine; + CleanlyLoadingComponent component(&engine, QUrl::fromLocalFile(testFilePath)); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(!obj.isNull()); + QMetaObject::invokeMethod(obj.data(), "runTest"); + QCOMPARE(obj->property("result").toInt(), 42); +} + QTEST_GUILESS_MAIN(tst_qmlcachegen) #include "tst_qmlcachegen.moc" diff --git a/tests/auto/qml/qqmlbinding/data/bindingOverwriting.qml b/tests/auto/qml/qqmlbinding/data/bindingOverwriting.qml new file mode 100644 index 0000000000..767ca0c719 --- /dev/null +++ b/tests/auto/qml/qqmlbinding/data/bindingOverwriting.qml @@ -0,0 +1,13 @@ +import QtQuick 2.9 + +Text { + visible: text && enabled + enabled: font.pixelSize === 25 + font: enabled ? Qt.font({ "pixelSize": 25 }) : Qt.font({ "pixelSize": 50 }) + + Component.onCompleted: { + enabled = Qt.binding(function() { return visible; }); // replacement binding, not breaking + visible = true; // breaks visible binding + font.bold = true; // breaks font binding + } +} diff --git a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp index 6f1d82eca5..4b485d2ce8 100644 --- a/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp +++ b/tests/auto/qml/qqmlbinding/tst_qqmlbinding.cpp @@ -50,6 +50,7 @@ private slots: void disabledOnUnknownProperty(); void disabledOnReadonlyProperty(); void delayed(); + void bindingOverwriting(); private: QQmlEngine engine; @@ -303,6 +304,21 @@ void tst_qqmlbinding::delayed() delete item; } +void tst_qqmlbinding::bindingOverwriting() +{ + QQmlTestMessageHandler messageHandler; + QLoggingCategory::setFilterRules(QStringLiteral("qt.qml.binding.removal.info=true")); + + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("bindingOverwriting.qml")); + QQuickItem *item = qobject_cast<QQuickItem*>(c.create()); + QVERIFY(item); + delete item; + + QLoggingCategory::setFilterRules(QString()); + QCOMPARE(messageHandler.messages().count(), 2); +} + QTEST_MAIN(tst_qqmlbinding) #include "tst_qqmlbinding.moc" diff --git a/tests/auto/qml/qqmlconnections/data/disabled-at-start.qml b/tests/auto/qml/qqmlconnections/data/disabled-at-start.qml new file mode 100644 index 0000000000..1a823f87f6 --- /dev/null +++ b/tests/auto/qml/qqmlconnections/data/disabled-at-start.qml @@ -0,0 +1,14 @@ +import QtQuick 2.9 + +Item { + id: root + + property bool tested: false + signal testMe() + + Connections { + target: root + enabled: false + onTestMe: root.tested = true; + } +} diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index 1ed94fcb93..22e9724c61 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -52,6 +52,7 @@ private slots: void rewriteErrors(); void singletonTypeTarget(); void enableDisable_QTBUG_36350(); + void disabledAtStart(); void clearImplicitTarget(); void onWithoutASignal(); @@ -354,6 +355,23 @@ void tst_qqmlconnections::enableDisable_QTBUG_36350() delete item; } +void tst_qqmlconnections::disabledAtStart() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("disabled-at-start.qml")); + QObject * const object = c.create(); + + QVERIFY(object != 0); + + QCOMPARE(object->property("tested").toBool(), false); + const int index = object->metaObject()->indexOfSignal("testMe()"); + const QMetaMethod method = object->metaObject()->method(index); + method.invoke(object, Qt::DirectConnection); + QCOMPARE(object->property("tested").toBool(), false); + + delete object; +} + //QTBUG-56499 void tst_qqmlconnections::clearImplicitTarget() { diff --git a/tests/auto/qml/qqmlecmascript/data/dynamicString.qml b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml index 5693794c71..c704161eb5 100644 --- a/tests/auto/qml/qqmlecmascript/data/dynamicString.qml +++ b/tests/auto/qml/qqmlecmascript/data/dynamicString.qml @@ -11,6 +11,6 @@ MyTypeObject { date.setHours(5); date.setMinutes(30); date.setSeconds(50); - stringProperty = stringProperty.arg("Hello World").arg(false).arg(true).arg(100).arg(-100).arg(3.1415926).arg(Qt.formatDateTime(date, "yyyy-MM-dd hh::mm:ss")); + stringProperty = stringProperty.arg("Hello World").arg(false).arg(true).arg(100).arg(-100).arg(Math.PI).arg(Qt.formatDateTime(date, "yyyy-MM-dd hh::mm:ss")); } } diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml new file mode 100644 index 0000000000..5f022f605a --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/TestObject.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 +import "components" + +QtObject { + id: root + property int counter + function increment() { + counter++ + return counter + } +} diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml new file mode 100644 index 0000000000..3c5e65a340 --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/components/Counter.qml @@ -0,0 +1,4 @@ +import QtQuick 2.0 + +QtObject {} + diff --git a/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml b/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml new file mode 100644 index 0000000000..b09366e9df --- /dev/null +++ b/tests/auto/qml/qqmlecmascript/data/qtbug60547/main.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +TestObject { + Component.onCompleted: { + increment() + } +} + diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 07ae9821e9..45f312e934 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -341,6 +341,7 @@ private slots: void redefineGlobalProp(); void freeze_empty_object(); void singleBlockLoops(); + void qtbug_60547(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -8358,6 +8359,16 @@ void tst_qqmlecmascript::singleBlockLoops() QVERIFY(!component.isError()); } +// 'counter' was incorrectly resolved as a type rather than a variable. +// This fix ensures it looks up the right thing. +void tst_qqmlecmascript::qtbug_60547() +{ + QQmlComponent component(&engine, testFileUrl("qtbug60547/main.qml")); + QScopedPointer<QObject> object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + QCOMPARE(object->property("counter"), QVariant(int(1))); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 3f6107ab2b..dac6ddaebd 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -36,10 +36,12 @@ #include <QSignalSpy> #include <QDebug> #include <QBuffer> +#include <QCryptographicHash> #include <QQmlComponent> #include <QQmlNetworkAccessManagerFactory> #include <QQmlExpression> #include <QQmlIncubationController> +#include <QTemporaryDir> #include <private/qqmlengine_p.h> #include <QQmlAbstractUrlInterceptor> @@ -50,6 +52,7 @@ public: tst_qqmlengine() {} private slots: + void initTestCase() override; void rootContext(); void networkAccessManager(); void synchronousNetworkAccessManager(); @@ -79,8 +82,17 @@ public slots: static QObject *ptr = new QObject(); return ptr; } + +private: + QTemporaryDir m_tempDir; }; +void tst_qqmlengine::initTestCase() +{ + QVERIFY2(m_tempDir.isValid(), qPrintable(m_tempDir.errorString())); + QQmlDataTest::initTestCase(); +} + void tst_qqmlengine::rootContext() { QQmlEngine engine; @@ -285,9 +297,12 @@ void tst_qqmlengine::clearComponentCache() { QQmlEngine engine; + const QString fileName = m_tempDir.filePath(QStringLiteral("temp.qml")); + const QUrl fileUrl = QUrl::fromLocalFile(fileName); + // Create original qml file { - QFile file("temp.qml"); + QFile file(fileName); QVERIFY(file.open(QIODevice::WriteOnly)); file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 10\n}\n"); file.close(); @@ -295,7 +310,7 @@ void tst_qqmlengine::clearComponentCache() // Test "test" property { - QQmlComponent component(&engine, "temp.qml"); + QQmlComponent component(&engine, fileUrl); QObject *obj = component.create(); QVERIFY(obj != 0); QCOMPARE(obj->property("test").toInt(), 10); @@ -310,7 +325,7 @@ void tst_qqmlengine::clearComponentCache() // Similar effects of lacking precision have been observed on some Linux systems. QThread::sleep(1); - QFile file("temp.qml"); + QFile file(fileName); QVERIFY(file.open(QIODevice::WriteOnly)); file.write("import QtQuick 2.0\nQtObject {\nproperty int test: 11\n}\n"); file.close(); @@ -318,7 +333,7 @@ void tst_qqmlengine::clearComponentCache() // Test cache hit { - QQmlComponent component(&engine, "temp.qml"); + QQmlComponent component(&engine, fileUrl); QObject *obj = component.create(); QVERIFY(obj != 0); QCOMPARE(obj->property("test").toInt(), 10); @@ -330,12 +345,18 @@ void tst_qqmlengine::clearComponentCache() // Test cache refresh { - QQmlComponent component(&engine, "temp.qml"); + QQmlComponent component(&engine, fileUrl); QObject *obj = component.create(); QVERIFY(obj != 0); QCOMPARE(obj->property("test").toInt(), 11); delete obj; } + + // Regular Synchronous loading will leave us with an event posted + // to the gui thread and an extra refcount that will only be dropped after the + // event delivery. Call sendPostedEvents() to get rid of it so that + // the temporary directory can be removed. + QCoreApplication::sendPostedEvents(); } struct ComponentCacheFunctions : public QObject, public QQmlIncubationController diff --git a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp index 124a107a37..268010ead8 100644 --- a/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp +++ b/tests/auto/qml/qqmlextensionplugin/tst_qqmlextensionplugin.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/qml/qqmlfile/qqmlfile.pro b/tests/auto/qml/qqmlfile/qqmlfile.pro new file mode 100644 index 0000000000..ab66792445 --- /dev/null +++ b/tests/auto/qml/qqmlfile/qqmlfile.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +TARGET = tst_qqmlfile +SOURCES += tst_qqmlfile.cpp +macos:CONFIG -= app_bundle +QT += qml testlib diff --git a/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp b/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp new file mode 100644 index 0000000000..a1c8daddcf --- /dev/null +++ b/tests/auto/qml/qqmlfile/tst_qqmlfile.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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 <QtCore> +#include <QtTest> +#include <QQmlFile> + +class tst_qqmlfile : public QObject +{ + Q_OBJECT + +public: + tst_qqmlfile() {} + +private Q_SLOTS: + void urlToLocalFileOrQrcOverloads(); +}; + + +void tst_qqmlfile::urlToLocalFileOrQrcOverloads() +{ + const QString urlString = QStringLiteral("qrc:///example.qml"); + const QUrl url(urlString); + const QString pathForUrlString = QQmlFile::urlToLocalFileOrQrc(urlString); + const QString pathForUrl = QQmlFile::urlToLocalFileOrQrc(url); + + QCOMPARE(pathForUrlString, pathForUrl); + QCOMPARE(pathForUrlString, QStringLiteral(":/example.qml")); +} + +QTEST_GUILESS_MAIN(tst_qqmlfile) + +#include "tst_qqmlfile.moc" diff --git a/tests/auto/qml/qqmllanguage/data/ConcurrentLoadA.qml b/tests/auto/qml/qqmllanguage/data/ConcurrentLoadA.qml new file mode 100644 index 0000000000..3d538c7572 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/ConcurrentLoadA.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import testModule 1.0 + +Item { + Test {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/ConcurrentLoadB.qml b/tests/auto/qml/qqmllanguage/data/ConcurrentLoadB.qml new file mode 100644 index 0000000000..3d538c7572 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/ConcurrentLoadB.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import testModule 1.0 + +Item { + Test {} +} + diff --git a/tests/auto/qml/qqmllanguage/data/concurrentLoad_main.qml b/tests/auto/qml/qqmllanguage/data/concurrentLoad_main.qml new file mode 100644 index 0000000000..8cfc90ac96 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/concurrentLoad_main.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 +Rectangle { +ConcurrentLoadA {} +ConcurrentLoadB {} +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index cc5b8cacbc..15f19d550b 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -267,6 +267,8 @@ private slots: void instanceof_data(); void instanceof(); + void concurrentLoadQmlDir(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -4559,6 +4561,20 @@ void tst_qqmllanguage::instanceof() } } +void tst_qqmllanguage::concurrentLoadQmlDir() +{ + ThreadedTestHTTPServer server(dataDirectory()); + QString serverdir = server.urlString("/lib/"); + engine.setImportPathList(QStringList(defaultImportPathList) << serverdir); + + QQmlComponent component(&engine, testFileUrl("concurrentLoad_main.qml")); + QTRY_VERIFY(component.isReady()); + VERIFY_ERRORS(0); + QScopedPointer<QObject> o(component.create()); + QVERIFY(!o.isNull()); + engine.setImportPathList(defaultImportPathList); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp index 555ca5713e..e442dd1421 100644 --- a/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp +++ b/tests/auto/qml/qqmllistmodel/tst_qqmllistmodel.cpp @@ -1204,8 +1204,8 @@ void tst_qqmllistmodel::role_mode_data() QTest::newRow("default1") << "{append({'a':1});dynamicRoles}" << 0 << ""; QTest::newRow("enableDynamic0") << "{dynamicRoles=true;dynamicRoles}" << 1 << ""; - QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << "<Unknown File>: QML ListModel: unable to enable dynamic roles as this model is not empty!"; - QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty!"; + QTest::newRow("enableDynamic1") << "{append({'a':1});dynamicRoles=true;dynamicRoles}" << 0 << "<Unknown File>: QML ListModel: unable to enable dynamic roles as this model is not empty"; + QTest::newRow("enableDynamic2") << "{dynamicRoles=true;append({'a':1});dynamicRoles=false;dynamicRoles}" << 1 << "<Unknown File>: QML ListModel: unable to enable static roles as this model is not empty"; } void tst_qqmllistmodel::role_mode() diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp index 357482b93f..ba2b836a6d 100644 --- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -49,6 +49,7 @@ private slots: void qmlParser_data(); void qmlParser(); #endif + void invalidEscapeSequence(); private: QStringList excludedDirs; @@ -192,6 +193,17 @@ void tst_qqmlparser::qmlParser() } #endif +void tst_qqmlparser::invalidEscapeSequence() +{ + using namespace QQmlJS; + + Engine engine; + Lexer lexer(&engine); + lexer.setCode(QLatin1String("\"\\"), 1); + Parser parser(&engine); + parser.parse(); +} + QTEST_MAIN(tst_qqmlparser) #include "tst_qqmlparser.moc" diff --git a/tests/auto/qml/qqmlsettings/data/aliases.qml b/tests/auto/qml/qqmlsettings/data/aliases.qml index 18bd7a0e07..dd11147532 100644 --- a/tests/auto/qml/qqmlsettings/data/aliases.qml +++ b/tests/auto/qml/qqmlsettings/data/aliases.qml @@ -38,8 +38,10 @@ QtObject { property double doubleProperty: 3.45 property string stringProperty: "foo" property url urlProperty: "http://www.qt-project.org" + property var objectProperty: {"foo":"bar"} property var intListProperty: [1, 2, 3] property var stringListProperty: ["a", "b", "c"] + property var objectListProperty: [{"a":"b"}, {"c":"d"}] property date dateProperty: "2000-01-02" // QTBUG-32295: Expected property type //property time timeProperty: "12:34:56" @@ -58,8 +60,10 @@ QtObject { property alias doubleProperty: root.doubleProperty property alias stringProperty: root.stringProperty property alias urlProperty: root.urlProperty + property alias objectProperty: root.objectProperty property alias intListProperty: root.intListProperty property alias stringListProperty: root.stringListProperty + property alias objectListProperty: root.objectListProperty property alias dateProperty: root.dateProperty // QTBUG-32295: Expected property type //property alias timeProperty: root.timeProperty diff --git a/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml b/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml index 8540838fb9..f5b18d1825 100644 --- a/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml +++ b/tests/auto/qml/qqmlsettings/data/cpp-aliases.qml @@ -40,8 +40,10 @@ CppObject { property alias doubleProperty: obj.doubleProperty property alias stringProperty: obj.stringProperty property alias urlProperty: obj.urlProperty + property alias objectProperty: obj.objectProperty property alias intListProperty: obj.intListProperty property alias stringListProperty: obj.stringListProperty + property alias objectListProperty: obj.objectListProperty property alias dateProperty: obj.dateProperty // QTBUG-32295: Expected property type //property alias timeProperty: obj.timeProperty diff --git a/tests/auto/qml/qqmlsettings/data/types.qml b/tests/auto/qml/qqmlsettings/data/types.qml index d1301af057..c4efa0be7c 100644 --- a/tests/auto/qml/qqmlsettings/data/types.qml +++ b/tests/auto/qml/qqmlsettings/data/types.qml @@ -38,8 +38,10 @@ QtObject { property double doubleProperty property string stringProperty property url urlProperty + property var objectProperty property var intListProperty property var stringListProperty + property var objectListProperty property date dateProperty // QTBUG-32295: Expected property type // property time timeProperty @@ -64,8 +66,10 @@ QtObject { to.doubleProperty = from.doubleProperty to.stringProperty = from.stringProperty to.urlProperty = from.urlProperty + to.objectProperty = from.objectProperty to.intListProperty = from.intListProperty to.stringListProperty = from.stringListProperty + to.objectListProperty = from.objectListProperty to.dateProperty = from.dateProperty //to.timeProperty = from.timeProperty to.sizeProperty = from.sizeProperty @@ -84,8 +88,10 @@ QtObject { property double doubleProperty: 3.45 property string stringProperty: "foo" property url urlProperty: "http://www.qt-project.org" + property var objectProperty: {"foo":"bar"} property var intListProperty: [1, 2, 3] property var stringListProperty: ["a", "b", "c"] + property var objectListProperty: [{"a":"b"}, {"c":"d"}] property date dateProperty: "2000-01-02" // QTBUG-32295: Expected property type //property time timeProperty: "12:34:56" diff --git a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp index c2e20f8892..e08389045c 100644 --- a/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp +++ b/tests/auto/qml/qqmlsettings/tst_qqmlsettings.cpp @@ -55,25 +55,36 @@ private slots: void initial(); }; +// ### Replace keyValueMap("foo", "bar") with QVariantMap({{"foo", "bar"}}) +// when C++11 uniform initialization can be used (not supported by MSVC 2013). +static QVariantMap keyValueMap(const QString &key, const QString &value) +{ + QVariantMap var; + var.insert(key, value); + return var; +} + class CppObject : public QObject { Q_OBJECT - Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty NOTIFY intPropertyChanged) - Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty NOTIFY boolPropertyChanged) - Q_PROPERTY(qreal realProperty READ realProperty WRITE setRealProperty NOTIFY realPropertyChanged) - Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty NOTIFY doublePropertyChanged) - Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringPropertyChanged) - Q_PROPERTY(QUrl urlProperty READ urlProperty WRITE setUrlProperty NOTIFY urlPropertyChanged) - Q_PROPERTY(QVariant varProperty READ varProperty WRITE setVarProperty NOTIFY varPropertyChanged) - Q_PROPERTY(QVariantList intListProperty READ intListProperty WRITE setIntListProperty NOTIFY intListPropertyChanged) - Q_PROPERTY(QVariantList stringListProperty READ stringListProperty WRITE setStringListProperty NOTIFY stringListPropertyChanged) - Q_PROPERTY(QDate dateProperty READ dateProperty WRITE setDateProperty NOTIFY datePropertyChanged) - // QTBUG-32295: Q_PROPERTY(QTime timeProperty READ timeProperty WRITE setTimeProperty NOTIFY timePropertyChanged) - Q_PROPERTY(QSizeF sizeProperty READ sizeProperty WRITE setSizeProperty NOTIFY sizePropertyChanged) - Q_PROPERTY(QPointF pointProperty READ pointProperty WRITE setPointProperty NOTIFY pointPropertyChanged) - Q_PROPERTY(QRectF rectProperty READ rectProperty WRITE setRectProperty NOTIFY rectPropertyChanged) - Q_PROPERTY(QColor colorProperty READ colorProperty WRITE setColorProperty NOTIFY colorPropertyChanged) - Q_PROPERTY(QFont fontProperty READ fontProperty WRITE setFontProperty NOTIFY fontPropertyChanged) + Q_PROPERTY(int intProperty MEMBER m_intProperty NOTIFY intPropertyChanged) + Q_PROPERTY(bool boolProperty MEMBER m_boolProperty NOTIFY boolPropertyChanged) + Q_PROPERTY(qreal realProperty MEMBER m_realProperty NOTIFY realPropertyChanged) + Q_PROPERTY(double doubleProperty MEMBER m_doubleProperty NOTIFY doublePropertyChanged) + Q_PROPERTY(QString stringProperty MEMBER m_stringProperty NOTIFY stringPropertyChanged) + Q_PROPERTY(QUrl urlProperty MEMBER m_urlProperty NOTIFY urlPropertyChanged) + Q_PROPERTY(QVariant varProperty MEMBER m_varProperty NOTIFY varPropertyChanged) + Q_PROPERTY(QVariantMap objectProperty MEMBER m_objectProperty NOTIFY objectPropertyChanged) + Q_PROPERTY(QVariantList intListProperty MEMBER m_intListProperty NOTIFY intListPropertyChanged) + Q_PROPERTY(QVariantList stringListProperty MEMBER m_stringListProperty NOTIFY stringListPropertyChanged) + Q_PROPERTY(QVariantList objectListProperty MEMBER m_objectListProperty NOTIFY objectListPropertyChanged) + Q_PROPERTY(QDate dateProperty MEMBER m_dateProperty NOTIFY datePropertyChanged) + // QTBUG-32295: Q_PROPERTY(QTime timeProperty MEMBER m_timeProperty NOTIFY timePropertyChanged) + Q_PROPERTY(QSizeF sizeProperty MEMBER m_sizeProperty NOTIFY sizePropertyChanged) + Q_PROPERTY(QPointF pointProperty MEMBER m_pointProperty NOTIFY pointPropertyChanged) + Q_PROPERTY(QRectF rectProperty MEMBER m_rectProperty NOTIFY rectPropertyChanged) + Q_PROPERTY(QColor colorProperty MEMBER m_colorProperty NOTIFY colorPropertyChanged) + Q_PROPERTY(QFont fontProperty MEMBER m_fontProperty NOTIFY fontPropertyChanged) public: CppObject(QObject *parent = 0) : QObject(parent), @@ -83,8 +94,10 @@ public: m_doubleProperty(3.45), m_stringProperty("foo"), m_urlProperty("http://www.qt-project.org"), + m_objectProperty(keyValueMap("foo", "bar")), m_intListProperty(QVariantList() << 1 << 2 << 3), m_stringListProperty(QVariantList() << "a" << "b" << "c"), + m_objectListProperty(QVariantList() << keyValueMap("a", "b") << keyValueMap("c", "d")), m_dateProperty(2000, 1, 2), // QTBUG-32295: m_timeProperty(12, 34, 56), m_sizeProperty(12, 34), @@ -94,143 +107,6 @@ public: { } - int intProperty() const { return m_intProperty; } - bool boolProperty() const { return m_boolProperty; } - qreal realProperty() const { return m_realProperty; } - double doubleProperty() const { return m_doubleProperty; } - QString stringProperty() const { return m_stringProperty; } - QUrl urlProperty() const { return m_urlProperty; } - QVariant varProperty() const { return m_varProperty; } - QVariantList intListProperty() const { return m_intListProperty; } - QVariantList stringListProperty() const { return m_stringListProperty; } - QDate dateProperty() const { return m_dateProperty; } - QSizeF sizeProperty() const { return m_sizeProperty; } - QPointF pointProperty() const { return m_pointProperty; } - QRectF rectProperty() const { return m_rectProperty; } - QColor colorProperty() const { return m_colorProperty; } - QFont fontProperty() const { return m_fontProperty; } - -public slots: - void setIntProperty(int arg) - { - if (m_intProperty != arg) { - m_intProperty = arg; - emit intPropertyChanged(arg); - } - } - - void setBoolProperty(bool arg) - { - if (m_boolProperty != arg) { - m_boolProperty = arg; - emit boolPropertyChanged(arg); - } - } - - void setRealProperty(qreal arg) - { - if (m_realProperty != arg) { - m_realProperty = arg; - emit realPropertyChanged(arg); - } - } - - void setDoubleProperty(double arg) - { - if (m_doubleProperty != arg) { - m_doubleProperty = arg; - emit doublePropertyChanged(arg); - } - } - - void setStringProperty(const QString &arg) - { - if (m_stringProperty != arg) { - m_stringProperty = arg; - emit stringPropertyChanged(arg); - } - } - - void setUrlProperty(const QUrl &arg) - { - if (m_urlProperty != arg) { - m_urlProperty = arg; - emit urlPropertyChanged(arg); - } - } - - void setVarProperty(const QVariant &arg) - { - if (m_varProperty != arg) { - m_varProperty = arg; - emit varPropertyChanged(arg); - } - } - - void setIntListProperty(const QVariantList &arg) - { - if (m_intListProperty != arg) { - m_intListProperty = arg; - emit intListPropertyChanged(arg); - } - } - - void setStringListProperty(const QVariantList &arg) - { - if (m_stringListProperty != arg) { - m_stringListProperty = arg; - emit stringListPropertyChanged(arg); - } - } - - void setDateProperty(const QDate &arg) - { - if (m_dateProperty != arg) { - m_dateProperty = arg; - emit datePropertyChanged(arg); - } - } - - void setSizeProperty(const QSizeF &arg) - { - if (m_sizeProperty != arg) { - m_sizeProperty = arg; - emit sizePropertyChanged(arg); - } - } - - void setPointProperty(const QPointF &arg) - { - if (m_pointProperty != arg) { - m_pointProperty = arg; - emit pointPropertyChanged(arg); - } - } - - void setRectProperty(const QRectF &arg) - { - if (m_rectProperty != arg) { - m_rectProperty = arg; - emit rectPropertyChanged(arg); - } - } - - void setColorProperty(const QColor &arg) - { - if (m_colorProperty != arg) { - m_colorProperty = arg; - emit colorPropertyChanged(arg); - } - } - - void setFontProperty(const QFont &arg) - { - if (m_fontProperty != arg) { - m_fontProperty = arg; - emit fontPropertyChanged(arg); - } - } - signals: void intPropertyChanged(int arg); void boolPropertyChanged(bool arg); @@ -239,8 +115,10 @@ signals: void stringPropertyChanged(const QString &arg); void urlPropertyChanged(const QUrl &arg); void varPropertyChanged(const QVariant &arg); + void objectPropertyChanged(const QVariantMap &arg); void intListPropertyChanged(const QVariantList &arg); void stringListPropertyChanged(const QVariantList &arg); + void objectListPropertyChanged(const QVariantList &arg); void datePropertyChanged(const QDate &arg); void sizePropertyChanged(const QSizeF &arg); void pointPropertyChanged(const QPointF &arg); @@ -256,8 +134,10 @@ private: QString m_stringProperty; QUrl m_urlProperty; QVariant m_varProperty; + QVariantMap m_objectProperty; QVariantList m_intListProperty; QVariantList m_stringListProperty; + QVariantList m_objectListProperty; QDate m_dateProperty; QSizeF m_sizeProperty; QPointF m_pointProperty; @@ -316,8 +196,10 @@ void tst_QQmlSettings::types() QCOMPARE(root->property("doubleProperty").toDouble(), static_cast<double>(0.0)); QCOMPARE(root->property("stringProperty").toString(), QString()); QCOMPARE(root->property("urlProperty").toUrl(), QUrl()); + QCOMPARE(root->property("objectProperty").toMap(), QVariantMap()); QCOMPARE(root->property("intListProperty").toList(), QVariantList()); QCOMPARE(root->property("stringListProperty").toList(), QVariantList()); + QCOMPARE(root->property("objectListProperty").toList(), QVariantList()); QCOMPARE(root->property("dateProperty").toDate(), QDate()); // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime()); QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF()); @@ -333,8 +215,10 @@ void tst_QQmlSettings::types() QCOMPARE(settings->property("doubleProperty").toDouble(), static_cast<double>(3.45)); QCOMPARE(settings->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(settings->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(settings->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(settings->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(settings->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); QCOMPARE(settings->property("dateProperty").toDate(), QDate(2000, 01, 02)); // QTBUG-32295: QCOMPARE(settings->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(12, 34)); @@ -351,9 +235,11 @@ void tst_QQmlSettings::types() QCOMPARE(root->property("doubleProperty").toDouble(), static_cast<double>(3.45)); QCOMPARE(root->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(root->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(root->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(root->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(root->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); QCOMPARE(root->property("dateProperty").toDate(), QDate(2000, 01, 02)); + QCOMPARE(root->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF(12, 34)); QCOMPARE(root->property("pointProperty").toPointF(), QPointF(12, 34)); @@ -368,8 +254,10 @@ void tst_QQmlSettings::types() QVERIFY(root->setProperty("doubleProperty", static_cast<double>(6.78))); QVERIFY(root->setProperty("stringProperty", QStringLiteral("bar"))); QVERIFY(root->setProperty("urlProperty", QUrl("https://codereview.qt-project.org"))); + QVERIFY(root->setProperty("objectProperty", keyValueMap("bar", "baz"))); QVERIFY(root->setProperty("intListProperty", QVariantList() << 4 << 5 << 6)); QVERIFY(root->setProperty("stringListProperty", QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f"))); + QVERIFY(root->setProperty("objectListProperty", QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h"))); QVERIFY(root->setProperty("dateProperty", QDate(2010, 02, 01))); // QTBUG-32295: QVERIFY(root->setProperty("timeProperty", QTime(6, 56, 34))); QVERIFY(root->setProperty("sizeProperty", QSizeF(56, 78))); @@ -387,8 +275,10 @@ void tst_QQmlSettings::types() QTRY_COMPARE(settings->property("doubleProperty").toDouble(), static_cast<double>(6.78)); QTRY_COMPARE(settings->property("stringProperty").toString(), QStringLiteral("bar")); QTRY_COMPARE(settings->property("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(settings->property("objectProperty").toMap(), keyValueMap("bar", "baz")); QTRY_COMPARE(settings->property("intListProperty").toList(), QVariantList() << 4 << 5 << 6); QTRY_COMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(settings->property("objectListProperty").toList(), QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h")); QTRY_COMPARE(settings->property("dateProperty").toDate(), QDate(2010, 02, 01)); // QTBUG-32295: QTRY_COMPARE(settings->property("timeProperty").toDate(), QTime(6, 56, 34)); QTRY_COMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(56, 78)); @@ -404,8 +294,10 @@ void tst_QQmlSettings::types() QTRY_COMPARE(qs.value("doubleProperty").toDouble(), static_cast<double>(6.78)); QTRY_COMPARE(qs.value("stringProperty").toString(), QStringLiteral("bar")); QTRY_COMPARE(qs.value("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(qs.value("objectProperty").toMap(), keyValueMap("bar", "baz")); QTRY_COMPARE(qs.value("intListProperty").toList(), QVariantList() << 4 << 5 << 6); QTRY_COMPARE(qs.value("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(qs.value("objectListProperty").toList(), QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h")); QTRY_COMPARE(qs.value("dateProperty").toDate(), QDate(2010, 02, 01)); // QTBUG-32295: QTRY_COMPARE(qs.value("timeProperty").toDate(), QTime(6, 56, 34)); QTRY_COMPARE(qs.value("sizeProperty").toSizeF(), QSizeF(56, 78)); @@ -440,8 +332,10 @@ void tst_QQmlSettings::aliases() QCOMPARE(root->property("doubleProperty").toDouble(), static_cast<double>(3.45)); QCOMPARE(root->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(root->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(root->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(root->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(root->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(root->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); QCOMPARE(root->property("dateProperty").toDate(), QDate(2000, 01, 02)); // QTBUG-32295: QCOMPARE(root->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(root->property("sizeProperty").toSizeF(), QSizeF(12, 34)); @@ -457,8 +351,10 @@ void tst_QQmlSettings::aliases() QCOMPARE(settings->property("doubleProperty").toDouble(), static_cast<double>(3.45)); QCOMPARE(settings->property("stringProperty").toString(), QStringLiteral("foo")); QCOMPARE(settings->property("urlProperty").toUrl(), QUrl("http://www.qt-project.org")); + QCOMPARE(settings->property("objectProperty").toMap(), keyValueMap("foo","bar")); QCOMPARE(settings->property("intListProperty").toList(), QVariantList() << 1 << 2 << 3); QCOMPARE(settings->property("stringListProperty").toList(), QVariantList() << QStringLiteral("a") << QStringLiteral("b") << QStringLiteral("c")); + QCOMPARE(settings->property("objectListProperty").toList(), QVariantList() << keyValueMap("a", "b") << keyValueMap("c","d")); QCOMPARE(settings->property("dateProperty").toDate(), QDate(2000, 01, 02)); // QTBUG-32295: QCOMPARE(settings->property("timeProperty").toDate(), QTime(12, 34, 56)); QCOMPARE(settings->property("sizeProperty").toSizeF(), QSizeF(12, 34)); @@ -474,8 +370,10 @@ void tst_QQmlSettings::aliases() QVERIFY(settings->setProperty("doubleProperty", static_cast<double>(6.78))); QVERIFY(settings->setProperty("stringProperty", QStringLiteral("bar"))); QVERIFY(settings->setProperty("urlProperty", QUrl("https://codereview.qt-project.org"))); + QVERIFY(settings->setProperty("objectProperty", keyValueMap("bar", "baz"))); QVERIFY(settings->setProperty("intListProperty", QVariantList() << 4 << 5 << 6)); QVERIFY(settings->setProperty("stringListProperty", QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f"))); + QVERIFY(settings->setProperty("objectListProperty", QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h"))); QVERIFY(settings->setProperty("dateProperty", QDate(2010, 02, 01))); // QTBUG-32295: QVERIFY(settings->setProperty("timeProperty", QTime(6, 56, 34))); QVERIFY(settings->setProperty("sizeProperty", QSizeF(56, 78))); @@ -492,8 +390,10 @@ void tst_QQmlSettings::aliases() QTRY_COMPARE(qs.value("doubleProperty").toDouble(), static_cast<double>(6.78)); QTRY_COMPARE(qs.value("stringProperty").toString(), QStringLiteral("bar")); QTRY_COMPARE(qs.value("urlProperty").toUrl(), QUrl("https://codereview.qt-project.org")); + QTRY_COMPARE(qs.value("objectProperty").toMap(), keyValueMap("bar", "baz")); QTRY_COMPARE(qs.value("intListProperty").toList(), QVariantList() << 4 << 5 << 6); QTRY_COMPARE(qs.value("stringListProperty").toList(), QVariantList() << QStringLiteral("d") << QStringLiteral("e") << QStringLiteral("f")); + QTRY_COMPARE(qs.value("objectListProperty").toList(), QVariantList() << keyValueMap("e", "f") << keyValueMap("g", "h")); QTRY_COMPARE(qs.value("dateProperty").toDate(), QDate(2010, 02, 01)); // QTBUG-32295: QTRY_COMPARE(qs.value("timeProperty").toDate(), QTime(6, 56, 34)); QTRY_COMPARE(qs.value("sizeProperty").toSizeF(), QSizeF(56, 78)); diff --git a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp index 163ce11cb8..ce52afc862 100644 --- a/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp +++ b/tests/auto/qml/qqmlvaluetypes/tst_qqmlvaluetypes.cpp @@ -1486,7 +1486,7 @@ void tst_qqmlvaluetypes::groupedInterceptors() QQmlComponent component(&engine, testFileUrl(qmlfile)); QObject *object = component.create(); - QVERIFY(object != 0); + QVERIFY2(object != nullptr, qPrintable(component.errorString())); QColor initialColor = object->property("color").value<QColor>(); QVERIFY(fuzzyCompare(initialColor.redF(), expectedInitialColor.redF())); diff --git a/tests/auto/qml/qqmlxmlhttprequest/data/send_patch.qml b/tests/auto/qml/qqmlxmlhttprequest/data/send_patch.qml index 2abf1c60a8..dd4dd435a5 100644 --- a/tests/auto/qml/qqmlxmlhttprequest/data/send_patch.qml +++ b/tests/auto/qml/qqmlxmlhttprequest/data/send_patch.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 Canonical Limited and/or its subsidiary(-ies). -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 Canonical Limited and/or its subsidiary(-ies). +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index 63da28b7ba..49135ca920 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -250,7 +250,7 @@ void tst_QQuickWorkerScript::scriptError_onLoad() QVERIFY(worker != 0); QTRY_COMPARE(qquickworkerscript_lastWarning, - testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3:10: Expected token `,'")); + testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3:10: SyntaxError: Expected token `,'")); qInstallMessageHandler(previousMsgHandler); qApp->processEvents(); diff --git a/tests/auto/qmltest/selftests/BLACKLIST b/tests/auto/qmltest/selftests/BLACKLIST index 9cb2313810..ffce42e4c0 100644 --- a/tests/auto/qmltest/selftests/BLACKLIST +++ b/tests/auto/qmltest/selftests/BLACKLIST @@ -6,3 +6,8 @@ # QTBUG-53793: seems to be failing on Linux a little too often... [tst_grabImage::test_equals] linux +[tst_grabImage::test_sizeProps] +linux +[tst_grabImage::test_save] +linux + diff --git a/tests/auto/qmltest/selftests/tst_grabImage.qml b/tests/auto/qmltest/selftests/tst_grabImage.qml index 954daaba42..7ce7e93a07 100644 --- a/tests/auto/qmltest/selftests/tst_grabImage.qml +++ b/tests/auto/qmltest/selftests/tst_grabImage.qml @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2017 Crimson AS <info@crimson.no> ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** @@ -45,9 +46,66 @@ TestCase { oldImage = grabImage(rect); // Don't change anything... newImage = grabImage(rect); - verify(newImage.equals(oldImage)); + try { + compare(newImage.size, oldImage.size); + verify(newImage.equals(oldImage)); + } catch (ex) { + oldImage.save("tst_grabImage_test_equals_oldImage.png") + newImage.save("tst_grabImage_test_equals_newImage.png") + throw ex; + } verify(!newImage.equals(null)); verify(!newImage.equals(undefined)); } + + function test_sizeProps() { + var rect = createTemporaryQmlObject("import QtQuick 2.0; Rectangle { color: 'red'; width: 10; height: 20; }", testCase); + var image = grabImage(rect); + + try { + compare(image.width, 10) + compare(image.height, 20) + compare(image.size, Qt.size(10, 20)) + } catch (ex) { + image.save("tst_grabImage_test_sizeProps.png") + throw ex; + } + } + + function test_save() { + var rect = createTemporaryQmlObject("import QtQuick 2.0; Rectangle { color: 'red'; width: 10; height: 20; }", testCase); + var grabbedImage = grabImage(rect); + grabbedImage.save("tst_grabImage_test_save.png") + + // Now try to load it + var url = Qt.resolvedUrl("tst_grabImage_test_save.png") + var image = createTemporaryQmlObject("import QtQuick 2.0; Image { source: \"" + url + "\" }", testCase); + tryCompare(image, "status", Image.Ready) + var grabbedImage2 = grabImage(image); + + try { + verify(grabbedImage2.equals(grabbedImage)) + } catch (ex) { + grabbedImage2.save("tst_grabImage_test_save2.png") + throw ex; + } + } + + function test_saveThrowsWhenFailing() { + var rect = createTemporaryQmlObject("import QtQuick 2.0; Rectangle { color: 'red'; width: 10; height: 20; }", testCase); + var grabbedImage = grabImage(rect); + var didThrow = false; + + try { + // Format doesn't exist, so this will throw + grabbedImage.save("tst_grabImage_test_saveThrowsWhenFailing.never-gonna-give-you-up"); + } catch (ex) { + didThrow = true; + } + + if (!didThrow) { + fail("save() should have thrown, but didn't!") + } + } } diff --git a/tests/auto/qmltest/statemachine/tst_signaltransition.qml b/tests/auto/qmltest/statemachine/tst_signaltransition.qml index 0e35207670..a57826855a 100644 --- a/tests/auto/qmltest/statemachine/tst_signaltransition.qml +++ b/tests/auto/qmltest/statemachine/tst_signaltransition.qml @@ -1,32 +1,27 @@ /**************************************************************************** ** -** Copyright (C) 2014 Ford Motor Company -** Copyright (C) 2016 The Qt Company +** Copyright (C) 2017 Ford Motor Company +** Copyright (C) 2017 The Qt Company ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml b/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml index 5d2e867da4..34c172aded 100644 --- a/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml +++ b/tests/auto/qmltest/statemachine/tst_triggeredArguments1.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 Ford Motor Company -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 Ford Motor Company +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml b/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml index f60f2ff78c..73bc653404 100644 --- a/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml +++ b/tests/auto/qmltest/statemachine/tst_triggeredArguments2.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 Ford Motor Company -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 Ford Motor Company +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/qmltest/url/tst_url.qml b/tests/auto/qmltest/url/tst_url.qml new file mode 100644 index 0000000000..ff41bd5070 --- /dev/null +++ b/tests/auto/qmltest/url/tst_url.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.2 +import QtTest 1.1 + +Item { + TestCase { + name: "URL" + property url path1: "path1" + property url path2: "path2" + + function test_url_compare() { + expectFail("", "compare() should fail here; if it passes we have QTBUG-61297") + compare(path1, path2) + } + function test_url_compare_string() { + expectFail("", "compare() should fail here") + compare(path1.toString(), path2.toString()) + } + function test_url_verify() { + verify(path1 != path2) + } + } +} diff --git a/tests/auto/quick/examples/tst_examples.cpp b/tests/auto/quick/examples/tst_examples.cpp index b6742b9efe..d35a2e971a 100644 --- a/tests/auto/quick/examples/tst_examples.cpp +++ b/tests/auto/quick/examples/tst_examples.cpp @@ -86,6 +86,8 @@ tst_examples::tst_examples() excludedDirs << "snippets/qml/visualdatamodel_rootindex"; excludedDirs << "snippets/qml/qtbinding"; excludedDirs << "snippets/qml/imports"; + excludedFiles << "examples/quick/shapes/content/pathitem.qml"; // relies on resources + excludedFiles << "examples/quick/shapes/content/pathiteminteract.qml"; // relies on resources #ifdef QT_NO_XMLPATTERNS excludedDirs << "demos/twitter"; diff --git a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp index 64ddf79255..09a3c36b6d 100644 --- a/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp +++ b/tests/auto/quick/pointerhandlers/multipointtoucharea_interop/tst_multipointtoucharea_interop.cpp @@ -109,7 +109,7 @@ void tst_MptaInterop::touchDrag() QPoint p1 = mpta->mapToScene(QPointF(20, 20)).toPoint(); touch.press(1, p1).commit(); QQuickTouchUtils::flush(window); - auto pointerEvent = touchPointerDevice->pointerEvent(); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); QCOMPARE(tp.at(0)->property("pressed").toBool(), false); // QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), mpta); @@ -151,9 +151,7 @@ void tst_MptaInterop::touchesThenPinch() QSignalSpy mptaPressedSpy(mpta, SIGNAL(pressed(QList<QObject*>))); QSignalSpy mptaReleasedSpy(mpta, SIGNAL(released(QList<QObject*>))); QTest::QTouchEventSequence touch = QTest::touchEvent(window, touchDevice); - auto pointerEvent = touchPointerDevice->pointerEvent(); - // TODO after merge of e0c30279ec1fad88346ed3fb483bc3c672fdd01b -// auto pointerEvent = QQuickWindowPrivate::pointerEventInstance(touchPointerDevice); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(touchPointerDevice); // Press one touchpoint: // DragHandler gets a passive grab diff --git a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp index 18369abec7..bb4361255c 100644 --- a/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickpointerhandler/tst_qquickpointerhandler.cpp @@ -318,7 +318,7 @@ void tst_PointerHandlers::touchEventDelivery() QCOMPARE(eventItem1->eventList.size(), 2); QCOMPARE_EVENT(0, Event::HandlerDestination, QEvent::Pointer, Qt::TouchPointPressed, NoGrab); QCOMPARE_EVENT(1, Event::TouchDestination, QEvent::TouchBegin, Qt::TouchPointPressed, QQuickEventPoint::GrabExclusive); - auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); + auto pointerEvent = QQuickWindowPrivate::get(window)->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1); p1 += QPoint(10, 0); QTest::touchEvent(window, touchDevice).move(0, p1, window); diff --git a/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml b/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml index 18a8f52661..c81a765c7e 100644 --- a/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml +++ b/tests/auto/quick/qquickanimatedsprite/data/sourceSwitch.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml b/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml index bfd475266e..bd3b42b397 100644 --- a/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml +++ b/tests/auto/quick/qquickanimators/data/positionerWithAnimator.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/quick/qquickapplication/BLACKLIST b/tests/auto/quick/qquickapplication/BLACKLIST deleted file mode 100644 index 81592db56f..0000000000 --- a/tests/auto/quick/qquickapplication/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[active] -osx-10.11 diff --git a/tests/auto/quick/qquickapplication/data/tst_platformname.qml b/tests/auto/quick/qquickapplication/data/tst_platformname.qml new file mode 100644 index 0000000000..1bcd66ac8d --- /dev/null +++ b/tests/auto/quick/qquickapplication/data/tst_platformname.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0; + +Item { + id: root; + property string platformName: Qt.platform.pluginName +} diff --git a/tests/auto/quick/qquickapplication/qquickapplication.pro b/tests/auto/quick/qquickapplication/qquickapplication.pro index c47f5472b7..00b5bb3a18 100644 --- a/tests/auto/quick/qquickapplication/qquickapplication.pro +++ b/tests/auto/quick/qquickapplication/qquickapplication.pro @@ -3,7 +3,8 @@ TARGET = tst_qquickapplication macx:CONFIG -= app_bundle SOURCES += tst_qquickapplication.cpp -OTHER_FILES += data/tst_displayname.qml +OTHER_FILES += data/tst_displayname.qml \ + data/tst_platformname.qml include (../../shared/util.pri) diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index d780b91260..e428a1fc6e 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -53,6 +53,7 @@ private slots: void styleHints(); void cleanup(); void displayName(); + void platformName(); private: QQmlEngine engine; @@ -264,6 +265,24 @@ void tst_qquickapplication::displayName() QCOMPARE(QGuiApplication::applicationDisplayName(), name[2]); } +void tst_qquickapplication::platformName() +{ + // Set up QML component + QQmlComponent component(&engine, testFileUrl("tst_platformname.qml")); + QQuickItem *item = qobject_cast<QQuickItem *>(component.create()); + QVERIFY(item); + QQuickView view; + item->setParentItem(view.rootObject()); + + // Get native platform name + QString guiApplicationPlatformName = QGuiApplication::platformName(); + QVERIFY(!guiApplicationPlatformName.isEmpty()); + + // Get platform name from QML component and verify it's same + QString qmlPlatformName = qvariant_cast<QString>(item->property("platformName")); + QCOMPARE(qmlPlatformName, guiApplicationPlatformName); +} + QTEST_MAIN(tst_qquickapplication) #include "tst_qquickapplication.moc" diff --git a/tests/auto/quick/qquickfocusscope/BLACKLIST b/tests/auto/quick/qquickfocusscope/BLACKLIST new file mode 100644 index 0000000000..cc3c8b6e8a --- /dev/null +++ b/tests/auto/quick/qquickfocusscope/BLACKLIST @@ -0,0 +1,2 @@ +[canvasFocus] +osx-10.11 diff --git a/tests/auto/quick/qquickgridview/data/releaseItems.qml b/tests/auto/quick/qquickgridview/data/releaseItems.qml new file mode 100644 index 0000000000..19d58550a4 --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/releaseItems.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +GridView { + width: 400 + height: 400 + model: 100 + delegate: Rectangle { + height: 100; width: 100 + color: index % 2 ? "lightsteelblue" : "lightgray" + } + contentHeight: contentItem.children.length * 40 +} diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 1acc36c9b0..b2d6584701 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -209,6 +209,7 @@ private slots: void QTBUG_48870_fastModelUpdates(); void keyNavigationEnabled(); + void releaseItems(); private: QList<int> toIntList(const QVariantList &list); @@ -6666,6 +6667,18 @@ void tst_QQuickGridView::QTBUG_48870_fastModelUpdates() } } +void tst_QQuickGridView::releaseItems() +{ + QScopedPointer<QQuickView> view(createView()); + view->setSource(testFileUrl("releaseItems.qml")); + + QQuickGridView *gridview = qobject_cast<QQuickGridView *>(view->rootObject()); + QVERIFY(gridview); + + // don't crash (QTBUG-61294) + gridview->setModel(123); +} + QTEST_MAIN(tst_QQuickGridView) #include "tst_qquickgridview.moc" diff --git a/tests/auto/quick/qquickitem/data/childAtRectangle.qml b/tests/auto/quick/qquickitem/data/childAtRectangle.qml index d459c2b3f1..2aaaedb06f 100644 --- a/tests/auto/quick/qquickitem/data/childAtRectangle.qml +++ b/tests/auto/quick/qquickitem/data/childAtRectangle.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/quick/qquickitem/data/shortcutOverride.qml b/tests/auto/quick/qquickitem/data/shortcutOverride.qml index fab9175c17..247b5fea04 100644 --- a/tests/auto/quick/qquickitem/data/shortcutOverride.qml +++ b/tests/auto/quick/qquickitem/data/shortcutOverride.qml @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/quick/qquickitem2/data/nonexistentPropertyConnection.qml b/tests/auto/quick/qquickitem2/data/nonexistentPropertyConnection.qml new file mode 100644 index 0000000000..ed0632a68a --- /dev/null +++ b/tests/auto/quick/qquickitem2/data/nonexistentPropertyConnection.qml @@ -0,0 +1,11 @@ +import QtQuick 2.4 + +Item { + function hint() { + } + + Connections { + target: BlaBlaBla + onHint: hint(); + } +} diff --git a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp index cc74b7e07d..09e89ff85f 100644 --- a/tests/auto/quick/qquickitem2/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem2/tst_qquickitem.cpp @@ -98,6 +98,7 @@ private slots: void mapCoordinatesRect(); void mapCoordinatesRect_data(); void propertyChanges(); + void nonexistentPropertyConnection(); void transforms(); void transforms_data(); void childrenRect(); @@ -2612,6 +2613,15 @@ void tst_QQuickItem::propertyChanges() delete window; } +void tst_QQuickItem::nonexistentPropertyConnection() +{ + // QTBUG-56551: don't crash + QQmlComponent component(&engine, testFileUrl("nonexistentPropertyConnection.qml")); + QObject *o = component.create(); + QVERIFY(o); + delete o; +} + void tst_QQuickItem::childrenRect() { QQuickView *window = new QQuickView(0); diff --git a/tests/auto/quick/qquicklistview/data/releaseItems.qml b/tests/auto/quick/qquicklistview/data/releaseItems.qml new file mode 100644 index 0000000000..de774e5e08 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/releaseItems.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +ListView { + width: 400 + height: 400 + model: 100 + delegate: Rectangle { + height: 40; width: 400 + color: index % 2 ? "lightsteelblue" : "lightgray" + } + contentHeight: contentItem.children.length * 40 +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index ff06c1e1a4..98c628068d 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -254,6 +254,7 @@ private slots: void keyNavigationEnabled(); void QTBUG_50097_stickyHeader_positionViewAtIndex(); void itemFiltered(); + void releaseItems(); private: template <class T> void items(const QUrl &source); @@ -8508,6 +8509,18 @@ void tst_QQuickListView::itemFiltered() model.setData(model.index(2), QStringLiteral("modified three"), Qt::DisplayRole); } +void tst_QQuickListView::releaseItems() +{ + QScopedPointer<QQuickView> view(createView()); + view->setSource(testFileUrl("releaseItems.qml")); + + QQuickListView *listview = qobject_cast<QQuickListView *>(view->rootObject()); + QVERIFY(listview); + + // don't crash (QTBUG-61294) + listview->setModel(123); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" diff --git a/tests/auto/quick/qquickrectangle/data/gradient-multiple.qml b/tests/auto/quick/qquickrectangle/data/gradient-multiple.qml new file mode 100644 index 0000000000..d58c857008 --- /dev/null +++ b/tests/auto/quick/qquickrectangle/data/gradient-multiple.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Item { + property alias firstRectangle: r1 + property alias secondRectangle: r2 + Rectangle { + id: r1 + gradient: someObject.someGradient + anchors.fill: parent + } + Rectangle { + id: r2 + gradient: someObject.someGradient + anchors.fill: parent + } + + function changeGradient() { + firstStop.color = "red" + secondStop.color = "blue" + } + + QtObject { + id: someObject + property Gradient someGradient: Gradient { + GradientStop { id: firstStop; position: 0.0; color: "gray" } + GradientStop { id: secondStop; position: 1.0; color: "white" } + } + } +} + diff --git a/tests/auto/quick/qquickrectangle/data/gradient-separate.qml b/tests/auto/quick/qquickrectangle/data/gradient-separate.qml new file mode 100644 index 0000000000..8ae3f3296b --- /dev/null +++ b/tests/auto/quick/qquickrectangle/data/gradient-separate.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Rectangle { + + function changeGradient() { + firstStop.color = "red" + secondStop.color = "blue" + } + + QtObject { + id: someObject + property Gradient someGradient: Gradient { + GradientStop { id: firstStop; position: 0.0; color: "gray" } + GradientStop { id: secondStop; position: 1.0; color: "white" } + } + } + + gradient: someObject.someGradient +} + diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp index 65c7e387a0..0d79592e37 100644 --- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp +++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp @@ -32,6 +32,7 @@ #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQuick/qquickview.h> +#include <private/qquickitem_p.h> #include <private/qquickrectangle_p.h> #include "../../shared/util.h" @@ -46,6 +47,8 @@ private slots: void color(); void gradient(); void gradient_border(); + void gradient_separate(); + void gradient_multiple(); void antialiasing(); private: @@ -111,6 +114,62 @@ void tst_qquickrectangle::gradient_border() QVERIFY(QTest::qWaitForWindowExposed(&view)); } +// A gradient not defined inline with the Rectangle using it should still change +// that Rectangle. +void tst_qquickrectangle::gradient_separate() +{ + QQuickView view; + view.setSource(testFileUrl("gradient-separate.qml")); + view.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(view.rootObject()); + QVERIFY(rect); + + // Start off clean + QQuickItemPrivate *rectPriv = QQuickItemPrivate::get(rect); + bool isDirty = rectPriv->dirtyAttributes & QQuickItemPrivate::Content; + QVERIFY(!isDirty); + + QMetaObject::invokeMethod(rect, "changeGradient"); + + // Changing the gradient should have scheduled an update of the item. + isDirty = rectPriv->dirtyAttributes & QQuickItemPrivate::Content; + QVERIFY(isDirty); +} + +// When a gradient is changed, every Rectangle connected to it must update. +void tst_qquickrectangle::gradient_multiple() +{ + QQuickView view; + view.setSource(testFileUrl("gradient-multiple.qml")); + view.show(); + + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + QQuickRectangle *firstRect = qobject_cast<QQuickRectangle*>(view.rootObject()->property("firstRectangle").value<QObject*>()); + QQuickRectangle *secondRect = qobject_cast<QQuickRectangle*>(view.rootObject()->property("secondRectangle").value<QObject*>()); + QVERIFY(firstRect); + QVERIFY(secondRect); + + // Start off clean + QQuickItemPrivate *firstRectPriv = QQuickItemPrivate::get(firstRect); + QQuickItemPrivate *secondRectPriv = QQuickItemPrivate::get(secondRect); + bool firstIsDirty = firstRectPriv->dirtyAttributes & QQuickItemPrivate::Content; + bool secondIsDirty = secondRectPriv->dirtyAttributes & QQuickItemPrivate::Content; + QVERIFY(!firstIsDirty); + QVERIFY(!secondIsDirty); + + QMetaObject::invokeMethod(view.rootObject(), "changeGradient"); + + // Changing the gradient should have scheduled an update of both items + firstIsDirty = firstRectPriv->dirtyAttributes & QQuickItemPrivate::Content; + secondIsDirty = secondRectPriv->dirtyAttributes & QQuickItemPrivate::Content; + QVERIFY(firstIsDirty); + QVERIFY(secondIsDirty); +} + void tst_qquickrectangle::antialiasing() { QQmlComponent component(&engine); diff --git a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp index 26b687a4a6..0a3796402a 100644 --- a/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp +++ b/tests/auto/quick/qquickscreen/tst_qquickscreen.cpp @@ -113,6 +113,9 @@ void tst_qquickscreen::fullScreenList() QQuickScreenInfo *info = qobject_cast<QQuickScreenInfo *>(screensArray.property(i).toQObject()); QVERIFY(info != nullptr); QCOMPARE(screenList[i]->name(), info->name()); + QCOMPARE(screenList[i]->manufacturer(), info->manufacturer()); + QCOMPARE(screenList[i]->model(), info->model()); + QCOMPARE(screenList[i]->serialNumber(), info->serialNumber()); QCOMPARE(screenList[i]->size().width(), info->width()); QCOMPARE(screenList[i]->size().height(), info->height()); QCOMPARE(screenList[i]->availableVirtualGeometry().width(), info->desktopAvailableWidth()); diff --git a/tests/auto/quick/qquickshape/data/pathitem1.qml b/tests/auto/quick/qquickshape/data/pathitem1.qml new file mode 100644 index 0000000000..29ca67b0bb --- /dev/null +++ b/tests/auto/quick/qquickshape/data/pathitem1.qml @@ -0,0 +1,5 @@ +import QtQuick 2.9 +import tst_qquickpathitem 1.0 + +Shape { +} diff --git a/tests/auto/quick/qquickshape/data/pathitem2.qml b/tests/auto/quick/qquickshape/data/pathitem2.qml new file mode 100644 index 0000000000..a255a37af6 --- /dev/null +++ b/tests/auto/quick/qquickshape/data/pathitem2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.9 +import tst_qquickpathitem 1.0 + +Shape { + ShapePath { } + ShapePath { } +} diff --git a/tests/auto/quick/qquickshape/data/pathitem3.png b/tests/auto/quick/qquickshape/data/pathitem3.png Binary files differnew file mode 100644 index 0000000000..a8b4483c96 --- /dev/null +++ b/tests/auto/quick/qquickshape/data/pathitem3.png diff --git a/tests/auto/quick/qquickshape/data/pathitem3.qml b/tests/auto/quick/qquickshape/data/pathitem3.qml new file mode 100644 index 0000000000..8328f2fc33 --- /dev/null +++ b/tests/auto/quick/qquickshape/data/pathitem3.qml @@ -0,0 +1,33 @@ +import QtQuick 2.9 +import tst_qquickpathitem 1.0 + +Item { + width: 200 + height: 150 + + Shape { + vendorExtensionsEnabled: false + objectName: "pathItem" + anchors.fill: parent + + ShapePath { + strokeWidth: 4 + strokeColor: "red" + fillGradient: LinearGradient { + x1: 20; y1: 20 + x2: 180; y2: 130 + GradientStop { position: 0; color: "blue" } + GradientStop { position: 0.2; color: "green" } + GradientStop { position: 0.4; color: "red" } + GradientStop { position: 0.6; color: "yellow" } + GradientStop { position: 1; color: "cyan" } + } + strokeStyle: ShapePath.DashLine + dashPattern: [ 1, 4 ] + startX: 20; startY: 20 + PathLine { x: 180; y: 130 } + PathLine { x: 20; y: 130 } + PathLine { x: 20; y: 20 } + } + } +} diff --git a/tests/auto/quick/qquickshape/data/pathitem4.png b/tests/auto/quick/qquickshape/data/pathitem4.png Binary files differnew file mode 100644 index 0000000000..3a988ba249 --- /dev/null +++ b/tests/auto/quick/qquickshape/data/pathitem4.png diff --git a/tests/auto/quick/qquickshape/data/pathitem4.qml b/tests/auto/quick/qquickshape/data/pathitem4.qml new file mode 100644 index 0000000000..635113416f --- /dev/null +++ b/tests/auto/quick/qquickshape/data/pathitem4.qml @@ -0,0 +1,56 @@ +import QtQuick 2.9 +import tst_qquickpathitem 1.0 + +Item { + width: 200 + height: 150 + + Shape { + vendorExtensionsEnabled: false + objectName: "pathItem" + anchors.fill: parent + + ShapePath { + strokeColor: "red" + fillColor: "green" + startX: 40; startY: 30 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } + } + + ShapePath { + strokeWidth: 10 + fillColor: "transparent" + strokeColor: "blue" + startX: 40; startY: 30 + PathCubic { x: 50; y: 80; control1X: 0; control1Y: 80; control2X: 100; control2Y: 100 } + } + + ShapePath { + fillGradient: LinearGradient { + y2: 150 + GradientStop { position: 0; color: "yellow" } + GradientStop { position: 1; color: "green" } + } + + startX: 10; startY: 100 + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 25 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 35 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 25; radiusY: 60 + } + PathArc { + relativeX: 50; y: 100 + radiusX: 50; radiusY: 120 + } + } + } +} diff --git a/tests/auto/quick/qquickshape/qquickshape.pro b/tests/auto/quick/qquickshape/qquickshape.pro new file mode 100644 index 0000000000..29c3502b86 --- /dev/null +++ b/tests/auto/quick/qquickshape/qquickshape.pro @@ -0,0 +1,35 @@ +CONFIG += testcase +TARGET = tst_qquickshape +macos:CONFIG -= app_bundle + +SOURCES += tst_qquickshape.cpp + +include (../../shared/util.pri) +include (../shared/util.pri) + +TESTDATA = data/* + +HEADERS += \ + ../../../../src/imports/shapes/qquickshape_p.h \ + ../../../../src/imports/shapes/qquickshape_p_p.h \ + ../../../../src/imports/shapes/qquickshapegenericrenderer_p.h \ + ../../../../src/imports/shapes/qquickshapesoftwarerenderer_p.h + +SOURCES += \ + ../../../../src/imports/shapes/qquickshape.cpp \ + ../../../../src/imports/shapes/qquickshapegenericrenderer.cpp \ + ../../../../src/imports/shapes/qquickshapesoftwarerenderer.cpp + +qtConfig(opengl) { + HEADERS += \ + ../../../../src/imports/shapes/qquicknvprfunctions_p.h \ + ../../../../src/imports/shapes/qquicknvprfunctions_p_p.h \ + ../../../../src/imports/shapes/qquickshapenvprrenderer_p.h + + SOURCES += \ + ../../../../src/imports/shapes/qquicknvprfunctions.cpp \ + ../../../../src/imports/shapes/qquickshapenvprrenderer.cpp +} + +QT += core-private gui-private qml-private quick-private testlib +qtHaveModule(widgets): QT += widgets diff --git a/tests/auto/quick/qquickshape/tst_qquickshape.cpp b/tests/auto/quick/qquickshape/tst_qquickshape.cpp new file mode 100644 index 0000000000..dcc79e6599 --- /dev/null +++ b/tests/auto/quick/qquickshape/tst_qquickshape.cpp @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtQuick/qquickview.h> +#include <QtQml/qqmlengine.h> +#include <QtQml/qqmlcomponent.h> +#include <QtQml/qqmlcontext.h> +#include <QtQml/qqmlexpression.h> +#include <QtQml/qqmlincubator.h> +#include "../../../../src/imports/shapes/qquickshape_p.h" + +#include "../../shared/util.h" +#include "../shared/viewtestutil.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickViewTestUtil; +using namespace QQuickVisualTestUtil; + +class tst_QQuickShape : public QQmlDataTest +{ + Q_OBJECT +public: + tst_QQuickShape(); + +private slots: + void initValues(); + void vpInitValues(); + void basicShape(); + void changeSignals(); + void render(); + void renderWithMultipleSp(); +}; + +tst_QQuickShape::tst_QQuickShape() +{ + // Force the software backend to get reliable rendering results regardless of the hw and drivers. + QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software); + + const char *uri = "tst_qquickpathitem"; + qmlRegisterType<QQuickShape>(uri, 1, 0, "Shape"); + qmlRegisterType<QQuickShapePath>(uri, 1, 0, "ShapePath"); + qmlRegisterUncreatableType<QQuickShapeGradient>(uri, 1, 0, "ShapeGradient", QQuickShapeGradient::tr("ShapeGradient is an abstract base class")); + qmlRegisterType<QQuickShapeLinearGradient>(uri, 1, 0, "LinearGradient"); +} + +void tst_QQuickShape::initValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathitem1.qml")); + QQuickShape *obj = qobject_cast<QQuickShape *>(c.create()); + + QVERIFY(obj != nullptr); + QVERIFY(obj->rendererType() == QQuickShape::UnknownRenderer); + QVERIFY(!obj->asynchronous()); + QVERIFY(obj->vendorExtensionsEnabled()); + QVERIFY(obj->status() == QQuickShape::Null); + auto vps = obj->data(); + QVERIFY(vps.count(&vps) == 0); + + delete obj; +} + +void tst_QQuickShape::vpInitValues() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("pathitem2.qml")); + QQuickShape *obj = qobject_cast<QQuickShape *>(c.create()); + + QVERIFY(obj != nullptr); + QVERIFY(obj->rendererType() == QQuickShape::UnknownRenderer); + QVERIFY(!obj->asynchronous()); + QVERIFY(obj->vendorExtensionsEnabled()); + QVERIFY(obj->status() == QQuickShape::Null); + auto vps = obj->data(); + QVERIFY(vps.count(&vps) == 2); + + QQuickShapePath *vp = qobject_cast<QQuickShapePath *>(vps.at(&vps, 0)); + QVERIFY(vp != nullptr); + QQmlListReference pathList(vp, "pathElements"); + QCOMPARE(pathList.count(), 0); + QCOMPARE(vp->strokeColor(), QColor(Qt::white)); + QCOMPARE(vp->strokeWidth(), 1.0f); + QCOMPARE(vp->fillColor(), QColor(Qt::white)); + QCOMPARE(vp->fillRule(), QQuickShapePath::OddEvenFill); + QCOMPARE(vp->joinStyle(), QQuickShapePath::BevelJoin); + QCOMPARE(vp->miterLimit(), 2); + QCOMPARE(vp->capStyle(), QQuickShapePath::SquareCap); + QCOMPARE(vp->strokeStyle(), QQuickShapePath::SolidLine); + QCOMPARE(vp->dashOffset(), 0.0f); + QCOMPARE(vp->dashPattern(), QVector<qreal>() << 4 << 2); + QVERIFY(!vp->fillGradient()); + + delete obj; +} + +void tst_QQuickShape::basicShape() +{ + QScopedPointer<QQuickView> window(createView()); + + window->setSource(testFileUrl("pathitem3.qml")); + qApp->processEvents(); + + QQuickShape *obj = findItem<QQuickShape>(window->rootObject(), "pathItem"); + QVERIFY(obj != nullptr); + QQmlListReference list(obj, "data"); + QCOMPARE(list.count(), 1); + QQuickShapePath *vp = qobject_cast<QQuickShapePath *>(list.at(0)); + QVERIFY(vp != nullptr); + QCOMPARE(vp->strokeWidth(), 4.0f); + QVERIFY(vp->fillGradient() != nullptr); + QCOMPARE(vp->strokeStyle(), QQuickShapePath::DashLine); + + vp->setStrokeWidth(5.0f); + QCOMPARE(vp->strokeWidth(), 5.0f); + + QQuickShapeLinearGradient *lgrad = qobject_cast<QQuickShapeLinearGradient *>(vp->fillGradient()); + QVERIFY(lgrad != nullptr); + QCOMPARE(lgrad->spread(), QQuickShapeGradient::PadSpread); + QCOMPARE(lgrad->x1(), 20.0f); + QQmlListReference stopList(lgrad, "stops"); + QCOMPARE(stopList.count(), 5); + QVERIFY(stopList.at(2) != nullptr); + + QQuickPath *path = vp; + QCOMPARE(path->startX(), 20.0f); + QQmlListReference pathList(path, "pathElements"); + QCOMPARE(pathList.count(), 3); +} + +void tst_QQuickShape::changeSignals() +{ + QScopedPointer<QQuickView> window(createView()); + + window->setSource(testFileUrl("pathitem3.qml")); + qApp->processEvents(); + + QQuickShape *obj = findItem<QQuickShape>(window->rootObject(), "pathItem"); + QVERIFY(obj != nullptr); + + QSignalSpy asyncPropSpy(obj, SIGNAL(asynchronousChanged())); + obj->setAsynchronous(true); + obj->setAsynchronous(false); + QCOMPARE(asyncPropSpy.count(), 2); + + QQmlListReference list(obj, "data"); + QQuickShapePath *vp = qobject_cast<QQuickShapePath *>(list.at(0)); + QVERIFY(vp != nullptr); + + // Verify that VisualPath property changes emit shapePathChanged(). + QSignalSpy vpChangeSpy(vp, SIGNAL(shapePathChanged())); + QSignalSpy strokeColorPropSpy(vp, SIGNAL(strokeColorChanged())); + vp->setStrokeColor(Qt::blue); + vp->setStrokeWidth(1.0f); + QQuickShapeGradient *g = vp->fillGradient(); + vp->setFillGradient(nullptr); + vp->setFillColor(Qt::yellow); + vp->setFillRule(QQuickShapePath::WindingFill); + vp->setJoinStyle(QQuickShapePath::MiterJoin); + vp->setMiterLimit(5); + vp->setCapStyle(QQuickShapePath::RoundCap); + vp->setDashOffset(10); + vp->setDashPattern(QVector<qreal>() << 1 << 2 << 3 << 4); + QCOMPARE(strokeColorPropSpy.count(), 1); + QCOMPARE(vpChangeSpy.count(), 10); + + // Verify that property changes from Path and its elements bubble up and result in shapePathChanged(). + QQuickPath *path = vp; + path->setStartX(30); + QCOMPARE(vpChangeSpy.count(), 11); + QQmlListReference pathList(path, "pathElements"); + qobject_cast<QQuickPathLine *>(pathList.at(1))->setY(200); + QCOMPARE(vpChangeSpy.count(), 12); + + // Verify that property changes from the gradient bubble up and result in shapePathChanged(). + vp->setFillGradient(g); + QCOMPARE(vpChangeSpy.count(), 13); + QQuickShapeLinearGradient *lgrad = qobject_cast<QQuickShapeLinearGradient *>(g); + lgrad->setX2(200); + QCOMPARE(vpChangeSpy.count(), 14); + QQmlListReference stopList(lgrad, "stops"); + QCOMPARE(stopList.count(), 5); + qobject_cast<QQuickGradientStop *>(stopList.at(1))->setPosition(0.3); + QCOMPARE(vpChangeSpy.count(), 15); + qobject_cast<QQuickGradientStop *>(stopList.at(1))->setColor(Qt::black); + QCOMPARE(vpChangeSpy.count(), 16); +} + +void tst_QQuickShape::render() +{ + QScopedPointer<QQuickView> window(createView()); + + window->setSource(testFileUrl("pathitem3.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QImage img = window->grabWindow(); + QVERIFY(!img.isNull()); + + QImage refImg(testFileUrl("pathitem3.png").toLocalFile()); + QVERIFY(!refImg.isNull()); + + QVERIFY(QQuickVisualTestUtil::compareImages(img.convertToFormat(refImg.format()), refImg)); +} + +void tst_QQuickShape::renderWithMultipleSp() +{ + QScopedPointer<QQuickView> window(createView()); + + window->setSource(testFileUrl("pathitem4.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QImage img = window->grabWindow(); + QVERIFY(!img.isNull()); + + QImage refImg(testFileUrl("pathitem4.png").toLocalFile()); + QVERIFY(!refImg.isNull()); + + QVERIFY(QQuickVisualTestUtil::compareImages(img.convertToFormat(refImg.format()), refImg)); +} + +QTEST_MAIN(tst_QQuickShape) + +#include "tst_qquickshape.moc" diff --git a/tests/auto/quick/qquickview/data/findChild.qml b/tests/auto/quick/qquickview/data/findChild.qml new file mode 100644 index 0000000000..8cbc46abe2 --- /dev/null +++ b/tests/auto/quick/qquickview/data/findChild.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +Item { + width: 200 + height: 200 + objectName: "rootObject" + Item { + objectName: "rootObjectChild" + } +} diff --git a/tests/auto/quick/qquickview/tst_qquickview.cpp b/tests/auto/quick/qquickview/tst_qquickview.cpp index fa9192edb4..04d21457e6 100644 --- a/tests/auto/quick/qquickview/tst_qquickview.cpp +++ b/tests/auto/quick/qquickview/tst_qquickview.cpp @@ -70,6 +70,7 @@ private slots: void resizemodeitem(); void errors(); void engine(); + void findChild(); }; @@ -265,6 +266,45 @@ void tst_QQuickView::engine() delete view4; } +void tst_QQuickView::findChild() +{ + QQuickView view; + view.setSource(testFileUrl("findChild.qml")); + + // QQuickView + // |_ QQuickWindow::contentItem + // | |_ QQuickView::rootObject: QML Item("rootObject") (findChild.qml) + // | | |_ QML Item("rootObjectChild") (findChild.qml) + // | |_ QObject("contentItemChild") + // |_ QObject("viewChild") + + QObject *viewChild = new QObject(&view); + viewChild->setObjectName("viewChild"); + + QObject *contentItemChild = new QObject(view.contentItem()); + contentItemChild->setObjectName("contentItemChild"); + + QObject *rootObject = view.rootObject(); + QVERIFY(rootObject); + + QObject *rootObjectChild = rootObject->findChild<QObject *>("rootObjectChild"); + QVERIFY(rootObjectChild); + + QCOMPARE(view.findChild<QObject *>("viewChild"), viewChild); + QCOMPARE(view.findChild<QObject *>("contentItemChild"), contentItemChild); + QCOMPARE(view.findChild<QObject *>("rootObject"), rootObject); + QCOMPARE(view.findChild<QObject *>("rootObjectChild"), rootObjectChild); + + QVERIFY(!view.contentItem()->findChild<QObject *>("viewChild")); // sibling + QCOMPARE(view.contentItem()->findChild<QObject *>("contentItemChild"), contentItemChild); + QCOMPARE(view.contentItem()->findChild<QObject *>("rootObject"), rootObject); + QCOMPARE(view.contentItem()->findChild<QObject *>("rootObjectChild"), rootObjectChild); + + QVERIFY(!view.rootObject()->findChild<QObject *>("viewChild")); // ancestor + QVERIFY(!view.rootObject()->findChild<QObject *>("contentItemChild")); // cousin + QVERIFY(!view.rootObject()->findChild<QObject *>("rootObject")); // self +} + QTEST_MAIN(tst_QQuickView) #include "tst_qquickview.moc" diff --git a/tests/auto/quick/qquickwindow/BLACKLIST b/tests/auto/quick/qquickwindow/BLACKLIST deleted file mode 100644 index 157808fdbf..0000000000 --- a/tests/auto/quick/qquickwindow/BLACKLIST +++ /dev/null @@ -1,4 +0,0 @@ -[requestActivate] -osx-10.11 -[attachedProperty] -osx-10.11 diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index 4fea13eb49..0c341b2663 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -388,6 +388,8 @@ private slots: void testDragEventPropertyPropagation(); + void findChild(); + private: QTouchDevice *touchDevice; QTouchDevice *touchDeviceWithVelocity; @@ -2875,6 +2877,28 @@ void tst_qquickwindow::testDragEventPropertyPropagation() } } +void tst_qquickwindow::findChild() +{ + QQuickWindow window; + + // QQuickWindow + // |_ QQuickWindow::contentItem + // | |_ QObject("contentItemChild") + // |_ QObject("viewChild") + + QObject *windowChild = new QObject(&window); + windowChild->setObjectName("windowChild"); + + QObject *contentItemChild = new QObject(window.contentItem()); + contentItemChild->setObjectName("contentItemChild"); + + QCOMPARE(window.findChild<QObject *>("windowChild"), windowChild); + QCOMPARE(window.findChild<QObject *>("contentItemChild"), contentItemChild); + + QVERIFY(!window.contentItem()->findChild<QObject *>("viewChild")); // sibling + QCOMPARE(window.contentItem()->findChild<QObject *>("contentItemChild"), contentItemChild); +} + QTEST_MAIN(tst_qquickwindow) #include "tst_qquickwindow.moc" diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index 99bd329f8e..9b7740646a 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -70,6 +70,7 @@ QUICKTESTS = \ qquickmousearea \ qquickmultipointtoucharea \ qquickpainteditem \ + qquickshape \ qquickpathview \ qquickpincharea \ qquickpositioners \ diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp index 01aa5d1c8e..646317078b 100644 --- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp +++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp @@ -590,7 +590,7 @@ void tst_TouchMouse::buttonOnFlickable() QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data()); QVERIFY(windowPriv->touchMouseId != -1); - auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); + auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), eventItem1); QCOMPARE(window->mouseGrabberItem(), eventItem1); @@ -651,7 +651,7 @@ void tst_TouchMouse::touchButtonOnFlickable() QQuickWindowPrivate *windowPriv = QQuickWindowPrivate::get(window.data()); QVERIFY(windowPriv->touchMouseId == -1); - auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); + auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); QCOMPARE(pointerEvent->point(0)->grabberItem(), eventItem2); QCOMPARE(window->mouseGrabberItem(), nullptr); @@ -777,8 +777,8 @@ void tst_TouchMouse::buttonOnDelayedPressFlickable() // for the touchMouseId to the new grabber. QCOMPARE(window->mouseGrabberItem(), flickable); QVERIFY(windowPriv->touchMouseId != -1); - auto pointerEvent = QQuickPointerDevice::touchDevices().at(0)->pointerEvent(); - QCOMPARE(pointerEvent->point(0)->exclusiveGrabber(), flickable); + auto pointerEvent = windowPriv->pointerEventInstance(QQuickPointerDevice::touchDevices().at(0)); + QCOMPARE(pointerEvent->point(0)->grabberItem(), flickable); QTest::touchEvent(window.data(), device).release(0, p3, window.data()); QQuickTouchUtils::flush(window.data()); @@ -1441,7 +1441,6 @@ void tst_TouchMouse::hoverEnabled() QSignalSpy exitSpy2(mouseArea2, SIGNAL(exited())); QSignalSpy clickSpy2(mouseArea2, SIGNAL(clicked(QQuickMouseEvent *))); - QPoint p0(50, 50); QPoint p1(150, 150); QPoint p2(150, 250); @@ -1467,9 +1466,6 @@ void tst_TouchMouse::hoverEnabled() QVERIFY(!mouseArea2->hovered()); // ------------------------- Touch click on mouseArea2 - if (QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive) == 0) - QSKIP("hover can be momentarily inconsistent on X11, depending on timing of flushFrameSynchronousEvents with touch and mouse movements (QTBUG-55350)"); - QTest::touchEvent(window.data(), device).press(0, p2, window.data()); QVERIFY(mouseArea1->hovered()); diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index bd051ec990..60495596d1 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -59,6 +59,7 @@ private slots: void reparentToNewWindow(); void nullEngine(); void keyEvents(); + void shortcuts(); }; @@ -365,6 +366,38 @@ void tst_qquickwidget::keyEvents() QTRY_VERIFY(widget.ok); } +class ShortcutEventFilter : public QObject +{ +public: + bool eventFilter(QObject *obj, QEvent *e) override { + if (e->type() == QEvent::ShortcutOverride) + shortcutOk = true; + + return QObject::eventFilter(obj, e); + } + + bool shortcutOk = false; +}; + +void tst_qquickwidget::shortcuts() +{ + // Verify that ShortcutOverride events do not get lost. (QTBUG-60988) + KeyHandlingWidget widget; + widget.setSource(testFileUrl("rectangle.qml")); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(widget.window(), 5000)); + + // Send to the widget, verify that the QQuickWindow sees it. + + ShortcutEventFilter filter; + widget.quickWindow()->installEventFilter(&filter); + + QKeyEvent e(QEvent::ShortcutOverride, Qt::Key_A, Qt::ControlModifier); + QCoreApplication::sendEvent(&widget, &e); + + QTRY_VERIFY(filter.shortcutOk); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" |