]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[PlacesItemModelTest] Try to use an event loop instead of an hardcoded timeout
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 13 Oct 2018 10:06:21 +0000 (12:06 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sat, 13 Oct 2018 10:09:32 +0000 (12:09 +0200)
Increasing the timeout from 5 to 10 seconds didn't work.
Let's see if an eventloop does the job.

src/panels/places/placesitemmodel.cpp
src/panels/places/placesitemmodel.h
src/tests/placesitemmodeltest.cpp

index f7fe5587c7fa3cd2c5ce855982aad8e93fe83925..e21c25a0e25269dac98ded389a62034c38c1fe9d 100644 (file)
@@ -68,6 +68,7 @@ PlacesItemModel::PlacesItemModel(QObject* parent) :
 
     connect(m_sourceModel, &KFilePlacesModel::rowsInserted, this, &PlacesItemModel::onSourceModelRowsInserted);
     connect(m_sourceModel, &KFilePlacesModel::rowsAboutToBeRemoved, this, &PlacesItemModel::onSourceModelRowsAboutToBeRemoved);
+    connect(m_sourceModel, &KFilePlacesModel::dataChanged, this, &PlacesItemModel::sourceModelDataChanged);
     connect(m_sourceModel, &KFilePlacesModel::dataChanged, this, &PlacesItemModel::onSourceModelDataChanged);
     connect(m_sourceModel, &KFilePlacesModel::rowsAboutToBeMoved, this, &PlacesItemModel::onSourceModelRowsAboutToBeMoved);
     connect(m_sourceModel, &KFilePlacesModel::rowsMoved, this, &PlacesItemModel::onSourceModelRowsMoved);
index c4ff7e2ddd97b549da74df073d084db5b940a56e..33760f2176473680a4f49cba596bd0af7b1836c0 100644 (file)
@@ -145,6 +145,7 @@ signals:
     void storageSetupDone(int index, bool success);
     void storageTearDownRequested(const QString& mountPath);
     void storageTearDownExternallyRequested(const QString& mountPath);
+    void sourceModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>());
 
 protected:
     void onItemInserted(int index) override;
index c05ce6882754121ec110b048ebfe8109974a22a2..73204954b9ffbad71ec708d1f6f89437ffa559c5 100644 (file)
@@ -43,11 +43,6 @@ Q_DECLARE_METATYPE(KItemRange)
 #define KDE_ROOT_PATH "/"
 #endif
 
-namespace
-{
-    constexpr int TIMEOUT = 10000;
-}
-
 static QString bookmarksFile()
 {
     return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel";
@@ -740,10 +735,13 @@ void PlacesItemModelTest::testRefresh()
     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_WITH_TIMEOUT(item->text(), sameItem->text(), TIMEOUT);
+    QCOMPARE(item->text(), sameItem->text());
 }
 
 void PlacesItemModelTest::testIcons_data()