aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2012-02-14 10:54:56 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-14 03:31:03 +0100
commit452be83f43f190cce04b8dc6b4b5f2e797c5886b (patch)
tree3e617c60996cef786323d01d4f357ea624c57c1f /tests
parentda068b60656dd80ba3a7b383b662800389323f83 (diff)
Fix and stabilise sectionsPositioning() test
The 'Turn sticky footer off' part was setting the content y to 40 which meant the sect_new was already below the last visible item of the previous section, so turning off the NextLabelAtEnd flag didn't move sect_new further down the view. (This test only occasionally failed since the window didn't always update after changing the content y, but now it changes the content y then waits for a polish before continuing.) Change-Id: I6a424f4bbd2eec1904a5fd20eb2bd79d5cac5b84 Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
index b77a8c0ca3..e809f95eed 100644
--- a/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/qtquick2/qquicklistview/tst_qquicklistview.cpp
@@ -1953,7 +1953,6 @@ void tst_QQuickListView::sectionsDelegate()
void tst_QQuickListView::sectionsPositioning()
{
QQuickView *canvas = createView();
- canvas->show();
QmlListModel model;
for (int i = 0; i < 30; i++)
@@ -1963,14 +1962,15 @@ void tst_QQuickListView::sectionsPositioning()
ctxt->setContextProperty("testModel", &model);
canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
+ canvas->show();
qApp->processEvents();
canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd)));
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
-
QQuickItem *contentItem = listview->contentItem();
QTRY_VERIFY(contentItem != 0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
for (int i = 0; i < 3; ++i) {
QQuickItem *item = findItem<QQuickItem>(contentItem, "sect_" + QString::number(i));
@@ -1988,10 +1988,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);
QCOMPARE(topItem->y(), 0.);
// push the top header up
listview->setContentY(110);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
topItem = findVisibleChild(contentItem, "sect_0"); // section header
QVERIFY(topItem);
QCOMPARE(topItem->y(), 100.);
@@ -2006,11 +2008,13 @@ void tst_QQuickListView::sectionsPositioning()
// Move past section 0
listview->setContentY(120);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
topItem = findVisibleChild(contentItem, "sect_0"); // section header
QVERIFY(!topItem);
// Push section footer down
listview->setContentY(70);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
bottomItem = findVisibleChild(contentItem, "sect_4"); // section footer
QVERIFY(bottomItem);
QCOMPARE(bottomItem->y(), 380.);
@@ -2038,6 +2042,7 @@ void tst_QQuickListView::sectionsPositioning()
// remove section boundary
listview->setContentY(120);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
model.removeItem(5);
QTRY_COMPARE(listview->count(), model.count());
for (int i = 0; i < 3; ++i) {
@@ -2052,24 +2057,28 @@ void tst_QQuickListView::sectionsPositioning()
// Change the next section
listview->setContentY(0);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
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);
QTRY_VERIFY(bottomItem = findVisibleChild(contentItem, "sect_new")); // section footer
QTRY_COMPARE(bottomItem->y(), 300.);
// Turn sticky footer off
- listview->setContentY(40);
+ listview->setContentY(20);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart)));
item = findVisibleChild(contentItem, "sect_new"); // inline label restored
QVERIFY(item);
- QCOMPARE(item->y(), 360.);
+ QCOMPARE(item->y(), 340.);
// Turn sticky header off
listview->setContentY(30);
+ QTRY_COMPARE(QQuickItemPrivate::get(listview)->polishScheduled, false);
canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels)));
item = findVisibleChild(contentItem, "sect_aaa"); // inline label restored
QVERIFY(item);