]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[PlacesItemModelTest] Check whether Desktop and Download folders exist
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 7 Oct 2018 14:50:27 +0000 (16:50 +0200)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Sun, 7 Oct 2018 14:50:27 +0000 (16:50 +0200)
KFilePlacesModel creates the Desktop and Downloads bookmarks only if
their folder exists.

This should hopefully fix the failing test on the CI (actual count = 15,
expected count = 17), since the CI runs in docker and probably doesn't
have those two folders by default.

src/tests/placesitemmodeltest.cpp

index 2e814220a15c88c6b07f9ac90a99ac54795991b4..e0fdb1d865a2aa1fadceb2befcddde59464a2997 100644 (file)
@@ -85,6 +85,7 @@ private:
     PlacesItemModel* m_model;
     QSet<int> m_tobeRemoved;
     QMap<QString, QDBusInterface *> m_interfacesMap;
+    int m_expectedModelCount = 15;
 
     void setBalooEnabled(bool enabled);
     int indexOf(const QUrl &url);
@@ -227,7 +228,7 @@ void PlacesItemModelTest::init()
     m_model = new PlacesItemModel();
     // WORKAROUND: need to wait for bookmark to load, check: PlacesItemModel::updateBookmarks
     QTest::qWait(300);
-    QCOMPARE(m_model->count(), 17);
+    QCOMPARE(m_model->count(), m_expectedModelCount);
 }
 
 void PlacesItemModelTest::cleanup()
@@ -261,6 +262,14 @@ void PlacesItemModelTest::initTestCase()
         QVERIFY(QFile::remove(bookmarsFileName));
     }
 
+    if (QDir(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).exists()) {
+        m_expectedModelCount++;
+    }
+
+    if (QDir(QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)).exists()) {
+        m_expectedModelCount++;
+    }
+
     qRegisterMetaType<KItemRangeList>();
     qRegisterMetaType<KItemRange>();
 }