diff options
Diffstat (limited to 'tests/auto/quick')
11 files changed, 274 insertions, 3 deletions
diff --git a/tests/auto/quick/qquickloader/data/noEngine.qml b/tests/auto/quick/qquickloader/data/noEngine.qml new file mode 100644 index 0000000000..19e619f32e --- /dev/null +++ b/tests/auto/quick/qquickloader/data/noEngine.qml @@ -0,0 +1,32 @@ +import QtQuick 2 + +Item { + id: root + property bool a: false + property int changes: 0 + onAChanged: { + m.model = 0 + m.model = 1 + ++changes; + } + + Repeater { + id: m + model: 1 + + Item { + Timer { + onTriggered: { + root.a = true + l.source = "loaded.qml" + } + interval: 0 + running: true + } + + Loader { + id: l + } + } + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index dddacbaa0b..db678ae5a1 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -133,6 +133,7 @@ private slots: void setSourceAndCheckStatus(); void asyncLoaderRace(); + void noEngine(); }; Q_DECLARE_METATYPE(QList<QQmlError>) @@ -1515,6 +1516,20 @@ void tst_QQuickLoader::asyncLoaderRace() QCOMPARE(loader->item(), nullptr); } +void tst_QQuickLoader::noEngine() +{ + QQmlEngine engine; + const QUrl url = testFileUrl("noEngine.qml"); + QQmlComponent component(&engine, url); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + QScopedPointer<QObject> o(component.create()); + + const QString message = url.toString() + + QStringLiteral(":27:13: QML Loader: createComponent: Cannot find a QML engine."); + QTest::ignoreMessage(QtWarningMsg, qPrintable(message)); + QTRY_COMPARE(o->property("changes").toInt(), 1); +} + QTEST_MAIN(tst_QQuickLoader) #include "tst_qquickloader.moc" diff --git a/tests/auto/quick/qquickmousearea/data/doubleClickToHide.qml b/tests/auto/quick/qquickmousearea/data/doubleClickToHide.qml new file mode 100644 index 0000000000..01f6eaabed --- /dev/null +++ b/tests/auto/quick/qquickmousearea/data/doubleClickToHide.qml @@ -0,0 +1,19 @@ +import QtQuick 2.0 + +Item { + id: root + property int clicked: 0 + property int doubleClicked: 0 + property int released: 0 + + MouseArea { + width: 200; height: 200 + onClicked: { root.clicked++ } + onDoubleClicked: { + root.doubleClicked++ + visible = false + } + onReleased: { root.released++ } + } +} + diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp index 1c99357ab7..27fee2aab3 100644 --- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp +++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp @@ -161,6 +161,7 @@ private slots: void nestedEventDelivery(); void settingHiddenInPressUngrabs(); void containsMouseAndVisibility(); + void doubleClickToHide(); private: int startDragDistance() const { @@ -2500,6 +2501,33 @@ void tst_QQuickMouseArea::containsMouseAndVisibility() QVERIFY(!mouseArea->hovered()); } +// QTBUG-35995 and QTBUG-102158 +void tst_QQuickMouseArea::doubleClickToHide() +{ + QQuickView window; + QByteArray errorMessage; + QVERIFY2(QQuickTest::initView(window, testFileUrl("doubleClickToHide.qml"), true, &errorMessage), errorMessage.constData()); + window.show(); + window.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + QQuickMouseArea *mouseArea = window.rootObject()->findChild<QQuickMouseArea *>(); + QVERIFY(mouseArea); + + QTest::mouseDClick(&window, Qt::LeftButton, Qt::NoModifier, {10, 10}); + + QCOMPARE(window.rootObject()->property("clicked").toInt(), 1); + QCOMPARE(window.rootObject()->property("doubleClicked").toInt(), 1); + QCOMPARE(mouseArea->isVisible(), false); + QCOMPARE(mouseArea->pressed(), false); + QCOMPARE(mouseArea->pressedButtons(), Qt::NoButton); + + mouseArea->setVisible(true); + + QTest::mouseClick(&window, Qt::LeftButton, Qt::NoModifier, {10, 10}); + QCOMPARE(window.rootObject()->property("clicked").toInt(), 2); +} + QTEST_MAIN(tst_QQuickMouseArea) #include "tst_qquickmousearea.moc" diff --git a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST index cfbd47d3dc..db8595544b 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST +++ b/tests/auto/quick/qquickmultipointtoucharea/BLACKLIST @@ -1,6 +1,6 @@ [nonOverlapping] # QTBUG-101499 -ubuntu-20 +ubuntu-20.04 ubuntu-16.04 ubuntu-18.04 opensuse-42.3 @@ -8,7 +8,7 @@ opensuse-leap sles [nested] # QTBUG-101499 -ubuntu-20 +ubuntu-20.04 ubuntu-16.04 ubuntu-18.04 opensuse-42.3 diff --git a/tests/auto/quick/qquickmultipointtoucharea/data/nestedPinchArea.qml b/tests/auto/quick/qquickmultipointtoucharea/data/nestedPinchArea.qml new file mode 100644 index 0000000000..0e51804b30 --- /dev/null +++ b/tests/auto/quick/qquickmultipointtoucharea/data/nestedPinchArea.qml @@ -0,0 +1,44 @@ +import QtQuick 2.15 + +MultiPointTouchArea { + width: 240 + height: 320 + mouseEnabled: true + property int pressedCount: 0 + property int updatedCount: 0 + property int releasedCount: 0 + + onPressed: (points) => { pressedCount = points.length } + onUpdated: (points) => { updatedCount = points.length } + onReleased: (points) => { releasedCount = points.length } + + touchPoints: [ + TouchPoint { + id: point1 + objectName: "point1" + }, + TouchPoint { + id: point2 + objectName: "point2" + } + ] + + PinchArea { + anchors.fill: parent + } + + Rectangle { + width: 30; height: 30 + color: "green" + x: point1.x + y: point1.y + } + + Rectangle { + id: rectangle + width: 30; height: 30 + color: "yellow" + x: point2.x + y: point2.y + } +} diff --git a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp index c18a220996..a9d557915a 100644 --- a/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp +++ b/tests/auto/quick/qquickmultipointtoucharea/tst_qquickmultipointtoucharea.cpp @@ -77,6 +77,7 @@ private slots: void mouseGestureStarted(); void cancel(); void stationaryTouchWithChangingPressure(); + void nestedPinchAreaMouse(); private: QQuickView *createAndShowView(const QString &file); @@ -1408,6 +1409,53 @@ void tst_QQuickMultiPointTouchArea::stationaryTouchWithChangingPressure() // QTB QCOMPARE(point1->pressure(), 0); } +void tst_QQuickMultiPointTouchArea::nestedPinchAreaMouse() +{ + QScopedPointer<QQuickView> window(createAndShowView("nestedPinchArea.qml")); + QQuickMultiPointTouchArea *mpta = qobject_cast<QQuickMultiPointTouchArea *>(window->rootObject()); + QVERIFY(mpta); + + QQuickTouchPoint *point1 = mpta->findChild<QQuickTouchPoint*>("point1"); + QCOMPARE(point1->pressed(), false); + QQuickTouchPoint *point2 = mpta->findChild<QQuickTouchPoint*>("point2"); + QCOMPARE(point2->pressed(), false); + QSignalSpy pressedSpy(mpta, &QQuickMultiPointTouchArea::pressed); + QSignalSpy updatedSpy(mpta, &QQuickMultiPointTouchArea::updated); + QSignalSpy releasedSpy(mpta, &QQuickMultiPointTouchArea::released); + + QPoint p1(20, 20); + QTest::mousePress(window.data(), Qt::LeftButton, Qt::NoModifier, p1); + QCOMPARE(point1->pressed(), true); + QCOMPARE(point2->pressed(), false); + QCOMPARE(pressedSpy.count(), 1); + QCOMPARE(mpta->property("pressedCount").toInt(), 1); + QCOMPARE(updatedSpy.count(), 0); + QCOMPARE(mpta->property("updatedCount").toInt(), 0); + QCOMPARE(releasedSpy.count(), 0); + QCOMPARE(mpta->property("releasedCount").toInt(), 0); + + p1 += QPoint(0, 15); + QTest::mouseMove(window.data(), p1); + QCOMPARE(point1->pressed(), true); + QCOMPARE(point2->pressed(), false); + QCOMPARE(pressedSpy.count(), 1); + QCOMPARE(mpta->property("pressedCount").toInt(), 1); + QCOMPARE(updatedSpy.count(), 1); + QCOMPARE(mpta->property("updatedCount").toInt(), 1); + QCOMPARE(releasedSpy.count(), 0); + QCOMPARE(mpta->property("releasedCount").toInt(), 0); + + QTest::mouseRelease(window.data(), Qt::LeftButton, Qt::NoModifier, p1); + QCOMPARE(point1->pressed(), false); + QCOMPARE(point2->pressed(), false); + QCOMPARE(pressedSpy.count(), 1); + QCOMPARE(mpta->property("pressedCount").toInt(), 1); + QCOMPARE(updatedSpy.count(), 1); + QCOMPARE(mpta->property("updatedCount").toInt(), 1); + QCOMPARE(releasedSpy.count(), 1); + QCOMPARE(mpta->property("releasedCount").toInt(), 1); +} + QTEST_MAIN(tst_QQuickMultiPointTouchArea) diff --git a/tests/auto/quick/qquicktext/data/fontSizeMode.qml b/tests/auto/quick/qquicktext/data/fontSizeMode.qml index 48e7c7b6d0..d5e794824f 100644 --- a/tests/auto/quick/qquicktext/data/fontSizeMode.qml +++ b/tests/auto/quick/qquicktext/data/fontSizeMode.qml @@ -16,7 +16,7 @@ Item { height: 35 minimumPointSize: 8 minimumPixelSize: 8 - font.pixelSize: 25 + font.pixelSize: 23 font.family: "Helvetica" } } diff --git a/tests/auto/quick/qquicktext/data/padding.qml b/tests/auto/quick/qquicktext/data/padding.qml index ab0a37d041..f830af0e40 100644 --- a/tests/auto/quick/qquicktext/data/padding.qml +++ b/tests/auto/quick/qquicktext/data/padding.qml @@ -9,4 +9,30 @@ Text { leftPadding: 30 rightPadding: 40 bottomPadding: 50 + + Rectangle { + width: parent.leftPadding + height: parent.height + color: "#6600FF00" + } + + Rectangle { + width: parent.width + height: parent.topPadding + color: "#66888800" + } + + Rectangle { + x: parent.width - parent.rightPadding + width: parent.rightPadding + height: parent.height + color: "#6600FFFF" + } + + Rectangle { + y: parent.height - parent.bottomPadding + width: parent.width + height: parent.bottomPadding + color: "#66880088" + } } diff --git a/tests/auto/quick/qquicktext/data/paddingInLoader.qml b/tests/auto/quick/qquicktext/data/paddingInLoader.qml new file mode 100644 index 0000000000..6ef7c25a9b --- /dev/null +++ b/tests/auto/quick/qquicktext/data/paddingInLoader.qml @@ -0,0 +1,14 @@ +import QtQuick 2.12 + +Item { + width: 30 + height: 30 + Loader { + anchors.fill: parent + sourceComponent: Text { + rightPadding: 30 + text: "Some text" + elide: Text.ElideRight + } + } +} diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index fe3f696dfa..ff191bbc7f 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -55,6 +55,8 @@ QT_BEGIN_NAMESPACE extern void qt_setQtEnableTestFont(bool value); QT_END_NAMESPACE +Q_LOGGING_CATEGORY(lcTests, "qt.quick.tests") + class tst_qquicktext : public QQmlDataTest { Q_OBJECT @@ -153,6 +155,7 @@ private slots: void growFromZeroWidth(); void padding(); + void paddingInLoader(); void hintingPreference(); @@ -4342,6 +4345,20 @@ void tst_qquicktext::padding() obj->setElideMode(QQuickText::ElideRight); QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding()); QCOMPARE(obj->implicitHeight(), ch + obj->topPadding() + obj->bottomPadding()); + + obj->setLeftPadding(0); + QCOMPARE(obj->implicitWidth(), cw + obj->leftPadding() + obj->rightPadding()); + + obj->setWidth(cw); + obj->setRightPadding(cw); + QCOMPARE(obj->contentWidth(), 0); + + for (int incr = 1; incr < 50 && qFuzzyIsNull(obj->contentWidth()); ++incr) + obj->setWidth(cw + incr); + QVERIFY(obj->contentWidth() > 0); + qCDebug(lcTests) << "increasing Text width from" << cw << "to" << obj->width() + << "rendered a character: contentWidth now" << obj->contentWidth(); + obj->setElideMode(QQuickText::ElideNone); obj->resetWidth(); @@ -4386,6 +4403,34 @@ void tst_qquicktext::padding() delete root; } +void tst_qquicktext::paddingInLoader() // QTBUG-83413 +{ + QQuickView view(testFileUrl("paddingInLoader.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QQuickText *qtext = view.rootObject()->findChild<QQuickText*>(); + QVERIFY(qtext); + QQuickTextPrivate *textPrivate = QQuickTextPrivate::get(qtext); + QVERIFY(textPrivate); + QCOMPARE(qtext->contentWidth(), 0); // does not render text, because width == rightPadding + QCOMPARE(textPrivate->availableWidth(), 0); + + qtext->setLeftPadding(qtext->width()); + qtext->setRightPadding(0); + QCOMPARE(qtext->contentWidth(), 0); // does not render text, because width == leftPadding + QCOMPARE(textPrivate->availableWidth(), 0); + + qtext->setRightPadding(qtext->width()); + QCOMPARE(qtext->contentWidth(), 0); // does not render text: available space is negative + QCOMPARE(textPrivate->availableWidth(), -qtext->width()); + + qtext->setLeftPadding(2); + qtext->setRightPadding(2); + QVERIFY(qtext->contentWidth() > 0); // finally space is available to render text + QCOMPARE(textPrivate->availableWidth(), qtext->width() - 4); +} + void tst_qquicktext::hintingPreference() { { |