Update dolphin tests following place changes D7446

Summary:
Adapt tests corresponding to changes in D7446
The placesitemmodeltest were not run due to KIO_VERSION not existing

Test Plan: LANG="en" ctest

Reviewers: #dolphin, elvisangelaccio

Reviewed By: #dolphin, elvisangelaccio

Subscribers: kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D23557
This commit is contained in:
Méven Car 2019-10-02 18:14:18 +02:00
parent 3d65fa9a79
commit 8645ed68a1
2 changed files with 17 additions and 6 deletions

View file

@ -71,7 +71,7 @@ LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
ecm_add_test(draganddrophelpertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
# PlacesItemModelTest
if (KF5_VERSION VERSION_GREATER_EQUAL "5.60.0")
if (KF5_VERSION VERSION_GREATER_EQUAL 5.63.0)
ecm_add_test(placesitemmodeltest.cpp
TEST_NAME placesitemmodeltest
LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)

View file

@ -28,6 +28,7 @@
#include <KConfigGroup>
#include <KAboutData>
#include <KFilePlacesModel>
#include <KProtocolInfo>
#include "dolphin_generalsettings.h"
#include "panels/places/placesitemmodel.h"
@ -79,7 +80,7 @@ private:
PlacesItemModel* m_model;
QSet<int> m_tobeRemoved;
QMap<QString, QDBusInterface *> m_interfacesMap;
int m_expectedModelCount = 14;
int m_expectedModelCount = qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused")) ? 16 : 14;
bool m_hasDesktopFolder = false;
bool m_hasDocumentsFolder = false;
bool m_hasDownloadsFolder = false;
@ -175,8 +176,14 @@ QStringList PlacesItemModelTest::initialUrls() const
urls << QStringLiteral("trash:/")
<< QStringLiteral("remote:/")
<< QStringLiteral("/media/nfs")
<< QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday")
<< QStringLiteral("/media/nfs");
if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) {
urls << QStringLiteral("recentlyused:/files");
urls << QStringLiteral("recentlyused:/locations");
}
urls << QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday")
<< QStringLiteral("search:/documents") << QStringLiteral("search:/images") << QStringLiteral("search:/audio") << QStringLiteral("search:/videos")
<< QStringLiteral("/foreign")
<< QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom");
@ -315,7 +322,11 @@ void PlacesItemModelTest::testGroups()
QCOMPARE(groups.at(1).second.toString(), QStringLiteral("Remote"));
QCOMPARE(groups.at(2).first, expectedRemoteIndex + 2);
QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recently Saved"));
QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recent"));
if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) {
expectedRemoteIndex += 2;
}
QCOMPARE(groups.at(3).first, expectedRemoteIndex + 4);
QCOMPARE(groups.at(3).second.toString(), QStringLiteral("Search For"));
@ -342,7 +353,7 @@ void PlacesItemModelTest::testPlaceItem_data()
QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << false << true << QStringLiteral("Search For") << false;
// baloo - timeline
QTest::newRow("Baloo - Today") << QUrl("timeline:/today") << false << true << QStringLiteral("Recently Saved") << false;
QTest::newRow("Baloo - Today") << QUrl("timeline:/today") << false << true << QStringLiteral("Recent") << false;
// devices
QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << false << false << QStringLiteral("Removable Devices") << false;