diff options
Diffstat (limited to 'tests/auto/declarative/qsglistview')
-rw-r--r-- | tests/auto/declarative/qsglistview/data/listview-initCurrent.qml | 13 | ||||
-rw-r--r-- | tests/auto/declarative/qsglistview/tst_qsglistview.cpp | 22 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml b/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml index ee1a333de0..c4f1860eda 100644 --- a/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qsglistview/data/listview-initCurrent.qml @@ -1,7 +1,12 @@ import QtQuick 2.0 Rectangle { + id: root + property int current: list.currentIndex + property bool showHeader: false + property bool showFooter: false + width: 240 height: 320 color: "#ffffff" @@ -36,6 +41,12 @@ Rectangle { } } ] + + Component { + id: headerFooter + Rectangle { height: 30; width: 240; color: "blue" } + } + ListView { id: list objectName: "list" @@ -47,5 +58,7 @@ Rectangle { delegate: myDelegate highlightMoveSpeed: 1000 model: testModel + header: root.showHeader ? headerFooter : null + footer: root.showFooter ? headerFooter : null } } diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 59847d37f5..e1e6edd53d 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -1478,6 +1478,26 @@ void tst_QSGListView::currentIndex() QTRY_COMPARE(listview->contentY(), 0.0); + + // footer should become visible if it is out of view, and then current index is set to count-1 + canvas->rootObject()->setProperty("showFooter", true); + QTRY_VERIFY(listview->footerItem()); + listview->setCurrentIndex(model.count()-2); + QTRY_VERIFY(listview->footerItem()->y() > listview->contentY() + listview->height()); + listview->setCurrentIndex(model.count()-1); + QTRY_COMPARE(listview->contentY() + listview->height(), (20.0 * model.count()) + listview->footerItem()->height()); + canvas->rootObject()->setProperty("showFooter", false); + + // header should become visible if it is out of view, and then current index is set to 0 + canvas->rootObject()->setProperty("showHeader", true); + QTRY_VERIFY(listview->headerItem()); + listview->setCurrentIndex(1); + QTRY_VERIFY(listview->headerItem()->y() + listview->headerItem()->height() < listview->contentY()); + listview->setCurrentIndex(0); + QTRY_COMPARE(listview->contentY(), -listview->headerItem()->height()); + canvas->rootObject()->setProperty("showHeader", false); + + // Test keys canvas->show(); qApp->setActiveWindow(canvas); @@ -1488,6 +1508,8 @@ void tst_QSGListView::currentIndex() QTRY_VERIFY(canvas->hasFocus()); qApp->processEvents(); + listview->setCurrentIndex(0); + QTest::keyClick(canvas, Qt::Key_Down); QCOMPARE(listview->currentIndex(), 1); |