From e7710b211cb08b3d975f7d8add6bedaf25d60c4d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Dec 2017 15:50:10 +0100 Subject: Pass the source directory in the plugindump test On shadow builds this fails when just passing ".", because "." is the build directory. Change-Id: Iee84b73f2c4e5c8663d84d53b31f658501244dc9 Reviewed-by: Simon Hausmann --- tests/auto/qml/qmlplugindump/qmlplugindump.pro | 1 + tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/qmlplugindump/qmlplugindump.pro b/tests/auto/qml/qmlplugindump/qmlplugindump.pro index c713edc541..9327beffa6 100644 --- a/tests/auto/qml/qmlplugindump/qmlplugindump.pro +++ b/tests/auto/qml/qmlplugindump/qmlplugindump.pro @@ -3,4 +3,5 @@ TARGET = tst_qmlplugindump QT += testlib gui-private macx:CONFIG -= app_bundle +DEFINES += QT_QMLTEST_DIR=\\\"$${_PRO_FILE_PWD_}\\\" SOURCES += tst_qmlplugindump.cpp diff --git a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp index 838966e2a0..235cf6fac9 100644 --- a/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp +++ b/tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp @@ -103,7 +103,7 @@ void tst_qmlplugindump::singleton() QProcess dumper; QStringList args; args << QLatin1String("tests.dumper.CompositeSingleton") << QLatin1String("1.0") - << QLatin1String("."); + << QLatin1String(QT_QMLTEST_DIR); dumper.start(qmlplugindumpPath, args); dumper.waitForFinished(); -- cgit v1.2.3 From 6015c5554fa11583be27f1835baa284801dcb75b Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Dec 2017 15:51:18 +0100 Subject: Add the source directory as import paths in tst_qqmlimport On shadow builds the QML components won't be found in the build directory. Change-Id: I0f524063537669f68e64fc6c04a6756ed1d130fd Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlimport/tst_qqmlimport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index 68739886c4..70aaa9678e 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -54,7 +54,7 @@ void tst_QQmlImport::cleanup() void tst_QQmlImport::testDesignerSupported() { QQuickView *window = new QQuickView(); - window->engine()->addImportPath(QT_TESTCASE_BUILDDIR); + window->engine()->addImportPath(directory()); window->setSource(testFileUrl("testfile_supported.qml")); QVERIFY(window->errors().isEmpty()); @@ -68,7 +68,7 @@ void tst_QQmlImport::testDesignerSupported() delete window; window = new QQuickView(); - window->engine()->addImportPath(QT_TESTCASE_BUILDDIR); + window->engine()->addImportPath(directory()); window->engine()->clearComponentCache(); window->setSource(testFileUrl("testfile_supported.qml")); @@ -91,7 +91,7 @@ void tst_QQmlImport::uiFormatLoading() int size = 0; QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("TestForm.ui.qml")); - test->addImportPath(QT_TESTCASE_BUILDDIR); + test->addImportPath(directory()); QCOMPARE(test->rootObjects().size(), ++size); QVERIFY(test->rootObjects()[size -1]); QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); -- cgit v1.2.3 From 96ec0ab8f0b2e53eff6e1887aff7e51601821845 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 20 Nov 2017 14:01:12 +0100 Subject: QQuickList/GridViewPrivate::fixupPosition: don't set moveReason In QQuickItemViewPrivate::applyModelChanges(), if moveReason = QQuickItemViewPrivate::Other, then QQuickItemView::trackedPositionChanged() will fail to call d->setPosition(pos), which is normally what keeps the Flickable moving for a while. Leave the reason as-is (it will be SetIndex in this case), so as not to forget that we were actually trying to move down when the sequence window->polishItems() -> QQIV::updatePolish() -> layout() -> fixupPosition() did its part of the work of moving down. Task-number: QTBUG-62864 Change-Id: I1021e2ea39265de9e1285e2ee17c5733189ab939 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicklistview/tst_qquicklistview.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 223f6004ff..73d831ecdd 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -255,6 +255,7 @@ private slots: void QTBUG_50105(); void keyNavigationEnabled(); void QTBUG_61269_appendDuringScrollDown(); + void QTBUG_61269_appendDuringScrollDown_data(); void QTBUG_50097_stickyHeader_positionViewAtIndex(); void QTBUG_63974_stickyHeader_positionViewAtIndex_Contain(); void itemFiltered(); @@ -8468,8 +8469,19 @@ void tst_QQuickListView::keyNavigationEnabled() QCOMPARE(listView->currentIndex(), 1); } -void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown() +void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown_data() { + QTest::addColumn("snapMode"); + + QTest::newRow("NoSnap") << QQuickListView::NoSnap; + QTest::newRow("SnapToItem") << QQuickListView::SnapToItem; + QTest::newRow("SnapOneItem") << QQuickListView::SnapOneItem; +} + +void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown() // AKA QTBUG-62864 +{ + QFETCH(QQuickListView::SnapMode, snapMode); + QScopedPointer window(createView()); window->setSource(testFileUrl("appendDuringScrollDown.qml")); window->show(); @@ -8477,6 +8489,7 @@ void tst_QQuickListView::QTBUG_61269_appendDuringScrollDown() QVERIFY(QTest::qWaitForWindowActive(window.data())); QQuickListView *listView = qobject_cast(window->rootObject()); + listView->setSnapMode(snapMode); QQuickItem *highlightItem = listView->highlightItem(); QVERIFY(listView); QCOMPARE(listView->isKeyNavigationEnabled(), true); -- cgit v1.2.3 From e8570bd1af74724b6fae1ac8a2d8bbdfee7a6504 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 13 Dec 2017 12:17:14 +0100 Subject: QQuickItemView: Clear pending changes when refilling Generally the bufferedChanges are an "extension" of the currentChanges, which can just not be applied at the moment because we are in a layout phase. If we regenerate or clear the whole view in the mean time, the bufferedChanges become just as invalid as the currentChanges. On top of that, refilling can trigger further changes, part of which will be applied during the refilling. As that leaves us in an inconsistent state, we need to loop the refilling until no further changes are generated. As the changes might affect items that are already visible, and therefore not subject to refilling, we need to clear all the items before refilling in this case. In QTBUG-46488 things are added in the onCompleted callback of the delegates (by expanding the tree view, which translates into adding rows to the list view). Depending on where you add the new items, the list view might pick them up when iterating the model on refill() or it might create delegates for the same model entry twice. So, if that happens we need to discard the result and refill again. Task-number: QTBUG-46488 Change-Id: Ie4e0a731f7feda6aa962b6cb9a6cd5c3bf90486e Reviewed-by: Richard Moe Gustavsen --- .../quick/qquicklistview/data/addoncompleted.qml | 90 ++++++++++++++++++++++ .../quick/qquicklistview/tst_qquicklistview.cpp | 32 ++++++++ 2 files changed, 122 insertions(+) create mode 100644 tests/auto/quick/qquicklistview/data/addoncompleted.qml (limited to 'tests') diff --git a/tests/auto/quick/qquicklistview/data/addoncompleted.qml b/tests/auto/quick/qquicklistview/data/addoncompleted.qml new file mode 100644 index 0000000000..57265cb2c0 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/addoncompleted.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 + +Rectangle { + width: 640 + height: 480 + color: "green" + + ListModel { + id: listModel + ListElement { name: "a" } + ListElement { name: "b" } + ListElement { name: "c" } + ListElement { name: "d" } + ListElement { name: "e" } + ListElement { name: "f" } + ListElement { name: "g" } + ListElement { name: "h" } + ListElement { name: "i" } + ListElement { name: "j" } + } + + ListView { + anchors.fill: parent + model: listModel + objectName: "view" + + delegate: Rectangle { + height: 15 + width: 15 + color: "blue" + objectName: name + Component.onCompleted: { + if (name.length === 1 && listModel.get(index + 1).name.length === 1) { + for (var i = 0; i < 10; ++i) + listModel.insert(index + 1, {name: name + i}); + } + } + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 73d831ecdd..a7583129f9 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -264,6 +264,8 @@ private slots: void QTBUG_34576_velocityZero(); void QTBUG_61537_modelChangesAsync(); + void addOnCompleted(); + private: template void items(const QUrl &source); template void changed(const QUrl &source); @@ -8735,6 +8737,36 @@ void tst_QQuickListView::QTBUG_61537_modelChangesAsync() QCOMPARE(reportedCount, actualCount); } +void tst_QQuickListView::addOnCompleted() +{ + QScopedPointer window(createView()); + window->setSource(testFileUrl("addoncompleted.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = findItem(window->rootObject(), "view"); + QTRY_VERIFY(listview != 0); + + QQuickItem *contentItem = listview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + qreal y = -1; + for (char name = 'a'; name <= 'j'; ++name) { + for (int num = 9; num >= 0; --num) { + const QString objName = QString::fromLatin1("%1%2").arg(name).arg(num); + QQuickItem *item = findItem(contentItem, objName); + if (!item) { + QVERIFY(name >= 'd'); + y = 9999999; + } else { + const qreal newY = item->y(); + QVERIFY2(newY > y, objName.toUtf8().constData()); + y = newY; + } + } + } +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" -- cgit v1.2.3 From 96158b46afbe4a71794206deacdc58e8022c57ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kari=20Hautam=C3=A4ki?= Date: Mon, 6 Nov 2017 11:47:36 +0200 Subject: Add test to QQuickShortcut when render window is used Add auto test for shortcuts when render window is used to draw QQuickShortcut. Task-number: QTBUG-64548 Change-Id: If2eb1f5618ae5f21477cc239acb42bc73ca7ec99 Reviewed-by: J-P Nurmi --- .../quick/qquickshortcut/data/shortcutsRect.qml | 54 +++++++++ tests/auto/quick/qquickshortcut/qquickshortcut.pro | 3 + .../quick/qquickshortcut/tst_qquickshortcut.cpp | 124 +++++++++++++++++++++ 3 files changed, 181 insertions(+) create mode 100644 tests/auto/quick/qquickshortcut/data/shortcutsRect.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickshortcut/data/shortcutsRect.qml b/tests/auto/quick/qquickshortcut/data/shortcutsRect.qml new file mode 100644 index 0000000000..9aced4e530 --- /dev/null +++ b/tests/auto/quick/qquickshortcut/data/shortcutsRect.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.5 + +Rectangle { + width: 300 + height: 300 + + property string activatedShortcut + property string ambiguousShortcut + + property alias shortcuts: repeater.model + + Repeater { + id: repeater + + Item { + Shortcut { + sequence: modelData.sequence + enabled: modelData.enabled + autoRepeat: modelData.autoRepeat + context: modelData.context + onActivated: activatedShortcut = sequence + onActivatedAmbiguously: ambiguousShortcut = sequence + } + } + } +} diff --git a/tests/auto/quick/qquickshortcut/qquickshortcut.pro b/tests/auto/quick/qquickshortcut/qquickshortcut.pro index d780d9061a..018bb91594 100644 --- a/tests/auto/quick/qquickshortcut/qquickshortcut.pro +++ b/tests/auto/quick/qquickshortcut/qquickshortcut.pro @@ -8,3 +8,6 @@ include (../../shared/util.pri) TESTDATA = data/* QT += core gui qml quick testlib +qtHaveModule(widgets) { + QT += quickwidgets +} diff --git a/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp b/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp index 75ccf26af9..4962690796 100644 --- a/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp +++ b/tests/auto/quick/qquickshortcut/tst_qquickshortcut.cpp @@ -29,6 +29,11 @@ #include #include #include +#include +#include +#ifdef QT_QUICKWIDGETS_LIB +#include +#endif #include "../../shared/util.h" @@ -47,6 +52,10 @@ private slots: void matcher(); void multiple_data(); void multiple(); +#ifdef QT_QUICKWIDGETS_LIB + void renderControlShortcuts_data(); + void renderControlShortcuts(); +#endif }; Q_DECLARE_METATYPE(Qt::Key) @@ -453,6 +462,121 @@ void tst_QQuickShortcut::multiple() QCOMPARE(window->property("activated").toBool(), activated); } +#ifdef QT_QUICKWIDGETS_LIB +void tst_QQuickShortcut::renderControlShortcuts_data() +{ + QTest::addColumn("shortcuts"); + QTest::addColumn("key"); + QTest::addColumn("modifiers"); + QTest::addColumn("activatedShortcut"); + QTest::addColumn("ambiguousShortcut"); + + QVariantList shortcuts; + shortcuts << shortcutMap("M") + << shortcutMap("Alt+M") + << shortcutMap("Ctrl+M") + << shortcutMap("Shift+M") + << shortcutMap("Ctrl+Alt+M") + << shortcutMap("+") + << shortcutMap("F1") + << shortcutMap("Shift+F1"); + + QTest::newRow("M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "M" << ""; + QTest::newRow("Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "Alt+M" << ""; + QTest::newRow("Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "Ctrl+M" << ""; + QTest::newRow("Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+M" << ""; + QTest::newRow("Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "Ctrl+Alt+M" << ""; + QTest::newRow("+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "+" << ""; + QTest::newRow("F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "F1" << ""; + QTest::newRow("Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+F1" << ""; + + // ambiguous + shortcuts << shortcutMap("M") + << shortcutMap("Alt+M") + << shortcutMap("Ctrl+M") + << shortcutMap("Shift+M") + << shortcutMap("Ctrl+Alt+M") + << shortcutMap("+") + << shortcutMap("F1") + << shortcutMap("Shift+F1"); + + QTest::newRow("?M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "" << "M"; + QTest::newRow("?Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "" << "Alt+M"; + QTest::newRow("?Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "" << "Ctrl+M"; + QTest::newRow("?Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << "Shift+M"; + QTest::newRow("?Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "" << "Ctrl+Alt+M"; + QTest::newRow("?+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "" << "+"; + QTest::newRow("?F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "" << "F1"; + QTest::newRow("?Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << "Shift+F1"; + + // disabled + shortcuts.clear(); + shortcuts << shortcutMap("M", DisabledShortcut) + << shortcutMap("Alt+M", DisabledShortcut) + << shortcutMap("Ctrl+M", DisabledShortcut) + << shortcutMap("Shift+M", DisabledShortcut) + << shortcutMap("Ctrl+Alt+M", DisabledShortcut) + << shortcutMap("+", DisabledShortcut) + << shortcutMap("F1", DisabledShortcut) + << shortcutMap("Shift+F1", DisabledShortcut); + + QTest::newRow("!M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "" << ""; + QTest::newRow("!Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "" << ""; + QTest::newRow("!Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "" << ""; + QTest::newRow("!Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << ""; + QTest::newRow("!Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "" << ""; + QTest::newRow("!+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "" << ""; + QTest::newRow("!F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "" << ""; + QTest::newRow("!Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "" << ""; + + // unambigous because others disabled + shortcuts << shortcutMap("M") + << shortcutMap("Alt+M") + << shortcutMap("Ctrl+M") + << shortcutMap("Shift+M") + << shortcutMap("Ctrl+Alt+M") + << shortcutMap("+") + << shortcutMap("F1") + << shortcutMap("Shift+F1"); + + QTest::newRow("/M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::NoModifier) << "M" << ""; + QTest::newRow("/Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::AltModifier) << "Alt+M" << ""; + QTest::newRow("/Ctrl+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier) << "Ctrl+M" << ""; + QTest::newRow("/Shift+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+M" << ""; + QTest::newRow("/Ctrl+Alt+M") << shortcuts << Qt::Key_M << Qt::KeyboardModifiers(Qt::ControlModifier|Qt::AltModifier) << "Ctrl+Alt+M" << ""; + QTest::newRow("/+") << shortcuts << Qt::Key_Plus << Qt::KeyboardModifiers(Qt::NoModifier) << "+" << ""; + QTest::newRow("/F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::NoModifier) << "F1" << ""; + QTest::newRow("/Shift+F1") << shortcuts << Qt::Key_F1 << Qt::KeyboardModifiers(Qt::ShiftModifier) << "Shift+F1" << ""; +} + +void tst_QQuickShortcut::renderControlShortcuts() +{ + QFETCH(QVariantList, shortcuts); + QFETCH(Qt::Key, key); + QFETCH(Qt::KeyboardModifiers, modifiers); + QFETCH(QString, activatedShortcut); + QFETCH(QString, ambiguousShortcut); + + QScopedPointer quickWidget(new QQuickWidget); + quickWidget->resize(300,300); + + QSignalSpy spy(qApp, &QGuiApplication::focusObjectChanged); + + quickWidget->setSource(testFileUrl("shortcutsRect.qml")); + quickWidget->show(); + + spy.wait(); + + QVERIFY(qobject_cast(qApp->focusObject()) == quickWidget.data()); + + QQuickItem* item = quickWidget->rootObject(); + item->setProperty("shortcuts", shortcuts); + QTest::keyPress(quickWidget->quickWindow(), key, modifiers, 1500); + QCOMPARE(item->property("activatedShortcut").toString(), activatedShortcut); + QCOMPARE(item->property("ambiguousShortcut").toString(), ambiguousShortcut); +} +#endif // QT_QUICKWIDGETS_LIB + QTEST_MAIN(tst_QQuickShortcut) #include "tst_qquickshortcut.moc" -- cgit v1.2.3 From 52bc4fbfbae6aa1569dc134dd103e966f04bc2e6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 11 Dec 2017 12:44:47 +0100 Subject: Use potentially intercepted URL as ID for compilation units We generally have to pass a URL and a file name everywhere because the logical URL might be something else than the actual file being loaded. For example a QQmlFileSelector might modify the URL to be loaded for a specific file. This resulting URL, however, should not be used to resolve further URLs defined in the file loaded that way. As we need to access QQmlTypeLoader::m_url as string more often now, cache it and avoid frequent translations between QUrl and QString. Furthermore, QQmlDataBlob's URLs are changed to follow the same semantics. The finalUrl is the one that should be used to resolve further URLs, the url is the one used to load the content, and subject to any redirects or interceptions. This changes the semantics of URL redirects. Previously a redirected URL was used as the base URL for furher URL resolution. This doesn't work because redirection occurs after interception and interception should not influence the resolution of further URLs. We now use the original URL as base URL for resolution of further URLs and rely on the server to redirect those, too. Task-number: QTBUG-61209 Change-Id: I93822f820bed2515995de3cb118099218b510ca4 Reviewed-by: Michael Brasser --- tests/auto/qml/qml.pro | 1 + .../qml/qqmlfileselector/tst_qqmlfileselector.cpp | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro index 12a8bd3829..42a5400dc1 100644 --- a/tests/auto/qml/qml.pro +++ b/tests/auto/qml/qml.pro @@ -8,6 +8,7 @@ PUBLICTESTS += \ qjsvalueiterator \ qjsonbinding \ qqmlfile \ + qqmlfileselector !boot2qt { PUBLICTESTS += \ diff --git a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp index 648e4490ee..2c62353630 100644 --- a/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp +++ b/tests/auto/qml/qqmlfileselector/tst_qqmlfileselector.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "../../shared/util.h" @@ -44,6 +45,7 @@ public: private slots: void basicTest(); + void basicTestCached(); void applicationEngineTest(); }; @@ -62,6 +64,25 @@ void tst_qqmlfileselector::basicTest() delete object; } +void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message) +{ + if (type == QtDebugMsg + && QByteArray(context.category) == QByteArray("qt.qml.diskcache") + && message.contains("QML source file has moved to a different location.")) { + QFAIL(message.toUtf8()); + } +} + +void tst_qqmlfileselector::basicTestCached() +{ + basicTest(); // Seed the cache, in case basicTestCached() is run on its own + QtMessageHandler defaultHandler = qInstallMessageHandler(&messageHandler); + QLoggingCategory::setFilterRules("qt.qml.diskcache.debug=true"); + basicTest(); // Run again and check that the file is in the cache now + QLoggingCategory::setFilterRules(QString()); + qInstallMessageHandler(defaultHandler); +} + void tst_qqmlfileselector::applicationEngineTest() { QQmlApplicationEngine engine; -- cgit v1.2.3 From 78a5add79497300802c2152b5bf561b6bef305f1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 21 Dec 2017 11:03:53 -0600 Subject: Remove extra addref The code was previously updated to use QQmlRefPointer, so we shouldn't explicitly addref. This allows more components to be correctly trimmed when needed. Change-Id: I15a961cfc456eeab5c791c8a282cc7e2852912cb Reviewed-by: Lars Knoll --- .../qqmltypeloader/data/ComponentWithIncubator.qml | 9 +++++++++ tests/auto/qml/qqmltypeloader/data/trim_cache3.qml | 14 ++++++++++++++ .../auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 21 +++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/trim_cache3.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml b/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml new file mode 100644 index 0000000000..b3610831df --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Item { + Repeater { + model: 3 + Item {} + } +} + diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml new file mode 100644 index 0000000000..219c7d3bcb --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + + property alias source: loader.source + + Loader { + id: loader + source: "ComponentWithIncubator.qml" + } +} + diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 5ab729042f..5a3d76e903 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -44,6 +44,7 @@ private slots: void loadComponentSynchronously(); void trimCache(); void trimCache2(); + void trimCache3(); void keepSingleton(); void keepRegistrations(); void intercept(); @@ -124,6 +125,26 @@ void tst_QQMLTypeLoader::trimCache2() QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), false); } +// test trimming the cache of an item that contains sub-items created via incubation +void tst_QQMLTypeLoader::trimCache3() +{ + QScopedPointer window(new QQuickView()); + window->setSource(testFileUrl("trim_cache3.qml")); + QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader; + QCOMPARE(loader.isTypeLoaded(testFileUrl("ComponentWithIncubator.qml")), true); + + QQmlProperty::write(window->rootObject(), "source", QString()); + + // handle our deleteLater and cleanup + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + QCoreApplication::processEvents(); + window->engine()->collectGarbage(); + + window->engine()->trimComponentCache(); + + QCOMPARE(loader.isTypeLoaded(testFileUrl("ComponentWithIncubator.qml")), false); +} + static void checkSingleton(const QString &dataDirectory) { QQmlEngine engine; -- cgit v1.2.3 From 17d9a17db4ea2cac900325f3bec5559bd100f275 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 22 Dec 2017 14:13:00 +0100 Subject: Fix animation benchmark This was broken by 49a11e882059ee1729f776722e085dd21d378c36. Change-Id: Ic7f261bce5e35b3dbcbdaf0b8718e08c56e55b39 Reviewed-by: Lars Knoll --- tests/benchmarks/qml/animation/tst_animation.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/benchmarks/qml/animation/tst_animation.cpp b/tests/benchmarks/qml/animation/tst_animation.cpp index 27622ed013..f377c94f72 100644 --- a/tests/benchmarks/qml/animation/tst_animation.cpp +++ b/tests/benchmarks/qml/animation/tst_animation.cpp @@ -125,12 +125,12 @@ void tst_animation::animationelements_data() void tst_animation::animationelements() { QFETCH(QString, type); - QQmlType *t = QQmlMetaType::qmlType(type, 2, 0); - if (!t || !t->isCreatable()) + QQmlType t = QQmlMetaType::qmlType(type, 2, 0); + if (!t.isValid() || !t.isCreatable()) QSKIP("Non-creatable type"); QBENCHMARK { - QObject *obj = t->create(); + QObject *obj = t.create(); delete obj; } } -- cgit v1.2.3 From 0dbdfaa78d9c3ac0c1a9cfff440d753b159a3a14 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Fri, 22 Dec 2017 14:41:06 +0100 Subject: Fix holistic benchmark Each test now uses its own QQmlEngine, instead of using a single instance across all benchmarks. The effect is that peak heap usage (on macos) is now about 77MB, where it previously peaked at 770MB. This benchmark would actually crash on some platforms due to excessive malloc/mmap usage. Change-Id: I214f7b9b3d8c5565c0578b82c9c144ec87ed0f2b Reviewed-by: Lars Knoll --- tests/benchmarks/qml/holistic/tst_holistic.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/benchmarks/qml/holistic/tst_holistic.cpp b/tests/benchmarks/qml/holistic/tst_holistic.cpp index 791ae6812b..9186816a16 100644 --- a/tests/benchmarks/qml/holistic/tst_holistic.cpp +++ b/tests/benchmarks/qml/holistic/tst_holistic.cpp @@ -107,9 +107,6 @@ private slots: void typeResolution_data(); void typeResolution(); - -private: - QQmlEngine engine; }; tst_holistic::tst_holistic() @@ -251,6 +248,8 @@ void tst_holistic::compilation() Q_ASSERT(files.size() > 0); Q_ASSERT(repetitions > 0); + QQmlEngine engine; + QBENCHMARK { engine.clearComponentCache(); for (int i = 0; i < repetitions; ++i) { @@ -272,6 +271,8 @@ void tst_holistic::instantiation() Q_ASSERT(files.size() > 0); Q_ASSERT(repetitions > 0); + QQmlEngine engine; + QList components; for (int i = 0; i < files.size(); ++i) { QQmlComponent *c = new QQmlComponent(&engine, QUrl::fromLocalFile(files.at(i))); @@ -306,6 +307,8 @@ void tst_holistic::creation() Q_ASSERT(files.size() > 0); Q_ASSERT(repetitions > 0); + QQmlEngine engine; + QBENCHMARK { engine.clearComponentCache(); for (int i = 0; i < repetitions; ++i) { @@ -369,6 +372,7 @@ void tst_holistic::dynamicity() QFETCH(QVariant, writeValueTwo); QFETCH(QString, readProperty); + QQmlEngine engine; QQmlComponent c(&engine, file); QObject *obj = c.create(); @@ -478,6 +482,7 @@ void tst_holistic::cppToJsDirect() QFETCH(QString, file); QFETCH(QString, methodName); + QQmlEngine engine; QQmlComponent c(&engine, file); QObject *obj = c.create(); @@ -497,6 +502,7 @@ void tst_holistic::cppToJsIndirect() // The benchmark deliberately causes change signals to be emitted (and // modifies the scarce resources) so that the properties are updated. + QQmlEngine engine; QQmlComponent c(&engine, QString(SRCDIR + QLatin1String("/data/scopeSwitching/ScarceTwo.qml"))); QObject *obj = c.create(); @@ -560,6 +566,7 @@ void tst_holistic::typeResolution() Q_ASSERT(propertyNameTwo.size() == propertyValueTwo.size()); Q_ASSERT(repetitions > 0); + QQmlEngine engine; QQmlComponent c(&engine, file); QObject *obj = c.create(); -- cgit v1.2.3 From 8836896dff45fe1d21736835845e36d03763117f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 12 Dec 2017 11:16:45 +0100 Subject: Allow QQmlComponent::loadUrl() to load absolute URLs with relative paths Currently, QQmlTypeLoader::getType() will assert if passed a relative URL, because it needs absolute URLs in order to ensure that it can use them as keys for its cache. After dc6b73390 was merged, URLs like QUrl::fromLocalFile("main.qml") (which are currently used in examples of how to load a QQmlComponent) started causing the assertion to fail. As mentioned in the comments of the bug report, some patches have already been applied to QQmlComponent's QString-based constructors, but both the constructors taking a QUrl and loadUrl() itself need fixing. This patch puts the fix into loadUrl() (the constructors call this function) so that every operation involving URLs is successful when using the documented methods. Task-number: QTBUG-58837 Change-Id: Ib54ca52eddce6e7781cf96015f4c15af604233d3 Reviewed-by: David Faure --- .../qml/qqmlcomponent/data/QtObjectComponent#2.qml | 3 +++ .../qml/qqmlcomponent/data/QtObjectComponent.qml | 3 +++ tests/auto/qml/qqmlcomponent/qqmlcomponent.pro | 2 ++ tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 24 ++++++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml create mode 100644 tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml new file mode 100644 index 0000000000..431c659424 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent#2.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 + +QtObject {} diff --git a/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml new file mode 100644 index 0000000000..431c659424 --- /dev/null +++ b/tests/auto/qml/qqmlcomponent/data/QtObjectComponent.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 + +QtObject {} diff --git a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro index 9f8c8a4e24..0d501ebefd 100644 --- a/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro +++ b/tests/auto/qml/qqmlcomponent/qqmlcomponent.pro @@ -8,6 +8,8 @@ SOURCES += tst_qqmlcomponent.cpp \ HEADERS += ../../shared/testhttpserver.h +RESOURCES += data/QtObjectComponent.qml + include (../../shared/util.pri) TESTDATA = data/* diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index f2b0b9973e..3c78f6601e 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -117,6 +117,8 @@ private slots: void recursion(); void recursionContinuation(); void callingContextForInitialProperties(); + void relativeUrl_data(); + void relativeUrl(); private: QQmlEngine engine; @@ -581,6 +583,28 @@ void tst_qqmlcomponent::callingContextForInitialProperties() QVERIFY(checker->scopeObject->metaObject()->indexOfProperty("incubatedObject") != -1); } +void tst_qqmlcomponent::relativeUrl_data() +{ + QTest::addColumn("url"); + + QTest::addRow("fromLocalFile") << QUrl::fromLocalFile("data/QtObjectComponent.qml"); + QTest::addRow("fromLocalFileHash") << QUrl::fromLocalFile("data/QtObjectComponent#2.qml"); + QTest::addRow("constructor") << QUrl("data/QtObjectComponent.qml"); + QTest::addRow("absolute") << QUrl::fromLocalFile(QFINDTESTDATA("data/QtObjectComponent.qml")); + QTest::addRow("qrc") << QUrl("qrc:/data/QtObjectComponent.qml"); +} + +void tst_qqmlcomponent::relativeUrl() +{ + QFETCH(QUrl, url); + + QQmlComponent component(&engine); + // Shouldn't assert in QQmlTypeLoader; we want QQmlComponent to assume that + // data/QtObjectComponent.qml refers to the data/QtObjectComponent.qml in the current working directory. + component.loadUrl(url); + QVERIFY2(!component.isError(), qPrintable(component.errorString())); +} + QTEST_MAIN(tst_qqmlcomponent) #include "tst_qqmlcomponent.moc" -- cgit v1.2.3 From ccee761f06be0f62b84f944a76b0aa4dc759091f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 4 Jan 2018 14:52:56 +0100 Subject: Fix segfault on invalid property alias syntax Task-number: QTBUG-64798 Change-Id: Id1eb434f83ec89c5ea1ebaa4d8ec86fce9f4428f Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt | 1 + tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml | 6 ++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 1 + 3 files changed, 8 insertions(+) create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt create mode 100644 tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt new file mode 100644 index 0000000000..8b94763860 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.errors.txt @@ -0,0 +1 @@ +4:28:Invalid alias target location: source diff --git a/tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml new file mode 100644 index 0000000000..71063ae320 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/invalidAlias.12.qml @@ -0,0 +1,6 @@ +import QtQuick 2.0 + +QtObject { + property alias source: previewImage.source + previewImage { id: previewImage } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index d04a83cd5b..b1a17afd2c 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -510,6 +510,7 @@ void tst_qqmllanguage::errors_data() QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false; QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.errors.txt" << false; QTest::newRow("invalidAlias.11") << "invalidAlias.11.qml" << "invalidAlias.11.errors.txt" << false; + QTest::newRow("invalidAlias.12") << "invalidAlias.12.qml" << "invalidAlias.12.errors.txt" << false; QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; -- cgit v1.2.3 From 66f8b97f5ea4a8d196f908fae78d2b68cfab32cf Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 12 Dec 2017 14:35:13 +0100 Subject: QQmlEngineDebugService: Actually call value types' toString() method QML value types generally are Q_GADGETs, but the userType we see there is the wrapped class's type, which doesn't have to be a gadget. So, the toString() method was rarely called, and a model index would still crash the debug service. Change-Id: I63778953eb9d2fc60113c11057da3047fc75a9bd Reviewed-by: Simon Hausmann --- .../qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 57e95f7b89..6d31ff9219 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -896,7 +896,8 @@ void tst_QQmlEngineDebugService::queryObjectWithNonStreamableTypes() QmlDebugObjectReference obj = m_dbg->object(); QVERIFY(!obj.className.isEmpty()); - QCOMPARE(findProperty(obj.properties, "modelIndex").value, QVariant()); + QCOMPARE(findProperty(obj.properties, "modelIndex").value, + QVariant(QLatin1String("QModelIndex()"))); } -- cgit v1.2.3 From 709b09b026d34b6a9c30c02cedae56a4d467c960 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 9 Jan 2018 15:40:07 +0100 Subject: lancelot: Add tests for some emoji cases This adds a test that emojis can be mixed with non-latin scripts and that ZWJ correctly joins together emojis when applicable. Task-number: QTBUG-61882 Task-number: QTBUG-65519 Change-Id: I6d52382886c9a0c8f2d07ef56abad49ec2f2798e Reviewed-by: Eirik Aavitsland --- .../data/text/text_emoji_hebrew.qml | 45 ++++++++++++++++++++++ .../data/text/text_emoji_zwj.qml | 45 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml create mode 100644 tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml (limited to 'tests') diff --git a/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml b/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml new file mode 100644 index 0000000000..b67d584a12 --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_emoji_hebrew.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Component { + id: component + Column { + property variant listModel: model + Repeater { + model: [Text.NativeRendering, Text.QtRendering] + Rectangle { + width: text.implicitWidth + height: text.implicitHeight + color: listModel.backGroundColor ? listModel.backGroundColor : "white" + + Text { + id: text + font.pixelSize: 32 + renderType: modelData + text: "ื๐Ÿ˜ƒื๐Ÿ˜‡ื๐Ÿ˜ื๐Ÿ˜œื๐Ÿ˜ธ!" + + color: listModel.color ? listModel.color : "black" + opacity: listModel.opacity ? listModel.opacity : 1.0 + } + } + } + } + } + + Column { + anchors.centerIn: parent + Repeater { + model: ListModel { + ListElement { color: "black" } + ListElement { color: "blue" } + ListElement { color: "#990000ff" } + ListElement { opacity: 0.5 } + ListElement { backGroundColor: "green" } + } + delegate: component + } + } +} diff --git a/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml b/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml new file mode 100644 index 0000000000..4691ff7efd --- /dev/null +++ b/tests/manual/scenegraph_lancelot/data/text/text_emoji_zwj.qml @@ -0,0 +1,45 @@ +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Component { + id: component + Column { + property variant listModel: model + Repeater { + model: [Text.NativeRendering, Text.QtRendering] + Rectangle { + width: text.implicitWidth + height: text.implicitHeight + color: listModel.backGroundColor ? listModel.backGroundColor : "white" + + Text { + id: text + font.pixelSize: 32 + renderType: modelData + text: "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ" + + color: listModel.color ? listModel.color : "black" + opacity: listModel.opacity ? listModel.opacity : 1.0 + } + } + } + } + } + + Column { + anchors.centerIn: parent + Repeater { + model: ListModel { + ListElement { color: "black" } + ListElement { color: "blue" } + ListElement { color: "#990000ff" } + ListElement { opacity: 0.5 } + ListElement { backGroundColor: "green" } + } + delegate: component + } + } +} -- cgit v1.2.3 From ddf495fb81ea89173af3310f50314b177bc866d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 13 Dec 2017 16:16:44 +0100 Subject: GridView: Fix an off-by-one offset of positioning of items The block for finding the position for the item *before* needs to be applied for the case where visibleItems is empty too, so we separate it out. Change-Id: I60a7e3a44d01a0087970e37bf4e73b94da5ebd48 Task-number: QTBUG-49218 Reviewed-by: Shawn Rutledge --- .../auto/quick/qquickgridview/data/qtbug49218.qml | 126 +++++++++++++++++++++ .../quick/qquickgridview/tst_qquickgridview.cpp | 31 +++++ 2 files changed, 157 insertions(+) create mode 100644 tests/auto/quick/qquickgridview/data/qtbug49218.qml (limited to 'tests') diff --git a/tests/auto/quick/qquickgridview/data/qtbug49218.qml b/tests/auto/quick/qquickgridview/data/qtbug49218.qml new file mode 100644 index 0000000000..1a55fe5b3a --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/qtbug49218.qml @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 2.4 + +Item { + width: 500 + height: 160 + visible: true + + property var model1: ["1","2","3","4","5","6","7","8","9","10", + "11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30", + "31","32","33","34","a"] + property var model2: ["a","b","c","d","e","f","g","h","i","j","k","l","m","1"] + property bool useModel1: true + + function changeModel() { + useModel1 = !useModel1 + grid.loadModel(useModel1 ? model1 : model2) + } + + function scrollToTop() { + grid.contentY = grid.originY; + } + + GridView { + id: grid + anchors.fill: parent + + model: ListModel { + } + + onCurrentIndexChanged: { + positionViewAtIndex(currentIndex, GridView.Contain) + } + + Component.onCompleted: { + loadModel(model1) + grid.currentIndex = 34 + grid.positionViewAtIndex(34, GridView.Contain) + } + + function loadModel(m) { + var remove = {}; + var add = {}; + var i; + for (i=0; i < model.count; ++i) + remove[model.get(i).name] = true; + for (i=0; i < m.length; ++i) + if (remove[m[i]]) + delete remove[m[i]]; + else + add[m[i]] = true; + + for (i=model.count-1; i>= 0; --i) + if (remove[model.get(i).name]) + model.remove(i, 1); + + for (i=0; isetSource(testFileUrl("qtbug49218.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickItem *rootItem = qobject_cast(window->rootObject()); + QQuickGridView *gridview = qobject_cast(rootItem->childItems().first()); + QVERIFY(gridview != 0); + + auto processEventsAndForceLayout = [&gridview] () { + for (int pass = 0; pass < 2; ++pass) { + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); + gridview->forceLayout(); + } + }; + QMetaObject::invokeMethod(rootItem, "scrollToTop"); + processEventsAndForceLayout(); + QMetaObject::invokeMethod(rootItem, "changeModel"); + processEventsAndForceLayout(); + QMetaObject::invokeMethod(rootItem, "changeModel"); + processEventsAndForceLayout(); + QMetaObject::invokeMethod(rootItem, "scrollToTop"); + processEventsAndForceLayout(); + + QCOMPARE(gridview->indexAt(gridview->cellWidth() - 10, gridview->cellHeight() - 10), 0); + delete window; +} + void tst_QQuickGridView::keyNavigationEnabled() { QScopedPointer window(createView()); -- cgit v1.2.3 From bbf3c4715a1569b26a3aa029046e26989efd6edc Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 10 Jan 2018 15:42:01 +0100 Subject: Fix crash when accessing a deleted object In QObjectWrapper::query(), return QV4::Attr_Invalid if the object was deleted. Task-number: QTBUG-44153 Change-Id: I53e8be6196489c323b190dbfa20d2dda2a54315e Reviewed-by: Simon Hausmann --- .../qml/qqmllanguage/data/accessDeletedObject.qml | 12 +++++++++++ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 24 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml b/tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml new file mode 100644 index 0000000000..e5151096e5 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/accessDeletedObject.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0 + +Item { + id: root + + Component.onCompleted: { + var createdObject = objectCreator.create() + createdObject.del() + // Shouldn't crash. + var test = "index" in createdObject + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index b1a17afd2c..1af57f9247 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -269,6 +269,8 @@ private slots: void concurrentLoadQmlDir(); + void accessDeletedObject(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -4571,6 +4573,28 @@ void tst_qqmllanguage::concurrentLoadQmlDir() engine.setImportPathList(defaultImportPathList); } +// Test that deleting an object and then accessing it doesn't crash. +// QTBUG-44153 +class ObjectCreator : public QObject +{ + Q_OBJECT +public slots: + QObject *create() { return (new ObjectCreator); } + void del() { delete this; } +}; + +void tst_qqmllanguage::accessDeletedObject() +{ + QQmlEngine engine; + + engine.rootContext()->setContextProperty("objectCreator", new ObjectCreator); + QQmlComponent component(&engine, testFileUrl("accessDeletedObject.qml")); + VERIFY_ERRORS(0); + + QScopedPointer o(component.create()); + QVERIFY(!o.isNull()); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3 From 6b1682870c20a0fc86e0bb2ea8d63c3d1df1be86 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 17 Jan 2018 10:33:34 +0100 Subject: Blacklist test_move() in tst_qquickcustomaffector on win/gcc The test is unstable. Also, print the actual numbers if the fuzzyCompare QVERIFYs fail again. This way we can see better what is going on. Task-number: QTBUG-65819 Change-Id: I65368300498382f7bfebb25299280aa15e3a56ef Reviewed-by: Jani Heikkinen --- tests/auto/particles/qquickcustomaffector/BLACKLIST | 2 ++ .../qquickcustomaffector/tst_qquickcustomaffector.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 tests/auto/particles/qquickcustomaffector/BLACKLIST (limited to 'tests') diff --git a/tests/auto/particles/qquickcustomaffector/BLACKLIST b/tests/auto/particles/qquickcustomaffector/BLACKLIST new file mode 100644 index 0000000000..0757641bcc --- /dev/null +++ b/tests/auto/particles/qquickcustomaffector/BLACKLIST @@ -0,0 +1,2 @@ +[test_move] +windows gcc developer-build diff --git a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp index ee05fb29c9..cad3813e92 100644 --- a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp +++ b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp @@ -98,16 +98,17 @@ void tst_qquickcustomaffector::test_move() if (!d->stillAlive(system)) continue; //parameters no longer get set once you die - QVERIFY(myFuzzyCompare(d->curX(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curY(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curVX(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curVY(system), 50.0)); - QVERIFY(myFuzzyCompare(d->curAX(), 50.0)); - QVERIFY(myFuzzyCompare(d->curAY(), 50.0)); + QVERIFY2(myFuzzyCompare(d->curX(system), 50.0), QByteArray::number(d->curX(system))); + QVERIFY2(myFuzzyCompare(d->curY(system), 50.0), QByteArray::number(d->curY(system))); + QVERIFY2(myFuzzyCompare(d->curVX(system), 50.0), QByteArray::number(d->curVX(system))); + QVERIFY2(myFuzzyCompare(d->curVY(system), 50.0), QByteArray::number(d->curVY(system))); + QVERIFY2(myFuzzyCompare(d->curAX(), 50.0), QByteArray::number(d->curAX())); + QVERIFY2(myFuzzyCompare(d->curAY(), 50.0), QByteArray::number(d->curAY())); QCOMPARE(d->lifeSpan, 0.5f); QCOMPARE(d->size, 32.f); QCOMPARE(d->endSize, 32.f); - QVERIFY(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0))); + QVERIFY2(myFuzzyLEQ(d->t, ((qreal)system->timeInt/1000.0)), + QString::fromLatin1("%1 <= %2 / 1000").arg(d->t).arg(system->timeInt).toUtf8()); } delete view; } -- cgit v1.2.3 From 317908e72a6ea0b4ca179690539cb352bbf60832 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 16 Jan 2018 14:29:40 +0100 Subject: Use localPos for windowPos when passing mouse events to QQuickWidget QQuickWidget thinks of itself as a toplevel window, so it cannot process the offsets in a parent window. Amends 41293196b4db1aa7a0c616af312875c484639644. Task-number: QTBUG-65800 Change-Id: I8c5dcb8f44a6cbdb58bcc956d8263e68d8180bec Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- .../auto/quickwidgets/qquickwidget/data/mouse.qml | 18 ++++++++++++++ .../quickwidgets/qquickwidget/tst_qquickwidget.cpp | 29 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/auto/quickwidgets/qquickwidget/data/mouse.qml (limited to 'tests') diff --git a/tests/auto/quickwidgets/qquickwidget/data/mouse.qml b/tests/auto/quickwidgets/qquickwidget/data/mouse.qml new file mode 100644 index 0000000000..5d1c6e8443 --- /dev/null +++ b/tests/auto/quickwidgets/qquickwidget/data/mouse.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 50 + height: 50 + + property bool wasClicked: false + property bool wasDoubleClicked: false + property bool wasMoved: false + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: wasClicked = true + onDoubleClicked: wasDoubleClicked = true + onMouseXChanged: wasMoved = true + } +} diff --git a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp index e4991a5f26..6c8d8191a5 100644 --- a/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp +++ b/tests/auto/quickwidgets/qquickwidget/tst_qquickwidget.cpp @@ -62,6 +62,7 @@ private slots: void keyEvents(); void shortcuts(); void enterLeave(); + void mouseEventWindowPos(); }; @@ -433,6 +434,34 @@ void tst_qquickwidget::enterLeave() QTRY_VERIFY(!rootItem->property("hasMouse").toBool()); } +void tst_qquickwidget::mouseEventWindowPos() +{ + QWidget widget; + widget.resize(100, 100); + QQuickWidget *quick = new QQuickWidget(&widget); + quick->setSource(testFileUrl("mouse.qml")); + quick->move(50, 50); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget, 5000)); + QQuickItem *rootItem = quick->rootObject(); + QVERIFY(rootItem); + + QVERIFY(!rootItem->property("wasClicked").toBool()); + QVERIFY(!rootItem->property("wasDoubleClicked").toBool()); + QVERIFY(!rootItem->property("wasMoved").toBool()); + + QWindow *window = widget.windowHandle(); + QVERIFY(window); + + QTest::mouseMove(window, QPoint(60, 60)); + QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(60, 60)); + QTRY_VERIFY(rootItem->property("wasClicked").toBool()); + QTest::mouseDClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(60, 60)); + QTRY_VERIFY(rootItem->property("wasDoubleClicked").toBool()); + QTest::mouseMove(window, QPoint(70, 70)); + QTRY_VERIFY(rootItem->property("wasMoved").toBool()); +} + QTEST_MAIN(tst_qquickwidget) #include "tst_qquickwidget.moc" -- cgit v1.2.3 From 00a601436ad85491650b889eccfddc031fd20030 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 17 Jan 2018 14:34:54 +0100 Subject: Blacklist tst_TouchMouse::buttonOnDelayedPressFlickable() on mingw It is flaky and needs to be fixed. Task-number: QTBUG-65823 Change-Id: I471754631493eed20400a2a57b7e55c5007e55f7 Reviewed-by: Shawn Rutledge Reviewed-by: Frederik Gladhorn --- tests/auto/quick/touchmouse/BLACKLIST | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/auto/quick/touchmouse/BLACKLIST (limited to 'tests') diff --git a/tests/auto/quick/touchmouse/BLACKLIST b/tests/auto/quick/touchmouse/BLACKLIST new file mode 100644 index 0000000000..b2ba52eca9 --- /dev/null +++ b/tests/auto/quick/touchmouse/BLACKLIST @@ -0,0 +1,2 @@ +[buttonOnDelayedPressFlickable] +windows gcc developer-build -- cgit v1.2.3