From 9655f7fdc96d26de369578bb6620f525c6f919d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 15 Aug 2019 11:22:40 +0200 Subject: Fix flakiness in QQuickTextEdit::mouseSelection Avoid that the last click from the previous test data and the first click in the current test data happens so close in time that they are interpreted as a double click. Task-number: QTBUG-77389 Change-Id: Ia2d159452dcdb58cacccf7101cc3360175b39594 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index 33a6b829bc..a9016be84a 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2106,13 +2106,17 @@ void tst_qquicktextedit::mouseSelection() textEditObject->setFocus(focus); textEditObject->setFocusOnPress(focusOnPress); + // Avoid that the last click from the previous test data and the first click in the + // current test data happens so close in time that they are interpreted as a double click. + static const int moreThanDoubleClickInterval = QGuiApplication::styleHints()->mouseDoubleClickInterval() + 1; + // press-and-drag-and-release from x1 to x2 QPoint p1 = textEditObject->positionToRectangle(from).center().toPoint(); QPoint p2 = textEditObject->positionToRectangle(to).center().toPoint(); if (clicks == 2) - QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1); + QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); else if (clicks == 3) - QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1); + QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1); if (clicks == 2) { // QTBUG-50022: Since qtbase commit beef975, QTestLib avoids generating -- cgit v1.2.3 From 4b944cb61fb3ceee2f1b743823e4a83b686bafd6 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 26 Aug 2019 11:48:48 +0200 Subject: Fix loading of ES modules when using CONFIG += qtquickcompiler Added the missing lookup for cached .mjs files in ExecutionEngine::compileModule. This allows using .mjs files in WorkerScript {} elements in conjunction with the Qt Quick Compiler and also fixes the use when using QJSEngine::importModule. [ChangeLog][QtQml] Fix loading of EcmaScript modules when using the Qt Quick Compiler. Fixes: QTBUG-77761 Change-Id: I58130b0468f4920b2f6c49b98a2f51d5ae3a0491 Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmlcachegen/data/module.mjs | 6 ++++++ tests/auto/qml/qmlcachegen/data/utils.mjs | 4 ++++ tests/auto/qml/qmlcachegen/qmlcachegen.pro | 4 +++- tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp | 10 ++++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qmlcachegen/data/module.mjs create mode 100644 tests/auto/qml/qmlcachegen/data/utils.mjs (limited to 'tests/auto') diff --git a/tests/auto/qml/qmlcachegen/data/module.mjs b/tests/auto/qml/qmlcachegen/data/module.mjs new file mode 100644 index 0000000000..6838766329 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/module.mjs @@ -0,0 +1,6 @@ + +import { helper } from "utils.mjs" + +export function entry() { + return helper() +} diff --git a/tests/auto/qml/qmlcachegen/data/utils.mjs b/tests/auto/qml/qmlcachegen/data/utils.mjs new file mode 100644 index 0000000000..25a1f38709 --- /dev/null +++ b/tests/auto/qml/qmlcachegen/data/utils.mjs @@ -0,0 +1,4 @@ + +export function helper() { + return "ok" +} diff --git a/tests/auto/qml/qmlcachegen/qmlcachegen.pro b/tests/auto/qml/qmlcachegen/qmlcachegen.pro index 7f8e93d101..ec1ec10ec1 100644 --- a/tests/auto/qml/qmlcachegen/qmlcachegen.pro +++ b/tests/auto/qml/qmlcachegen/qmlcachegen.pro @@ -15,7 +15,9 @@ RESOURCES += \ data/Enums.qml \ data/componentInItem.qml \ data/jsmoduleimport.qml \ - data/script.mjs + data/script.mjs \ + data/module.mjs \ + data/utils.mjs workerscripts_test.files = \ data/worker.js \ diff --git a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp index e290f21986..27314d815b 100644 --- a/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp +++ b/tests/auto/qml/qmlcachegen/tst_qmlcachegen.cpp @@ -63,6 +63,7 @@ private slots: void qrcScriptImport(); void fsScriptImport(); void moduleScriptImport(); + void esModulesViaQJSEngine(); void enums(); @@ -596,6 +597,15 @@ void tst_qmlcachegen::moduleScriptImport() } } +void tst_qmlcachegen::esModulesViaQJSEngine() +{ + QCOMPARE(QFileInfo(":/data/module.mjs").size(), 0); + QJSEngine engine; + QJSValue module = engine.importModule(":/data/module.mjs"); + QJSValue result = module.property("entry").call(); + QCOMPARE(result.toString(), "ok"); +} + void tst_qmlcachegen::enums() { QQmlEngine engine; -- cgit v1.2.3 From 7b47350736f46c59d81238d3d6284358a652983b Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Tue, 20 Aug 2019 13:16:26 +0300 Subject: Add changes file for Qt 5.12.5 Change-Id: I147d3faefac8114e08a0594a0c43b3cdae959804 Reviewed-by: Ulf Hermann Reviewed-by: Shawn Rutledge --- tests/auto/qml/ecmascripttests/test262 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 index 6b0c42c63c..3c69133cc4 160000 --- a/tests/auto/qml/ecmascripttests/test262 +++ b/tests/auto/qml/ecmascripttests/test262 @@ -1 +1 @@ -Subproject commit 6b0c42c63c2492bd0a7a96d3179d122b5f71793f +Subproject commit 3c69133cc419840c1be34638039cd8c48a7ef581 -- cgit v1.2.3 From cfa2c53bc085c775f8ea8dd907e7cd0538542816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 22 Aug 2019 16:47:58 +0200 Subject: Make mouseSelection test more stable QTestLib assumes that the double click interval is below 500ms. Therefore it adds a 500ms delay after all synthesized single- and doubleclick releases to prevent unintentional synthesizing of double click events. This has two unfortunate side-effects: 1. If the double click interval is smaller than 500 ms, it is not possible to synthesize a triple click. (Triple clicks are used for selecting paragraphs in text). This is why the workaround in the block (if clicks ==2) was needed. 2. If the double click interval is bigger than 500ms we might still accidentally trigger a double click event with two successive single click events, so it doesn't even work reliably for that case (!). Therefore, the hardcoded 500ms in QTestLib should probably be revisited. Anyway, to fix this test we therefore have to cancel the 500ms delta QTestLib adds in order to properly synthesize the triple click by adjusting the internal QTest::lastMouseTimestamp. Task-number: QTBUG-77389 Change-Id: Ic738f51b294270ddf99b6d91d256f6ec4b34d039 Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index a9016be84a..facd63027e 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -2117,23 +2117,20 @@ void tst_qquicktextedit::mouseSelection() QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); else if (clicks == 3) QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1, moreThanDoubleClickInterval); + // cancel the 500ms delta QTestLib adds in order to properly synthesize a triple click within the required interval + QTest::lastMouseTimestamp -= QTest::mouseDoubleClickInterval; QTest::mousePress(&window, Qt::LeftButton, Qt::NoModifier, p1); - if (clicks == 2) { - // QTBUG-50022: Since qtbase commit beef975, QTestLib avoids generating - // double click events by adding 500ms delta to release event timestamps. - // Send a double click event by hand to ensure the correct sequence: - // press, release, press, _dbl click_, move, release. - QMouseEvent dblClickEvent(QEvent::MouseButtonDblClick, p1, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); - QGuiApplication::sendEvent(textEditObject, &dblClickEvent); - } QTest::mouseMove(&window, p2); QTest::mouseRelease(&window, Qt::LeftButton, Qt::NoModifier, p2); QTRY_COMPARE(textEditObject->selectedText(), selectedText); // Clicking and shift to clicking between the same points should select the same text. textEditObject->setCursorPosition(0); - if (clicks > 1) + if (clicks > 1) { QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, p1); + // cancel the 500ms delta QTestLib adds in order to properly synthesize a triple click within the required interval + QTest::lastMouseTimestamp -= QTest::mouseDoubleClickInterval; + } if (clicks != 2) QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, p1); QTest::mouseClick(&window, Qt::LeftButton, Qt::ShiftModifier, p2); -- cgit v1.2.3 From da04b1d716617fbe4a2d93dc5a51f38dbd03a5b8 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 23 Aug 2019 13:11:31 +0200 Subject: QQuickTableView: always relayout after a rebuild The current logic was based on the idea that if both rowHeight-, and columnWidthProveders were set, we didn't have to relayout the items at the end of a rebuild. Because in that case, the row and column sizes would already be correct after the initial load. This assumption turns out to be false, because the providers are allowed to return -1 to signal that the size of a row or column should use default values (meaning, calculated by TableView). And for those cases, we need to do a relayout at the end of a rebuild. Fixes: QTBUG-77074 Change-Id: I0e0f2fdca1cfa9e98f2a0a2b227c3715c16a70f9 Reviewed-by: Mitch Curtis --- .../qquicktableview/data/tweakimplicitsize.qml | 89 ++++++++++++++++++++++ .../quick/qquicktableview/tst_qquicktableview.cpp | 27 +++++++ 2 files changed, 116 insertions(+) create mode 100644 tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml b/tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml new file mode 100644 index 0000000000..ecc79a9368 --- /dev/null +++ b/tests/auto/quick/qquicktableview/data/tweakimplicitsize.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2018 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:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** 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-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Window 2.3 + +Item { + width: 640 + height: 450 + + property alias tableView: tableView + property real delegateSize: 10 + property int hideRow: -1 + + TableView { + id: tableView + width: 600 + height: 400 + anchors.margins: 1 + clip: true + delegate: tableViewDelegate + columnSpacing: 1 + rowSpacing: 1 + columnWidthProvider: function(column) { + return -1 + } + rowHeightProvider: function(row) { + if (row === hideRow) + return 0 + return -1 + } + } + + Component { + id: tableViewDelegate + Rectangle { + objectName: "tableViewDelegate" + implicitWidth: row === 0 ? 10 : delegateSize + implicitHeight: column === 0 ? 10 : delegateSize + color: "lightgray" + border.width: 1 + + Text { + id: textItem + anchors.centerIn: parent + text: model.display + renderType: Text.NativeRendering + } + } + } + +} + diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index 60d48bb59f..acb475b1c5 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -119,6 +119,7 @@ private slots: void checkRowHeightProviderNegativeReturnValue(); void checkRowHeightProviderNotCallable(); void checkForceLayoutFunction(); + void checkForceLayoutEndUpDoingALayout(); void checkContentWidthAndHeight(); void checkPageFlicking(); void checkExplicitContentWidthAndHeight(); @@ -550,6 +551,32 @@ void tst_QQuickTableView::checkForceLayoutFunction() QCOMPARE(fxItem->item->width(), newColumnWidth); } +void tst_QQuickTableView::checkForceLayoutEndUpDoingALayout() +{ + // QTBUG-77074 + // Check that we change the implicit size of the delegate after + // the initial loading, and at the same time hide some rows or + // columns, and then do a forceLayout(), we end up with a + // complete relayout that respects the new implicit size. + LOAD_TABLEVIEW("tweakimplicitsize.qml"); + + auto model = TestModelAsVariant(10, 10); + + tableView->setModel(model); + + WAIT_UNTIL_POLISHED; + + const qreal newDelegateSize = 20; + view->rootObject()->setProperty("delegateSize", newDelegateSize); + // Hide a row, just to force the following relayout to + // do a complete reload (and not just a relayout) + view->rootObject()->setProperty("hideRow", 1); + tableView->forceLayout(); + + for (auto fxItem : tableViewPrivate->loadedItems) + QCOMPARE(fxItem->item->height(), newDelegateSize); +} + void tst_QQuickTableView::checkContentWidthAndHeight() { // Check that contentWidth/Height reports the correct size of the the -- cgit v1.2.3 From 35acc9fc3c41446bacbbfe754f7f494de7f62411 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Fri, 23 Aug 2019 22:28:56 +0800 Subject: QQuickTextNodeEngine: don't create background when its alpha is 0 If the alpha value for the background color of a text element is 0, we don't need to create a rectangle node to represent it, as the rectangle will be invisible anyway. [ChangeLog][QtQuick][QQuickTextNodeEngine] don't create a new rectangle node as the background of text, when the alpha of it is 0 Fixes: QTBUG-76137 Change-Id: I40c624ee8f61740fd07e7d3751a78b6224882913 Reviewed-by: Shawn Rutledge Reviewed-by: Eskil Abrahamsen Blomfeldt --- .../qquicktext/data/transparentBackground.qml | 16 ++++++++++++++++ tests/auto/quick/qquicktext/tst_qquicktext.cpp | 22 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/auto/quick/qquicktext/data/transparentBackground.qml (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicktext/data/transparentBackground.qml b/tests/auto/quick/qquicktext/data/transparentBackground.qml new file mode 100644 index 0000000000..a10a1779bb --- /dev/null +++ b/tests/auto/quick/qquicktext/data/transparentBackground.qml @@ -0,0 +1,16 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "white" + Text { + objectName: "text" + textFormat: Text.RichText + anchors.fill: parent + color: "black" + text: "

foo

" + verticalAlignment: Text.AlignTop + horizontalAlignment: Text.AlignLeft + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index eafa6cb052..3414bec4a6 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -163,6 +163,8 @@ private slots: void verticallyAlignedImageInTable(); + void transparentBackground(); + private: QStringList standard; QStringList richText; @@ -4428,6 +4430,26 @@ void tst_qquicktext::verticallyAlignedImageInTable() // Don't crash } +void tst_qquicktext::transparentBackground() +{ + if ((QGuiApplication::platformName() == QLatin1String("offscreen")) + || (QGuiApplication::platformName() == QLatin1String("minimal"))) + QSKIP("Skipping due to grabToImage not functional on offscreen/minimimal platforms"); + + QScopedPointer window(new QQuickView); + window->setSource(testFileUrl("transparentBackground.qml")); + QTRY_COMPARE(window->status(), QQuickView::Ready); + + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QImage img = window->grabWindow(); + QCOMPARE(img.isNull(), false); + + QColor color = img.pixelColor(0, 0); + QCOMPARE(color.red(), 255); + QCOMPARE(color.blue(), 255); + QCOMPARE(color.green(), 255); +} QTEST_MAIN(tst_qquicktext) #include "tst_qquicktext.moc" -- cgit v1.2.3 From 2b566231a6e35ee1646754cee09b30fc99240a80 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Sun, 8 Sep 2019 01:40:19 +0800 Subject: QQuickFolderListModel: make sure properties' values can be update There are some properties in FolderListModel neglect to update their values, although the new values are passed to the thread which does the real work [ChangeLog][QtQuick][QQuickFolderListModel] update the values of some properties when setting new values to them Fixes: QTBUG-77965 Change-Id: I77db3388cee569479459deaa2e19546a77da6178 Reviewed-by: Ulf Hermann --- .../tst_qquickfolderlistmodel.cpp | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index b7600351b7..ae99e35467 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -75,6 +75,7 @@ private slots: void introspectQrc(); void sortCaseSensitive_data(); void sortCaseSensitive(); + void updateProperties(); private: void checkNoErrors(const QQmlComponent& component); QQmlEngine engine; @@ -425,6 +426,47 @@ void tst_qquickfolderlistmodel::sortCaseSensitive() QTRY_COMPARE(flm->data(flm->index(i),FileNameRole).toString(), expectedOrder.at(i)); } +void tst_qquickfolderlistmodel::updateProperties() +{ + QQmlComponent component(&engine, testFileUrl("basic.qml")); + checkNoErrors(component); + + QObject *folderListModel = component.create(); + QVERIFY(folderListModel); + + QVariant caseSensitive = folderListModel->property("caseSensitive"); + QVERIFY(caseSensitive.isValid()); + QCOMPARE(caseSensitive.toBool(), true); + folderListModel->setProperty("caseSensitive", false); + caseSensitive = folderListModel->property("caseSensitive"); + QVERIFY(caseSensitive.isValid()); + QCOMPARE(caseSensitive.toBool(), false); + + QVariant showOnlyReadable = folderListModel->property("showOnlyReadable"); + QVERIFY(showOnlyReadable.isValid()); + QCOMPARE(showOnlyReadable.toBool(), false); + folderListModel->setProperty("showOnlyReadable", true); + showOnlyReadable = folderListModel->property("showOnlyReadable"); + QVERIFY(showOnlyReadable.isValid()); + QCOMPARE(showOnlyReadable.toBool(), true); + + QVariant showDotAndDotDot = folderListModel->property("showDotAndDotDot"); + QVERIFY(showDotAndDotDot.isValid()); + QCOMPARE(showDotAndDotDot.toBool(), false); + folderListModel->setProperty("showDotAndDotDot", true); + showDotAndDotDot = folderListModel->property("showDotAndDotDot"); + QVERIFY(showDotAndDotDot.isValid()); + QCOMPARE(showDotAndDotDot.toBool(), true); + + QVariant showHidden = folderListModel->property("showHidden"); + QVERIFY(showHidden.isValid()); + QCOMPARE(showHidden.toBool(), false); + folderListModel->setProperty("showHidden", true); + showHidden = folderListModel->property("showHidden"); + QVERIFY(showHidden.isValid()); + QCOMPARE(showHidden.toBool(), true); +} + QTEST_MAIN(tst_qquickfolderlistmodel) #include "tst_qquickfolderlistmodel.moc" -- cgit v1.2.3 From 5ca1d2e0b2912e578a32c5e11b4fd1d7a0ef28f3 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 11 Sep 2019 16:38:29 +0200 Subject: QQmlTypeLoader: Prevent trivial cycles The type loader already contained a cycle check, however it did not work for the attached example. We now do an additional test for A->B->A cycles, which fixes the bug. This is a valid strategy, as in that case the currently resolved type would immediately fullfill the depentency of the type waiting on it, which in turn resolves the only dependency of the current type. Fixes: QTBUG-78098 Change-Id: I8b550a1c240d3d0fbf158beb99a5daf992904cb0 Reviewed-by: Simon Hausmann --- .../qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml | 5 +++++ .../data/Com/Orga/Handlers/Handler.qml | 7 +++++++ .../qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir | 2 ++ .../auto/qml/qqmltypeloader/data/Com/Orga/Style.qml | 6 ++++++ tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir | 2 ++ tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 20 +++++++++++++++++++- 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml b/tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml new file mode 100644 index 0000000000..28521e3af2 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/BaseStyle.qml @@ -0,0 +1,5 @@ +import QtQuick 2.6 + +Item { + +} diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml new file mode 100644 index 0000000000..b20a2def11 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/Handler.qml @@ -0,0 +1,7 @@ +import QtQuick 2.6 +import Com.Orga 1.0 + +Rectangle { + color: Style.name + Text {text: "Hello world!"} +} diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir new file mode 100644 index 0000000000..368cb65b35 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Handlers/qmldir @@ -0,0 +1,2 @@ +module Com.Orga.Handlers +Handler 1.0 Handler.qml diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml new file mode 100644 index 0000000000..7951f5e768 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/Style.qml @@ -0,0 +1,6 @@ +pragma Singleton +import QtQuick 2.6 + +BaseStyle { + property color name: "black" +} diff --git a/tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir b/tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir new file mode 100644 index 0000000000..9c5560b323 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/Com/Orga/qmldir @@ -0,0 +1,2 @@ +singleton Style 1.0 Style.qml +BaseStyle 1.0 BaseStyle.qml diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index 2993b4b3c8..9ad53aaa8b 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -60,6 +60,7 @@ private slots: void implicitComponentModule(); void qrcRootPathUrl(); void implicitImport(); + void compositeSingletonCycle(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -434,7 +435,7 @@ void tst_QQMLTypeLoader::redirect() component.loadUrl(server.urlString("/Load.qml"), QQmlComponent::Asynchronous); QTRY_VERIFY2(component.isReady(), qPrintable(component.errorString())); - QObject *object = component.create(); + QScopedPointer object {component.create()}; QTRY_COMPARE(object->property("xy").toInt(), 323232); } @@ -524,6 +525,23 @@ void tst_QQMLTypeLoader::implicitImport() QVERIFY(!obj.isNull()); } +void tst_QQMLTypeLoader::compositeSingletonCycle() +{ + TestHTTPServer server; + QVERIFY2(server.listen(), qPrintable(server.errorString())); + QVERIFY(server.serveDirectory(dataDirectory())); + + QQmlEngine engine; + QQmlComponent component(&engine); + engine.addImportPath(server.baseUrl().toString()); + component.loadUrl(server.urlString("Com/Orga/Handlers/Handler.qml"), QQmlComponent::Asynchronous); + QTRY_VERIFY2(component.isReady(), qPrintable(component.errorString())); + + QScopedPointer object {component.create()}; + QVERIFY(object); + QCOMPARE(qvariant_cast(object->property("color")), QColorConstants::Black); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" -- cgit v1.2.3 From e38ab72a7c2ce12b44e7772dee79cf1e00386b38 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 12 Sep 2019 09:31:16 +0200 Subject: tst_qqmlecmascript: Cast pointer to unsigned for printing Otherwise QString::number() will apparently extend "negative" values to 64bits even if the actual type is only 32bits long. Change-Id: Ibdecff2fe707616d2254b7e34e08247f0ff52489 Reviewed-by: Fabian Kosmale Reviewed-by: Assam Boudjelthia Reviewed-by: Liang Qi --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index d06243897c..df4963cb6e 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -2047,7 +2047,7 @@ void tst_qqmlecmascript::functionErrors() QObject *resource = qobject_cast(QQmlProperty::read(object, "a").value()); warning = url + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); - warning = warning.arg(QString::number((qintptr)resource, 16)); + warning = warning.arg(QString::number(quintptr(resource), 16)); QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); delete object; @@ -4553,7 +4553,7 @@ void tst_qqmlecmascript::scarceResources_other() eo = qobject_cast(QQmlProperty::read(object, "a").value()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. expectedWarning = varComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); - expectedWarning = expectedWarning.arg(QString::number((qintptr)eo, 16)); + expectedWarning = expectedWarning.arg(QString::number(quintptr(eo), 16)); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. @@ -4627,7 +4627,7 @@ void tst_qqmlecmascript::scarceResources_other() eo = qobject_cast(QQmlProperty::read(object, "a").value()); QVERIFY(eo->scarceResourceIsDetached()); // should be no other copies of it at this stage. expectedWarning = variantComponentTwelve.url().toString() + QLatin1String(":16: TypeError: Property 'scarceResource' of object ScarceResourceObject(0x%1) is not a function"); - expectedWarning = expectedWarning.arg(QString::number((qintptr)eo, 16)); + expectedWarning = expectedWarning.arg(QString::number(quintptr(eo), 16)); QTest::ignoreMessage(QtWarningMsg, qPrintable(expectedWarning)); // we expect a meaningful warning to be printed. QMetaObject::invokeMethod(object, "retrieveScarceResource"); QVERIFY(!object->property("scarceResourceCopy").isValid()); // due to exception, assignment will NOT have occurred. -- cgit v1.2.3 From a852ec4fd0c2ea6560270da8ead43a85f1573412 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 10 Sep 2019 12:58:01 +0200 Subject: Blacklist tst_qquicktextinput::mouseSelectionMode on OpenSuse 15.0 Task-number: QTBUG-78162 Change-Id: I8b4f536583afba889a9225d257900031c21ba9e0 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquicktextinput/BLACKLIST | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/auto/quick/qquicktextinput/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicktextinput/BLACKLIST b/tests/auto/quick/qquicktextinput/BLACKLIST new file mode 100644 index 0000000000..ada7c57c75 --- /dev/null +++ b/tests/auto/quick/qquicktextinput/BLACKLIST @@ -0,0 +1,3 @@ +# QTBUG-78162 +[mouseSelectionMode] +opensuse-leap -- cgit v1.2.3 From c950ce0daf4b9fbfbcf6c00aa8ef4875297046f9 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 10 Sep 2019 09:26:33 +0200 Subject: Blacklist tst_qquickmousearea::nestedStopAtBounds on opensuse 15.0 Task-number: QTBUG-78153 Change-Id: Ifdca53d4eed452067ba7f75ae0b3e74cf2027895 Reviewed-by: Fabian Kosmale Reviewed-by: Shawn Rutledge --- tests/auto/quick/qquickmousearea/BLACKLIST | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/auto/quick/qquickmousearea/BLACKLIST (limited to 'tests/auto') diff --git a/tests/auto/quick/qquickmousearea/BLACKLIST b/tests/auto/quick/qquickmousearea/BLACKLIST new file mode 100644 index 0000000000..f2cb00225b --- /dev/null +++ b/tests/auto/quick/qquickmousearea/BLACKLIST @@ -0,0 +1,4 @@ +# QTBUG-78153 +[nestedStopAtBounds] +opensuse-leap + -- cgit v1.2.3 From b1b284e3cea67ef4ef128af50dd6c3aa35c46809 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 11 Sep 2019 14:20:19 +0200 Subject: tst_gridlayout.qml: convert to a proper data-driven test Change-Id: I9f2ccd3d4e6933d68b03d82c2c319aa2e8951e78 Reviewed-by: Liang Qi --- .../quick/qquicklayouts/data/tst_gridlayout.qml | 39 ++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml index 6a1c0632ad..abd386aeb7 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml @@ -60,8 +60,8 @@ Item { id: testCase name: "Tests_GridLayout" when: windowShown - width: 200 - height: 200 + width: parent.width + height: parent.height Component { id: layout_flow_Component @@ -851,24 +851,37 @@ Item { } } - function test_spacings() + function test_spacings_data() + { + let data = [ + { spacing: Number.NaN }, + { spacing: 0 }, + { spacing: 10 }, + { spacing: -5 }, + { spacing: -19 } + ] + for (let i = 0; i < data.length; ++i) { + data[i].tag = data[i].spacing.toString() + } + return data + } + + function test_spacings(data) { var layout = layout_spacings_Component.createObject(container); // breaks down below -19. This is acceptable, since it means that the implicit size of the layout is negative var testSpacings = [Number.NaN, 0, 10, -5, -19] layout.rowSpacing = 0 - for (var i = 0; i < testSpacings.length; ++i) { - var sp = testSpacings[i] - if (isNaN(sp)) { - sp = 5 // Test defaults - } else { - layout.columnSpacing = sp - } - tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) - tryCompare(layout.children[1], "itemRect", [10 + sp, 0, 10, 10]) - compare(layout.implicitWidth, 20 + sp) + var spacing = data.spacing + if (isNaN(spacing)) { + spacing = 5 // Test defaults + } else { + layout.columnSpacing = spacing } + tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) + tryCompare(layout.children[1], "itemRect", [10 + spacing, 0, 10, 10]) + compare(layout.implicitWidth, 20 + spacing) // do not crash layout.columnSpacing = -100 -- cgit v1.2.3 From 69f62dc8efc738dff1fac50f8a6d8b2b09e654cf Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 11 Sep 2019 14:25:05 +0200 Subject: tst_gridlayout.qml: use createTemporaryObject() Ensures that items created in a function are destroyed upon failures in that function, and results in less code. Change-Id: I62b3b7c3a19dbb2128c5c45bdc7adf4fe80df70d Reviewed-by: Liang Qi --- .../quick/qquicklayouts/data/tst_gridlayout.qml | 56 ++++++---------------- 1 file changed, 15 insertions(+), 41 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml index abd386aeb7..49838c4fd5 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml @@ -84,7 +84,7 @@ Item { function test_flow() { - var layout = layout_flow_Component.createObject(container); + var layout = createTemporaryObject(layout_flow_Component, container); tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) tryCompare(layout.children[1], "itemRect", [10, 0, 10, 10]) tryCompare(layout.children[2], "itemRect", [20, 0, 10, 10]) @@ -102,8 +102,6 @@ Item { tryCompare(layout.children[4], "itemRect", [10, 0, 10, 10]) tryCompare(layout.children[5], "itemRect", [10, 10, 10, 10]) - - layout.destroy() } Component { @@ -178,7 +176,7 @@ Item { } function test_flowLeftToRight() { - var layout = layout_flowLeftToRight_Component.createObject(container); + var layout = createTemporaryObject(layout_flowLeftToRight_Component, container); compare(layout.implicitWidth, 80); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); @@ -208,8 +206,6 @@ Item { compare(layout.children[11].y, 60); compare(layout.children[12].x, 40); compare(layout.children[12].y, 80); - - layout.destroy(); } @@ -259,7 +255,7 @@ Item { function test_flowLeftToRightDefaultPositions() { ignoreWarning("QGridLayoutEngine::addItem: Cell (1, 0) already taken"); - var layout = layout_flowLeftToRightDefaultPositions_Component.createObject(container); + var layout = createTemporaryObject(layout_flowLeftToRightDefaultPositions_Component, container); compare(layout.implicitWidth, 40); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); @@ -267,7 +263,6 @@ Item { compare(layout.children[1].y, 20); compare(layout.children[2].x, 20); compare(layout.children[2].y, 20); - layout.destroy(); } @@ -342,7 +337,7 @@ Item { } function test_flowTopToBottom() { - var layout = layout_flowTopToBottom_Component.createObject(container); + var layout = createTemporaryObject(layout_flowTopToBottom_Component, container); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); compare(layout.children[1].x, 20); @@ -371,8 +366,6 @@ Item { compare(layout.children[11].y, 60); compare(layout.children[12].x, 80); compare(layout.children[12].y, 0); - - layout.destroy(); } Component { @@ -432,7 +425,7 @@ Item { } function test_spanAcrossEmptyRows() { - var layout = layout_spanAcrossEmptyRows_Component.createObject(container); + var layout = createTemporaryObject(layout_spanAcrossEmptyRows_Component, container); compare(layout.children[0].x, 0); compare(layout.children[0].y, 0); compare(layout.children[1].x, 20); @@ -442,8 +435,6 @@ Item { compare(layout.implicitWidth, 60); compare(layout.Layout.maximumWidth, 120); - - layout.destroy(); } Component { @@ -463,14 +454,13 @@ Item { } function test_spanIsMoreThanColumns() { - var layout = layout_spanIsMoreThanColumns_Component.createObject(container); + var layout = createTemporaryObject(layout_spanIsMoreThanColumns_Component, container); // item was not added, therefore implicit width is 0 compare(layout.implicitWidth, 0); - layout.destroy(); } function test_sizeHints() { - var layout = layout_spanAcrossEmptyRows_Component.createObject(container); + var layout = createTemporaryObject(layout_spanAcrossEmptyRows_Component, container); compare(layout.visible, true) var minWidth = layout.Layout.minimumWidth @@ -489,8 +479,6 @@ Item { compare(prefHeight, layout.implicitHeight) compare(maxWidth, layout.Layout.maximumWidth) compare(maxHeight, layout.Layout.maximumHeight) - - layout.destroy(); } Component { @@ -567,7 +555,7 @@ Item { function test_alignment() { - var layout = layout_alignment_Component.createObject(container); + var layout = createTemporaryObject(layout_alignment_Component, container); layout.width = 60; layout.height = 100; @@ -596,8 +584,6 @@ Item { layout.children[4].Layout.alignment = Qt.AlignLeft tryCompare(layout.children[4], "x", 0); tryCompare(layout.children[4], "y", 60); - - layout.destroy(); } @@ -648,7 +634,7 @@ Item { function test_rightToLeft() { - var layout = layout_rightToLeft_Component.createObject(container); + var layout = createTemporaryObject(layout_rightToLeft_Component, container); layout.width = 180; layout.height = 50; @@ -674,8 +660,6 @@ Item { layout.LayoutMirroring.enabled = true verifyIsRightToLeft(layout) - - layout.destroy(); } Component { @@ -698,7 +682,7 @@ Item { function test_columnsChanged() { - var layout = layout_columnsOrRowsChanged_Component.createObject(container); + var layout = createTemporaryObject(layout_columnsOrRowsChanged_Component, container); layout.width = 40; layout.height = 20; tryCompare(layout.children[0], "itemRect", [ 0, 5, 10, 10]) @@ -711,13 +695,11 @@ Item { tryCompare(layout.children[1], "itemRect", [20, 0, 10, 10]) tryCompare(layout.children[2], "itemRect", [ 0, 10, 10, 10]) tryCompare(layout.children[3], "itemRect", [20, 10, 10, 10]) - - layout.destroy() } function test_rowsChanged() { - var layout = layout_columnsOrRowsChanged_Component.createObject(container); + var layout = createTemporaryObject(layout_columnsOrRowsChanged_Component, container); layout.flow = GridLayout.TopToBottom layout.width = 20; layout.height = 40; @@ -731,8 +713,6 @@ Item { tryCompare(layout.children[1], "itemRect", [ 0, 25, 10, 10]) tryCompare(layout.children[2], "itemRect", [10, 5, 10, 10]) tryCompare(layout.children[3], "itemRect", [10, 25, 10, 10]) - - layout.destroy() } Component { @@ -767,7 +747,7 @@ Item { function test_columnOrRowChanged() { - var layout = layout_columnOrRowChanged_Component.createObject(container); + var layout = createTemporaryObject(layout_columnOrRowChanged_Component, container); layout.width = layout.implicitWidth layout.height = layout.implicitHeight // c0-c1-c2 @@ -795,8 +775,6 @@ Item { tryCompare(layout.children[0], "itemRect", [10, 10, 10, 10]) tryCompare(layout.children[1], "itemRect", [ 0, 0, 10, 10]) tryCompare(layout.children[2], "itemRect", [20, 0, 10, 10]) - - layout.destroy() } Component { @@ -819,7 +797,7 @@ Item { } function test_baselines() { - var layout = layout_baselines_Component.createObject(container); + var layout = createTemporaryObject(layout_baselines_Component, container); tryCompare(layout.children[0], "itemRect", [ 0, 0, 10, 10]) tryCompare(layout.children[1], "itemRect", [10, 0, 10, 10]) compare(layout.implicitWidth, 20) @@ -832,8 +810,6 @@ Item { tryCompare(layout.children[1], "itemRect", [10, 10, 10, 10]) compare(layout.implicitWidth, 20) compare(layout.implicitHeight, 20) - - layout.destroy(); } Component { @@ -868,7 +844,7 @@ Item { function test_spacings(data) { - var layout = layout_spacings_Component.createObject(container); + var layout = createTemporaryObject(layout_spacings_Component, container); // breaks down below -19. This is acceptable, since it means that the implicit size of the layout is negative var testSpacings = [Number.NaN, 0, 10, -5, -19] @@ -887,7 +863,6 @@ Item { layout.columnSpacing = -100 waitForRendering(layout) verify(isFinite(layout.implicitWidth)) - layout.destroy(); } Component { @@ -1039,11 +1014,10 @@ Item { function test_invalidateWhileRearranging_QTBUG_44139() { - var layout = layout_invalidateWhileRearranging_Component.createObject(container) + var layout = createTemporaryObject(layout_invalidateWhileRearranging_Component, container) waitForRendering(layout); verify(layout.children[1].visible == false); - layout.destroy() } } } -- cgit v1.2.3 From 122d0367fd96526b3573a3188286153c846680ca Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 12 Sep 2019 17:44:04 +0200 Subject: Use the correct type's meta-type ID for int and save a misplaced cast I got compiler warnings because of a comparison of a QVariant::type() with an int(). These were caused by a "fix" that cast to int a QMetaType::Int, where the correct fix was surely to use QVariant::Int. This amends commit 83f8d886cee0a40ac1ad5e43e597f309f602ad76. Change-Id: I3f1718e4f2c0c5a6a1cbb79266768fba4e3290e3 Reviewed-by: Friedemann Kleint --- tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp index cf0f3c7bb3..07af519a3d 100644 --- a/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp +++ b/tests/auto/qml/qqmlconnections/tst_qqmlconnections.cpp @@ -470,7 +470,7 @@ void tst_qqmlconnections::noAcceleratedGlobalLookup() QVERIFY(c.isReady()); QScopedPointer object(c.create()); const QVariant val = object->property("testEnum"); - QCOMPARE(val.type(), int(QMetaType::Int)); + QCOMPARE(val.type(), QVariant::Int); QCOMPARE(val.toInt(), int(Proxy::EnumValue)); } -- cgit v1.2.3 From 28eb0caec23e0c315056cb035535b8806ccb0f37 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 5 Sep 2019 16:41:11 +0200 Subject: Force creation of metaobjects for top level objects and components We want those to be different types, even if they don't add any properties, signals etc. Otherwise you can cross-assign objects of components defined in different files. Fully-dynamic types, such as QQmlPropertyMap are still an exception to this. We need to use the original meta object so that you can still dynamically add properties to any derived types. Therefore, all types derived from QQmlPropertyMap are in fact just aliases of each other. Also, types which aren't addressable from the outside don't get their own meta object. Types are addressable if they live in files and the file name starts with an uppercase character. Otherwise there is no way to refer to the component from anywhere else in QML. Fixes: QTBUG-76021 Change-Id: I96a01fdad13e50e4705520fec46f2b3373e0c365 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 12 ++++++------ tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 17 +++++++++++++---- tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp | 11 +++++++++-- .../auto/qml/qqmlpropertycache/data/SpecialObject1.qml | 5 +++++ .../auto/qml/qqmlpropertycache/data/SpecialObject2.qml | 5 +++++ tests/auto/qml/qqmlpropertycache/data/noDuckType.qml | 7 +++++++ .../qml/qqmlpropertycache/tst_qqmlpropertycache.cpp | 11 +++++++++++ 7 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml create mode 100644 tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml create mode 100644 tests/auto/qml/qqmlpropertycache/data/noDuckType.qml (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp index 79ec507388..1d2fa42b75 100644 --- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp +++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp @@ -222,12 +222,12 @@ void tst_qqmlcomponent::qmlCreateObjectAutoParent() QVERIFY(window_item); QVERIFY(window_window); - QCOMPARE(qtobject_item->metaObject()->className(), "QQuickItem"); - QCOMPARE(qtobject_window->metaObject()->className(), "QQuickWindow"); - QCOMPARE(item_item->metaObject()->className(), "QQuickItem"); - QCOMPARE(item_window->metaObject()->className(), "QQuickWindow"); - QCOMPARE(window_item->metaObject()->className(), "QQuickItem"); - QCOMPARE(window_window->metaObject()->className(), "QQuickWindow"); + QVERIFY(QByteArray(qtobject_item->metaObject()->className()).startsWith("QQuickItem")); + QVERIFY(QByteArray(qtobject_window->metaObject()->className()).startsWith("QQuickWindow")); + QVERIFY(QByteArray(item_item->metaObject()->className()).startsWith("QQuickItem")); + QVERIFY(QByteArray(item_window->metaObject()->className()).startsWith("QQuickWindow")); + QVERIFY(QByteArray(window_item->metaObject()->className()).startsWith("QQuickItem")); + QVERIFY(QByteArray(window_window->metaObject()->className()).startsWith("QQuickWindow")); QCOMPARE(qtobject_qtobject->parent(), qtobjectParent); QCOMPARE(qtobject_item->parent(), qtobjectParent); diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 8adacd8829..007fb5cef2 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -2500,7 +2500,15 @@ void tst_qqmllanguage::testType(const QString& qml, const QString& type, const Q VERIFY_ERRORS(0); QScopedPointer object(component.create()); QVERIFY(object != nullptr); - QCOMPARE(QString(object->metaObject()->className()), type); + const QMetaObject *meta = object->metaObject(); + for (; meta; meta = meta->superClass()) { + const QString className(meta->className()); + if (!className.contains("_QMLTYPE_") && !className.contains("_QML_")) { + QCOMPARE(className, type); + break; + } + } + QVERIFY(meta != nullptr); } engine.setImportPathList(defaultImportPathList); @@ -4043,10 +4051,12 @@ void tst_qqmllanguage::implicitImportsLast() VERIFY_ERRORS(0); QScopedPointer object(component.create()); QVERIFY(object != nullptr); - QVERIFY(QString(object->metaObject()->className()).startsWith(QLatin1String("QQuickMouseArea"))); + QVERIFY(QString(object->metaObject()->superClass()->superClass()->className()) + .startsWith(QLatin1String("QQuickMouseArea"))); QObject* object2 = object->property("item").value(); QVERIFY(object2 != nullptr); - QCOMPARE(QString(object2->metaObject()->className()), QLatin1String("QQuickRectangle")); + QCOMPARE(QString(object2->metaObject()->superClass()->className()), + QLatin1String("QQuickRectangle")); engine.setImportPathList(defaultImportPathList); } @@ -5030,7 +5040,6 @@ void tst_qqmllanguage::instanceof() if (QTest::currentDataTag() == QLatin1String("customRectangleWithPropInstance instanceof CustomRectangle") || QTest::currentDataTag() == QLatin1String("customRectangleWithPropInstance instanceof CustomImport.CustomRectangle")) - QEXPECT_FAIL("", "QTBUG-58477: QML type rules are a little lax", Continue); QCOMPARE(returnValue, expectedValue.toBool()); } else { QVERIFY(expr.hasError()); diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 67da768f73..bc407e97a2 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -35,6 +35,9 @@ #include #include #include +#if QT_CONFIG(regularexpression) +#include +#endif #include #include "../../shared/util.h" @@ -2015,9 +2018,13 @@ void tst_qqmlproperty::warnOnInvalidBinding() expectedWarning = testUrl.toString() + QString::fromLatin1(":7:5: Unable to assign QQuickText to QQuickRectangle"); QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); +#if QT_CONFIG(regularexpression) // V8 error message for invalid binding to anchor - expectedWarning = testUrl.toString() + QString::fromLatin1(":14:9: Unable to assign QQuickItem_QML_8 to QQuickAnchorLine"); - QTest::ignoreMessage(QtWarningMsg, expectedWarning.toLatin1().constData()); + const QRegularExpression warning( + "^" + testUrl.toString() + + ":14:9: Unable to assign QQuickItem_QML_\\d+ to QQuickAnchorLine$"); + QTest::ignoreMessage(QtWarningMsg, warning); +#endif QQmlComponent component(&engine, testUrl); QObject *obj = component.create(); diff --git a/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml b/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml new file mode 100644 index 0000000000..9559bc0b5f --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/SpecialObject1.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + readonly property bool fakeProperty: false +} diff --git a/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml b/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml new file mode 100644 index 0000000000..ed4ad04fef --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/SpecialObject2.qml @@ -0,0 +1,5 @@ +import QtQml 2.0 + +QtObject { + objectName: "special" +} diff --git a/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml b/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml new file mode 100644 index 0000000000..5e1ea233b9 --- /dev/null +++ b/tests/auto/qml/qqmlpropertycache/data/noDuckType.qml @@ -0,0 +1,7 @@ +import QtQml 2.9 + +QtObject { + property SpecialObject1 obj1: SpecialObject1 {} + property SpecialObject2 obj2: SpecialObject2 {} + property string result: (obj1 instanceof SpecialObject2) ? "bad" : "good" +} diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp index 9a1e4667dd..c9e92cd3c9 100644 --- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp +++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp @@ -54,6 +54,7 @@ private slots: void metaObjectSize_data(); void metaObjectSize(); void metaObjectChecksum(); + void metaObjectsForRootElements(); private: QQmlEngine engine; @@ -543,4 +544,14 @@ void tst_qqmlpropertycache::metaObjectChecksum() } } +void tst_qqmlpropertycache::metaObjectsForRootElements() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("noDuckType.qml")); + QVERIFY(c.isReady()); + QScopedPointer obj(c.create()); + QVERIFY(!obj.isNull()); + QCOMPARE(obj->property("result").toString(), QString::fromLatin1("good")); +} + QTEST_MAIN(tst_qqmlpropertycache) -- cgit v1.2.3 From b7e5b0c25b7c02b40c2072f45a0a0feb8bd2a977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Mon, 16 Sep 2019 14:12:50 +0200 Subject: Fix qmlobject_{dis}connect macros to require semicolon at the end Just do the typical do { [..stuff..] } while(0) in the macros Fix the places that didn't have semicolons. This should eliminate some compiler warnings complaining about excessive semicolons Change-Id: I6b0e7a55badfd0f80c3cd0e9e1da42dc41945485 Reviewed-by: Shawn Rutledge --- tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp index 99cabb4b09..13e4d4c53b 100644 --- a/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp +++ b/tests/auto/qml/qqmlcpputils/tst_qqmlcpputils.cpp @@ -71,7 +71,7 @@ void tst_qqmlcpputils::fastConnect() { MyObject obj; - qmlobject_connect(&obj, MyObject, SIGNAL(signal1()), &obj, MyObject, SLOT(slot1())) + qmlobject_connect(&obj, MyObject, SIGNAL(signal1()), &obj, MyObject, SLOT(slot1())); obj.signal1(); QCOMPARE(obj.slotCount, 1); -- cgit v1.2.3 From 36be27265d61c76b25417a25e482030e30ff380f Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Fri, 20 Sep 2019 16:38:30 +0200 Subject: QMLJS: Fix exception handling in promises If an exception is thrown inside a promise's resolve or reject handler, the promise needs to resolve into a rejected state with the exceptions value. The value was previously not set. Fixes: QTBUG-78554 Change-Id: Ic22faa6ef1e519e4cae6732c69bb14f7053d13da Reviewed-by: Ulf Hermann Reviewed-by: Qt CI Bot --- .../auto/qml/qqmlpromise/data/promisehandlerthrows.qml | 17 +++++++++++++++++ tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp | 12 ++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml b/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml new file mode 100644 index 0000000000..d23ea43e74 --- /dev/null +++ b/tests/auto/qml/qqmlpromise/data/promisehandlerthrows.qml @@ -0,0 +1,17 @@ +import QtQuick 2.12 + +Item { + id: root + property string errorMessage + Component.onCompleted: () => { + let prom = Promise.reject("Some error") + .then( + o => {console.log("Never reached");}, + err => { + console.log("Rethrowing err"); + throw err; + } + ) + .catch(err => root.errorMessage = err) + } +} diff --git a/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp b/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp index 41850d0263..b430434526 100644 --- a/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp +++ b/tests/auto/qml/qqmlpromise/tst_qqmlpromise.cpp @@ -83,6 +83,7 @@ private slots: void then_reject_non_callable(); void then_resolve_multiple_then(); void promiseChain(); + void promiseHandlerThrows(); private: void execute_test(QString testName); @@ -285,6 +286,17 @@ void tst_qqmlpromise::promiseChain() } +void tst_qqmlpromise::promiseHandlerThrows() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("promisehandlerthrows.qml")); + QVERIFY(component.isReady()); + QTest::ignoreMessage(QtDebugMsg, "Rethrowing err"); + QScopedPointer root(component.create()); + QVERIFY(root); + QTRY_VERIFY(root->property("errorMessage") == QLatin1String("Some error")); +} + QTEST_MAIN(tst_qqmlpromise) -- cgit v1.2.3 From e2df4233a77ce8a37d2c8ef26b7b42fc0d33a24b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 5 Sep 2019 13:57:19 +0200 Subject: PathView: grab mouse on press if already moving A side effect of 8fd398c9d2f5f54e446e0b402bc63a2edb50da6f is that it became possible for the highlight to stop between items, rather than snapping to a specific item, if the user taps, clicks or drags an additional time while the movement is ongoing. That was because it didn't get a mouse grab, so it missed the release event. QQuickPathViewPrivate::handleMouseReleaseEvent() needs to take care of the snapping behavior after the user stops dragging. This only affects behavior in the case that the PathView is already moving and the mouse is pressed again: we assume the user wants to alter the PathView's velocity, not interact with any delegate inside or with any parent item. Task-number: QTBUG-77173 Task-number: QTBUG-59620 Change-Id: I7b2f69a6ef8d8022d7c917a5bf9e8fb40c8848db Reviewed-by: Mitch Curtis --- tests/auto/qml/ecmascripttests/test262 | 2 +- .../quick/qquickpathview/data/nestedmousearea2.qml | 101 +++++++++++++++++++++ .../quick/qquickpathview/tst_qquickpathview.cpp | 27 ++++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 tests/auto/quick/qquickpathview/data/nestedmousearea2.qml (limited to 'tests/auto') diff --git a/tests/auto/qml/ecmascripttests/test262 b/tests/auto/qml/ecmascripttests/test262 index 3c69133cc4..6b0c42c63c 160000 --- a/tests/auto/qml/ecmascripttests/test262 +++ b/tests/auto/qml/ecmascripttests/test262 @@ -1 +1 @@ -Subproject commit 3c69133cc419840c1be34638039cd8c48a7ef581 +Subproject commit 6b0c42c63c2492bd0a7a96d3179d122b5f71793f diff --git a/tests/auto/quick/qquickpathview/data/nestedmousearea2.qml b/tests/auto/quick/qquickpathview/data/nestedmousearea2.qml new file mode 100644 index 0000000000..ff11002552 --- /dev/null +++ b/tests/auto/quick/qquickpathview/data/nestedmousearea2.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +PathView { + id: view + width: 400; height: 240 + highlight: Rectangle { width: 80; height: 80; color: "lightsteelblue" } + preferredHighlightBegin: 0.5 + preferredHighlightEnd: 0.5 + model: ListModel { + id: appModel + ListElement { name: "Music" } + ListElement { name: "Movies" } + ListElement { name: "Camera" } + ListElement { name: "Calendar" } + ListElement { name: "Messaging" } + ListElement { name: "Todo List" } + ListElement { name: "Contacts" } + } + delegate: Rectangle { + width: 100; height: 100 + scale: PathView.iconScale + border.color: "lightgrey" + color: "transparent" + Text { + anchors { horizontalCenter: parent.horizontalCenter } + text: name + smooth: true + color: ma.pressed ? "red" : "black" + } + + MouseArea { + id: ma + anchors.fill: parent + onClicked: view.currentIndex = index + } + } + path: Path { + startX: 10 + startY: 50 + PathAttribute { name: "iconScale"; value: 0.5 } + PathQuad { x: 200; y: 150; controlX: 50; controlY: 200 } + PathAttribute { name: "iconScale"; value: 1.0 } + PathQuad { x: 390; y: 50; controlX: 350; controlY: 200 } + PathAttribute { name: "iconScale"; value: 0.5 } + } + Text { + anchors.horizontalCenter: parent.horizontalCenter + y: 20 + text: view.currentIndex + " @ " + offset.toFixed(2) + } +} diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 8b963117ed..8a1ab40475 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -120,6 +120,7 @@ private slots: void undefinedPath(); void mouseDrag(); void nestedMouseAreaDrag(); + void flickNClick(); void treeModel(); void changePreferredHighlight(); void missingPercent(); @@ -1601,6 +1602,32 @@ void tst_QQuickPathView::nestedMouseAreaDrag() QVERIFY(pathview->isMoving()); } +void tst_QQuickPathView::flickNClick() // QTBUG-77173 +{ + QScopedPointer window(createView()); + QQuickViewTestUtil::moveMouseAway(window.data()); + window->setSource(testFileUrl("nestedmousearea2.qml")); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QCOMPARE(window.data(), qGuiApp->focusWindow()); + + QQuickPathView *pathview = qobject_cast(window->rootObject()); + QVERIFY(pathview != nullptr); + + for (int duration = 100; duration > 0; duration -= 20) { + // Dragging the child mouse area should animate the PathView (MA has no drag target) + flick(window.data(), QPoint(200,200), QPoint(400,200), duration); + QVERIFY(pathview->isMoving()); + + // Now while it's still moving, click it. + // The PathView should stop at a position such that offset is a whole number. + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, QPoint(200, 200)); + QTRY_VERIFY(!pathview->isMoving()); + QVERIFY(qFuzzyIsNull(pathview->offset() - int(pathview->offset()))); + } +} + void tst_QQuickPathView::treeModel() { QScopedPointer window(createView()); -- cgit v1.2.3 From 8f1857f907153c4a98c73d572ea76c2b7ca33b5d Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Thu, 19 Sep 2019 18:04:55 +0800 Subject: QQuickMouseArea: fix containsMouse when mousearea become visible If enabled is false, then containsMouse will not become true when hovering on mousearea, even if hoverEnabled is true. However when an invisible mousearea become visible, the value of enabled isn't checked. In this case, the value of containsMouse is not affected by enabled. [ChangeLog][QtQuick][QQuickMouseArea] containsMouse property will not become true when the an invisible mousearea become visible, if the enabled property is false or its parent item is not enabled Fixes: QTBUG-77983 Change-Id: I923bdcf3eda813aea51a04515d530093d6eb77b2 Reviewed-by: Shawn Rutledge --- .../quick/qquickmousearea/tst_qquickmousearea.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 5844720aa4..17553ee6c4 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -1359,6 +1359,34 @@ void tst_QQuickMouseArea::hoverVisible() QCOMPARE(enteredSpy.count(), 1); QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(11,33)); + + // QTBUG-77983 + mouseTracker->setVisible(false); + mouseTracker->setEnabled(false); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + // if the enabled property is false, the containsMouse property shouldn't become true + // when an invisible mousearea become visible + QCOMPARE(mouseTracker->hovered(), false); + + mouseTracker->parentItem()->setEnabled(false); + mouseTracker->setVisible(false); + mouseTracker->setEnabled(true); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + // if the parent item is not enabled, the containsMouse property will be false, even if + // the mousearea is enabled + QCOMPARE(mouseTracker->hovered(), false); + + mouseTracker->parentItem()->setEnabled(true); + mouseTracker->setVisible(false); + mouseTracker->setEnabled(true); + + QCOMPARE(mouseTracker->hovered(), false); + mouseTracker->setVisible(true); + QCOMPARE(mouseTracker->hovered(), true); } void tst_QQuickMouseArea::hoverAfterPress() -- cgit v1.2.3 From a439a25f468d8c5623f2e0949b55a0c85c850f5f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 24 Sep 2019 09:11:04 +0200 Subject: Ensure AnimatedImage currentFrame/onCurrentFrameChanged 2.0 compatibility Change 5d995ae122aa07486ead849560b74d2b62b883bb did not make the actual QQuickImageBase::currentFrameChanged signal accessible to the Qt Quick 2.0 revision. Normally the QML engine would implement a JS onCurrentFrameChanged handler by connecting to the currentFrame property's frameChanged notifier signal; but in this case it tried to connect to the explicit QQuickImageBase::currentFrameChanged signal instead (because the name is a better match), and failed because of the revision. So we need another duplicate unrevisioned signal QQuickAnimatedImage::currentFrameChanged for use when the import is less than Qt Quick 2.14. As pointed out during review, an autotest for the revisioning is good to have anyway. Fixes: QTBUG-78713 Task-number: QTBUG-77506 Change-Id: I121508acac81d47e3c0a4c0ed12257c10b30970b Reviewed-by: Ulf Hermann Reviewed-by: Fabian Kosmale --- .../qquickanimatedimage/data/currentframe.qml | 13 ++++++ .../tst_qquickanimatedimage.cpp | 46 ++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/auto/quick/qquickanimatedimage/data/currentframe.qml (limited to 'tests/auto') diff --git a/tests/auto/quick/qquickanimatedimage/data/currentframe.qml b/tests/auto/quick/qquickanimatedimage/data/currentframe.qml new file mode 100644 index 0000000000..b679da2a99 --- /dev/null +++ b/tests/auto/quick/qquickanimatedimage/data/currentframe.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +AnimatedImage { + property int currentFrameChangeCount: 0 + property int frameChangeCount: 0 + source: "stickman.gif" + onCurrentFrameChanged: if (currentFrame > 0) ++currentFrameChangeCount; + onFrameChanged: if (currentFrame > 0) ++frameChangeCount; + function scriptedSetCurrentFrame(frame) { + currentFrame = frame; + } +} + diff --git a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp index 8026bafb9e..31c3fb9946 100644 --- a/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp +++ b/tests/auto/quick/qquickanimatedimage/tst_qquickanimatedimage.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include #include +#include #include #include #include @@ -40,6 +41,23 @@ Q_DECLARE_METATYPE(QQuickImageBase::Status) +template static T evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + QVariant result = expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); + return result.value(); +} + +template <> void evaluate(QObject *scope, const QString &expression) +{ + QQmlExpression expr(qmlContext(scope), scope, expression); + expr.evaluate(); + if (expr.hasError()) + qWarning() << expr.error().toString(); +} + class tst_qquickanimatedimage : public QQmlDataTest { Q_OBJECT @@ -68,6 +86,7 @@ private slots: void playingAndPausedChanges(); void noCaching(); void sourceChangesOnFrameChanged(); + void currentFrame(); }; void tst_qquickanimatedimage::cleanup() @@ -618,6 +637,33 @@ void tst_qquickanimatedimage::sourceChangesOnFrameChanged() qDeleteAll(images); } +void tst_qquickanimatedimage::currentFrame() +{ + QQuickView window; + window.setSource(testFileUrl("currentframe.qml")); + window.show(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QQuickAnimatedImage *anim = qobject_cast(window.rootObject()); + QVERIFY(anim); + QSignalSpy frameChangedSpy(anim, SIGNAL(frameChanged())); + QSignalSpy currentFrameChangedSpy(anim, SIGNAL(currentFrameChanged())); + + anim->setCurrentFrame(1); + QCOMPARE(anim->currentFrame(), 1); + QCOMPARE(frameChangedSpy.count(), 1); + QCOMPARE(currentFrameChangedSpy.count(), 1); + QCOMPARE(anim->property("currentFrameChangeCount"), 1); + QCOMPARE(anim->property("frameChangeCount"), 1); + + evaluate(anim, "scriptedSetCurrentFrame(2)"); + QCOMPARE(anim->currentFrame(), 2); + QCOMPARE(frameChangedSpy.count(), 2); + QCOMPARE(currentFrameChangedSpy.count(), 2); + QCOMPARE(anim->property("currentFrameChangeCount"), 2); + QCOMPARE(anim->property("frameChangeCount"), 2); +} + QTEST_MAIN(tst_qquickanimatedimage) #include "tst_qquickanimatedimage.moc" -- cgit v1.2.3 From ae346195efaca5d01b67c5df1209512c7edaddb0 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 12 Sep 2019 20:44:43 +0200 Subject: Handle "interesting" stationary touchpoints as if they moved MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt Quick will not receive "uninteresting" stationary touchpoints, but only those in which some property has changed. So MultiPointTouchArea should react to stationary touchpoints in the same way as if they moved, so that UIs can react to changes in touchpoint velocity, pressure etc. And QQuickWindow has to be willing to delivery stationary touchpoints to make this possible. However when a QTouchEvent is customized for delivery to a specific Item, by including only the touchpoints that are inside the Item, then if those touchpoints are all stationary, the event only needs to be delivered if at least one of them is an "interesting" stationary touchpoint. So we need to depend on a new per-touchpoint flag that QGuiApplication will set when it discovers that some property of the touchpoint has changed. That is QTouchEventTouchPointPrivate::stationaryWithModifiedProperty. Fixes: QTBUG-77142 Change-Id: I763d56ff55c048b258dca40d88283ed016447c35 Reviewed-by: Jan Arve Sæther --- .../tst_qquickmultipointtoucharea.cpp | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index cd66fc4ede..e96b892b54 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -72,6 +72,7 @@ private slots: void mouseGestureStarted_data(); void mouseGestureStarted(); void cancel(); + void stationaryTouchWithChangingPressure(); private: QQuickView *createAndShowView(const QString &file); @@ -1305,6 +1306,42 @@ void tst_QQuickMultiPointTouchArea::cancel() } +void tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() // QTBUG-77142 +{ + QScopedPointer window(createAndShowView("basic.qml")); + QVERIFY(window->rootObject() != nullptr); + + QQuickTouchPoint *point1 = window->rootObject()->findChild("point1"); + QCOMPARE(point1->pressed(), false); + + QPoint p1(20,100); + QTouchEvent::TouchPoint tp1(1); + + tp1.setScreenPos(window->mapToGlobal(p1)); + tp1.setState(Qt::TouchPointPressed); + tp1.setPressure(0.5); + qt_handleTouchEvent(window.data(), device, {tp1}); + QQuickTouchUtils::flush(window.data()); + + QCOMPARE(point1->pressed(), true); + QCOMPARE(point1->pressure(), 0.5); + + tp1.setState(Qt::TouchPointStationary); + tp1.setPressure(0.6); + qt_handleTouchEvent(window.data(), device, {tp1}); + QQuickTouchUtils::flush(window.data()); + + QCOMPARE(point1->pressure(), 0.6); + + tp1.setState(Qt::TouchPointReleased); + tp1.setPressure(0); + qt_handleTouchEvent(window.data(), device, {tp1}); + QQuickTouchUtils::flush(window.data()); + + QCOMPARE(point1->pressed(), false); + QCOMPARE(point1->pressure(), 0); +} + QTEST_MAIN(tst_QQuickMultiPointTouchArea) -- cgit v1.2.3 From e0334d05c00cfe6140ac55f8b6aa8ee83795b940 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 13:24:57 +0200 Subject: Don't leak the context property in tst_qqmllanguage::accessDeletedObject Change-Id: I27baef97537bb8fda7fcc00d934f0b2568b4284e Reviewed-by: Fabian Kosmale Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 007fb5cef2..12ed50137b 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -5075,7 +5075,8 @@ void tst_qqmllanguage::accessDeletedObject() { QQmlEngine engine; - engine.rootContext()->setContextProperty("objectCreator", new ObjectCreator); + QScopedPointer creator(new ObjectCreator); + engine.rootContext()->setContextProperty("objectCreator", creator.get()); QQmlComponent component(&engine, testFileUrl("accessDeletedObject.qml")); VERIFY_ERRORS(0); -- cgit v1.2.3 From 45a6b25cc3bc62668097945d2569070e0be9a0e6 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 17:36:27 +0200 Subject: tst_qqmllanguage: Fix singleton tests The JavaScript pragma test expected the dynamic signal test to run before. Therefore, it would fail when run in isolation. Move the two tests into one function. Change-Id: I0edb1f091c6a845110c3f741cbb48e846c423005 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 55 ++++++++++++------------ 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 12ed50137b..ad96b1438f 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -243,12 +243,11 @@ private slots: void compositeSingletonModuleQualified(); void compositeSingletonInstantiateError(); void compositeSingletonDynamicPropertyError(); - void compositeSingletonDynamicSignal(); + void compositeSingletonDynamicSignalAndJavaScriptPragma(); void compositeSingletonQmlRegisterTypeError(); void compositeSingletonQmldirNoPragmaError(); void compositeSingletonQmlDirError(); void compositeSingletonRemote(); - void compositeSingletonJavaScriptPragma(); void compositeSingletonSelectors(); void compositeSingletonRegistered(); void compositeSingletonCircular(); @@ -4277,16 +4276,35 @@ void tst_qqmllanguage::compositeSingletonDynamicPropertyError() VERIFY_ERRORS(0); } -// Having a composite singleton type as dynamic signal parameter succeeds -// (like C++ singleton) -void tst_qqmllanguage::compositeSingletonDynamicSignal() +void tst_qqmllanguage::compositeSingletonDynamicSignalAndJavaScriptPragma() { - QQmlComponent component(&engine, testFileUrl("singletonTest11.qml")); - VERIFY_ERRORS(0); - QScopedPointer o(component.create()); - QVERIFY(o != nullptr); + { + // Having a composite singleton type as dynamic signal parameter succeeds + // (like C++ singleton) + + QQmlComponent component(&engine, testFileUrl("singletonTest11.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(o != nullptr); + + verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", -55); + } + { + // Load a composite singleton type and a javascript file that has .pragma library + // in it. This will make sure that the javascript .pragma does not get mixed with + // the pragma Singleton changes. - verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", -55); + QQmlComponent component(&engine, testFileUrl("singletonTest16.qml")); + VERIFY_ERRORS(0); + QScopedPointer o(component.create()); + QVERIFY(o != nullptr); + + // The value1 that is read from the SingletonType was changed from 125 to 99 + // above. As the type is a singleton and + // the engine has not been destroyed, we just retrieve the old instance and + // the value is still 99. + verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", 333); + } } // Use qmlRegisterType to register a qml composite type with pragma Singleton defined in it. @@ -4338,23 +4356,6 @@ void tst_qqmllanguage::compositeSingletonRemote() verifyCompositeSingletonPropertyValues(o.data(), "value1", 525, "value2", 355); } -// Load a composite singleton type and a javascript file that has .pragma library -// in it. This will make sure that the javascript .pragma does not get mixed with -// the pragma Singleton changes. -void tst_qqmllanguage::compositeSingletonJavaScriptPragma() -{ - QQmlComponent component(&engine, testFileUrl("singletonTest16.qml")); - VERIFY_ERRORS(0); - QScopedPointer o(component.create()); - QVERIFY(o != nullptr); - - // The value1 that is read from the SingletonType was changed from 125 to 99 - // in compositeSingletonDynamicSignal() above. As the type is a singleton and - // the engine has not been destroyed, we just retrieve the old instance and - // the value is still 99. - verifyCompositeSingletonPropertyValues(o.data(), "value1", 99, "value2", 333); -} - // Reads values from a Singleton accessed through selectors. void tst_qqmllanguage::compositeSingletonSelectors() { -- cgit v1.2.3 From 702249777f9052c0f26793187f36fa0301dee105 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 18:09:22 +0200 Subject: tst_qqmlecmascript: Don't leak created objects The result from component.create() has to be deleted somewhere. Change-Id: I23135cb639fc316641e399decc740d9f5d445a84 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/testtypes.h | 8 +- .../auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 101 +++++++++++---------- 2 files changed, 54 insertions(+), 55 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h index 730dc7cab8..3233e7f105 100644 --- a/tests/auto/qml/qqmlecmascript/testtypes.h +++ b/tests/auto/qml/qqmlecmascript/testtypes.h @@ -1098,13 +1098,11 @@ class MyItemUsingRevisionedObject : public QObject Q_PROPERTY(MyRevisionedClass *revisioned READ revisioned) public: - MyItemUsingRevisionedObject() { - m_revisioned = new MyRevisionedClass; - } + MyItemUsingRevisionedObject() : m_revisioned (new MyRevisionedClass) {} - MyRevisionedClass *revisioned() const { return m_revisioned; } + MyRevisionedClass *revisioned() const { return m_revisioned.get(); } private: - MyRevisionedClass *m_revisioned; + QScopedPointer m_revisioned; }; QML_DECLARE_TYPE(MyRevisionedBaseClassRegistered) diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index fa78e60bba..05ad5e2f22 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -1693,10 +1693,10 @@ void tst_qqmlecmascript::componentCreation() } QQmlComponent component(&engine, testUrl); - MyTypeObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); - QMetaObject::invokeMethod(object, method.toUtf8()); + QMetaObject::invokeMethod(object.get(), method.toUtf8()); QQmlComponent *created = object->componentProperty(); if (creationError.isEmpty()) { @@ -1704,7 +1704,7 @@ void tst_qqmlecmascript::componentCreation() QObject *expectedParent = reinterpret_cast(quintptr(-1)); if (createdParent == QLatin1String("obj")) { - expectedParent = object; + expectedParent = object.get(); } else if ((createdParent == QLatin1String("null")) || createdParent.isEmpty()) { expectedParent = nullptr; } @@ -3124,13 +3124,13 @@ void tst_qqmlecmascript::callQtInvokables() void tst_qqmlecmascript::resolveClashingProperties() { - ClashingNames *o = new ClashingNames(); + QScopedPointer o(new ClashingNames()); QQmlEngine qmlengine; QV4::ExecutionEngine *engine = qmlengine.handle(); QV4::Scope scope(engine); - QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(engine, o)); + QV4::ScopedValue object(scope, QV4::QObjectWrapper::wrap(engine, o.get())); QV4::ObjectIterator it(scope, object->as(), QV4::ObjectIterator::EnumerableOnly); QV4::ScopedValue name(scope); QV4::ScopedValue value(scope); @@ -6093,7 +6093,7 @@ void tst_qqmlecmascript::variants() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("variants.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); QCOMPARE(object->property("undefinedVariant").type(), QVariant::Invalid); @@ -6102,13 +6102,13 @@ void tst_qqmlecmascript::variants() QCOMPARE(object->property("doubleVariant").type(), QVariant::Double); QVariant result; - QMetaObject::invokeMethod(object, "checkNull", Q_RETURN_ARG(QVariant, result)); + QMetaObject::invokeMethod(object.get(), "checkNull", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); - QMetaObject::invokeMethod(object, "checkUndefined", Q_RETURN_ARG(QVariant, result)); + QMetaObject::invokeMethod(object.get(), "checkUndefined", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); - QMetaObject::invokeMethod(object, "checkNumber", Q_RETURN_ARG(QVariant, result)); + QMetaObject::invokeMethod(object.get(), "checkNumber", Q_RETURN_ARG(QVariant, result)); QCOMPARE(result.toBool(), true); } @@ -6998,12 +6998,12 @@ void tst_qqmlecmascript::realToInt() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("realToInt.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); - QMetaObject::invokeMethod(object, "test1"); + QMetaObject::invokeMethod(object.get(), "test1"); QCOMPARE(object->value(), int(4)); - QMetaObject::invokeMethod(object, "test2"); + QMetaObject::invokeMethod(object.get(), "test2"); QCOMPARE(object->value(), int(7)); } @@ -7012,7 +7012,7 @@ void tst_qqmlecmascript::urlProperty() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("urlProperty.1.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); object->setStringProperty("http://qt-project.org"); QCOMPARE(object->urlProperty(), QUrl("http://qt-project.org/index.html")); @@ -7027,7 +7027,7 @@ void tst_qqmlecmascript::urlPropertyWithEncoding() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("urlProperty.2.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); object->setStringProperty("http://qt-project.org"); const QUrl encoded = QUrl::fromEncoded("http://qt-project.org/?get%3cDATA%3e", QUrl::TolerantMode); @@ -7062,7 +7062,7 @@ void tst_qqmlecmascript::dynamicString() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("dynamicString.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); QCOMPARE(object->property("stringProperty").toString(), QString::fromLatin1("string:Hello World false:0 true:1 uint32:100 int32:-100 double:3.14159 date:2011-02-11 05::30:50!")); @@ -7072,7 +7072,7 @@ void tst_qqmlecmascript::deleteLaterObjectMethodCall() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("deleteLaterObjectMethodCall.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7080,7 +7080,7 @@ void tst_qqmlecmascript::automaticSemicolon() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("automaticSemicolon.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7088,7 +7088,7 @@ void tst_qqmlecmascript::compatibilitySemicolon() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("compatibilitySemicolon.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7096,7 +7096,7 @@ void tst_qqmlecmascript::incrDecrSemicolon1() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon1.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7104,7 +7104,7 @@ void tst_qqmlecmascript::incrDecrSemicolon2() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("incrDecrSemicolon2.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7120,7 +7120,7 @@ void tst_qqmlecmascript::unaryExpression() { QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("unaryExpression.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -7260,7 +7260,7 @@ void tst_qqmlecmascript::switchStatement() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("switchStatement.1.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7283,7 +7283,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.2.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7306,7 +7306,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.3.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7333,7 +7333,7 @@ void tst_qqmlecmascript::switchStatement() QString warning = component.url().toString() + ":4:5: Unable to assign [undefined] to int"; QTest::ignoreMessage(QtWarningMsg, qPrintable(warning)); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7357,7 +7357,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.5.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7380,7 +7380,7 @@ void tst_qqmlecmascript::switchStatement() { QQmlComponent component(&engine, testFileUrl("switchStatement.6.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); // `object->value()' is the number of executed statements @@ -7408,7 +7408,7 @@ void tst_qqmlecmascript::withStatement() { QUrl url = testFileUrl("withStatement.1.qml"); QQmlComponent component(&engine, url); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->value(), 123); @@ -7420,7 +7420,7 @@ void tst_qqmlecmascript::tryStatement() QQmlEngine engine; { QQmlComponent component(&engine, testFileUrl("tryStatement.1.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->value(), 123); @@ -7428,7 +7428,7 @@ void tst_qqmlecmascript::tryStatement() { QQmlComponent component(&engine, testFileUrl("tryStatement.2.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QCOMPARE(object->value(), 321); @@ -7436,7 +7436,7 @@ void tst_qqmlecmascript::tryStatement() { QQmlComponent component(&engine, testFileUrl("tryStatement.3.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QVERIFY(object->qjsvalue().isUndefined()); @@ -7444,7 +7444,7 @@ void tst_qqmlecmascript::tryStatement() { QQmlComponent component(&engine, testFileUrl("tryStatement.4.qml")); - MyQmlObject *object = qobject_cast(component.create()); + QScopedPointer object(qobject_cast(component.create())); QVERIFY(object != nullptr); QVERIFY(object->qjsvalue().isUndefined()); @@ -7585,7 +7585,7 @@ void tst_qqmlecmascript::onDestruction() // component instance. This shouldn't crash. QQmlEngine engine; QQmlComponent c(&engine, testFileUrl("onDestruction.qml")); - QObject *obj = c.create(); + QScopedPointer obj(c.create()); QVERIFY(obj != nullptr); QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); } @@ -7926,19 +7926,19 @@ void tst_qqmlecmascript::dateParse() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("date.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); if (object == nullptr) qDebug() << component.errorString(); QVERIFY(object != nullptr); QVariant q; - QMetaObject::invokeMethod(object, "test_is_invalid_jsDateTime", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "test_is_invalid_jsDateTime", Q_RETURN_ARG(QVariant, q)); QVERIFY(q.toBool()); - QMetaObject::invokeMethod(object, "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "test_is_invalid_qtDateTime", Q_RETURN_ARG(QVariant, q)); QVERIFY(q.toBool()); - QMetaObject::invokeMethod(object, "test_rfc2822_date", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "test_rfc2822_date", Q_RETURN_ARG(QVariant, q)); QCOMPARE(q.toLongLong(), 1379512851000LL); } @@ -7947,14 +7947,14 @@ void tst_qqmlecmascript::utcDate() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("utcdate.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); if (object == nullptr) qDebug() << component.errorString(); QVERIFY(object != nullptr); QVariant q; QVariant val = QString::fromLatin1("2014-07-16T23:30:31"); - QMetaObject::invokeMethod(object, "check_utc", Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, val)); + QMetaObject::invokeMethod(object.get(), "check_utc", Q_RETURN_ARG(QVariant, q), Q_ARG(QVariant, val)); QVERIFY(q.toBool()); } @@ -7963,20 +7963,20 @@ void tst_qqmlecmascript::negativeYear() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("negativeyear.qml")); - QObject *object = component.create(); + QScopedPointer object(component.create()); if (object == nullptr) qDebug() << component.errorString(); QVERIFY(object != nullptr); QVariant q; - QMetaObject::invokeMethod(object, "check_negative_tostring", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "check_negative_tostring", Q_RETURN_ARG(QVariant, q)); // Only check for the year. We hope that every language writes the year in arabic numerals and // in relation to a specific dude's date of birth. We also hope that no language adds a "-2001" // junk string somewhere in the middle. QVERIFY(q.toString().indexOf(QStringLiteral("-2001")) != -1); - QMetaObject::invokeMethod(object, "check_negative_toisostring", Q_RETURN_ARG(QVariant, q)); + QMetaObject::invokeMethod(object.get(), "check_negative_toisostring", Q_RETURN_ARG(QVariant, q)); QCOMPARE(q.toString().left(16), QStringLiteral("result: -002000-")); } @@ -8019,6 +8019,7 @@ void tst_qqmlecmascript::jsOwnedObjectsDeletedOnEngineDestroy() QCOMPARE(spy1.count(), 1); QCOMPARE(spy2.count(), 1); + deleteObject.deleteNestedObject(); delete object; } @@ -8030,7 +8031,7 @@ void tst_qqmlecmascript::updateCall() QString file("updateCall.qml"); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl(file)); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } @@ -8041,7 +8042,7 @@ void tst_qqmlecmascript::numberParsing() QString file("numberParsing.%1.qml"); file = file.arg(i); QQmlComponent component(&engine, testFileUrl(file)); - QObject *object = component.create(); + QScopedPointer object(component.create()); QVERIFY(object != nullptr); } for (int i = 1; i < 3; ++i) { @@ -8224,8 +8225,8 @@ void tst_qqmlecmascript::idsAsLValues() QString err = QString(QLatin1String("%1:5: Error: left-hand side of assignment operator is not an lvalue")).arg(testFileUrl("idAsLValue.qml").toString()); QQmlComponent component(&engine, testFileUrl("idAsLValue.qml")); QTest::ignoreMessage(QtWarningMsg, qPrintable(err)); - MyQmlObject *object = qobject_cast(component.create()); - QVERIFY(!object); + QScopedPointer object(component.create()); + QVERIFY(!qobject_cast(object.get())); } void tst_qqmlecmascript::qtbug_34792() @@ -8440,10 +8441,10 @@ void tst_qqmlecmascript::readUnregisteredQObjectProperty() qmlRegisterType("Test", 1, 0, "ObjectContainer"); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("accessUnregisteredQObjectProperty.qml")); - QObject *root = component.create(); + QScopedPointer root(component.create()); QVERIFY(root); - QMetaObject::invokeMethod(root, "readProperty"); + QMetaObject::invokeMethod(root.get(), "readProperty"); QCOMPARE(root->property("container").value()->mGetterCalled, true); } @@ -8452,10 +8453,10 @@ void tst_qqmlecmascript::writeUnregisteredQObjectProperty() qmlRegisterType("Test", 1, 0, "ObjectContainer"); QQmlEngine engine; QQmlComponent component(&engine, testFileUrl("accessUnregisteredQObjectProperty.qml")); - QObject *root = component.create(); + QScopedPointer root(component.create()); QVERIFY(root); - QMetaObject::invokeMethod(root, "writeProperty"); + QMetaObject::invokeMethod(root.get(), "writeProperty"); QCOMPARE(root->property("container").value()->mSetterCalled, true); } -- cgit v1.2.3 From b1b25db63b465a17d7834d388916bf89f426fe35 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 30 Sep 2019 17:45:51 +0200 Subject: tst_qqmlecmascript: import QtQuick when using color properties QtQuick defines the color provider necessary to use colors. If QtQuick is not loaded at that point, the test fails. Change-Id: I7d2eb25f7482d18b304d9274bce4a6bd6fa34741 Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto') diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml index 54d29dfc94..9fdb7f92f3 100644 --- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml +++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml @@ -1,4 +1,5 @@ import Qt.test 1.0 +import QtQuick 2.0 // We need the the QtQuick color provider for colorProperty MyQmlObject { -- cgit v1.2.3