diff options
| author | Frank Reininghaus <[email protected]> | 2010-11-20 17:53:38 +0000 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2010-11-20 17:53:38 +0000 |
| commit | 5e7da43c2ddeb9cf99e5a2d2521b4274557b921a (patch) | |
| tree | f9b542eaa2c9c3299d85cbaabdd65e6e34a6bda7 /src/tests | |
| parent | 6ec1a1eb364f70d33922a6936f01d981e9e7f620 (diff) | |
Make sure that an item's visualRect in the Details View is not wider
than the "Name" column. Fixes keyboard navigation problems if files
with very wide names are present in the current folder.
Unit test included.
CCBUG: 257401
svn path=/trunk/KDE/kdebase/apps/; revision=1199123
Diffstat (limited to 'src/tests')
| -rw-r--r-- | src/tests/dolphindetailsviewtest.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tests/dolphindetailsviewtest.cpp b/src/tests/dolphindetailsviewtest.cpp index 0ca19bddd..6f10c0f55 100644 --- a/src/tests/dolphindetailsviewtest.cpp +++ b/src/tests/dolphindetailsviewtest.cpp @@ -44,6 +44,7 @@ private slots: void bug217447_shiftArrowSelection(); void bug234600_overlappingIconsWhenZooming(); + void bug257401_longFilenamesKeyboardNavigation(); private: @@ -256,6 +257,58 @@ void DolphinDetailsViewTest::bug234600_overlappingIconsWhenZooming() cleanupTestDir(); } +/** + * The width of the visualRect of an item is usually replaced by the width of the file name. + * However, if the file name is wider then the view's name column, this leads to problems with + * keyboard navigation if files with very long names are present in the current folder, see + * + * https://bugs.kde.org/show_bug.cgi?id=257401 + * + * This test checks that the visualRect of an item is never wider than the "Name" column. + */ + +void DolphinDetailsViewTest::bug257401_longFilenamesKeyboardNavigation() { + QString name; + for (int i = 0; i < 20; i++) { + name += "mmmmmmmmmm"; + createFile(name); + } + + m_view->setMode(DolphinView::DetailsView); + DolphinDetailsView* detailsView = qobject_cast<DolphinDetailsView*>(itemView()); + QVERIFY(detailsView); + m_view->resize(400, 400); + m_view->show(); + QTest::qWaitForWindowShown(m_view); + reloadViewAndWait(); + + // Select the first item + QModelIndex index0 = detailsView->model()->index(0, 0); + detailsView->setCurrentIndex(index0); + QCOMPARE(detailsView->currentIndex(), index0); + QVERIFY(detailsView->visualRect(index0).width() < detailsView->columnWidth(DolphinModel::Name)); + + QItemSelectionModel* selectionModel = detailsView->selectionModel(); + QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); + QCOMPARE(selectedIndexes.count(), 1); + QVERIFY(selectedIndexes.contains(index0)); + + // Move down successively using the "Down" key and check that current item + // and selection are as expected. + for (int i = 0; i < 19; i++) { + QTest::keyClick(detailsView->viewport(), Qt::Key_Down, Qt::NoModifier); + QModelIndex currentIndex = detailsView->model()->index(i + 1, 0); + QCOMPARE(detailsView->currentIndex(), currentIndex); + QVERIFY(detailsView->visualRect(currentIndex).width() <= detailsView->columnWidth(DolphinModel::Name)); + selectedIndexes = selectionModel->selectedIndexes(); + QCOMPARE(selectedIndexes.count(), 1); + QVERIFY(selectedIndexes.contains(currentIndex)); + } + + m_view->hide(); + cleanupTestDir(); +} + QTEST_KDEMAIN(DolphinDetailsViewTest, GUI) #include "dolphindetailsviewtest.moc"
\ No newline at end of file |
