diff options
Diffstat (limited to 'tests/auto/quick')
24 files changed, 555 insertions, 361 deletions
diff --git a/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro index 85f71bb605..a337473d99 100644 --- a/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro +++ b/tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro @@ -8,7 +8,7 @@ macx:CONFIG -= app_bundle TESTDATA = data/* -QT += core-private gui-private qml-private quick-private network testlib +QT += core-private gui-private qml-private quick-private network testlib qmltest OTHER_FILES += \ $$files(data/*.qml) diff --git a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp index 4ca31fd957..d2bbf9e6b1 100644 --- a/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp +++ b/tests/auto/quick/qquickanimatedsprite/tst_qquickanimatedsprite.cpp @@ -28,6 +28,7 @@ #include <QtTest/QtTest> #include "../../shared/util.h" #include <QtQuick/qquickview.h> +#include <QtQuickTest/QtQuickTest> #include <private/qabstractanimation_p.h> #include <private/qquickanimatedsprite_p.h> #include <private/qquickitem_p.h> @@ -290,8 +291,8 @@ void tst_qquickanimatedsprite::test_reparenting() sprite->setParentItem(window.rootObject()); // don't crash (QTBUG-51162) sprite->polish(); - QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, true); - QTRY_COMPARE(QQuickItemPrivate::get(sprite)->polishScheduled, false); + QVERIFY(QQuickTest::qIsPolishScheduled(sprite)); + QVERIFY(QQuickTest::qWaitForItemPolished(sprite)); } class KillerThread : public QThread diff --git a/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml b/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml index 09983645ef..0ac7f87c42 100644 --- a/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml +++ b/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml @@ -5,6 +5,7 @@ Item { property bool someValue Behavior on someValue { + objectName: "behavior" ScriptAction { script: { parent.behaviorTriggered = true }} } } diff --git a/tests/auto/quick/qquickbehaviors/data/aliased.qml b/tests/auto/quick/qquickbehaviors/data/aliased.qml index e65e035d83..1840cdd22e 100644 --- a/tests/auto/quick/qquickbehaviors/data/aliased.qml +++ b/tests/auto/quick/qquickbehaviors/data/aliased.qml @@ -17,6 +17,7 @@ Rectangle { anchors.fill: parent value: accelerating ? 400 : 0 Behavior on value { + objectName: "behavior" NumberAnimation { duration: 500 } diff --git a/tests/auto/quick/qquickbehaviors/data/oneway.qml b/tests/auto/quick/qquickbehaviors/data/oneway.qml new file mode 100644 index 0000000000..0b438b80f6 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/oneway.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRectOneWay" + width: 100; height: 100; color: "green" + Behavior on x { + id: behavior + objectName: "MyBehaviorOneWay"; + enabled: (behavior.targetValue === 0) + NumberAnimation { + id: ani + objectName: "MyAnimationOneWay"; + duration: 200; + } + } + } +} diff --git a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro index 51bc42c390..fd64eb1d40 100644 --- a/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro +++ b/tests/auto/quick/qquickbehaviors/qquickbehaviors.pro @@ -7,5 +7,5 @@ include (../../shared/util.pri) macx:CONFIG -= app_bundle TESTDATA = data/* - +DISTFILES = $$files(data/*) QT += core-private gui-private qml-private quick-private testlib diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index fa9eba095d..6367f327da 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -73,6 +73,7 @@ private slots: void disabledWriteWhileRunning(); void aliasedProperty(); void innerBehaviorOverwritten(); + void oneWay(); }; void tst_qquickbehaviors::simpleBehavior() @@ -516,6 +517,7 @@ void tst_qquickbehaviors::disabledWriteWhileRunning() myRect->setProperty("x", 200); QCOMPARE(myAnimation->isRunning(), true); QTRY_VERIFY(myRect->x() != qreal(0) && myRect->x() != qreal(200)); + QCOMPARE(myBehavior->targetValue(), 200); // grabbed before starting the animation // set disabled while animation is in progress myBehavior->setProperty("enabled", false); @@ -526,6 +528,7 @@ void tst_qquickbehaviors::disabledWriteWhileRunning() myRect->setProperty("x", 100); QCOMPARE(myAnimation->isRunning(), false); QCOMPARE(myRect->x(), qreal(100)); + QCOMPARE(myBehavior->targetValue(), 100); QTest::qWait(200); QCOMPARE(myRect->x(), qreal(100)); } @@ -546,17 +549,20 @@ void tst_qquickbehaviors::disabledWriteWhileRunning() // initial values QCOMPARE(myBehavior->enabled(), true); + QCOMPARE(myBehavior->targetValue(), QVariant()); QCOMPARE(myAnimation->isRunning(), false); QCOMPARE(myRect->x(), qreal(0)); // start animation myRect->setProperty("x", 200); QCOMPARE(myAnimation->isRunning(), true); + QCOMPARE(myBehavior->targetValue(), 200); QTRY_VERIFY(myRect->x() != qreal(0) && myRect->x() != qreal(200)); //set second value myRect->setProperty("x", 300); QCOMPARE(myAnimation->isRunning(), true); + QCOMPARE(myBehavior->targetValue(), 300); QTRY_VERIFY(myRect->x() != qreal(0) && myRect->x() != qreal(200)); // set disabled while animation is in progress @@ -568,6 +574,7 @@ void tst_qquickbehaviors::disabledWriteWhileRunning() myRect->setProperty("x", 100); QCOMPARE(myAnimation->isRunning(), false); QCOMPARE(myRect->x(), qreal(100)); + QCOMPARE(myBehavior->targetValue(), 100); QTest::qWait(200); QCOMPARE(myRect->x(), qreal(100)); } @@ -580,7 +587,12 @@ void tst_qquickbehaviors::aliasedProperty() QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create())); QVERIFY2(!rect.isNull(), qPrintable(c.errorString())); + QQuickBehavior* behavior = + qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("behavior")); + QSignalSpy targetValueSpy(behavior, SIGNAL(targetValueChanged())); QQuickItemPrivate::get(rect.data())->setState("moved"); + QCOMPARE(behavior->targetValue(), 400); + QCOMPARE(targetValueSpy.count(), 1); QScopedPointer<QQuickRectangle> acc(qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("acc"))); QScopedPointer<QQuickRectangle> range(qobject_cast<QQuickRectangle*>(acc->findChild<QQuickRectangle*>("range"))); QTRY_VERIFY(acc->property("value").toDouble() > 0); @@ -595,7 +607,44 @@ void tst_qquickbehaviors::innerBehaviorOverwritten() QQmlEngine engine; QQmlComponent c(&engine, testFileUrl("overwrittenbehavior.qml")); QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create())); + QQuickBehavior* behavior = + qobject_cast<QQuickBehavior*>(item->findChild<QQuickBehavior*>("behavior")); QVERIFY(item->property("behaviorTriggered").toBool()); + QCOMPARE(behavior->targetValue(), true); +} + +void tst_qquickbehaviors::oneWay() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("oneway.qml")); + QScopedPointer<QQuickRectangle> rect(qobject_cast<QQuickRectangle*>(c.create()));; + QVERIFY2(!rect.isNull(), qPrintable(c.errorString())); + QQuickBehavior* behavior = + qobject_cast<QQuickBehavior*>(rect->findChild<QQuickBehavior*>("MyBehaviorOneWay")); + QCOMPARE(behavior->enabled(), false); + QCOMPARE(behavior->targetValue(), QVariant()); + + QSignalSpy targetValueSpy(behavior, SIGNAL(targetValueChanged())); + QQuickRectangle *myRect = qobject_cast<QQuickRectangle*>(rect->findChild<QQuickRectangle*>("MyRectOneWay")); + myRect->setProperty("x", 100); + QCOMPARE(behavior->targetValue(), 100); + QCOMPARE(targetValueSpy.count(), 1); + QCOMPARE(behavior->enabled(), false); + qreal x = myRect->x(); + QCOMPARE(x, qreal(100)); //should change immediately + QQuickNumberAnimation *myAnimation = + qobject_cast<QQuickNumberAnimation*>(behavior->findChild<QQuickNumberAnimation*>("MyAnimationOneWay")); + QCOMPARE(myAnimation->isRunning(), false); + + myRect->setProperty("x", 0); + QCOMPARE(behavior->targetValue(), 0); + QCOMPARE(targetValueSpy.count(), 2); + QCOMPARE(behavior->enabled(), true); + QCOMPARE(myAnimation->isRunning(), true); + QVERIFY(myRect->x() > 0.0); + QTRY_VERIFY(myRect->x() < 100.0); + QTRY_COMPARE(myRect->x(), qreal(0)); + QCOMPARE(myAnimation->isRunning(), false); } QTEST_MAIN(tst_qquickbehaviors) diff --git a/tests/auto/quick/qquickgridview/qquickgridview.pro b/tests/auto/quick/qquickgridview/qquickgridview.pro index 3c33cc78fb..5051f8bc62 100644 --- a/tests/auto/quick/qquickgridview/qquickgridview.pro +++ b/tests/auto/quick/qquickgridview/qquickgridview.pro @@ -10,5 +10,5 @@ include (../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib qmltest diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 301ec43cb5..3b704d7fa4 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -29,6 +29,7 @@ #include <QtTest/QtTest> #include <QtCore/qstringlistmodel.h> #include <QtQuick/qquickview.h> +#include <QtQuickTest/QtQuickTest> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <QtQml/qqmlcontext.h> @@ -535,7 +536,7 @@ void tst_QQuickGridView::inserted_defaultLayout(QQuickGridView::Flow flow, insertCount = insertCount_ttb; } if (setContentPos(gridview, contentYRowOffset)) - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QList<QPair<QString, QString> > newData; for (int i=0; i<insertCount; i++) @@ -721,13 +722,13 @@ void tst_QQuickGridView::insertBeforeVisible() QTRY_VERIFY(contentItem != nullptr); gridview->setCacheBuffer(cacheBuffer); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // trigger a refill (not just setting contentY) so that the visibleItems grid is updated int firstVisibleIndex = 12; // move to an index where the top item is not visible gridview->setContentY(firstVisibleIndex/3 * 60.0); gridview->setCurrentIndex(firstVisibleIndex); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QTRY_COMPARE(gridview->currentIndex(), firstVisibleIndex); QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex); @@ -744,7 +745,7 @@ void tst_QQuickGridView::insertBeforeVisible() // now, moving to the top of the view should position the inserted items correctly int itemsOffsetAfterMove = (insertCount / 3) * -60.0; gridview->setCurrentIndex(0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QTRY_COMPARE(gridview->currentIndex(), 0); QTRY_COMPARE(gridview->contentY(), 0.0 + itemsOffsetAfterMove); @@ -803,7 +804,7 @@ void tst_QQuickGridView::removed_basic() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.removeItem(1); QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); @@ -890,7 +891,7 @@ void tst_QQuickGridView::removed_basic() QTRY_VERIFY(gridview->currentItem() != oldCurrent); gridview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // Confirm items positioned correctly itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -966,7 +967,7 @@ void tst_QQuickGridView::removed_defaultLayout(QQuickGridView::Flow flow, firstVisible = firstVisible_ttb; } if (setContentPos(gridview, contentYRowOffset)) - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.removeItems(removeIndex, removeCount); gridview->forceLayout(); @@ -1182,7 +1183,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible() gridview->setCurrentIndex(0); qApp->processEvents(); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // scroll down until item 0 is no longer drawn // (bug not triggered if we just move using content y, since that doesn't @@ -1193,7 +1194,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible() QTRY_COMPARE(gridview->currentIndex(), 24); QTRY_COMPARE(gridview->contentY(), 220.0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QTRY_VERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 0)); // 0 shouldn't be visible if (doAdd) { @@ -1254,7 +1255,7 @@ void tst_QQuickGridView::clear() QVERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.clear(); gridview->forceLayout(); @@ -1307,7 +1308,7 @@ void tst_QQuickGridView::moved_defaultLayout(QQuickGridView::Flow flow, QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *currentItem = gridview->currentItem(); QTRY_VERIFY(currentItem != nullptr); @@ -1318,10 +1319,10 @@ void tst_QQuickGridView::moved_defaultLayout(QQuickGridView::Flow flow, count = count_ttb; } if (setContentPos(gridview, contentYRowOffset)) - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.moveItems(from, to, count); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // Confirm items positioned correctly and indexes correct QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); @@ -1560,7 +1561,7 @@ void tst_QQuickGridView::multipleChanges(bool condensed) QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid"); QTRY_VERIFY(gridview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); for (int i=0; i<changes.count(); i++) { switch (changes[i].type) { @@ -1588,10 +1589,10 @@ void tst_QQuickGridView::multipleChanges(bool condensed) break; } if (condensed) { - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); } } - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QCOMPARE(gridview->count(), newCount); QCOMPARE(gridview->count(), model.count()); @@ -1834,7 +1835,7 @@ void tst_QQuickGridView::currentIndex() QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid"); QVERIFY(gridview != nullptr); - QTRY_VERIFY(!QQuickItemPrivate::get(gridview)->polishScheduled); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); @@ -1936,7 +1937,7 @@ void tst_QQuickGridView::noCurrentIndex() QVERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // current index should be -1 QCOMPARE(gridview->currentIndex(), -1); @@ -1981,7 +1982,7 @@ void tst_QQuickGridView::keyNavigation() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -2491,7 +2492,7 @@ void tst_QQuickGridView::positionViewAtBeginningEnd() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // positionViewAtBeginning gridview->setContentY(150); @@ -2578,10 +2579,10 @@ void tst_QQuickGridView::positionViewAtIndex() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); window->rootObject()->setProperty("enforceRange", enforceRange); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); if (topToBottom) gridview->setContentX(initContentPos); @@ -2791,7 +2792,7 @@ void tst_QQuickGridView::resetModel() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QTRY_COMPARE(gridview->count(), model.rowCount()); @@ -2840,7 +2841,7 @@ void tst_QQuickGridView::enforceRange() QTRY_COMPARE(gridview->preferredHighlightBegin(), 100.0); QTRY_COMPARE(gridview->preferredHighlightEnd(), 100.0); QTRY_COMPARE(gridview->highlightRangeMode(), QQuickGridView::StrictlyEnforceRange); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3023,7 +3024,7 @@ void tst_QQuickGridView::footer() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3272,7 +3273,7 @@ void tst_QQuickGridView::header() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3296,7 +3297,7 @@ void tst_QQuickGridView::header() QCOMPARE(item->position(), firstDelegatePos); model.clear(); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QCOMPARE(header->position(), initialHeaderPos); // header should stay where it is if (flow == QQuickGridView::FlowLeftToRight) QCOMPARE(gridview->contentHeight(), header->height()); @@ -3349,7 +3350,7 @@ void tst_QQuickGridView::header() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); gridview->setWidth(240); gridview->setHeight(320); @@ -3494,7 +3495,7 @@ void tst_QQuickGridView::extents() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3655,7 +3656,7 @@ void tst_QQuickGridView::resizeViewAndRepaint() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // item at index 10 should not be currently visible QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10)); @@ -3736,7 +3737,7 @@ void tst_QQuickGridView::resizeGrid() // items are aligned correctly in right-to-left window->rootObject()->setWidth(260); window->rootObject()->setHeight(320); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QCOMPARE(gridview->contentX(), initialContentPos.x()); QCOMPARE(gridview->contentY(), initialContentPos.y()); @@ -3760,7 +3761,7 @@ void tst_QQuickGridView::resizeGrid() // change from 3x5 grid to 4x7 window->rootObject()->setWidth(window->rootObject()->width() + 80); window->rootObject()->setHeight(window->rootObject()->height() + 60*2); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // other than in LeftToRight+RightToLeft layout, the first item should not move // if view is resized @@ -3865,7 +3866,7 @@ void tst_QQuickGridView::changeColumnCount() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); // a single column of 6 items are visible int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -3879,7 +3880,7 @@ void tst_QQuickGridView::changeColumnCount() // now 6x3 grid is visible, plus 1 extra below for refill gridview->setWidth(240); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); QCOMPARE(itemCount, 6*3 + 1); for (int i = 0; i < model.count() && i < itemCount; ++i) { @@ -3891,7 +3892,7 @@ void tst_QQuickGridView::changeColumnCount() // back to single column gridview->setWidth(100); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); QCOMPARE(itemCount, 6); for (int i = 0; i < model.count() && i < itemCount; ++i) { @@ -4139,7 +4140,7 @@ void tst_QQuickGridView::margins() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QCOMPARE(gridview->contentX(), -30.); QCOMPARE(gridview->originX(), 0.); @@ -4217,7 +4218,7 @@ void tst_QQuickGridView::margins() // remove item before visible and check that left margin is maintained // and originX is updated gridview->setContentX(-400); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.removeItems(0, 4); gridview->forceLayout(); QTRY_COMPARE(model.count(), gridview->count()); @@ -4259,7 +4260,7 @@ void tst_QQuickGridView::margins() QVERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QCOMPARE(contentItem->x(), 200); QCOMPARE(contentItem->y(), 20); @@ -4341,7 +4342,7 @@ void tst_QQuickGridView::snapToRow() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4461,7 +4462,7 @@ void tst_QQuickGridView::snapOneRow() gridview->setFlow(flow); gridview->setLayoutDirection(layoutDirection); gridview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QQuickItem *contentItem = gridview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4623,7 +4624,7 @@ void tst_QQuickGridView::populateTransitions() QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0); QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 18); } else { - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QCOMPARE(gridview->property("countPopulateTransitions").toInt(), 0); QCOMPARE(gridview->property("countAddTransitions").toInt(), 0); } @@ -4659,7 +4660,7 @@ void tst_QQuickGridView::populateTransitions() for (int i = 0; i < 30; i++) model.addItem("item" + QString::number(i), ""); window->rootContext()->setContextProperty("testModel", &model); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 18 : 0); QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); @@ -4747,11 +4748,11 @@ void tst_QQuickGridView::addTransitions() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); if (contentYRowOffset != 0) { gridview->setContentY(contentYRowOffset * 60.0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -4956,7 +4957,7 @@ void tst_QQuickGridView::moveTransitions() if (contentYRowOffset != 0) { gridview->setContentY(contentYRowOffset * 60.0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -5197,11 +5198,11 @@ void tst_QQuickGridView::removeTransitions() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); if (contentYRowOffset != 0) { gridview->setContentY(contentYRowOffset * 60.0); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -5415,7 +5416,7 @@ void tst_QQuickGridView::displacedTransitions() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); gridview->setProperty("displaceTransitionsDone", false); @@ -5436,7 +5437,7 @@ void tst_QQuickGridView::displacedTransitions() break; case ListChange::Moved: model.moveItems(change.index, change.to, change.count); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); break; case ListChange::SetCurrent: case ListChange::SetContentY: @@ -5634,11 +5635,11 @@ void tst_QQuickGridView::multipleTransitions() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); if (contentY != 0) { gridview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); } int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt(); @@ -5675,7 +5676,7 @@ void tst_QQuickGridView::multipleTransitions() case ListChange::Moved: model.moveItems(changes[i].index, changes[i].to, changes[i].count); gridview->forceLayout(); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); if (i == changes.count() - 1) { QTRY_VERIFY(!gridview->property("runningMoveTargets").toBool()); QTRY_VERIFY(!gridview->property("runningMoveDisplaced").toBool()); @@ -5685,12 +5686,12 @@ void tst_QQuickGridView::multipleTransitions() break; case ListChange::SetCurrent: gridview->setCurrentIndex(changes[i].index); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); gridview->forceLayout(); break; case ListChange::SetContentY: gridview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); gridview->forceLayout(); break; case ListChange::Polish: @@ -5804,7 +5805,7 @@ void tst_QQuickGridView::multipleDisplaced() QTRY_VERIFY(gridview != nullptr); QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.moveItems(12, 8, 1); QTest::qWait(window->rootObject()->property("duration").toInt() / 2); @@ -5854,7 +5855,7 @@ void tst_QQuickGridView::regression_QTBUG_57225() QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid"); QVERIFY(gridview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(gridview)); model.removeItems(removeIndex, removeCount); QTRY_VERIFY(gridview->property("animationDone").toBool()); @@ -6127,7 +6128,7 @@ void tst_QQuickGridView::unrequestedVisibility() // move a non-visible item into view model.moveItems(10, 9, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); QTRY_VERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 1)); QCOMPARE(delegateVisible(item), false); @@ -6150,7 +6151,7 @@ void tst_QQuickGridView::unrequestedVisibility() // move a visible item out of view model.moveItems(5, 3, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3)); QCOMPARE(delegateVisible(item), false); @@ -6163,7 +6164,7 @@ void tst_QQuickGridView::unrequestedVisibility() // move a non-visible item into view model.moveItems(3, 5, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3)); QCOMPARE(delegateVisible(item), false); @@ -6176,7 +6177,7 @@ void tst_QQuickGridView::unrequestedVisibility() // move a visible item out of view model.moveItems(9, 10, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3)); QCOMPARE(delegateVisible(item), false); @@ -6189,7 +6190,7 @@ void tst_QQuickGridView::unrequestedVisibility() // move a non-visible item into view model.moveItems(10, 9, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); QVERIFY(item = findItem<QQuickItem>(leftContent, "wrapper", 3)); QCOMPARE(delegateVisible(item), false); diff --git a/tests/auto/quick/qquicklistview/data/listview-itematindex.qml b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml new file mode 100644 index 0000000000..fba8b11933 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/listview-itematindex.qml @@ -0,0 +1,15 @@ +import QtQuick 2.0 + +ListView { + width: 400 + height: 400 + focus: true + model: 3 + + delegate: Text { + width: parent.width + height: 10 + property int idx: index + text: index + } +} diff --git a/tests/auto/quick/qquicklistview/qquicklistview.pro b/tests/auto/quick/qquicklistview/qquicklistview.pro index a95b6fdf33..fd96c269a2 100644 --- a/tests/auto/quick/qquicklistview/qquicklistview.pro +++ b/tests/auto/quick/qquicklistview/qquicklistview.pro @@ -16,6 +16,7 @@ include (../../shared/util.pri) include (../shared/util.pri) TESTDATA = data/* +DISTFILES += data/* -QT += core-private gui-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib qmltest diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index ff796a5bd8..d96590bdae 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -31,6 +31,7 @@ #include <QtCore/QSortFilterProxyModel> #include <QtGui/QStandardItemModel> #include <QtQuick/qquickview.h> +#include <QtQuickTest/QtQuickTest> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlexpression.h> @@ -165,6 +166,7 @@ private slots: void QTBUG_16037(); void indexAt_itemAt_data(); void indexAt_itemAt(); + void itemAtIndex(); void incrementalModel(); void onAdd(); void onAdd_data(); @@ -470,8 +472,7 @@ void tst_QQuickListView::items(const QUrl &source) // Force a layout, necessary if ListView is completed before DelegateModel. listview->forceLayout(); - int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); - QTRY_COMPARE(itemCount, 0); + QTRY_VERIFY(findItems<QQuickItem>(contentItem, "wrapper").isEmpty()); QTRY_COMPARE(listview->highlightResizeVelocity(), 1000.0); QTRY_COMPARE(listview->highlightMoveVelocity(), 100000.0); @@ -647,7 +648,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v if (verticalLayoutDirection == QQuickItemView::BottomToTop) { listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); contentY = -listview->height() - contentY; } listview->setContentY(contentY); @@ -660,7 +661,7 @@ void tst_QQuickListView::inserted_more(QQuickItemView::VerticalLayoutDirection v model.insertItems(insertIndex, newData); //Wait for polish (updates list to the model changes) - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->property("count").toInt(), model.count()); @@ -841,7 +842,7 @@ void tst_QQuickListView::insertBeforeVisible() QTRY_VERIFY(contentItem != nullptr); listview->setCacheBuffer(cacheBuffer); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // trigger a refill (not just setting contentY) so that the visibleItems grid is updated int firstVisibleIndex = 20; // move to an index where the top item is not visible @@ -849,7 +850,7 @@ void tst_QQuickListView::insertBeforeVisible() listview->setCurrentIndex(firstVisibleIndex); qApp->processEvents(); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentIndex(), firstVisibleIndex); QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", firstVisibleIndex); QVERIFY(item); @@ -869,7 +870,7 @@ void tst_QQuickListView::insertBeforeVisible() // now, moving to the top of the view should position the inserted items correctly int itemsOffsetAfterMove = (removeCount - insertCount) * 20; listview->setCurrentIndex(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentIndex(), 0); QTRY_COMPARE(listview->contentY(), 0.0 + itemsOffsetAfterMove); @@ -952,7 +953,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.removeItem(1); QTRY_COMPARE(window->rootObject()->property("count").toInt(), model.count()); @@ -1031,7 +1032,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) listview->setContentY(20); // That's the top now // let transitions settle. - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -1045,7 +1046,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) // remove current item beyond visible items. listview->setCurrentIndex(20); listview->setContentY(40); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.removeItem(20); QTRY_COMPARE(listview->currentIndex(), 20); @@ -1053,7 +1054,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) // remove item before current, but visible listview->setCurrentIndex(8); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); oldCurrent = listview->currentItem(); model.removeItem(6); @@ -1061,7 +1062,7 @@ void tst_QQuickListView::removed(const QUrl &source, bool /* animated */) QTRY_COMPARE(listview->currentItem(), oldCurrent); listview->setContentY(80); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // remove all visible items model.removeItems(1, 18); @@ -1139,14 +1140,14 @@ void tst_QQuickListView::removed_more(const QUrl &source, QQuickItemView::Vertic if (verticalLayoutDirection == QQuickItemView::BottomToTop) { listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); contentY = -listview->height() - contentY; } listview->setContentY(contentY); model.removeItems(removeIndex, removeCount); //Wait for polish (updates list to the model changes) - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->property("count").toInt(), model.count()); @@ -1320,7 +1321,7 @@ void tst_QQuickListView::clear(const QUrl &source, QQuickItemView::VerticalLayou QTRY_VERIFY(contentItem != nullptr); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.clear(); @@ -1378,20 +1379,20 @@ void tst_QQuickListView::moved(const QUrl &source, QQuickItemView::VerticalLayou QTRY_VERIFY(contentItem != nullptr); // always need to wait for view to be painted before the first move() - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); bool waitForPolish = (contentY != 0); if (verticalLayoutDirection == QQuickItemView::BottomToTop) { listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); contentY = -listview->height() - contentY; } listview->setContentY(contentY); if (waitForPolish) - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.moveItems(from, to, count); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QList<QQuickItem*> items = findItems<QQuickItem>(contentItem, "wrapper"); int firstVisibleIndex = -1; @@ -1604,7 +1605,7 @@ void tst_QQuickListView::multipleChanges(bool condensed) QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i=0; i<changes.count(); i++) { switch (changes[i].type) { @@ -1632,10 +1633,10 @@ void tst_QQuickListView::multipleChanges(bool condensed) continue; } if (!condensed) { - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); } } - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(listview->count(), newCount); QCOMPARE(listview->count(), model.count()); @@ -1852,7 +1853,7 @@ void tst_QQuickListView::swapWithFirstItem() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // ensure content position is stable listview->setContentY(0); @@ -1915,7 +1916,7 @@ void tst_QQuickListView::enforceRange() QTRY_COMPARE(listview->preferredHighlightBegin(), 100.0); QTRY_COMPARE(listview->preferredHighlightEnd(), 100.0); QTRY_COMPARE(listview->highlightRangeMode(), QQuickListView::StrictlyEnforceRange); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -1970,7 +1971,7 @@ void tst_QQuickListView::enforceRange_withoutHighlight() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); qreal expectedPos = -100.0; @@ -2014,7 +2015,7 @@ void tst_QQuickListView::spacing() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -2073,7 +2074,7 @@ void tst_QQuickListView::sections(const QUrl &source) QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -2143,9 +2144,9 @@ void tst_QQuickListView::sections(const QUrl &source) // check that headers change when item changes listview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.modifyItem(0, "changed", "2"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); item = findItem<QQuickItem>(contentItem, "wrapper", 1); QTRY_VERIFY(item); @@ -2173,7 +2174,7 @@ void tst_QQuickListView::sectionsDelegate() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -2197,7 +2198,7 @@ void tst_QQuickListView::sectionsDelegate() model.modifyItem(2, "Three", "aaa"); model.modifyItem(3, "Four", "aaa"); model.modifyItem(4, "Five", "aaa"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, @@ -2233,7 +2234,7 @@ void tst_QQuickListView::sectionsDelegate() model.modifyItem(9, "Two", "aaa"); model.modifyItem(10, "Two", "aaa"); model.modifyItem(11, "Two", "aaa"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(findItems<QQuickItem>(contentItem, "sect_aaa").count(), 1); window->rootObject()->setProperty("sectionProperty", "name"); // ensure view has settled. @@ -2283,7 +2284,7 @@ void tst_QQuickListView::sectionsDragOutsideBounds() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // QTBUG-17769 // Drag view up beyond bounds @@ -2329,11 +2330,11 @@ void tst_QQuickListView::sectionsDelegate_headerVisibility() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // ensure section header is maintained in view listview->setCurrentIndex(20); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_VERIFY(qFuzzyCompare(listview->contentY(), 200.0)); QTRY_VERIFY(!listview->isMoving()); listview->setCurrentIndex(0); @@ -2360,7 +2361,7 @@ void tst_QQuickListView::sectionsPositioning() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i)); @@ -2378,12 +2379,12 @@ void tst_QQuickListView::sectionsPositioning() // move down a little and check that section header is at top listview->setContentY(10); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(topItem->y(), 0.); // push the top header up listview->setContentY(110); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); topItem = findVisibleChild(contentItem, "sect_0"); // section header QVERIFY(topItem); QCOMPARE(topItem->y(), 100.); @@ -2398,13 +2399,13 @@ void tst_QQuickListView::sectionsPositioning() // Move past section 0 listview->setContentY(120); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); topItem = findVisibleChild(contentItem, "sect_0"); // section header QVERIFY(!topItem); // Push section footer down listview->setContentY(70); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer QVERIFY(bottomItem); QCOMPARE(bottomItem->y(), 380.); @@ -2416,7 +2417,7 @@ void tst_QQuickListView::sectionsPositioning() model.modifyItem(2, "Three", "aAa"); model.modifyItem(3, "Four", "aaA"); model.modifyItem(4, "Five", "Aaa"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentSection(), QString("aaa")); @@ -2432,7 +2433,7 @@ void tst_QQuickListView::sectionsPositioning() // remove section boundary listview->setContentY(120); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.removeItem(5); listview->forceLayout(); QTRY_COMPARE(listview->count(), model.count()); @@ -2449,27 +2450,27 @@ void tst_QQuickListView::sectionsPositioning() // Change the next section listview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); bottomItem = findVisibleChild(contentItem, "sect_3"); // section footer QVERIFY(bottomItem); QTRY_COMPARE(bottomItem->y(), 300.); model.modifyItem(14, "New", "new"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer QTRY_COMPARE(bottomItem->y(), 300.); // delegate size increase should push section footer down listview->setContentY(70); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_3")); // section footer QTRY_COMPARE(bottomItem->y(), 370.); QQuickItem *inlineSection = findVisibleChild(contentItem, "sect_new"); item = findItem<QQuickItem>(contentItem, "wrapper", 13); QVERIFY(item); item->setHeight(40.); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(bottomItem->y(), 380.); QCOMPARE(inlineSection->y(), 360.); item->setHeight(20.); @@ -2477,14 +2478,14 @@ void tst_QQuickListView::sectionsPositioning() // Turn sticky footer off listview->setContentY(20); window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart))); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_new")); // inline label restored QCOMPARE(item->y(), 340.); // Turn sticky header off listview->setContentY(30); window->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels))); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_VERIFY(item = findVisibleChild(contentItem, "sect_aaa")); // inline label restored QCOMPARE(item->y(), 0.); @@ -2520,7 +2521,7 @@ void tst_QQuickListView::sectionPropertyChange() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2530,7 +2531,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGroups"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2540,7 +2541,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGroups"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2550,7 +2551,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGrouped"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2560,7 +2561,7 @@ void tst_QQuickListView::sectionPropertyChange() } QMetaObject::invokeMethod(window->rootObject(), "switchGrouped"); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly for (int i = 0; i < 2; ++i) { @@ -2584,7 +2585,7 @@ void tst_QQuickListView::sectionDelegateChange() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QQUICK_VERIFY_POLISH(listview); + QQuickTest::qWaitForItemPolished(listview); QVERIFY(findItems<QQuickItem>(contentItem, "section1").count() > 0); QCOMPARE(findItems<QQuickItem>(contentItem, "section2").count(), 0); @@ -2596,7 +2597,7 @@ void tst_QQuickListView::sectionDelegateChange() } QMetaObject::invokeMethod(window->rootObject(), "switchDelegates"); - QQUICK_VERIFY_POLISH(listview); + QQuickTest::qWaitForItemPolished(listview); QCOMPARE(findItems<QQuickItem>(contentItem, "section1").count(), 0); QVERIFY(findItems<QQuickItem>(contentItem, "section2").count() > 0); @@ -2628,7 +2629,7 @@ void tst_QQuickListView::sectionsItemInsertion() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 0; i < 3; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i)); @@ -2644,7 +2645,7 @@ void tst_QQuickListView::sectionsItemInsertion() for (int i = 0; i < 10; i++) model.insertItem(i, "Item" + QString::number(i), QLatin1String("A")); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); QVERIFY(itemCount > 10); @@ -2782,7 +2783,7 @@ void tst_QQuickListView::currentIndex() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // currentIndex is initialized to 20 // currentItem should be in view @@ -2885,7 +2886,7 @@ void tst_QQuickListView::noCurrentIndex() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // current index should be -1 at startup // and we should not have a currentItem or highlightItem @@ -2930,7 +2931,7 @@ void tst_QQuickListView::keyNavigation() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); window->requestActivate(); QVERIFY(QTest::qWaitForWindowActive(window)); @@ -3245,7 +3246,7 @@ void tst_QQuickListView::positionViewAtBeginningEnd() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); listview->setContentY(100); @@ -3305,10 +3306,10 @@ void tst_QQuickListView::positionViewAtIndex() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); window->rootObject()->setProperty("enforceRange", enforceRange); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); listview->setContentY(initContentY); @@ -3385,7 +3386,7 @@ void tst_QQuickListView::resetModel() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->count(), model.rowCount()); @@ -3656,7 +3657,7 @@ void tst_QQuickListView::QTBUG_11105() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -3748,7 +3749,7 @@ void tst_QQuickListView::header() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3827,7 +3828,7 @@ void tst_QQuickListView::header() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); listview->setWidth(240); listview->setHeight(320); @@ -3934,7 +3935,7 @@ void tst_QQuickListView::headerChangesViewport() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -3984,7 +3985,7 @@ void tst_QQuickListView::footer() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4173,7 +4174,7 @@ void tst_QQuickListView::extents() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -4313,7 +4314,7 @@ void tst_QQuickListView::resizeView() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -4329,7 +4330,7 @@ void tst_QQuickListView::resizeView() QCOMPARE(heightRatio.toReal(), 0.4); listview->setHeight(200); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QMetaObject::invokeMethod(window->rootObject(), "heightRatio", Q_RETURN_ARG(QVariant, heightRatio)); QCOMPARE(heightRatio.toReal(), 0.25); @@ -4390,7 +4391,7 @@ void tst_QQuickListView::resizeViewAndRepaint() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // item at index 10 should not be currently visible QVERIFY(!findItem<QQuickItem>(contentItem, "wrapper", 10)); @@ -4425,7 +4426,7 @@ void tst_QQuickListView::sizeLessThan1() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Confirm items positioned correctly int itemCount = findItems<QQuickItem>(contentItem, "wrapper").count(); @@ -4477,13 +4478,13 @@ void tst_QQuickListView::resizeDelegate() QVERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(listview->count(), model.rowCount()); listview->setCurrentIndex(25); listview->setContentY(0); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 0; i < 16; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4495,7 +4496,7 @@ void tst_QQuickListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 500.0); window->rootObject()->setProperty("delegateHeight", 30); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 0; i < 11; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4509,7 +4510,7 @@ void tst_QQuickListView::resizeDelegate() listview->setCurrentIndex(1); listview->positionViewAtIndex(25, QQuickListView::Beginning); listview->positionViewAtIndex(5, QQuickListView::Beginning); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 5; i < 16; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4521,7 +4522,7 @@ void tst_QQuickListView::resizeDelegate() QTRY_COMPARE(listview->highlightItem()->y(), 30.0); window->rootObject()->setProperty("delegateHeight", 20); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); for (int i = 5; i < 11; ++i) { QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", i); @@ -4558,7 +4559,7 @@ void tst_QQuickListView::resizeFirstDelegate() QVERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *item = nullptr; for (int i = 0; i < model.count(); ++i) { @@ -4597,7 +4598,7 @@ void tst_QQuickListView::resizeFirstDelegate() listview->setCurrentIndex(19); qApp->processEvents(); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // items 0-2 should have been deleted for (int i=0; i<3; i++) { @@ -4628,7 +4629,7 @@ void tst_QQuickListView::repositionResizedDelegate() QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *positioner = findItem<QQuickItem>(window->rootObject(), "positioner"); QVERIFY(positioner); @@ -4643,7 +4644,7 @@ void tst_QQuickListView::repositionResizedDelegate() listview->setContentX(contentPos_itemFirstHalfVisible.x()); listview->setContentY(contentPos_itemFirstHalfVisible.y()); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); prevSpyCount = spy.count(); QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater")); QTRY_COMPARE(positioner->boundingRect().size(), resizedPositionerRect.size()); @@ -4660,7 +4661,7 @@ void tst_QQuickListView::repositionResizedDelegate() listview->setContentX(contentPos_itemSecondHalfVisible.x()); listview->setContentY(contentPos_itemSecondHalfVisible.y()); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); prevSpyCount = spy.count(); QVERIFY(QMetaObject::invokeMethod(window->rootObject(), "incrementRepeater")); @@ -4768,7 +4769,7 @@ void tst_QQuickListView::indexAt_itemAt() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *item = nullptr; if (index >= 0) { @@ -4782,6 +4783,29 @@ void tst_QQuickListView::indexAt_itemAt() delete testObject; } +void tst_QQuickListView::itemAtIndex() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("listview-itematindex.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); + QVERIFY(listview != nullptr); + + QCOMPARE(listview->itemAtIndex(-1), nullptr); + QCOMPARE(listview->itemAtIndex(3), nullptr); + QQuickItem *item = listview->itemAtIndex(0); + QVERIFY(item); + QCOMPARE(item->property("idx"), 0); + item = listview->itemAtIndex(1); + QVERIFY(item); + QCOMPARE(item->property("idx"), 1); + item = listview->itemAtIndex(2); + QVERIFY(item); + QCOMPARE(item->property("idx"), 2); +} + void tst_QQuickListView::incrementalModel() { QScopedPointer<QQuickView> window(createView()); @@ -4926,7 +4950,7 @@ void tst_QQuickListView::rightToLeft() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQmlObjectModel *model = window->rootObject()->findChild<QQmlObjectModel*>("itemModel"); QTRY_VERIFY(model != nullptr); @@ -5039,7 +5063,7 @@ void tst_QQuickListView::margins() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(listview->contentY(), -30.); QCOMPARE(listview->originY(), 0.); @@ -5048,7 +5072,7 @@ void tst_QQuickListView::margins() listview->positionViewAtEnd(); qreal pos = listview->contentY(); listview->setContentY(pos + 80); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); listview->returnToBounds(); QTRY_COMPARE(listview->contentY(), pos + 50); @@ -5059,7 +5083,7 @@ void tst_QQuickListView::margins() listview->forceLayout(); QTRY_COMPARE(listview->count(), model.count()); listview->setContentY(-50); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); listview->returnToBounds(); QCOMPARE(listview->originY(), 20.); QTRY_COMPARE(listview->contentY(), -10.); @@ -5112,7 +5136,7 @@ void tst_QQuickListView::marginsResize() listview->setOrientation(orientation); listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // view is resized after componentCompleted - top margin should still be visible if (orientation == QQuickListView::Vertical) @@ -5252,7 +5276,7 @@ void tst_QQuickListView::snapToItem() listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -5304,7 +5328,7 @@ void tst_QQuickListView::snapToItemWithSpacing_QTBUG_59852() auto *listView = qobject_cast<QQuickListView*>(window->rootObject()); QVERIFY(listView); - QTRY_COMPARE(QQuickItemPrivate::get(listView)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listView)); // each item in the list is 100 pixels tall, and the spacing is 100 @@ -5335,14 +5359,14 @@ void tst_QQuickListView::snapOneItemResize_QTBUG_43555() QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentIndex(), 5); currentIndexSpy.clear(); window->resize(QSize(400, 320)); QTRY_COMPARE(int(listview->width()), 400); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentIndex(), 5); QCOMPARE(currentIndexSpy.count(), 0); @@ -5652,7 +5676,7 @@ void tst_QQuickListView::snapOneItem() listview->setLayoutDirection(layoutDirection); listview->setVerticalLayoutDirection(verticalLayoutDirection); listview->setHighlightRangeMode(QQuickItemView::HighlightRangeMode(highlightRangeMode)); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); @@ -5721,14 +5745,14 @@ void tst_QQuickListView::snapOneItemCurrentIndexRemoveAnimation() QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentIndex(), 0); QSignalSpy currentIndexSpy(listview, SIGNAL(currentIndexChanged())); QMetaObject::invokeMethod(window->rootObject(), "removeItemZero"); QTRY_COMPARE(listview->property("transitionsRun").toInt(), 1); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(listview->currentIndex(), 0); QCOMPARE(currentIndexSpy.count(), 0); @@ -5744,7 +5768,7 @@ void tst_QQuickListView::snapOneItemWrongDirection() QQuickListView *listview = qobject_cast<QQuickListView*>(window->rootObject()); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QTRY_COMPARE(listview->currentIndex(), 0); listview->flick(0,500); @@ -5894,7 +5918,7 @@ void tst_QQuickListView::unrequestedVisibility() QCOMPARE(delegateVisible(item), false); model.moveItems(19, 1, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); QTRY_VERIFY((item = findItem<QQuickItem>(leftContent, wrapperObjectName, 1))); QCOMPARE(delegateVisible(item), false); @@ -5923,7 +5947,7 @@ void tst_QQuickListView::unrequestedVisibility() QCOMPARE(delegateVisible(item), false); model.moveItems(3, 4, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); @@ -5939,7 +5963,7 @@ void tst_QQuickListView::unrequestedVisibility() QCOMPARE(delegateVisible(item), false); model.moveItems(4, 3, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); @@ -5955,7 +5979,7 @@ void tst_QQuickListView::unrequestedVisibility() QCOMPARE(delegateVisible(item), false); model.moveItems(16, 17, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); @@ -5971,7 +5995,7 @@ void tst_QQuickListView::unrequestedVisibility() QCOMPARE(delegateVisible(item), false); model.moveItems(17, 16, 1); - QTRY_COMPARE(QQuickItemPrivate::get(leftview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(leftview)); item = findItem<QQuickItem>(leftContent, wrapperObjectName, 4); QVERIFY(item); @@ -6031,7 +6055,7 @@ void tst_QQuickListView::populateTransitions() QTRY_COMPARE(listview->property("countPopulateTransitions").toInt(), 0); QTRY_COMPARE(listview->property("countAddTransitions").toInt(), 16); } else { - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(listview->property("countPopulateTransitions").toInt(), 0); QCOMPARE(listview->property("countAddTransitions").toInt(), 0); } @@ -6142,7 +6166,7 @@ void tst_QQuickListView::sizeTransitions() QQuickListView *listview = findItem<QQuickListView>(window->rootObject(), "list"); QTRY_VERIFY(listview != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // the following will start the transition model.addItem(QLatin1String("Test"), ""); @@ -6207,11 +6231,11 @@ void tst_QQuickListView::addTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); if (contentY != 0) { listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -6407,7 +6431,7 @@ void tst_QQuickListView::moveTransitions() if (contentY != 0) { listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -6606,11 +6630,11 @@ void tst_QQuickListView::removeTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); if (contentY != 0) { listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); } QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); @@ -6818,7 +6842,7 @@ void tst_QQuickListView::displacedTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QList<QPair<QString,QString> > expectedDisplacedValues = expectedDisplacedIndexes.getModelDataValues(model); listview->setProperty("displaceTransitionsDone", false); @@ -6839,7 +6863,7 @@ void tst_QQuickListView::displacedTransitions() break; case ListChange::Moved: model.moveItems(change.index, change.to, change.count); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); break; case ListChange::SetCurrent: case ListChange::SetContentY: @@ -7038,11 +7062,11 @@ void tst_QQuickListView::multipleTransitions() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); if (contentY != 0) { listview->setContentY(contentY); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); } int timeBetweenActions = window->rootObject()->property("timeBetweenActions").toInt(); @@ -7076,7 +7100,7 @@ void tst_QQuickListView::multipleTransitions() break; case ListChange::Moved: model.moveItems(changes[i].index, changes[i].to, changes[i].count); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); if (i == changes.count() - 1) { QTRY_VERIFY(!listview->property("runningMoveTargets").toBool()); QTRY_VERIFY(!listview->property("runningMoveDisplaced").toBool()); @@ -7089,7 +7113,7 @@ void tst_QQuickListView::multipleTransitions() break; case ListChange::SetContentY: listview->setContentY(changes[i].pos); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); break; case ListChange::Polish: break; @@ -7195,7 +7219,7 @@ void tst_QQuickListView::multipleDisplaced() QTRY_VERIFY(listview != nullptr); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); model.moveItems(12, 8, 1); QTest::qWait(window->rootObject()->property("duration").toInt() / 2); @@ -7289,7 +7313,7 @@ void tst_QQuickListView::flickBeyondBounds() QQuickItem *contentItem = listview->contentItem(); QTRY_VERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); // Flick view up beyond bounds flick(window.data(), QPoint(10, 10), QPoint(10, -2000), 180); @@ -7401,7 +7425,7 @@ void tst_QQuickListView::destroyItemOnCreation() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QCOMPARE(window->rootObject()->property("createdIndex").toInt(), -1); model.addItem("new item", ""); @@ -7425,7 +7449,7 @@ void tst_QQuickListView::parentBinding() QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem != nullptr); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QQuickItem *item = findItem<QQuickItem>(contentItem, "wrapper", 0); QVERIFY(item); @@ -8829,7 +8853,7 @@ void tst_QQuickListView::QTBUG_34576_velocityZero() QVERIFY(listview); QQuickItem *contentItem = listview->contentItem(); QVERIFY(contentItem); - QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(listview)); QSignalSpy horizontalVelocitySpy(listview, SIGNAL(horizontalVelocityChanged())); diff --git a/tests/auto/quick/qquickpathview/qquickpathview.pro b/tests/auto/quick/qquickpathview/qquickpathview.pro index 90c1eb0c67..f21fb64fa4 100644 --- a/tests/auto/quick/qquickpathview/qquickpathview.pro +++ b/tests/auto/quick/qquickpathview/qquickpathview.pro @@ -9,5 +9,5 @@ include (../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private quick-private testlib +QT += core-private gui-private qml-private quick-private testlib qmltest qtHaveModule(widgets): QT += widgets diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp index 6267a3771e..bf38d2d926 100644 --- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp +++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp @@ -38,6 +38,7 @@ #include <QtQuick/private/qquickpath_p.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickrectangle_p.h> +#include <QtQuickTest/QtQuickTest> #include <QtQml/private/qqmllistmodel_p.h> #include <QtQml/private/qqmlvaluetype_p.h> #include <QtGui/qstandarditemmodel.h> @@ -714,13 +715,13 @@ void tst_QQuickPathView::consecutiveModelChanges() pathview->setCurrentIndex(changes[i].index); break; case ListChange::Polish: - QQUICK_VERIFY_POLISH(pathview); + QQuickTest::qWaitForItemPolished(pathview); break; default: continue; } } - QQUICK_VERIFY_POLISH(pathview); + QQuickTest::qWaitForItemPolished(pathview); QCOMPARE(findItems<QQuickItem>(pathview, "wrapper").count(), count); QCOMPARE(pathview->count(), count); @@ -1371,7 +1372,7 @@ void tst_QQuickPathView::package() QSKIP("QTBUG-27170 view does not reliably receive polish without a running animation"); #endif - QQUICK_VERIFY_POLISH(pathView); + QQuickTest::qWaitForItemPolished(pathView); QQuickItem *item = findItem<QQuickItem>(pathView, "pathItem"); QVERIFY(item); QVERIFY(item->scale() != 1.0); diff --git a/tests/auto/quick/qquickpositioners/qquickpositioners.pro b/tests/auto/quick/qquickpositioners/qquickpositioners.pro index 6e85ba9db8..d1547df189 100644 --- a/tests/auto/quick/qquickpositioners/qquickpositioners.pro +++ b/tests/auto/quick/qquickpositioners/qquickpositioners.pro @@ -9,4 +9,4 @@ macx:CONFIG -= app_bundle TESTDATA = data/* -QT += testlib +QT += testlib qmltest diff --git a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp index 9881af690c..80be25d1b0 100644 --- a/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp +++ b/tests/auto/quick/qquickpositioners/tst_qquickpositioners.cpp @@ -31,6 +31,7 @@ #include <QtQuick/private/qquickrectangle_p.h> #include <QtQuick/private/qquickpositioners_p.h> #include <QtQuick/private/qquicktransition_p.h> +#include <QtQuickTest/QtQuickTest> #include <private/qquickitem_p.h> #include <qqmlexpression.h> #include "../shared/viewtestutil.h" @@ -1062,7 +1063,7 @@ void tst_qquickpositioners::populateTransitions(const QString &positionerObjectN QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone").toInt(), 0); QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), model.count()); } else { - QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); QTRY_COMPARE(window->rootObject()->property("populateTransitionsDone").toInt(), 0); QTRY_COMPARE(window->rootObject()->property("addTransitionsDone").toInt(), 0); } @@ -1128,7 +1129,7 @@ void tst_qquickpositioners::addTransitions(const QString &positionerObjectName) QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName); QVERIFY(positioner); positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model)); - QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); for (int i = 0; i < initialItemCount; i++) model.addItem("Original item" + QString::number(i), ""); @@ -1253,7 +1254,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) QQuickItem *positioner = window->rootObject()->findChild<QQuickItem*>(positionerObjectName); QVERIFY(positioner); positioner->findChild<QQuickItem*>("repeater")->setProperty("model", QVariant::fromValue(&model)); - QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); switch (change.type) { case ListChange::Removed: @@ -1262,7 +1263,7 @@ void tst_qquickpositioners::moveTransitions(const QString &positionerObjectName) break; case ListChange::Moved: model.moveItems(change.index, change.to, change.count); - QTRY_COMPARE(QQuickItemPrivate::get(positioner)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(positioner)); break; case ListChange::Inserted: case ListChange::SetCurrent: @@ -3815,7 +3816,7 @@ void tst_qquickpositioners::test_mirroring() QQuickItem *positionerB = itemB->parentItem(); positionerA->setWidth(positionerA->width() * 2); positionerB->setWidth(positionerB->width() * 2); - QTRY_VERIFY(!QQuickItemPrivate::get(positionerA)->polishScheduled && !QQuickItemPrivate::get(positionerB)->polishScheduled); + QVERIFY(QQuickTest::qWaitForItemPolished(positionerA) && QQuickTest::qWaitForItemPolished(positionerB)); QTRY_COMPARE(itemA->x(), itemB->x()); } diff --git a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp index f601f520bb..a57b7d4c1f 100644 --- a/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp +++ b/tests/auto/quick/qquickshadereffect/tst_qquickshadereffect.cpp @@ -46,6 +46,10 @@ class TestShaderEffect : public QQuickShaderEffect Q_PROPERTY(QMatrix4x4 mat4x4 READ mat4x4Read NOTIFY dummyChanged) public: + TestShaderEffect(QQuickItem* parent = nullptr) : QQuickShaderEffect(parent) + { + } + QMatrix4x4 mat4x4Read() const { return QMatrix4x4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1); } QVariant dummyRead() const { return QVariant(); } @@ -79,6 +83,8 @@ private slots: void deleteShaderEffectSource(); void twoImagesOneShaderEffect(); + void withoutQmlEngine(); + private: enum PresenceFlags { VertexPresent = 0x01, @@ -320,6 +326,16 @@ void tst_qquickshadereffect::twoImagesOneShaderEffect() delete view; } +void tst_qquickshadereffect::withoutQmlEngine() +{ + // using a shader without QML engine used to crash + auto window = new QQuickWindow; + auto shaderEffect = new TestShaderEffect(window->contentItem()); + shaderEffect->setVertexShader(""); + QVERIFY(shaderEffect->isComponentComplete()); + delete window; +} + QTEST_MAIN(tst_qquickshadereffect) #include "tst_qquickshadereffect.moc" diff --git a/tests/auto/quick/qquicktableview/qquicktableview.pro b/tests/auto/quick/qquicktableview/qquicktableview.pro index f4d0265dd3..cf831ed5b5 100644 --- a/tests/auto/quick/qquicktableview/qquicktableview.pro +++ b/tests/auto/quick/qquicktableview/qquicktableview.pro @@ -1,4 +1,5 @@ CONFIG += testcase +QT += qmltest TARGET = tst_qquicktableview macos:CONFIG -= app_bundle diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index d475ef9c4d..d2ec9948c9 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include <QtQuickTest/quicktest.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquicktableview_p.h> @@ -79,8 +80,8 @@ Q_DECLARE_METATYPE(QMarginsF); DECLARE_TABLEVIEW_VARIABLES #define WAIT_UNTIL_POLISHED \ - QVERIFY(tableViewPrivate->polishScheduled); \ - QTRY_VERIFY(!tableViewPrivate->polishScheduled) + QVERIFY(QQuickTest::qIsPolishScheduled(tableView)); \ + QVERIFY(QQuickTest::qWaitForItemPolished(tableView)) class tst_QQuickTableView : public QQmlDataTest { @@ -250,8 +251,9 @@ void tst_QQuickTableView::checkPreload() WAIT_UNTIL_POLISHED; if (reuseItems) { - QSize visibleTableSize = tableViewPrivate->loadedTable.size(); - int expectedPoolSize = visibleTableSize.height() + visibleTableSize.width() + 1; + const int rowCount = tableViewPrivate->loadedRows.count(); + const int columnCount = tableViewPrivate->loadedColumns.count(); + const int expectedPoolSize = rowCount + columnCount + 1; QCOMPARE(tableViewPrivate->tableModel->poolSize(), expectedPoolSize); } else { QCOMPARE(tableViewPrivate->tableModel->poolSize(), 0); @@ -320,10 +322,9 @@ void tst_QQuickTableView::checkColumnWidthWithoutProvider() WAIT_UNTIL_POLISHED; - QRect table = tableViewPrivate->loadedTable; - for (int column = table.left(); column <= table.right(); ++column) { + for (const int column : tableViewPrivate->loadedColumns.keys()) { const qreal expectedColumnWidth = tableViewPrivate->sizeHintForColumn(column); - for (int row = table.top(); row <= table.bottom(); ++row) { + for (const int row : tableViewPrivate->loadedRows.keys()) { const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item; QCOMPARE(item->width(), expectedColumnWidth); } @@ -413,10 +414,9 @@ void tst_QQuickTableView::checkRowHeightWithoutProvider() WAIT_UNTIL_POLISHED; - QRect table = tableViewPrivate->loadedTable; - for (int row = table.top(); row <= table.bottom(); ++row) { + for (const int row : tableViewPrivate->loadedRows.keys()) { const qreal expectedRowHeight = tableViewPrivate->sizeHintForRow(row); - for (int column = table.left(); column <= table.right(); ++column) { + for (const int column : tableViewPrivate->loadedColumns.keys()) { const auto item = tableViewPrivate->loadedTableItem(QPoint(column, row))->item; QCOMPARE(item->height(), expectedRowHeight); } @@ -564,8 +564,8 @@ void tst_QQuickTableView::checkContentWidthAndHeight() const int largeSizeCellCountInView = qCeil(tableView->width() / cellSizeLarge); const int columnCount = smallCellCount + largeSizeCellCountInView; - QCOMPARE(tableViewPrivate->loadedTable.left(), smallCellCount); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), smallCellCount); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); const qreal firstHalfLength = smallCellCount * cellSizeSmall; const qreal secondHalfOneScreenLength = largeSizeCellCountInView * cellSizeLarge; @@ -617,17 +617,18 @@ void tst_QQuickTableView::checkPageFlicking() const int cellWidth = 100; const int cellHeight = 50; auto model = TestModelAsVariant(10000, 10000); + const auto &loadedRows = tableViewPrivate->loadedRows; + const auto &loadedColumns = tableViewPrivate->loadedColumns; tableView->setModel(model); WAIT_UNTIL_POLISHED; // Sanity check startup table - QRect tableRect = tableViewPrivate->loadedTable; - QCOMPARE(tableRect.x(), 0); - QCOMPARE(tableRect.y(), 0); - QCOMPARE(tableRect.width(), tableView->width() / cellWidth); - QCOMPARE(tableRect.height(), tableView->height() / cellHeight); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(loadedRows.count(), tableView->height() / cellHeight); + QCOMPARE(loadedColumns.count(), tableView->width() / cellWidth); // Since all cells have the same size, the average row/column // size found by TableView should be exactly equal to this. @@ -651,11 +652,10 @@ void tst_QQuickTableView::checkPageFlicking() WAIT_UNTIL_POLISHED; - tableRect = tableViewPrivate->loadedTable; - QCOMPARE(tableRect.x(), flickToColumn); - QCOMPARE(tableRect.y(), 0); - QCOMPARE(tableRect.width(), tableView->width() / cellWidth); - QCOMPARE(tableRect.height(), tableView->height() / cellHeight); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->leftColumn(), flickToColumn); + QCOMPARE(loadedColumns.count(), tableView->width() / cellWidth); + QCOMPARE(loadedRows.count(), tableView->height() / cellHeight); // Flick 5000 rows down as well. Since flicking down should only calculate a new row (but // keep the current column), we deliberatly change the average width to check that it's @@ -674,11 +674,10 @@ void tst_QQuickTableView::checkPageFlicking() WAIT_UNTIL_POLISHED; - tableRect = tableViewPrivate->loadedTable; - QCOMPARE(tableRect.x(), flickToRow); - QCOMPARE(tableRect.y(), flickToColumn); - QCOMPARE(tableRect.width(), tableView->width() / cellWidth); - QCOMPARE(tableRect.height(), tableView->height() / cellHeight); + QCOMPARE(tableViewPrivate->topRow(), flickToColumn); + QCOMPARE(tableViewPrivate->leftColumn(), flickToRow); + QCOMPARE(loadedRows.count(), tableView->height() / cellHeight); + QCOMPARE(loadedColumns.count(), tableView->width() / cellWidth); } void tst_QQuickTableView::checkExplicitContentWidthAndHeight() @@ -728,8 +727,8 @@ void tst_QQuickTableView::checkContentXY() // Check that we end up at the correct top-left cell: const qreal delegateWidth = tableViewPrivate->loadedItems.values().first()->item->width(); const int expectedCellXY = qCeil(expectedXY / delegateWidth); - QCOMPARE(tableViewPrivate->loadedTable.left(), expectedCellXY); - QCOMPARE(tableViewPrivate->loadedTable.top(), expectedCellXY); + QCOMPARE(tableViewPrivate->leftColumn(), expectedCellXY); + QCOMPARE(tableViewPrivate->topRow(), expectedCellXY); } void tst_QQuickTableView::noDelegate() @@ -1003,7 +1002,8 @@ void tst_QQuickTableView::fillTableViewButNothingMore() auto const topLeftFxItem = tableViewPrivate->loadedTableItem(QPoint(0, 0)); auto const topLeftItem = topLeftFxItem->item; - auto const bottomRightFxItem = tableViewPrivate->loadedTableItem(tableViewPrivate->loadedTable.bottomRight()); + auto const bottomRightLoadedCell = QPoint(tableViewPrivate->rightColumn(), tableViewPrivate->bottomRow()); + auto const bottomRightFxItem = tableViewPrivate->loadedTableItem(bottomRightLoadedCell); auto const bottomRightItem = bottomRightFxItem->item; const QPoint bottomRightCell = getContextRowAndColumn(bottomRightItem.data()); @@ -1181,15 +1181,13 @@ void tst_QQuickTableView::flick() WAIT_UNTIL_POLISHED; - const QRect loadedTable = tableViewPrivate->loadedTable; + const int expectedTableLeft = int(cellsToFlick - int((margins.left() + spacing.width()) / cellWidth)); + const int expectedTableTop = int(cellsToFlick - int((margins.top() + spacing.height()) / cellHeight)); - const int expectedTableLeft = cellsToFlick - int((margins.left() + spacing.width()) / cellWidth); - const int expectedTableTop = cellsToFlick - int((margins.top() + spacing.height()) / cellHeight); - - QCOMPARE(loadedTable.left(), expectedTableLeft); - QCOMPARE(loadedTable.right(), expectedTableLeft + visualColumnCount); - QCOMPARE(loadedTable.top(), expectedTableTop); - QCOMPARE(loadedTable.bottom(), expectedTableTop + visualRowCount); + QCOMPARE(tableViewPrivate->leftColumn(), expectedTableLeft); + QCOMPARE(tableViewPrivate->rightColumn(), expectedTableLeft + visualColumnCount); + QCOMPARE(tableViewPrivate->topRow(), expectedTableTop); + QCOMPARE(tableViewPrivate->bottomRow(), expectedTableTop + visualRowCount); } } @@ -1251,10 +1249,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), 0); - QCOMPARE(tableViewPrivate->loadedTable.right(), 0); - QCOMPARE(tableViewPrivate->loadedTable.top(), 0); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(tableViewPrivate->rightColumn(), 0); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1); // Flick table out of view right tableView->setContentX(tableWidth + outsideMargin); @@ -1263,10 +1261,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.top(), 0); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1); // Flick table out of view on top tableView->setContentX(0); @@ -1275,10 +1273,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), 0); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.top(), 0); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), 0); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->bottomRow(), 0); // Flick table out of view at the bottom tableView->setContentX(0); @@ -1287,10 +1285,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), 0); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.top(), rowCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->topRow(), rowCount - 1); + QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1); // Flick table out of view left and top at the same time tableView->setContentX(-tableView->width() - outsideMargin); @@ -1299,10 +1297,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), 0); - QCOMPARE(tableViewPrivate->loadedTable.right(), 0); - QCOMPARE(tableViewPrivate->loadedTable.top(), 0); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), 0); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(tableViewPrivate->rightColumn(), 0); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->bottomRow(), 0); // Flick table back to origo tableView->setContentX(0); @@ -1311,10 +1309,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), 0); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.top(), 0); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1); // Flick table out of view right and bottom at the same time tableView->setContentX(tableWidth + outsideMargin); @@ -1323,10 +1321,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.top(), rowCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->topRow(), rowCount - 1); + QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1); // Flick table back to origo tableView->setContentX(0); @@ -1335,10 +1333,10 @@ void tst_QQuickTableView::flickOvershoot() WAIT_UNTIL_POLISHED; - QCOMPARE(tableViewPrivate->loadedTable.left(), 0); - QCOMPARE(tableViewPrivate->loadedTable.right(), columnCount - 1); - QCOMPARE(tableViewPrivate->loadedTable.top(), 0); - QCOMPARE(tableViewPrivate->loadedTable.bottom(), rowCount - 1); + QCOMPARE(tableViewPrivate->leftColumn(), 0); + QCOMPARE(tableViewPrivate->rightColumn(), columnCount - 1); + QCOMPARE(tableViewPrivate->topRow(), 0); + QCOMPARE(tableViewPrivate->bottomRow(), rowCount - 1); } void tst_QQuickTableView::checkRowColumnCount() @@ -1352,6 +1350,8 @@ void tst_QQuickTableView::checkRowColumnCount() const qreal delegateWidth = 100; const qreal delegateHeight = 50; auto model = TestModelAsVariant(100, 100); + const auto &loadedRows = tableViewPrivate->loadedRows; + const auto &loadedColumns = tableViewPrivate->loadedColumns; tableView->setModel(model); @@ -1359,17 +1359,15 @@ void tst_QQuickTableView::checkRowColumnCount() // We expect that the number of created items after start-up should match //the size of the visible table, pluss one extra preloaded row and column. - const QSize visibleTableSize = tableViewPrivate->loadedTable.size(); const int qmlCountAfterInit = view->rootObject()->property(maxDelegateCountProp).toInt(); - const int expectedCount = (visibleTableSize.width() + 1) * (visibleTableSize.height() + 1); + const int expectedCount = (loadedColumns.count() + 1) * (loadedRows.count() + 1); QCOMPARE(qmlCountAfterInit, expectedCount); // This test will keep track of the maximum number of delegate items TableView // had to show at any point while flicking (in countingtableview.qml). Because // of the geometries chosen for TableView and the delegate, only complete columns // will be shown at start-up. - const QRect loadedTable = tableViewPrivate->loadedTable; - QVERIFY(loadedTable.height() > loadedTable.width()); + QVERIFY(loadedRows.count() > loadedColumns.count()); QCOMPARE(tableViewPrivate->loadedTableOuterRect.width(), tableView->width()); QCOMPARE(tableViewPrivate->loadedTableOuterRect.height(), tableView->height()); @@ -1618,8 +1616,8 @@ void tst_QQuickTableView::checkIfDelegatesAreReused() fxItem->item->setProperty("reusedCount", 0); } - const int visibleColumnCount = tableViewPrivate->loadedTable.width(); - const int visibleRowCount = tableViewPrivate->loadedTable.height(); + const int visibleColumnCount = tableViewPrivate->loadedColumns.count(); + const int visibleRowCount = tableViewPrivate->loadedRows.count(); const int delegateCountAfterInit = view->rootObject()->property(kDelegatesCreatedCountProp).toInt(); for (int column = 1; column <= (visibleColumnCount * pageFlickCount); ++column) { @@ -1686,7 +1684,7 @@ void tst_QQuickTableView::checkIfDelegatesAreReusedAsymmetricTableSize() // Since we have flicked half a delegate to the left, the number of visible // columns is now one more than the column count were when we started the test. - const int visibleColumnCount = tableViewPrivate->loadedTable.width(); + const int visibleColumnCount = tableViewPrivate->loadedColumns.count(); QCOMPARE(visibleColumnCount, columnCount + 1); // We expect no items to have been pooled so far @@ -1886,7 +1884,7 @@ void tst_QQuickTableView::checkChangingModelFromDelegate() // We now expect two rows in the table, one more than initially QCOMPARE(tableViewPrivate->tableSize.height(), 2); - QCOMPARE(tableViewPrivate->loadedTable.height(), 2); + QCOMPARE(tableViewPrivate->loadedRows.count(), 2); // And since the QML code tried to add another row as well, we // expect rebuildScheduled to be true, and a polish event to be pending. @@ -1896,7 +1894,7 @@ void tst_QQuickTableView::checkChangingModelFromDelegate() // After handling the polish event, we expect also the third row to now be added QCOMPARE(tableViewPrivate->tableSize.height(), 3); - QCOMPARE(tableViewPrivate->loadedTable.height(), 3); + QCOMPARE(tableViewPrivate->loadedRows.count(), 3); } void tst_QQuickTableView::checkRebuildViewportOnly() @@ -1981,8 +1979,8 @@ void tst_QQuickTableView::checkTableviewInsideAsyncLoader() const qreal delegateHeight = 50; int expectedColumns = qCeil(tableView->width() / delegateWidth); int expectedRows = qCeil(tableView->height() / delegateHeight); - QCOMPARE(tableViewPrivate->loadedTable.width(), expectedColumns); - QCOMPARE(tableViewPrivate->loadedTable.height(), expectedRows); + QCOMPARE(tableViewPrivate->loadedColumns.count(), expectedColumns); + QCOMPARE(tableViewPrivate->loadedRows.count(), expectedRows); // Check that the loader was still in a loading state while TableView was creating // delegate items. If we delayed creating delegate items until we got the first diff --git a/tests/auto/quick/qquicktext/qquicktext.pro b/tests/auto/quick/qquicktext/qquicktext.pro index f76e8c95b2..fdea9dcddd 100644 --- a/tests/auto/quick/qquicktext/qquicktext.pro +++ b/tests/auto/quick/qquicktext/qquicktext.pro @@ -11,4 +11,4 @@ include (../../shared/util.pri) TESTDATA = data/* -QT += core-private gui-private qml-private quick-private network testlib +QT += core-private gui-private qml-private quick-private network testlib qmltest diff --git a/tests/auto/quick/qquicktext/tst_qquicktext.cpp b/tests/auto/quick/qquicktext/tst_qquicktext.cpp index a9c35e0cc4..fd0ba0f49b 100644 --- a/tests/auto/quick/qquicktext/tst_qquicktext.cpp +++ b/tests/auto/quick/qquicktext/tst_qquicktext.cpp @@ -32,6 +32,7 @@ #include <QtQml/qqmlcomponent.h> #include <QtQuick/private/qquicktext_p.h> #include <QtQuick/private/qquickmousearea_p.h> +#include <QtQuickTest/QtQuickTest> #include <private/qquicktext_p_p.h> #include <private/qquicktextdocument_p.h> #include <private/qquickvaluetypes_p.h> @@ -3142,7 +3143,7 @@ void tst_qquicktext::fontSizeMode() QVERIFY(myText != nullptr); myText->setText(text); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); qreal originalWidth = myText->contentWidth(); qreal originalHeight = myText->contentHeight(); @@ -3156,7 +3157,7 @@ void tst_qquicktext::fontSizeMode() myText->setFont(font); myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Font size reduced to fit within the width of the item. qreal horizontalFitWidth = myText->contentWidth(); qreal horizontalFitHeight = myText->contentHeight(); @@ -3165,28 +3166,28 @@ void tst_qquicktext::fontSizeMode() // Elide won't affect the size with HorizontalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Font size increased to fill the height of the item. qreal verticalFitHeight = myText->contentHeight(); QVERIFY(myText->contentWidth() > myText->width()); @@ -3195,57 +3196,57 @@ void tst_qquicktext::fontSizeMode() // Elide won't affect the height of a single line with VerticalFit but will crop the width. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(myText->truncated()); QVERIFY(myText->contentWidth() <= myText->width() + 2); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(myText->truncated()); QVERIFY(myText->contentWidth() <= myText->width() + 2); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(myText->truncated()); QVERIFY(myText->contentWidth() <= myText->width() + 2); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Should be the same as HorizontalFit with no wrapping. QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); // Elide won't affect the size with Fit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::FixedSize); myText->setWrapMode(QQuickText::Wrap); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); originalWidth = myText->contentWidth(); originalHeight = myText->contentHeight(); @@ -3255,7 +3256,7 @@ void tst_qquicktext::fontSizeMode() QVERIFY(originalHeight > myText->height()); myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the // same size as without text wrapping. QCOMPARE(myText->contentWidth(), horizontalFitWidth); @@ -3263,16 +3264,16 @@ void tst_qquicktext::fontSizeMode() // Elide won't affect the size with HorizontalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // VerticalFit should reduce the size to the wrapped text within the vertical height. verticalFitHeight = myText->contentHeight(); qreal verticalFitWidth = myText->contentWidth(); @@ -3282,40 +3283,40 @@ void tst_qquicktext::fontSizeMode() // Elide won't affect the height or width of a wrapped text with VerticalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Should be the same as VerticalFit with wrapping. QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); // Elide won't affect the size with Fit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::FixedSize); myText->setMaximumLineCount(2); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // The original text wrapped should exceed the height of the item. QVERIFY(originalWidth <= myText->width() + 2); QVERIFY(originalHeight > myText->height()); myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the // same size as without text wrapping. QCOMPARE(myText->contentWidth(), horizontalFitWidth); @@ -3323,16 +3324,16 @@ void tst_qquicktext::fontSizeMode() // Elide won't affect the size with HorizontalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // VerticalFit should reduce the size to the wrapped text within the vertical height. verticalFitHeight = myText->contentHeight(); verticalFitWidth = myText->contentWidth(); @@ -3342,29 +3343,29 @@ void tst_qquicktext::fontSizeMode() // Elide won't affect the height or width of a wrapped text with VerticalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Should be the same as VerticalFit with wrapping. QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); // Elide won't affect the size with Fit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); } void tst_qquicktext::fontSizeModeMultiline_data() @@ -3385,7 +3386,7 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(myText != nullptr); myText->setText(text); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); qreal originalWidth = myText->contentWidth(); qreal originalHeight = myText->contentHeight(); @@ -3400,7 +3401,7 @@ void tst_qquicktext::fontSizeModeMultiline() myText->setFont(font); myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Font size reduced to fit within the width of the item. QCOMPARE(myText->lineCount(), 2); qreal horizontalFitWidth = myText->contentWidth(); @@ -3410,7 +3411,7 @@ void tst_qquicktext::fontSizeModeMultiline() // Right eliding will remove the last line myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(myText->truncated()); QCOMPARE(myText->lineCount(), 1); QVERIFY(myText->contentWidth() <= myText->width() + 2); @@ -3418,22 +3419,22 @@ void tst_qquicktext::fontSizeModeMultiline() // Left or middle eliding wont have any effect. myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), horizontalFitWidth); QCOMPARE(myText->contentHeight(), horizontalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Font size reduced to fit within the height of the item. qreal verticalFitWidth = myText->contentWidth(); qreal verticalFitHeight = myText->contentHeight(); @@ -3442,58 +3443,58 @@ void tst_qquicktext::fontSizeModeMultiline() // Elide will have no effect. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QVERIFY(myText->contentWidth() <= myText->width() + 2); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Should be the same as VerticalFit with no wrapping. QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); // Elide won't affect the size with Fit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideLeft); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideMiddle); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::FixedSize); myText->setWrapMode(QQuickText::Wrap); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); originalWidth = myText->contentWidth(); originalHeight = myText->contentHeight(); @@ -3503,7 +3504,7 @@ void tst_qquicktext::fontSizeModeMultiline() QVERIFY(originalHeight > myText->height()); myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the // same size as without text wrapping. QCOMPARE(myText->contentWidth(), horizontalFitWidth); @@ -3511,16 +3512,16 @@ void tst_qquicktext::fontSizeModeMultiline() // Text will be elided vertically with HorizontalFit myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(myText->truncated()); QVERIFY(myText->contentWidth() <= myText->width() + 2); QVERIFY(myText->contentHeight() <= myText->height() + 2); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // VerticalFit should reduce the size to the wrapped text within the vertical height. verticalFitHeight = myText->contentHeight(); verticalFitWidth = myText->contentWidth(); @@ -3530,40 +3531,40 @@ void tst_qquicktext::fontSizeModeMultiline() // Elide won't affect the height or width of a wrapped text with VerticalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Should be the same as VerticalFit with wrapping. QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); // Elide won't affect the size with Fit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::FixedSize); myText->setMaximumLineCount(2); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // The original text wrapped should exceed the height of the item. QVERIFY(originalWidth <= myText->width() + 2); QVERIFY(originalHeight > myText->height()); myText->setFontSizeMode(QQuickText::HorizontalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // HorizontalFit should reduce the font size to minimize wrapping, which brings it back to the // same size as without text wrapping. QCOMPARE(myText->contentWidth(), horizontalFitWidth); @@ -3571,16 +3572,16 @@ void tst_qquicktext::fontSizeModeMultiline() // Elide won't affect the size with HorizontalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(myText->truncated()); QVERIFY(myText->contentWidth() <= myText->width() + 2); QVERIFY(myText->contentHeight() <= myText->height() + 2); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::VerticalFit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // VerticalFit should reduce the size to the wrapped text within the vertical height. verticalFitHeight = myText->contentHeight(); verticalFitWidth = myText->contentWidth(); @@ -3590,29 +3591,29 @@ void tst_qquicktext::fontSizeModeMultiline() // Elide won't affect the height or width of a wrapped text with VerticalFit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); myText->setFontSizeMode(QQuickText::Fit); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); // Should be the same as VerticalFit with wrapping. QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); // Elide won't affect the size with Fit. myText->setElideMode(QQuickText::ElideRight); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QVERIFY(!myText->truncated()); QCOMPARE(myText->contentWidth(), verticalFitWidth); QCOMPARE(myText->contentHeight(), verticalFitHeight); myText->setElideMode(QQuickText::ElideNone); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); } void tst_qquicktext::multilengthStrings_data() @@ -3637,17 +3638,17 @@ void tst_qquicktext::multilengthStrings() const QString shortText = "fox jumped dog"; myText->setText(longText); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); const qreal longWidth = myText->contentWidth(); const qreal longHeight = myText->contentHeight(); myText->setText(mediumText); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); const qreal mediumWidth = myText->contentWidth(); const qreal mediumHeight = myText->contentHeight(); myText->setText(shortText); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); const qreal shortWidth = myText->contentWidth(); const qreal shortHeight = myText->contentHeight(); @@ -3655,21 +3656,21 @@ void tst_qquicktext::multilengthStrings() myText->setText(longText + QLatin1Char('\x9c') + mediumText + QLatin1Char('\x9c') + shortText); myText->setSize(QSizeF(longWidth, longHeight)); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QCOMPARE(myText->contentWidth(), longWidth); QCOMPARE(myText->contentHeight(), longHeight); QCOMPARE(myText->truncated(), false); myText->setSize(QSizeF(mediumWidth, mediumHeight)); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QCOMPARE(myText->contentWidth(), mediumWidth); QCOMPARE(myText->contentHeight(), mediumHeight); QCOMPARE(myText->truncated(), true); myText->setSize(QSizeF(shortWidth, shortHeight)); - QTRY_COMPARE(QQuickItemPrivate::get(myText)->polishScheduled, false); + QVERIFY(QQuickTest::qWaitForItemPolished(myText)); QCOMPARE(myText->contentWidth(), shortWidth); QCOMPARE(myText->contentHeight(), shortHeight); diff --git a/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml b/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml new file mode 100644 index 0000000000..24bd434830 --- /dev/null +++ b/tests/auto/quick/qquicktextedit/data/keys_shortcutoverride.qml @@ -0,0 +1,34 @@ +import QtQuick 2.10 + +Item { + width: 320 + height: 200 + property string who : "nobody" + + Shortcut { + sequence: "Esc" + onActivated: who = "Shortcut" + } + + TextEdit { + id: txt + x: 100 + text: "enter text" + Keys.onShortcutOverride: { + who = "TextEdit" + event.accepted = (event.key === Qt.Key_Escape) + } + } + + Rectangle { + objectName: "rectangle" + width: 90 + height: width + focus: true + color: focus ? "red" : "gray" + Keys.onShortcutOverride: { + who = "Rectangle" + event.accepted = (event.key === Qt.Key_Escape) + } + } +} diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index da15ca6b48..f32da44daa 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -36,6 +36,7 @@ #include <QtQml/qqmlexpression.h> #include <QtQml/qqmlcomponent.h> #include <QtGui/qguiapplication.h> +#include <private/qquickrectangle_p.h> #include <private/qquicktextedit_p.h> #include <private/qquicktextedit_p_p.h> #include <private/qquicktext_p.h> @@ -205,6 +206,7 @@ private slots: void padding(); void QTBUG_51115_readOnlyResetsSelection(); + void keys_shortcutoverride(); private: void simulateKeys(QWindow *window, const QList<Key> &keys); @@ -5671,6 +5673,36 @@ void tst_qquicktextedit::QTBUG_51115_readOnlyResetsSelection() QCOMPARE(obj->selectedText(), QString()); } +void tst_qquicktextedit::keys_shortcutoverride() +{ + // Tests that QML TextEdit receives Keys.onShortcutOverride (QTBUG-68711) + QQuickView view; + view.setSource(testFileUrl("keys_shortcutoverride.qml")); + view.show(); + view.requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + QObject *root = view.rootObject(); + QVERIFY(root); + + QQuickTextEdit *textEdit = root->findChild<QQuickTextEdit*>(); + QVERIFY(textEdit); + QQuickRectangle *rectangle = root->findChild<QQuickRectangle*>(QLatin1String("rectangle")); + QVERIFY(rectangle); + + // Precondition: check if its not already changed + QCOMPARE(root->property("who").value<QString>(), QLatin1String("nobody")); + + // send Key_Escape to the Rectangle + QVERIFY(rectangle->hasActiveFocus()); + QTest::keyPress(&view, Qt::Key_Escape); + QCOMPARE(root->property("who").value<QString>(), QLatin1String("Rectangle")); + + // send Key_Escape to TextEdit + textEdit->setFocus(true); + QTest::keyPress(&view, Qt::Key_Escape); + QCOMPARE(root->property("who").value<QString>(), QLatin1String("TextEdit")); +} + QTEST_MAIN(tst_qquicktextedit) #include "tst_qquicktextedit.moc" diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h index 1cdbaf838b..e623e3e225 100644 --- a/tests/auto/quick/shared/visualtestutil.h +++ b/tests/auto/quick/shared/visualtestutil.h @@ -100,7 +100,4 @@ namespace QQuickVisualTestUtil bool compareImages(const QImage &ia, const QImage &ib, QString *errorMessage); } -#define QQUICK_VERIFY_POLISH(item) \ - QTRY_COMPARE(QQuickItemPrivate::get(item)->polishScheduled, false) - #endif // QQUICKVISUALTESTUTIL_H |