From a0adcc6480bce8ca4f91afc792176d313f92ecee Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 20 Apr 2012 17:02:38 +1000 Subject: Only run populate for items in model at creation Don't run for items added in Component.onCompleted. Change-Id: I58745ab989efae168d036875cb2fb88e3e2db0c3 Reviewed-by: Andrew den Exter --- .../quick/qquickgridview/tst_qquickgridview.cpp | 44 ++++++++++------------ 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'tests/auto/quick/qquickgridview') diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index f5019fce52..d39fbe5e29 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -4531,37 +4531,37 @@ void tst_QQuickGridView::populateTransitions() QQuickItem *contentItem = gridview->contentItem(); QVERIFY(contentItem); - if (staticallyPopulate || dynamicallyPopulate) { - // check the populate transition is run - if (usePopulateTransition) { - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 19); - } else { - QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0); - } + // check the populate transition is run + if (staticallyPopulate && usePopulateTransition) { + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 18); QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); + } else if (dynamicallyPopulate) { + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0); + QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 18); } else { QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); + QCOMPARE(gridview->property("countPopulateTransitions").toInt(), 0); + QCOMPARE(gridview->property("countAddTransitions").toInt(), 0); } int itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); QQuickText *name = findItem(contentItem, "textName", i); QVERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); } + gridview->setProperty("countPopulateTransitions", 0); + gridview->setProperty("countAddTransitions", 0); + // add an item and check this is done with add transition, not populate model.insertItem(0, "another item", ""); QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 1); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), - (usePopulateTransition && (staticallyPopulate || dynamicallyPopulate)) ? 19 : 0); + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), 0); // clear the model canvas->rootContext()->setContextProperty("testModel", QVariant()); @@ -4577,17 +4577,15 @@ void tst_QQuickGridView::populateTransitions() canvas->rootContext()->setContextProperty("testModel", &model); QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0); + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 18 : 0); QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); QQuickText *name = findItem(contentItem, "textName", i); QVERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); @@ -4597,17 +4595,15 @@ void tst_QQuickGridView::populateTransitions() gridview->setProperty("countPopulateTransitions", 0); gridview->setProperty("countAddTransitions", 0); model.reset(); - QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 19 : 0); + QTRY_COMPARE(gridview->property("countPopulateTransitions").toInt(), usePopulateTransition ? 18 : 0); QTRY_COMPARE(gridview->property("countAddTransitions").toInt(), 0); itemCount = findItems(contentItem, "wrapper").count(); - if (usePopulateTransition) - QCOMPARE(itemCount, gridview->property("countPopulateTransitions").toInt()); for (int i=0; i < model.count() && i < itemCount; ++i) { QQuickItem *item = findItem(contentItem, "wrapper", i); QVERIFY2(item, QTest::toString(QString("Item %1 not found").arg(i))); - QCOMPARE(item->x(), (i%3)*80.0); - QCOMPARE(item->y(), (i/3)*60.0); + QTRY_COMPARE(item->x(), (i%3)*80.0); + QTRY_COMPARE(item->y(), (i/3)*60.0); QQuickText *name = findItem(contentItem, "textName", i); QVERIFY(name != 0); QTRY_COMPARE(name->text(), model.name(i)); -- cgit v1.2.3