summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-11-17 01:01:29 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-11-17 01:01:29 (GMT)
commitd2fc7cdc3eb436d4ed8149ec25f692864e518105 (patch)
tree5fb5b361c17c62bfab2a235c9f9c9bdb8ac41c84 /tests
parent5b3cc2f64f15b48edaa6f2470c96e87ab98390c5 (diff)
downloadQt-d2fc7cdc3eb436d4ed8149ec25f692864e518105.zip
Qt-d2fc7cdc3eb436d4ed8149ec25f692864e518105.tar.gz
Qt-d2fc7cdc3eb436d4ed8149ec25f692864e518105.tar.bz2
Hit some more untested lines in ListView and GridView.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp36
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/data/listview.qml1
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp19
3 files changed, 54 insertions, 2 deletions
diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
index d0b7462..197191e 100644
--- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
+++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp
@@ -61,8 +61,8 @@ private slots:
void inserted();
void removed();
void moved();
- void currentIndex();
void changeFlow();
+ void currentIndex();
void defaultValues();
void properties();
@@ -310,7 +310,7 @@ void tst_QmlGraphicsGridView::removed()
QmlView *canvas = createView(SRCDIR "/data/gridview.qml");
TestModel model;
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 40; i++)
model.addItem("Item" + QString::number(i), "");
QmlContext *ctxt = canvas->rootContext();
@@ -388,6 +388,7 @@ void tst_QmlGraphicsGridView::removed()
// Remove items before visible
gridview->setViewportY(120);
+ QTest::qWait(500);
gridview->setCurrentIndex(10);
// let transitions settle.
@@ -421,6 +422,14 @@ void tst_QmlGraphicsGridView::removed()
QVERIFY(item->y() == (i/3)*60);
}
+ // remove item outside current view.
+ gridview->setCurrentIndex(32);
+ QTest::qWait(500);
+ gridview->setViewportY(240);
+
+ model.removeItem(30);
+ QVERIFY(gridview->currentIndex() == 31);
+
delete canvas;
}
@@ -623,6 +632,29 @@ void tst_QmlGraphicsGridView::currentIndex()
QVERIFY(key.isAccepted());
QCOMPARE(gridview->currentIndex(), 0);
+ gridview->setFlow(QmlGraphicsGridView::TopToBottom);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Right, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(gridview->currentIndex(), 5);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(gridview->currentIndex(), 0);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(gridview->currentIndex(), 1);
+
+ key = QKeyEvent(QEvent::KeyPress, Qt::Key_Up, Qt::NoModifier, "", false, 1);
+ QApplication::sendEvent(canvas, &key);
+ QVERIFY(key.isAccepted());
+ QCOMPARE(gridview->currentIndex(), 0);
+
+
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
QVERIFY(gridview->highlightFollowsCurrentItem() == false);
diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
index ec8bb68..b64b399 100644
--- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
+++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml
@@ -114,5 +114,6 @@ Rectangle {
highlight: testObject.invalidHighlight ? invalidHl : myHighlight
highlightMoveSpeed: 1000
highlightResizeSpeed: 1000
+ cacheBuffer: testObject.cacheBuffer
}
}
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
index c5dadab..36f4dc5 100644
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
@@ -575,6 +575,25 @@ void tst_QmlGraphicsListView::removed(bool animated)
QCOMPARE(item->y(),40+i*20.0);
}
+ // remove current item beyond visible items.
+ listview->setCurrentIndex(20);
+ QTest::qWait(500);
+ model.removeItem(20);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 20);
+ QVERIFY(listview->currentItem() != 0);
+
+ // remove item before current, but visible
+ listview->setCurrentIndex(8);
+ QTest::qWait(500);
+ QmlGraphicsItem *oldCurrent = listview->currentItem();
+ model.removeItem(6);
+ QTest::qWait(500);
+
+ QCOMPARE(listview->currentIndex(), 7);
+ QVERIFY(listview->currentItem() == oldCurrent);
+
delete canvas;
}