From 28a114cbf7a3c2c18948e8bd582e5b5463443cab Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 27 Mar 2019 13:23:18 +0100 Subject: Allow enums in QQmlType to be set up in two separate passes The baseMetaObject and the property cache can become available at different points in time. If we have initialized the enums before either of them is available we want to add the additional enums when the other one appears. Fixes: QTBUG-74677 Change-Id: I57276681a50b6c04181c6a29e736f2dc20632a0c Reviewed-by: Lars Knoll --- .../auto/qml/qqmlmetatype/data/Components/App.qml | 57 ++++++++++++++++++++++ tests/auto/qml/qqmlmetatype/data/Components/qmldir | 3 ++ .../qqmlmetatype/data/enumsInRecursiveImport.qml | 11 +++++ tests/auto/qml/qqmlmetatype/qqmlmetatype.pro | 7 +++ tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 32 ++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 tests/auto/qml/qqmlmetatype/data/Components/App.qml create mode 100644 tests/auto/qml/qqmlmetatype/data/Components/qmldir create mode 100644 tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmlmetatype/data/Components/App.qml b/tests/auto/qml/qqmlmetatype/data/Components/App.qml new file mode 100644 index 0000000000..3792ca665e --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/Components/App.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml 2.0 + +import Components 1.0 + +QtObject { + id: mainRect + + property int appState: App.AppState.Blue + property string color: "blue" + + enum AppState { + Red, + Green, + Blue + } + + onAppStateChanged: { + if (appState === App.AppState.Green) + mainRect.color = "green" + else if (appState === App.AppState.Red) + mainRect.color = "red" + } + + property Timer timer: Timer { + onTriggered: appState = App.AppState.Green + running: true + interval: 100 + } +} diff --git a/tests/auto/qml/qqmlmetatype/data/Components/qmldir b/tests/auto/qml/qqmlmetatype/data/Components/qmldir new file mode 100644 index 0000000000..3f6db4ed2d --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/Components/qmldir @@ -0,0 +1,3 @@ +module Components + +App 1.0 App.qml diff --git a/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml b/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml new file mode 100644 index 0000000000..eef6abc6e5 --- /dev/null +++ b/tests/auto/qml/qqmlmetatype/data/enumsInRecursiveImport.qml @@ -0,0 +1,11 @@ +import QtQml 2.0 + +import Components 1.0 + +QtObject { + property App app: App { + appState: 0 + } + + property string color: app.color +} diff --git a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro index 345bc59615..109de7d212 100644 --- a/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro +++ b/tests/auto/qml/qqmlmetatype/qqmlmetatype.pro @@ -10,4 +10,11 @@ qmlfiles.files = data/CompositeType.qml qmlfiles.prefix = /tstqqmlmetatype RESOURCES += qmlfiles +qmldirresource.files = \ + data/Components/App.qml \ + data/Components/qmldir \ + data/enumsInRecursiveImport.qml +qmldirresource.prefix = / +RESOURCES += qmldirresource + QT += core-private gui-private qml-private testlib diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index ce72f40dcc..7f103dc5ed 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -67,6 +67,9 @@ private slots: void normalizeUrls(); void unregisterAttachedProperties(); void revisionedGroupedProperties(); + + void enumsInRecursiveImport_data(); + void enumsInRecursiveImport(); }; class TestType : public QObject @@ -629,6 +632,35 @@ void tst_qqmlmetatype::revisionedGroupedProperties() } } +void tst_qqmlmetatype::enumsInRecursiveImport_data() +{ + QTest::addColumn("importPath"); + QTest::addColumn("componentUrl"); + + QTest::addRow("data directory") << dataDirectory() + << testFileUrl("enumsInRecursiveImport.qml"); + + // The qrc case behaves differently because we failed to detect the recursion in type loading + // due to varying numbers of slashes after the "qrc:" in the URLs. + QTest::addRow("resources") << QStringLiteral("qrc:/data") + << QUrl("qrc:/data/enumsInRecursiveImport.qml"); +} + +void tst_qqmlmetatype::enumsInRecursiveImport() +{ + QFETCH(QString, importPath); + QFETCH(QUrl, componentUrl); + + qmlClearTypeRegistrations(); + QQmlEngine engine; + engine.addImportPath(importPath); + QQmlComponent c(&engine, componentUrl); + QVERIFY(c.isReady()); + QScopedPointer obj(c.create()); + QVERIFY(!obj.isNull()); + QTRY_COMPARE(obj->property("color").toString(), QString("green")); +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" -- cgit v1.2.3 From aba6cea90e023c99ac55b0e8dcdeae0af8305ef2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 3 Apr 2019 16:16:19 +0200 Subject: In response to touch cancel, don't just ungrab, send an ungrab event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QQuickWindowPrivate::sendUngrabEvent() sends an UngrabMouse event, and that can be filtered by parent filters. If a touch cancel happens to a MouseArea in a ListView delegate, we need the ListView to filter the UngrabMouse event so that QQuickFlickable::childMouseEventFilter() will call QQuickFlickable::mouseUngrabEvent() and QQuickFlickablePrivate::cancelInteraction() will set pressed to false. The pressed state became true because Flickable filtered the press event; so for symmetry, it also needs to filter the touch cancel (in the form of a mouse ungrab), to avoid being stuck in a state where it can't move programmatically. Fixes: QTBUG-74679 Change-Id: I6c0ed364d2bc1f45c7e7b17846a09f6b53f91d0a Reviewed-by: Qt CI Bot Reviewed-by: Jan Arve Sæther --- .../qquicklistview/data/delegateWithMouseArea.qml | 29 ++++++++++++++++++ .../quick/qquicklistview/tst_qquicklistview.cpp | 34 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml (limited to 'tests') diff --git a/tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml b/tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml new file mode 100644 index 0000000000..e0b8222bfb --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/delegateWithMouseArea.qml @@ -0,0 +1,29 @@ +import QtQuick 2.12 + +ListView { + id: root + objectName: "view" + width: 600 + height: 600 + model: 3 + snapMode: ListView.SnapOneItem + boundsBehavior: Flickable.StopAtBounds + highlightRangeMode: ListView.StrictlyEnforceRange + preferredHighlightBegin: 0 + preferredHighlightEnd: 0 + highlightMoveDuration: 100 + delegate: Rectangle { + id: delegateRect + width: 500 + height: 500 + color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1) + Text { + text: index + font.pixelSize: 128 + anchors.centerIn: parent + } + MouseArea { + anchors.fill: parent + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index ff796a5bd8..fddba77f35 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -273,6 +274,7 @@ private slots: void addOnCompleted(); void setPositionOnLayout(); + void touchCancel(); private: template void items(const QUrl &source); @@ -328,6 +330,7 @@ private: QQuickView *m_view; QString testForView; + QTouchDevice *touchDevice = QTest::createTouchDevice(); }; class TestObject : public QObject @@ -8944,6 +8947,37 @@ void tst_QQuickListView::useDelegateChooserWithoutDefault() window->show(); }; +void tst_QQuickListView::touchCancel() // QTBUG-74679 +{ + QScopedPointer window(createView()); + window->setSource(testFileUrl("delegateWithMouseArea.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast(window->rootObject()); + QVERIFY(listview); + QQuickMouseArea *mouseArea = listview->currentItem()->findChild(); + QVERIFY(mouseArea); + + QPoint p1(300, 300); + QTest::touchEvent(window.data(), touchDevice).press(0, p1, window.data()); + QQuickTouchUtils::flush(window.data()); + QTRY_VERIFY(mouseArea->pressed()); + // and because Flickable filtered it, QQuickFlickablePrivate::pressed + // should be true, but it's not easily tested here + + QTouchEvent cancelEvent(QEvent::TouchCancel); + cancelEvent.setDevice(touchDevice); + QCoreApplication::sendEvent(window.data(), &cancelEvent); + // now QQuickWindowPrivate::sendUngrabEvent() will be called, Flickable will filter it, + // QQuickFlickablePrivate::pressed will be set to false, and that will allow setCurrentIndex() to make it move + QQuickTouchUtils::flush(window.data()); + + listview->setCurrentIndex(1); + // ensure that it actually moves (animates) to the second delegate + QTRY_COMPARE(listview->contentY(), 500.0); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" -- cgit v1.2.3 From 0c02691f7ba646e782b04347fde3d75f9582b317 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 5 Apr 2019 15:00:59 +0200 Subject: If DragHandler is dragged within its margin, don't jump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not being pressed inside the target is a necessary but not sufficient reason to reset m_pressTargetPos to the center of the target. The intention was rather to make the target jump into position when the parent was a different item: e.g. if a Slider has a DragHandler whose target is the slider's knob, you can start dragging anywhere on the whole Slider but you want the knob to jump to the cursor position when the drag begins. While we're at it, both branches of the if in onGrabChanged() are checking that target() isn't null, so we can move that check out. Fixes: QTBUG-74966 Change-Id: I05be11d27422b070d941b9e43d4e1157e071c3a5 Reviewed-by: Jan Arve Sæther --- .../qquickdraghandler/data/dragMargin.qml | 36 ++++++++++++++++++++++ .../qquickdraghandler/tst_qquickdraghandler.cpp | 33 ++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml (limited to 'tests') diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml new file mode 100644 index 0000000000..e5ca681bd5 --- /dev/null +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/data/dragMargin.qml @@ -0,0 +1,36 @@ +import QtQuick 2.12 + +Rectangle { + color: "#333" + width: 480; height: 480 + + Rectangle { + color: "#112" + width: 100 + height: 100 + x: 50; y: 50 + + DragHandler { + id: dragHandler + margin: 20 + } + + Rectangle { + id: rect + anchors.fill: parent + anchors.margins: -dragHandler.margin + color: "transparent" + border.color: "cyan" + border.width: 2 + radius: 10 + antialiasing: true + + Text { + color: "cyan" + text: "drag this margin area" + font.pixelSize: 10 + anchors.horizontalCenter: parent.horizontalCenter + } + } + } +} diff --git a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp index eb210c2112..cc8c567e5c 100644 --- a/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickdraghandler/tst_qquickdraghandler.cpp @@ -55,6 +55,7 @@ private slots: void defaultPropertyValues(); void touchDrag(); void mouseDrag(); + void dragFromMargin(); void touchDragMulti(); void touchDragMultiSliders_data(); void touchDragMultiSliders(); @@ -251,6 +252,38 @@ void tst_DragHandler::mouseDrag() QCOMPARE(centroidChangedSpy.count(), 5); } +void tst_DragHandler::dragFromMargin() // QTBUG-74966 +{ + const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); + QScopedPointer windowPtr; + createView(windowPtr, "dragMargin.qml"); + QQuickView * window = windowPtr.data(); + + QQuickItem *draggableItem = window->rootObject()->childItems().first(); + QVERIFY(draggableItem); + QQuickDragHandler *dragHandler = draggableItem->findChild(); + QVERIFY(dragHandler); + + QPointF originalPos = draggableItem->position(); + QPointF scenePressPos = originalPos - QPointF(10, 0); + QPoint p1 = scenePressPos.toPoint(); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, p1); + QVERIFY(!dragHandler->active()); + QCOMPARE(dragHandler->centroid().scenePosition(), scenePressPos); + QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); + p1 += QPoint(dragThreshold * 2, 0); + QTest::mouseMove(window, p1); + QTRY_VERIFY(dragHandler->active()); + QCOMPARE(dragHandler->centroid().scenePressPosition(), scenePressPos); + QCOMPARE(dragHandler->centroid().sceneGrabPosition(), p1); + QCOMPARE(dragHandler->translation().x(), 0.0); // hmm that's odd + QCOMPARE(dragHandler->translation().y(), 0.0); + QCOMPARE(draggableItem->position(), originalPos + QPointF(dragThreshold * 2, 0)); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, p1); + QTRY_VERIFY(!dragHandler->active()); + QCOMPARE(dragHandler->centroid().pressedButtons(), Qt::NoButton); +} + void tst_DragHandler::touchDragMulti() { const int dragThreshold = QGuiApplication::styleHints()->startDragDistance(); -- cgit v1.2.3 From 59410dd2f587945441791e76a5ac07acbe15989f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 10:07:40 +0200 Subject: Tests: Fix warnings about comparing signed/unsigned Fix warnings like: qtestcase.h: In instantiation of 'bool QTest::qCompare(const T1&, const T2&, const char*, const char*, const char*, int) [with T1 = unsigned int; T2 = int]': tst_qquickrectangle.cpp:137:1559: required from here qtestcase.h:423:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] Change-Id: I1039e70a2933f196266512a1f5880ee409c1548b Reviewed-by: Shawn Rutledge Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmlparser/tst_qqmlparser.cpp | 10 +++++----- tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp | 4 ++-- tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp index 71dd900073..fead8c4ebc 100644 --- a/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp +++ b/tests/auto/qml/qqmlparser/tst_qqmlparser.cpp @@ -234,8 +234,8 @@ void tst_qqmlparser::stringLiteral() auto *literal = QQmlJS::AST::cast(expression); QVERIFY(literal); QCOMPARE(literal->value, "hello string"); - QCOMPARE(literal->firstSourceLocation().begin(), 0); - QCOMPARE(literal->lastSourceLocation().end(), code.size()); + QCOMPARE(literal->firstSourceLocation().begin(), 0u); + QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size())); } void tst_qqmlparser::noSubstitutionTemplateLiteral() @@ -255,8 +255,8 @@ void tst_qqmlparser::noSubstitutionTemplateLiteral() QVERIFY(literal); QCOMPARE(literal->value, "hello template"); - QCOMPARE(literal->firstSourceLocation().begin(), 0); - QCOMPARE(literal->lastSourceLocation().end(), code.size()); + QCOMPARE(literal->firstSourceLocation().begin(), 0u); + QCOMPARE(literal->lastSourceLocation().end(), quint32(code.size())); } void tst_qqmlparser::templateLiteral() @@ -275,7 +275,7 @@ void tst_qqmlparser::templateLiteral() auto *templateLiteral = QQmlJS::AST::cast(expression); QVERIFY(templateLiteral); - QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0); + QCOMPARE(templateLiteral->firstSourceLocation().begin(), 0u); auto *e = templateLiteral->expression; QVERIFY(e); } diff --git a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp index 095943cdc7..308fba9049 100644 --- a/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp +++ b/tests/auto/qml/qv4identifiertable/tst_qv4identifiertable.cpp @@ -67,8 +67,8 @@ void tst_qv4identifiertable::sweepFirstEntryInBucket() table.asPropertyKey(entry2); table.asPropertyKey(entry3); - QCOMPARE(table.size, 3); - QCOMPARE(table.alloc, 5); + QCOMPARE(table.size, 3u); + QCOMPARE(table.alloc, 5u); QCOMPARE(table.entriesByHash[0], entry1); QCOMPARE(table.entriesByHash[1], entry2); diff --git a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp index 832b973d96..710caaa734 100644 --- a/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp +++ b/tests/auto/quick/qquickrectangle/tst_qquickrectangle.cpp @@ -134,7 +134,7 @@ void tst_qquickrectangle::gradient_separate() // Start off clean QQuickItemPrivate *rectPriv = QQuickItemPrivate::get(rect); - QTRY_COMPARE(rectPriv->dirtyAttributes & QQuickItemPrivate::Content, 0); + QTRY_COMPARE(rectPriv->dirtyAttributes & QQuickItemPrivate::Content, 0u); QMetaObject::invokeMethod(rect, "changeGradient"); -- cgit v1.2.3 From 5a5441f38e0529d852536b776cd9f26dad410e62 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 10:03:49 +0200 Subject: Tests: Fix warnings about ignoring return value of QTest::qWaitForWindowExposed() Fix warnings like: ../shared/particlestestsshared.h: In function 'QQuickView* createView(const QUrl&, int)': ../shared/particlestestsshared.h:64:33: warning: ignoring return value of 'bool QTest::qWaitForWindowExposed(QWindow*, int)', declared with attribute nodiscard [-Wunused-result] by checking the return and adding some handling. Change-Id: I1390f9738430042fcc45e243567a9d5a4f632a6d Reviewed-by: Qt CI Bot Reviewed-by: Ulf Hermann --- tests/auto/particles/shared/particlestestsshared.h | 11 +++++++---- .../qquickhoverhandler/tst_qquickhoverhandler.cpp | 2 +- tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp | 13 ++++++++++--- .../tst_qquickmultipointtoucharea.cpp | 10 ++++++---- 4 files changed, 24 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/auto/particles/shared/particlestestsshared.h b/tests/auto/particles/shared/particlestestsshared.h index 5ef1d2cabb..e1fc6f4ccd 100644 --- a/tests/auto/particles/shared/particlestestsshared.h +++ b/tests/auto/particles/shared/particlestestsshared.h @@ -31,6 +31,8 @@ #include #include #include +#include + const qreal EPSILON = 0.0001; bool extremelyFuzzyCompare(qreal a, qreal b, qreal e)//For cases which can have larger variances @@ -55,17 +57,18 @@ bool myFuzzyGEQ(qreal a, qreal b) QQuickView* createView(const QUrl &filename, int additionalWait=0) { - QQuickView *view = new QQuickView(0); + QScopedPointer view(new QQuickView(nullptr)); view->setSource(filename); if (view->status() != QQuickView::Ready) - return 0; + return nullptr; view->show(); - QTest::qWaitForWindowExposed(view); + if (!QTest::qWaitForWindowExposed(view.data())) + return nullptr; if (additionalWait) QTest::qWait(additionalWait); - return view; + return view.take(); } void ensureAnimTime(int requiredTime, QAbstractAnimation* anim)//With consistentTiming, who knows how long an animation really takes... diff --git a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp index f141a2546c..575139f851 100644 --- a/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp +++ b/tests/auto/quick/pointerhandlers/qquickhoverhandler/tst_qquickhoverhandler.cpp @@ -252,7 +252,7 @@ void tst_HoverHandler::movingItemWithHoverHandler() QTRY_COMPARE(window->isVisible(), false); QCursor::setPos(paddlePos); window->show(); - QTest::qWaitForWindowExposed(window); + QVERIFY(QTest::qWaitForWindowExposed(window)); QTRY_COMPARE(paddleHH->isHovered(), true); diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 1a289a2087..2f90632841 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -51,9 +51,8 @@ public: view.setSource(testFileUrl(fileName)); view.showNormal(); - QTest::qWaitForWindowExposed(&view); - - return view.grabWindow(); + return QTest::qWaitForWindowExposed(&view) + ? view.grabWindow() : QImage(); } private slots: @@ -153,6 +152,7 @@ void tst_QQuickItemLayer::layerSmooth() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("Smooth.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0, 0xff)); @@ -177,6 +177,7 @@ void tst_QQuickItemLayer::layerEnabled() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("Enabled.qml"); + QVERIFY(!fb.size().isEmpty()); // Verify the banding QCOMPARE(fb.pixel(0, 0), fb.pixel(0, 1)); // Verify the gradient @@ -212,6 +213,7 @@ void tst_QQuickItemLayer::layerEffect() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("Effect.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); } @@ -229,6 +231,7 @@ void tst_QQuickItemLayer::layerSourceRect() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("SourceRect.qml"); + QVERIFY(!fb.size().isEmpty()); // Check that the edges are converted to blue QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); @@ -253,6 +256,7 @@ void tst_QQuickItemLayer::layerIsTextureProvider() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("TextureProvider.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(fb.width() - 1, 0), qRgb(0, 0xff, 0)); } @@ -448,6 +452,7 @@ void tst_QQuickItemLayer::changeSamplerName() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("SamplerNameChange.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff)); } @@ -459,6 +464,7 @@ void tst_QQuickItemLayer::itemEffect() QSKIP("Only OpenGL Renderer supports GLSL ShaderEffects"); QImage fb = runTest("ItemEffect.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0)); QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff)); @@ -472,6 +478,7 @@ void tst_QQuickItemLayer::rectangleEffect() QSKIP("Skipping due to grabWindow not functional on offscreen/minimimal platforms"); QImage fb = runTest("RectangleEffect.qml"); + QVERIFY(!fb.size().isEmpty()); QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0)); QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0)); QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0)); diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index d4ad282701..cd66fc4ede 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -1145,16 +1145,18 @@ void tst_QQuickMultiPointTouchArea::transformedTouchArea() QQuickView *tst_QQuickMultiPointTouchArea::createAndShowView(const QString &file) { - QQuickView *window = new QQuickView(nullptr); + QScopedPointer window(new QQuickView(nullptr)); window->setSource(testFileUrl(file)); + if (window->status() != QQuickView::Ready) + return nullptr; const QRect screenGeometry = window->screen()->availableGeometry(); const QSize size = window->size(); const QPoint offset = QPoint(size.width() / 2, size.height() / 2); window->setFramePosition(screenGeometry.center() - offset); window->show(); - QTest::qWaitForWindowExposed(window); - - return window; + if (!QTest::qWaitForWindowExposed(window.data())) + return nullptr; + return window.take(); } void tst_QQuickMultiPointTouchArea::mouseInteraction_data() -- cgit v1.2.3 From 78787011651692b64bef19f6bec03d0dbf390e18 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 8 Apr 2019 14:45:23 +0200 Subject: Avoid INT_MIN % -1 and INT_MIN / -1 Those throw arithmetic exceptions as the result doesn't fit into an integer. Fixes: QTBUG-75030 Change-Id: Ibd978848f42cf1c9da1e4af2dc9d7da123ef8f5a Reviewed-by: Simon Hausmann --- tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index d8784f4855..0e8844d23f 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -366,6 +366,7 @@ private slots: void tailCallWithArguments(); void deleteSparseInIteration(); void saveAccumulatorBeforeToInt32(); + void intMinDividedByMinusOne(); private: // static void propertyVarWeakRefCallback(v8::Persistent object, void* parameter); @@ -8941,6 +8942,22 @@ void tst_qqmlecmascript::saveAccumulatorBeforeToInt32() QCOMPARE(value.toString(), QLatin1String("RangeError: Maximum call stack size exceeded.")); } +void tst_qqmlecmascript::intMinDividedByMinusOne() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData(QByteArray("import QtQml 2.2\n" + "QtObject {\n" + " property int intMin: -2147483648\n" + " property int minusOne: -1\n" + " property double doesNotFitInInt: intMin / minusOne\n" + "}"), QUrl()); + QVERIFY(component.isReady()); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + QCOMPARE(object->property("doesNotFitInInt").toUInt(), 2147483648u); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" -- cgit v1.2.3