]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/tests/placesitemmodeltest.cpp
[InformationPanel] Hide the video when the preview is disabled, avoid computing the...
[dolphin.git] / src / tests / placesitemmodeltest.cpp
index 432c6077c1c7b110de0eb9434bfc21f916257e0f..fac0931a6c31a56b6a6beac397a2e1c9b7935950 100644 (file)
@@ -29,6 +29,7 @@
 #include <KAboutData>
 #include <KFilePlacesModel>
 
+#include "dolphin_generalsettings.h"
 #include "panels/places/placesitemmodel.h"
 #include "panels/places/placesitem.h"
 #include "views/viewproperties.h"
@@ -96,7 +97,7 @@ private:
     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;
@@ -190,7 +191,7 @@ void PlacesItemModelTest::createPlaceItem(const QString &text, const QUrl &url,
     m_model->createPlacesItem(text, url, icon);
 }
 
-void PlacesItemModelTest::removePlaceAfter(int index)
+void PlacesItemModelTest::schedulePlaceRemoval(int index)
 {
     m_tobeRemoved.insert(index);
 }
@@ -475,10 +476,18 @@ void PlacesItemModelTest::testDefaultViewProperties()
     QFETCH(bool, expectedPreviewShow);
     QFETCH(QList<QByteArray>, expectedVisibleRole);
 
+    // In order to test the default view properties, turn off the global view properties.
+    GeneralSettings* settings = GeneralSettings::self();
+    settings->setGlobalViewProps(false);
+    settings->save();
+
     ViewProperties properties(KFilePlacesModel::convertedUrl(url));
     QCOMPARE(properties.viewMode(), expectedViewMode);
     QCOMPARE(properties.previewsShown(), expectedPreviewShow);
     QCOMPARE(properties.visibleRoles(), expectedVisibleRole);
+
+    settings->setGlobalViewProps(true);
+    settings->save();
 }
 
 void PlacesItemModelTest::testClear()
@@ -563,7 +572,7 @@ void PlacesItemModelTest::testSystemItems()
     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>();
@@ -602,7 +611,7 @@ void PlacesItemModelTest::testEditBookmark()
     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);
 
@@ -646,7 +655,7 @@ void PlacesItemModelTest::testEditAfterCreation()
     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);
@@ -684,7 +693,7 @@ void PlacesItemModelTest::testEditMetadata()
     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);
@@ -722,7 +731,7 @@ void PlacesItemModelTest::testRefresh()
     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);
@@ -913,7 +922,7 @@ void PlacesItemModelTest::renameAfterCreation()
     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());