diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-05-20 04:25:27 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-05-20 04:25:27 (GMT) |
commit | 3eb8f4b9cf8c643d0198ca0af298376b4f1b74e3 (patch) | |
tree | 2b2be51a39c7a57bb98cae0d9d4f55ebfb265822 /tests | |
parent | 2f0ebdedbdac619f4ac7638fd215aa4c1f7bb328 (diff) | |
parent | 972134e16767d1ea5224fba911c894eb22b70ca4 (diff) | |
download | Qt-3eb8f4b9cf8c643d0198ca0af298376b4f1b74e3.zip Qt-3eb8f4b9cf8c643d0198ca0af298376b4f1b74e3.tar.gz Qt-3eb8f4b9cf8c643d0198ca0af298376b4f1b74e3.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'tests')
4 files changed, 154 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml new file mode 100644 index 0000000..510fcc5 --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/manual-highlight.qml @@ -0,0 +1,48 @@ +import Qt 4.7 + +Item { + + ListModel { + id: model + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bob Brown" + number: "555 5845" + } + } + + Component { + id: highlight + Rectangle { + objectName: "highlight" + width: 80; height: 80 + color: "lightsteelblue"; radius: 5 + y: grid.currentItem.y + x: grid.currentItem.x + } + } + + GridView { + id: grid + objectName: "grid" + anchors.fill: parent + model: model + delegate: Text { objectName: "wrapper"; text: name; width: 80; height: 80 } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true + } + +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 89be151..2db3ee6 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -75,6 +75,7 @@ private slots: void resetModel(); void enforceRange(); void QTBUG_8456(); + void manualHighlight(); private: QDeclarativeView *createView(); @@ -1107,6 +1108,35 @@ void tst_QDeclarativeGridView::QTBUG_8456() QTRY_COMPARE(gridview->currentIndex(), 0); } +void tst_QDeclarativeGridView::manualHighlight() +{ + QDeclarativeView *canvas = createView(); + + QString filename(SRCDIR "/data/manual-highlight.qml"); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem<QDeclarativeGridView>(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *viewport = gridview->viewport(); + QTRY_VERIFY(viewport != 0); + + QTRY_COMPARE(gridview->currentIndex(), 0); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); + + gridview->setCurrentIndex(2); + + QTRY_COMPARE(gridview->currentIndex(), 2); + QTRY_COMPARE(gridview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(gridview->highlightItem()->y(), gridview->currentItem()->y()); + QTRY_COMPARE(gridview->highlightItem()->x(), gridview->currentItem()->x()); +} + + QDeclarativeView *tst_QDeclarativeGridView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); diff --git a/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml new file mode 100644 index 0000000..4913ebe --- /dev/null +++ b/tests/auto/declarative/qdeclarativelistview/data/manual-highlight.qml @@ -0,0 +1,47 @@ +import Qt 4.7 + +Item { + + ListModel { + id: model + ListElement { + name: "Bill Smith" + number: "555 3264" + } + ListElement { + name: "John Brown" + number: "555 8426" + } + ListElement { + name: "Sam Wise" + number: "555 0473" + } + ListElement { + name: "Bob Brown" + number: "555 5845" + } + } + + Component { + id: highlight + Rectangle { + objectName: "highlight" + width: 180; height: 20 + color: "lightsteelblue"; radius: 5 + y: list.currentItem.y + } + } + + ListView { + id: list + objectName: "list" + anchors.fill: parent + model: model + delegate: Text { objectName: "wrapper"; text: name } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true + } + +} diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index fde2e43..203760e 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -90,6 +90,7 @@ private slots: void componentChanges(); void modelChanges(); void QTBUG_9791(); + void manualHighlight(); private: template <class T> void items(); @@ -1463,6 +1464,34 @@ void tst_QDeclarativeListView::QTBUG_9791() delete canvas; } +void tst_QDeclarativeListView::manualHighlight() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setFixedSize(240,320); + + QDeclarativeContext *ctxt = canvas->rootContext(); + + QString filename(SRCDIR "/data/manual-highlight.qml"); + canvas->setSource(QUrl::fromLocalFile(filename)); + + qApp->processEvents(); + + QDeclarativeListView *listview = findItem<QDeclarativeListView>(canvas->rootObject(), "list"); + QTRY_VERIFY(listview != 0); + + QDeclarativeItem *viewport = listview->viewport(); + QTRY_VERIFY(viewport != 0); + + QTRY_COMPARE(listview->currentIndex(), 0); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 0)); + QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); + + listview->setCurrentIndex(2); + + QTRY_COMPARE(listview->currentIndex(), 2); + QTRY_COMPARE(listview->currentItem(), findItem<QDeclarativeItem>(viewport, "wrapper", 2)); + QTRY_COMPARE(listview->highlightItem()->y(), listview->currentItem()->y()); +} void tst_QDeclarativeListView::qListModelInterface_items() { |