summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativegridview
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-23 06:13:18 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-23 06:13:18 (GMT)
commita60f8832425aafbe6c5e8be3c25fefc9f8f2f87b (patch)
treed3dc3a72de7b1d19671e2d006dc201842e7d85f0 /tests/auto/declarative/qdeclarativegridview
parent3e209785c3f027973089ccbebc6528501f416f2b (diff)
downloadQt-a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b.zip
Qt-a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b.tar.gz
Qt-a60f8832425aafbe6c5e8be3c25fefc9f8f2f87b.tar.bz2
Ensure the view is correctly positioned at component complete.
If a currentIndex has been specified, ensure the view starts at the correct position immediately, rather than scrolling to it after startup.
Diffstat (limited to 'tests/auto/declarative/qdeclarativegridview')
-rw-r--r--tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml2
-rw-r--r--tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp57
2 files changed, 30 insertions, 29 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
index 9331243..a5d651d 100644
--- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
+++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml
@@ -43,7 +43,7 @@ Rectangle {
focus: true
width: 240
height: 320
- currentIndex: 5
+ currentIndex: 35
cellWidth: 80
cellHeight: 60
delegate: myDelegate
diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
index 4e35bc0..deff1f8 100644
--- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
+++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp
@@ -557,7 +557,7 @@ void tst_QDeclarativeGridView::moved()
void tst_QDeclarativeGridView::currentIndex()
{
TestModel model;
- for (int i = 0; i < 30; i++)
+ for (int i = 0; i < 60; i++)
model.addItem("Item" + QString::number(i), QString::number(i));
QDeclarativeView *canvas = new QDeclarativeView(0);
@@ -572,57 +572,58 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid");
- QTRY_VERIFY(gridview != 0);
+ QVERIFY(gridview != 0);
QDeclarativeItem *viewport = gridview->viewport();
- QTRY_VERIFY(viewport != 0);
+ QVERIFY(viewport != 0);
// current item should be third item
- QTRY_COMPARE(gridview->currentIndex(), 5);
- QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 5));
- QTRY_COMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->currentIndex(), 35);
+ QCOMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 35));
+ QCOMPARE(gridview->currentItem()->y(), gridview->highlightItem()->y());
+ QCOMPARE(gridview->contentY(), 399.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), 9);
+ QCOMPARE(gridview->currentIndex(), 39);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 6);
+ QCOMPARE(gridview->currentIndex(), 36);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 35);
// no wrap
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexUp();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setCurrentIndex(model.count()-1);
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
gridview->moveCurrentIndexDown();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
// with wrap
gridview->setWrapEnabled(true);
gridview->setCurrentIndex(0);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->moveCurrentIndexLeft();
- QTRY_COMPARE(gridview->currentIndex(), model.count()-1);
+ QCOMPARE(gridview->currentIndex(), model.count()-1);
- QTRY_COMPARE(gridview->contentY(), 279.0);
+ QTRY_COMPARE(gridview->contentY(), 879.0);
gridview->moveCurrentIndexRight();
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTRY_COMPARE(gridview->contentY(), 0.0);
@@ -638,30 +639,30 @@ void tst_QDeclarativeGridView::currentIndex()
qApp->processEvents();
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 3);
+ QCOMPARE(gridview->currentIndex(), 3);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
gridview->setFlow(QDeclarativeGridView::TopToBottom);
QTest::keyClick(canvas, Qt::Key_Right);
- QTRY_COMPARE(gridview->currentIndex(), 5);
+ QCOMPARE(gridview->currentIndex(), 5);
QTest::keyClick(canvas, Qt::Key_Left);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
QTest::keyClick(canvas, Qt::Key_Down);
- QTRY_COMPARE(gridview->currentIndex(), 1);
+ QCOMPARE(gridview->currentIndex(), 1);
QTest::keyClick(canvas, Qt::Key_Up);
- QTRY_COMPARE(gridview->currentIndex(), 0);
+ QCOMPARE(gridview->currentIndex(), 0);
// turn off auto highlight
gridview->setHighlightFollowsCurrentItem(false);
- QTRY_VERIFY(gridview->highlightFollowsCurrentItem() == false);
- QTRY_VERIFY(gridview->highlightItem());
+ QVERIFY(gridview->highlightFollowsCurrentItem() == false);
+ QVERIFY(gridview->highlightItem());
qreal hlPosX = gridview->highlightItem()->x();
qreal hlPosY = gridview->highlightItem()->y();