diff options
author | Bea Lam <bea.lam@nokia.com> | 2011-07-28 16:10:46 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-28 10:04:08 +0200 |
commit | 43d940fd30ea4728664de393479438f54e888b32 (patch) | |
tree | cea5a67db0f2d9d468f3194dd3534e0d3d6c9e27 /tests | |
parent | da0441aa30e1e10c1e0ac9a8cd305c1b6e63c111 (diff) |
Fix auto-repeat key navigation for GridView
Shouldn't set moveReason=SetIndex in key navigation. ListView didn't
do this in its keyPress implementation.
Added extra tests for GridView and ListView.
Task-number: QTBUG-20408
Change-Id: Iaf0f331d3ba4f037c5bbc0a41418dd656b5a3695
Reviewed-on: http://codereview.qt.nokia.com/2318
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qsggridview/tst_qsggridview.cpp | 37 | ||||
-rw-r--r-- | tests/auto/declarative/qsglistview/tst_qsglistview.cpp | 19 |
2 files changed, 56 insertions, 0 deletions
diff --git a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp index 9a401f6681..e7dce4c86d 100644 --- a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp +++ b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp @@ -895,6 +895,25 @@ void tst_QSGGridView::currentIndex() QTest::keyClick(canvas, Qt::Key_Up); QCOMPARE(gridview->currentIndex(), 0); + // hold down Key_Down + for (int i=0; i<(model.count() / 3) - 1; i++) { + QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*3 + 3); + } + QTest::keyRelease(canvas, Qt::Key_Down); + QTRY_COMPARE(gridview->currentIndex(), 57); + QTRY_COMPARE(gridview->contentY(), 880.0); + + // hold down Key_Up + for (int i=(model.count() / 3) - 1; i > 0; i--) { + QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*3 - 3); + } + QTest::keyRelease(canvas, Qt::Key_Up); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->contentY(), 0.0); + + gridview->setFlow(QSGGridView::TopToBottom); qApp->setActiveWindow(canvas); @@ -917,6 +936,24 @@ void tst_QSGGridView::currentIndex() QTest::keyClick(canvas, Qt::Key_Up); QCOMPARE(gridview->currentIndex(), 0); + // hold down Key_Right + for (int i=0; i<(model.count() / 5) - 1; i++) { + QTest::simulateEvent(canvas, true, Qt::Key_Right, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*5 + 5); + } + QTest::keyRelease(canvas, Qt::Key_Right); + QTRY_COMPARE(gridview->currentIndex(), 55); + QTRY_COMPARE(gridview->contentX(), 720.0); + + // hold down Key_Left + for (int i=(model.count() / 5) - 1; i > 0; i--) { + QTest::simulateEvent(canvas, true, Qt::Key_Left, Qt::NoModifier, "", true); + QTRY_COMPARE(gridview->currentIndex(), i*5 - 5); + } + QTest::keyRelease(canvas, Qt::Key_Left); + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->contentX(), 0.0); + // turn off auto highlight gridview->setHighlightFollowsCurrentItem(false); diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 43efea268b..5ee13e8724 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -1447,6 +1447,25 @@ void tst_QSGListView::currentIndex() QTest::keyClick(canvas, Qt::Key_Up); QCOMPARE(listview->currentIndex(), 0); + // hold down Key_Down + for (int i=0; i<model.count()-1; i++) { + QTest::simulateEvent(canvas, true, Qt::Key_Down, Qt::NoModifier, "", true); + QTRY_COMPARE(listview->currentIndex(), i+1); + } + QTest::keyRelease(canvas, Qt::Key_Down); + QTRY_COMPARE(listview->currentIndex(), model.count()-1); + QTRY_COMPARE(listview->contentY(), 280.0); + + // hold down Key_Up + for (int i=model.count()-1; i > 0; i--) { + QTest::simulateEvent(canvas, true, Qt::Key_Up, Qt::NoModifier, "", true); + QTRY_COMPARE(listview->currentIndex(), i-1); + } + QTest::keyRelease(canvas, Qt::Key_Up); + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->contentY(), 0.0); + + // turn off auto highlight listview->setHighlightFollowsCurrentItem(false); QVERIFY(listview->highlightFollowsCurrentItem() == false); |