summaryrefslogtreecommitdiff
path: root/tests/auto/qlistview
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-07-24 11:45:33 +0200
committerJason Barron <jbarron@trolltech.com>2009-07-27 15:04:30 +0200
commit3643028959f0b38350e57e60ba4000435b75e592 (patch)
treec129e4dee11487abd437ab8ebd993ba261e06fa6 /tests/auto/qlistview
parentcf66c667a97c0079141eb3f2d9e997b7378ae792 (diff)
parentc36139c665e61866aff4bf8572890a735167a7d0 (diff)
downloadqt4-tools-3643028959f0b38350e57e60ba4000435b75e592.tar.gz
Merge commit 'qt/master-stable'
Conflicts: configure.exe qmake/Makefile.unix qmake/generators/makefile.cpp src/corelib/global/qglobal.h src/corelib/kernel/kernel.pri src/corelib/kernel/qcoreevent.cpp src/corelib/kernel/qsharedmemory_unix.cpp src/gui/graphicsview/qgraphicsscene.cpp src/gui/kernel/qaction.cpp src/gui/kernel/qaction.h src/gui/kernel/qaction_p.h src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication.h src/gui/kernel/qwidget.cpp src/gui/kernel/qwidget.h src/gui/kernel/qwidget_mac.mm src/gui/painting/qgraphicssystemfactory.cpp src/gui/styles/qwindowsstyle.cpp src/gui/text/qfontengine_qpf.cpp src/gui/widgets/qabstractscrollarea_p.h src/network/access/qnetworkaccessdebugpipebackend.cpp src/network/socket/qlocalsocket_unix.cpp src/network/socket/qnativesocketengine_p.h src/network/socket/qnativesocketengine_unix.cpp src/openvg/qpaintengine_vg.cpp tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp tests/auto/qcssparser/qcssparser.pro tests/auto/qdir/tst_qdir.cpp tests/auto/qfile/tst_qfile.cpp tests/auto/qobject/tst_qobject.cpp tests/auto/qpathclipper/qpathclipper.pro tests/auto/qprocess/tst_qprocess.cpp tests/auto/qsettings/tst_qsettings.cpp tests/auto/qsharedpointer/qsharedpointer.pro tests/auto/qsqlquerymodel/qsqlquerymodel.pro tests/auto/qsqlrelationaltablemodel/qsqlrelationaltablemodel.pro tests/auto/qsqltablemodel/qsqltablemodel.pro tests/auto/qsqlthread/qsqlthread.pro tests/auto/qwidget/tst_qwidget.cpp
Diffstat (limited to 'tests/auto/qlistview')
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index 390ec19025..13b68c8d43 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -112,6 +112,7 @@ private slots:
void task196118_visualRegionForSelection();
void task254449_draggingItemToNegativeCoordinates();
void keyboardSearch();
+ void shiftSelectionWithNonUniformItemSizes();
};
// Testing get/set functions
@@ -1658,5 +1659,71 @@ void tst_QListView::keyboardSearch()
QCOMPARE(view.currentIndex() , model.index(6,0)); //KONQUEROR
}
+void tst_QListView::shiftSelectionWithNonUniformItemSizes()
+{
+ // This checks that no items are selected unexpectedly by Shift-Arrow
+ // when items with non-uniform sizes are laid out in a grid
+ { // First test: QListView::LeftToRight flow
+ QStringList items;
+ items << "Long\nText" << "Text" << "Text" << "Text";
+ QStringListModel model(items);
+
+ QListView view;
+ view.setFixedSize(250, 250);
+ view.setFlow(QListView::LeftToRight);
+ view.setGridSize(QSize(100, 100));
+ view.setSelectionMode(QListView::ExtendedSelection);
+ view.setViewMode(QListView::IconMode);
+ view.setModel(&model);
+ view.show();
+ QTest::qWait(30);
+
+ // Verfify that item sizes are non-uniform
+ QVERIFY(view.sizeHintForIndex(model.index(0, 0)).height() > view.sizeHintForIndex(model.index(1, 0)).height());
+
+ QModelIndex index = model.index(3, 0);
+ view.setCurrentIndex(index);
+ QCOMPARE(view.currentIndex(), index);
+
+ QTest::keyClick(&view, Qt::Key_Up, Qt::ShiftModifier);
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex(), model.index(1, 0));
+
+ QModelIndexList selected = view.selectionModel()->selectedIndexes();
+ QCOMPARE(selected.count(), 3);
+ QVERIFY(!selected.contains(model.index(0, 0)));
+ }
+ { // Second test: QListView::TopToBottom flow
+ QStringList items;
+ items << "ab" << "a" << "a" << "a";
+ QStringListModel model(items);
+
+ QListView view;
+ view.setFixedSize(250, 250);
+ view.setFlow(QListView::TopToBottom);
+ view.setGridSize(QSize(100, 100));
+ view.setSelectionMode(QListView::ExtendedSelection);
+ view.setViewMode(QListView::IconMode);
+ view.setModel(&model);
+ view.show();
+ QTest::qWait(30);
+
+ // Verfify that item sizes are non-uniform
+ QVERIFY(view.sizeHintForIndex(model.index(0, 0)).width() > view.sizeHintForIndex(model.index(1, 0)).width());
+
+ QModelIndex index = model.index(3, 0);
+ view.setCurrentIndex(index);
+ QCOMPARE(view.currentIndex(), index);
+
+ QTest::keyClick(&view, Qt::Key_Left, Qt::ShiftModifier);
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex(), model.index(1, 0));
+
+ QModelIndexList selected = view.selectionModel()->selectedIndexes();
+ QCOMPARE(selected.count(), 3);
+ QVERIFY(!selected.contains(model.index(0, 0)));
+ }
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"