return view->m_viewAccessor.itemView();
}
-bool TestBase::waitForFinishedPathLoading(DolphinView* view, int milliseconds)
+void TestBase::waitForFinishedPathLoading(DolphinView* view, int milliseconds)
{
- return QTest::kWaitForSignal(view, SIGNAL(finishedPathLoading(const KUrl&)), milliseconds);
+ // If the signal is not received, somthing is going seriously wrong.
+ // -> assert here rather than continuing, which might result in test failures which are hard to unterstand.
+ bool viewHasFinishedLoading = QTest::kWaitForSignal(view, SIGNAL(finishedPathLoading(const KUrl&)), milliseconds);
+ Q_ASSERT(viewHasFinishedLoading);
+ Q_UNUSED(viewHasFinishedLoading) // suppress compiler warining is asserts are disabled
}
void TestBase::reloadViewAndWait(DolphinView* view)
{
view->reload();
- QVERIFY(waitForFinishedPathLoading(view));
+ waitForFinishedPathLoading(view);
}
QStringList TestBase::viewItems(const DolphinView* view)
return itemList;
}
+
+QStringList TestBase::selectedItems(const DolphinView* view)
+{
+ QStringList itemList;
+ const QAbstractItemModel* model = itemView(view)->model();
+ const QModelIndexList selectedIndexes = itemView(view)->selectionModel()->selectedIndexes();
+
+ for (int row = 0; row < model->rowCount(); row++) {
+ const QModelIndex index = model->index(row, 0);
+ if (selectedIndexes.contains(index)) {
+ itemList << model->data(model->index(row, 0), Qt::DisplayRole).toString();
+ }
+ }
+
+ return itemList;
+}