QStringList placesUrls(PlacesItemModel *model = nullptr) const;
QStringList initialUrls() const;
void createPlaceItem(const QString &text, const QUrl &url, const QString &icon);
- void removePlaceAfter(int index);
+ void schedulePlaceRemoval(int index);
void cancelPlaceRemoval(int index);
void removeTestUserData();
QMimeData *createMimeData(const QList<int> &indexes) const;
m_model->createPlacesItem(text, url, icon);
}
-void PlacesItemModelTest::removePlaceAfter(int index)
+void PlacesItemModelTest::schedulePlaceRemoval(int index)
{
m_tobeRemoved.insert(index);
}
QTRY_COMPARE(itemsInsertedSpy.count(), 1);
// make sure the new place get removed
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex);
QList<QVariant> args = itemsInsertedSpy.takeFirst();
KItemRangeList range = args.at(0).value<KItemRangeList>();
createPlaceItem(QStringLiteral("Temporary Dir"), QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation)), QString());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex + 2);
+ schedulePlaceRemoval(tempDirIndex + 2);
QSignalSpy itemsChangedSply(m_model, &PlacesItemModel::itemsChanged);
QTRY_COMPARE(model->count(), m_model->count());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex + 2);
+ schedulePlaceRemoval(tempDirIndex + 2);
// modify place text
PlacesItem *item = m_model->placesItem(tempDirIndex);
QTRY_COMPARE(model->count(), m_model->count());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex + 2);
+ schedulePlaceRemoval(tempDirIndex + 2);
// modify place metadata
PlacesItem *item = m_model->placesItem(tempDirIndex);
QTRY_COMPARE(model->count(), m_model->count());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex);
+ schedulePlaceRemoval(tempDirIndex);
PlacesItem *item = m_model->placesItem(tempDirIndex);
PlacesItem *sameItem = model->placesItem(tempDirIndex);
QVERIFY(item->text() != sameItem->text());
// propagate change
+ QEventLoop eventLoop;
+ connect(m_model, &PlacesItemModel::sourceModelDataChanged, &eventLoop, &QEventLoop::quit);
m_model->refresh();
+ eventLoop.exec();
// item must be equal
- QTRY_COMPARE(item->text(), sameItem->text());
+ QCOMPARE(item->text(), sameItem->text());
}
void PlacesItemModelTest::testIcons_data()
urls.insert(tempDirIndex + 2, tempUrl.toLocalFile());
// make sure that the new item will be removed later
- removePlaceAfter(tempDirIndex + 2);
+ schedulePlaceRemoval(tempDirIndex + 2);
CHECK_PLACES_URLS(urls);
QCOMPARE(model->count(), m_model->count());