diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-06-25 13:49:53 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-06-25 13:49:53 (GMT) |
commit | db8f05e257019694f5e8076845626008f2adc3dd (patch) | |
tree | 05d3959403cf15ac5f702091439e028af01f343b /tests/auto/qlistview | |
parent | 8aafaa65a1d16f8b982279f5aceedf1e281ddb5a (diff) | |
parent | 796a5a2c7d8c91a46ac761dde18b7da2ec6c177b (diff) | |
download | Qt-db8f05e257019694f5e8076845626008f2adc3dd.zip Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.gz Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.bz2 |
Merge commit 'qt/master-stable' into 4.6-stable
Bring Qt 4.6 into the Qt-S60 repo.
Conflicts:
configure.exe
mkspecs/features/qttest_p4.prf
qmake/generators/makefile.cpp
src/corelib/io/qdir.cpp
src/corelib/io/qprocess.h
src/corelib/kernel/qcoreevent.h
src/corelib/kernel/qobject.cpp
src/corelib/kernel/qsharedmemory_unix.cpp
src/corelib/thread/qthread_p.h
src/corelib/tools/qvector.h
src/gui/dialogs/qdialog.cpp
src/gui/dialogs/qfiledialog.cpp
src/gui/dialogs/qfiledialog_p.h
src/gui/dialogs/qmessagebox.cpp
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsview.cpp
src/gui/image/qpixmapcache.cpp
src/gui/kernel/qapplication.cpp
src/gui/kernel/qapplication_p.h
src/gui/kernel/qwidget.cpp
src/gui/kernel/qwidget_p.h
src/gui/painting/qdrawhelper.cpp
src/gui/painting/qpaintengine_raster.cpp
src/gui/text/qfontengine_qpf.cpp
src/gui/widgets/qmenubar.cpp
src/network/socket/qlocalserver.cpp
src/testlib/qtestcase.cpp
src/testlib/testlib.pro
tests/auto/qimagereader/tst_qimagereader.cpp
tests/auto/qitemdelegate/tst_qitemdelegate.cpp
tests/auto/qnetworkreply/tst_qnetworkreply.cpp
tests/auto/qpixmap/qpixmap.pro
Diffstat (limited to 'tests/auto/qlistview')
-rw-r--r-- | tests/auto/qlistview/tst_qlistview.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index db11447..b65fb81 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -54,6 +54,7 @@ #include <math.h> #include <QtGui/QScrollBar> #include <QtGui/QDialog> +#include <QtGui/QStyledItemDelegate> #if defined(Q_OS_WIN) || defined(Q_OS_WINCE) #include <windows.h> #endif @@ -108,6 +109,9 @@ private slots: void task228566_infiniteRelayout(); void task248430_crashWith0SizedItem(); void task250446_scrollChanged(); + void task196118_visualRegionForSelection(); + void task254449_draggingItemToNegativeCoordinates(); + void keyboardSearch(); }; // Testing get/set functions @@ -1557,6 +1561,102 @@ void tst_QListView::task250446_scrollChanged() QCOMPARE(view.currentIndex(), index); } +void tst_QListView::task196118_visualRegionForSelection() +{ + class MyListView : public QListView + { + public: + QRegion visualRegionForSelection() const + { return QListView::visualRegionForSelection( selectionModel()->selection()); } + } view; + + QStandardItemModel model; + QStandardItem top1("top1"); + QStandardItem sub1("sub1"); + top1.appendRow(QList<QStandardItem*>() << &sub1); + model.appendColumn(QList<QStandardItem*>() << &top1); + view.setModel(&model); + view.setRootIndex(top1.index()); + + view.selectionModel()->select(top1.index(), QItemSelectionModel::Select); + + QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1); + QVERIFY(view.visualRegionForSelection().isEmpty()); +} + +void tst_QListView::task254449_draggingItemToNegativeCoordinates() +{ + //we'll check that the items are painted correctly + class MyListView : public QListView + { + public: + void setPositionForIndex(const QPoint &position, const QModelIndex &index) + { QListView::setPositionForIndex(position, index); } + + } list; + + QStandardItemModel model(1,1); + QModelIndex index = model.index(0,0); + model.setData(index, QLatin1String("foo")); + list.setModel(&model); + list.setViewMode(QListView::IconMode); + list.show(); + QTest::qWait(200); //makes sure the layout is done + + const QPoint topLeft(-6, 0); + + + list.setPositionForIndex(topLeft, index); + + class MyItemDelegate : public QStyledItemDelegate + { + public: + MyItemDelegate() : numPaints(0) { } + void paint(QPainter *painter, + const QStyleOptionViewItem &option, const QModelIndex &index) const + { + numPaints++; + QStyledItemDelegate::paint(painter, option, index); + } + + mutable int numPaints; + } delegate; + + list.setItemDelegate(&delegate); + + //we'll make sure the item is repainted + delegate.numPaints = 0; + list.viewport()->repaint(); + + QCOMPARE(list.visualRect(index).topLeft(), topLeft); + QCOMPARE(delegate.numPaints, 1); +} + + +void tst_QListView::keyboardSearch() +{ + QStringList items; + items << "AB" << "AC" << "BA" << "BB" << "BD" << "KAFEINE" << "KONQUEROR" << "KOPETE" << "KOOKA" << "OKULAR"; + QStringListModel model(items); + + QListView view; + view.setModel(&model); + view.show(); + QTest::qWait(30); +// QCOMPARE(view.currentIndex() , model.index(0,0)); + + QTest::keyClick(&view, Qt::Key_K); + QTest::qWait(10); + QCOMPARE(view.currentIndex() , model.index(5,0)); //KAFEINE + + QTest::keyClick(&view, Qt::Key_O); + QTest::qWait(10); + QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR + + QTest::keyClick(&view, Qt::Key_N); + QTest::qWait(10); + QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR +} QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" |