summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmlgraphicslistview
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-09 04:54:19 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-09 04:54:19 (GMT)
commit26dbd51beadc290ea2ad7ce046d1bf8485fbffc4 (patch)
treea999bda642740dc22e25e3b3c24649075ae26e5a /tests/auto/declarative/qmlgraphicslistview
parent714a957a9144e6c4189dacf96132cf01bf9350e8 (diff)
downloadQt-26dbd51beadc290ea2ad7ce046d1bf8485fbffc4.zip
Qt-26dbd51beadc290ea2ad7ce046d1bf8485fbffc4.tar.gz
Qt-26dbd51beadc290ea2ad7ce046d1bf8485fbffc4.tar.bz2
More tests and fixes for ListView and GridView
Diffstat (limited to 'tests/auto/declarative/qmlgraphicslistview')
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml43
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp35
2 files changed, 78 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml b/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml
new file mode 100644
index 0000000..36d3501
--- /dev/null
+++ b/tests/auto/declarative/qmlgraphicslistview/data/itemlist.qml
@@ -0,0 +1,43 @@
+// This example demonstrates placing items in a view using
+// a VisualItemModel
+
+import Qt 4.6
+
+Rectangle {
+ color: "lightgray"
+ width: 240
+ height: 320
+
+ VisualItemModel {
+ id: itemModel
+ objectName: "itemModel"
+ Rectangle {
+ objectName: "item1"
+ height: view.height; width: view.width; color: "#FFFEF0"
+ Text { text: "Page 1"; font.bold: true; anchors.centerIn: parent }
+ }
+ Rectangle {
+ objectName: "item2"
+ height: view.height; width: view.width; color: "#F0FFF7"
+ Text { text: "Page 2"; font.bold: true; anchors.centerIn: parent }
+ }
+ Rectangle {
+ objectName: "item3"
+ height: view.height; width: view.width; color: "#F4F0FF"
+ Text { text: "Page 3"; font.bold: true; anchors.centerIn: parent }
+ }
+ }
+
+ ListView {
+ id: view
+ objectName: "view"
+ anchors.fill: parent
+ anchors.bottomMargin: 30
+ model: itemModel
+ preferredHighlightBegin: 0
+ preferredHighlightEnd: 0
+ highlightRangeMode: "StrictlyEnforceRange"
+ orientation: ListView.Horizontal
+ flickDeceleration: 2000
+ }
+}
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
index de26635..afef47a 100644
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
@@ -43,6 +43,7 @@
#include <qmlview.h>
#include <private/qmlgraphicslistview_p.h>
#include <private/qmlgraphicstext_p.h>
+#include <private/qmlgraphicsvisualitemmodel_p.h>
#include <qmlcontext.h>
#include <qmlexpression.h>
@@ -53,6 +54,7 @@ public:
tst_QmlGraphicsListView();
private slots:
+ void itemList();
// Test both QListModelInterface and QAbstractItemModel model types
void qListModelInterface_items();
void qAbstractItemModel_items();
@@ -844,6 +846,39 @@ void tst_QmlGraphicsListView::currentIndex()
delete canvas;
}
+void tst_QmlGraphicsListView::itemList()
+{
+ QmlView *canvas = createView(SRCDIR "/data/itemlist.qml");
+
+ canvas->execute();
+ qApp->processEvents();
+
+ QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->root(), "view");
+ QVERIFY(listview != 0);
+
+ QmlGraphicsItem *viewport = listview->viewport();
+ QVERIFY(viewport != 0);
+
+ QmlGraphicsVisualItemModel *model = canvas->root()->findChild<QmlGraphicsVisualItemModel*>("itemModel");
+ QVERIFY(model != 0);
+
+ QVERIFY(model->count() == 3);
+ QCOMPARE(listview->currentIndex(), 0);
+
+ QmlGraphicsItem *item = findItem<QmlGraphicsItem>(viewport, "item1");
+ QVERIFY(item);
+ QCOMPARE(item->x(), 0.0);
+
+ listview->setCurrentIndex(2);
+ QTest::qWait(1000);
+
+ item = findItem<QmlGraphicsItem>(viewport, "item3");
+ QVERIFY(item);
+ QCOMPARE(item->x(), 480.0);
+
+ delete canvas;
+}
+
void tst_QmlGraphicsListView::qListModelInterface_items()
{
items<TestModel>();