From 80d85e0017cb5cc4b0a0df6c19d4126bf5062731 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 12 Jan 2012 15:31:00 +1000 Subject: Handle views with negative width/height A view with a negative d->size() would get stuck in an infinite loop. Also make sure item layout/visibility is updated when the view size changes. Change-Id: I1f16a714ecebe1c4b71902c460e27fb0f1c4406f Reviewed-by: Bea Lam --- .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp') diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index a83d8a2d08..ed7ee4daeb 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -3175,6 +3175,41 @@ void tst_QQuickGridView::resizeViewAndRepaint() gridview->setHeight(100); QTRY_VERIFY(!findItem(contentItem, "wrapper", 10)); + // Ensure we handle -ve sizes + gridview->setHeight(-100); + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 3); + + gridview->setCacheBuffer(120); + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 9); + + // ensure items in cache become visible + gridview->setHeight(120); + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 15); + + int itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal((i%3)*80)); + QTRY_COMPARE(item->y(), qreal((i/3)*60)); + QCOMPARE(item->isVisible(), i < 9); // inside view visible, outside not visible + } + + // ensure items outside view become invisible + gridview->setHeight(60); + QTRY_COMPARE(findItems(contentItem, "wrapper").count(), 12); + + itemCount = findItems(contentItem, "wrapper").count(); + for (int i = 0; i < model.count() && i < itemCount; ++i) { + QQuickItem *item = findItem(contentItem, "wrapper", i); + if (!item) qWarning() << "Item" << i << "not found"; + QTRY_VERIFY(item); + QTRY_COMPARE(item->x(), qreal((i%3)*80)); + QTRY_COMPARE(item->y(), qreal((i/3)*60)); + QCOMPARE(item->isVisible(), i < 6); // inside view visible, outside not visible + } + delete canvas; } -- cgit v1.2.3 From 5f730bc3ae4cf18c46e513bf1db055b2d9255fdc Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 16 Jan 2012 18:30:58 +1000 Subject: Wait for polish at the start of addOrRemoveBeforeVisible Change-Id: I1cf13af7e9b854cee7754b31643438eab3085084 Reviewed-by: Bea Lam --- tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp') diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index ed7ee4daeb..e2bcbfd420 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -1040,6 +1040,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible() gridview->setCurrentIndex(0); qApp->processEvents(); + QTRY_COMPARE(QQuickItemPrivate::get(gridview)->polishScheduled, false); // scroll down until item 0 is no longer drawn // (bug not triggered if we just move using content y, since that doesn't -- cgit v1.2.3 From 52c1d7a994216f0b37ac04a2fea4337bc0c7550b Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 13 Jan 2012 14:35:04 +1000 Subject: Insertions were calculating wrong insertion pos After removes, and after each insertion, the view must adjust the visibleItems.first() position and call layoutVisibleItems() to ensure that the correct insertion position is calculated for insertions that follow. When applyInsertionChange() in GridView and ListView calculates the position for item insertion, it looks at the current positions of the items in visibleItems, so these positions must be updated prior to this calculation. Otherwise, insertions that follow a remove may not calculate this position correctly and will neglect to add some items, and multiple insertions may unnecessarily create items at positions that are not actually visible. resetFirstItemPosition() is changed to take a set position and it replaces resetItemPosition() since it can do the same thing. Task-number: QTBUG-23610 QTBUG-23609 Change-Id: I8839ee7d15853301435e80c0dc563f93fc3605cf Reviewed-by: Martin Jones --- .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp') diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index e2bcbfd420..132fa5fad3 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -1302,6 +1302,26 @@ void tst_QQuickGridView::moved_data() << 0 << 6 << 3 << 60.0; // top row moved and shifted to below 3rd row, all items should shift down by 1 row + QTest::newRow("move multiple forwards, mix of non-visible/visible") + << 120.0 + << 3 << 16 << 6 + << 60.0; // top two rows removed, third row is now the first visible + + QTest::newRow("move multiple forwards, to bottom of view") + << 0.0 + << 5 << 13 << 5 + << 0.0; + + QTest::newRow("move multiple forwards, to bottom of view, first row -> last") + << 0.0 + << 0 << 15 << 3 + << 0.0; + + QTest::newRow("move multiple forwards, to bottom of view, content y not 0") + << 120.0 + << 5+4 << 13+4 << 5 + << 0.0; + QTest::newRow("move multiple forwards, from visible -> non-visible") << 0.0 << 1 << 16 << 3 -- cgit v1.2.3 From d9fd9ff55d4d8717cb35b7af39f9f5f39f9a3448 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 18 Jan 2012 16:21:50 +1000 Subject: Fix lockup in views due to endless polish loop. It was possible to cause an endless polish loop in some rare cases. Eliminate all calls to polish() within existing polish() code paths. Cleanup delegate creation and cancelling in the cacheBuffer area. Adjust first item position correctly when inserting/removing before visibleItems list. Change-Id: I508a2e6de8cb09d904466cbf5fb6b5dfd1e89c49 Reviewed-by: Bea Lam --- .../qtquick2/qquickgridview/tst_qquickgridview.cpp | 64 +++++++++++----------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp') diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 132fa5fad3..15abe325fa 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -467,7 +467,7 @@ void tst_QQuickGridView::inserted_more() // check visibleItems.first() is in correct position QQuickItem *item0 = findItem(contentItem, "wrapper", 0); QVERIFY(item0); - QCOMPARE(item0->y(), itemsOffsetAfterMove); + QCOMPARE(item0->y(), 0.0); QList items = findItems(contentItem, "wrapper"); int firstVisibleIndex = -1; @@ -840,6 +840,7 @@ void tst_QQuickGridView::removed_more() QFETCH(int, removeIndex); QFETCH(int, removeCount); QFETCH(qreal, itemsOffsetAfterMove); + QFETCH(QString, firstVisible); QQuickText *name; QQuickText *number; @@ -868,22 +869,20 @@ void tst_QQuickGridView::removed_more() model.removeItems(removeIndex, removeCount); QTRY_COMPARE(gridview->property("count").toInt(), model.count()); - // check visibleItems.first() is in correct position - QQuickItem *item0 = findItem(contentItem, "wrapper", 0); -// qApp->exec(); - QVERIFY(item0); - QCOMPARE(item0->y(), itemsOffsetAfterMove); - + QString firstName; int firstVisibleIndex = -1; QList items = findItems(contentItem, "wrapper"); for (int i=0; iy() >= contentY) { QDeclarativeExpression e(qmlContext(items[i]), items[i], "index"); firstVisibleIndex = e.evaluate().toInt(); + QDeclarativeExpression en(qmlContext(items[i]), items[i], "name"); + firstName = en.evaluate().toString(); break; } } QVERIFY2(firstVisibleIndex >= 0, QTest::toString(firstVisibleIndex)); + QCOMPARE(firstName, firstVisible); // Confirm items positioned correctly and indexes correct int itemCount = findItems(contentItem, "wrapper").count(); @@ -911,21 +910,27 @@ void tst_QQuickGridView::removed_more_data() QTest::addColumn("removeIndex"); QTest::addColumn("removeCount"); QTest::addColumn("itemsOffsetAfterMove"); + QTest::addColumn("firstVisible"); QTest::newRow("remove 1, before visible items") << 120.0 // show 6-23 << 3 << 1 - << 0.0; + << 0.0 << "Item7"; QTest::newRow("remove multiple, all before visible items") << 120.0 << 1 << 3 - << 60.0; // removed top row, slide down by 1 row + << 60.0 << "Item6"; // removed top row, slide down by 1 row QTest::newRow("remove multiple, all before visible items, remove item 0") << 120.0 << 0 << 4 - << 60.0; // removed top row, slide down by 1 row + << 60.0 << "Item7"; // removed top row, slide down by 1 row + + QTest::newRow("remove multiple rows, all before visible items") + << 240.0 // show 12-29 + << 1 << 7 + << 120.0 << "Item13"; // remove 3,4,5 before the visible pos, first row moves down to just before the visible pos, @@ -933,80 +938,80 @@ void tst_QQuickGridView::removed_more_data() QTest::newRow("remove multiple, mix of items from before and within visible items") << 120.0 << 3 << 5 - << 60.0; // adjust for the 1 row removed before the visible + << 60.0 << "Item8"; // adjust for the 1 row removed before the visible QTest::newRow("remove multiple, mix of items from before and within visible items, remove item 0") << 120.0 << 0 << 8 - << 60.0 * 2; // adjust for the 2 rows removed before the visible + << 60.0 * 2 << "Item8"; // adjust for the 2 rows removed before the visible QTest::newRow("remove 1, from start of visible, content at start") << 0.0 << 0 << 1 - << 0.0; + << 0.0 << "Item1"; QTest::newRow("remove multiple, from start of visible, content at start") << 0.0 << 0 << 3 - << 0.0; + << 0.0 << "Item3"; QTest::newRow("remove 1, from start of visible, content not at start") << 120.0 // show 6-23 << 4 << 1 - << 0.0; + << 0.0 << "Item7"; QTest::newRow("remove multiple, from start of visible, content not at start") << 120.0 // show 6-23 << 4 << 3 - << 0.0; + << 0.0 << "Item9"; QTest::newRow("remove 1, from middle of visible, content at start") << 0.0 << 10 << 1 - << 0.0; + << 0.0 << "Item0"; QTest::newRow("remove multiple, from middle of visible, content at start") << 0.0 << 10 << 5 - << 0.0; + << 0.0 << "Item0"; QTest::newRow("remove 1, from middle of visible, content not at start") << 120.0 // show 6-23 << 10 << 1 - << 0.0; + << 0.0 << "Item6"; QTest::newRow("remove multiple, from middle of visible, content not at start") << 120.0 // show 6-23 << 10 << 5 - << 0.0; + << 0.0 << "Item6"; QTest::newRow("remove 1, after visible, content at start") << 0.0 << 16 << 1 - << 0.0; + << 0.0 << "Item0"; QTest::newRow("remove multiple, after visible, content at start") << 0.0 << 16 << 5 - << 0.0; + << 0.0 << "Item0"; QTest::newRow("remove 1, after visible, content not at start") << 120.0 // show 6-23 << 16+4 << 1 - << 0.0; + << 0.0 << "Item6"; QTest::newRow("remove multiple, after visible, content not at start") << 120.0 // show 6-23 << 16+4 << 5 - << 0.0; + << 0.0 << "Item6"; QTest::newRow("remove multiple, mix of items from within and after visible items") << 120.0 // show 6-23 << 20 << 5 - << 0.0; + << 0.0 << "Item6"; } void tst_QQuickGridView::addOrRemoveBeforeVisible() @@ -1092,7 +1097,7 @@ void tst_QQuickGridView::addOrRemoveBeforeVisible_data() QTest::addColumn("newTopContentY"); QTest::newRow("add") << true << -60.0; - QTest::newRow("remove") << false << 0.0; + QTest::newRow("remove") << false << -60.0; } void tst_QQuickGridView::clear() @@ -1135,11 +1140,6 @@ void tst_QQuickGridView::clear() void tst_QQuickGridView::moved() { - if (QTest::currentDataTag() == QLatin1String("move 1 forwards, from non-visible -> visible") - || QTest::currentDataTag() == QLatin1String("move 1 forwards, from non-visible -> visible (move first item)")) { - QSKIP("QTBUG-23455"); - } - QFETCH(qreal, contentY); QFETCH(int, from); QFETCH(int, to); @@ -1223,13 +1223,11 @@ void tst_QQuickGridView::moved_data() << 1 << 8 << 1 << 0.0; - // skipped QTBUG-23455 QTest::newRow("move 1 forwards, from non-visible -> visible") << 120.0 // show 6-23 << 1 << 23 << 1 << 0.0; - // skipped QTBUG-23455 QTest::newRow("move 1 forwards, from non-visible -> visible (move first item)") << 120.0 // // show 6-23 << 0 << 6 << 1 -- cgit v1.2.3 From e6b224aa2872d7d1030fa98bd30603e16f8f9604 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Fri, 20 Jan 2012 14:04:27 +1000 Subject: Update obsolete contact address. Replace Nokia contact email address with Qt Project website. Change-Id: I6a730abc0c396fb545a48b2d6938abedac2e3f1c Reviewed-by: Rohan McGovern Reviewed-by: Alan Alpert --- tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp') diff --git a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp index 15abe325fa..0a6e41fc5e 100644 --- a/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/qtquick2/qquickgridview/tst_qquickgridview.cpp @@ -2,7 +2,7 @@ ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) +** Contact: http://www.qt-project.org/ ** ** This file is part of the test suite of the Qt Toolkit. ** -- cgit v1.2.3