summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-07-14 05:32:32 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-07-14 05:32:32 (GMT)
commit9adc85fdfa0af2b6948408932188ee1b79247fa6 (patch)
tree42e472c72c1cd4a51383ff948e16eec970ae625f /tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
parent7bd9e6c5805ab78c68161bec20c225965ea59ddb (diff)
downloadQt-9adc85fdfa0af2b6948408932188ee1b79247fa6.zip
Qt-9adc85fdfa0af2b6948408932188ee1b79247fa6.tar.gz
Qt-9adc85fdfa0af2b6948408932188ee1b79247fa6.tar.bz2
Position GridView and ListView footer correctly when model cleared.
Task-number: QTBUG-12167
Diffstat (limited to 'tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index a67c56f..1a28b71 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -81,6 +81,7 @@ private slots:
void enforceRange();
void QTBUG_8456();
void manualHighlight();
+ void footer();
private:
QDeclarativeView *createView();
@@ -147,6 +148,14 @@ public:
emit dataChanged(index(idx,0), index(idx,0));
}
+ void clear() {
+ int count = list.count();
+ emit beginRemoveRows(QModelIndex(), 0, count-1);
+ list.clear();
+ emit endRemoveRows();
+ }
+
+
private:
QList<QPair<QString,QString> > list;
};
@@ -1162,6 +1171,38 @@ void tst_QDeclarativeGridView::manualHighlight()
QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x());
}
+void tst_QDeclarativeGridView::footer()
+{
+ QDeclarativeView *canvas = createView();
+
+ TestModel model;
+ for (int i = 0; i < 7; i++)
+ model.addItem("Item" + QString::number(i), "");
+
+ QDeclarativeContext *ctxt = canvas->rootContext();
+ ctxt->setContextProperty("testModel", &model);
+
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/footer.qml"));
+ qApp->processEvents();
+
+ QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
+ QTRY_VERIFY(gridview != 0);
+
+ QDeclarativeItem *contentItem = gridview->contentItem();
+ QTRY_VERIFY(contentItem != 0);
+
+ QDeclarativeText *footer = findItem<QDeclarativeText>(contentItem, "footer");
+ QVERIFY(footer);
+
+ QCOMPARE(footer->y(), 180.0);
+
+ model.removeItem(2);
+ QTRY_COMPARE(footer->y(), 120.0);
+
+ model.clear();
+ QTRY_COMPARE(footer->y(), 0.0);
+}
+
QDeclarativeView *tst_QDeclarativeGridView::createView()
{