Changeset View
Changeset View
Standalone View
Standalone View
src/tests/placesitemmodeltest.cpp
Show All 22 Lines | |||||
23 | #include <QAction> | 23 | #include <QAction> | ||
24 | #include <QDBusInterface> | 24 | #include <QDBusInterface> | ||
25 | 25 | | |||
26 | #include <KBookmarkManager> | 26 | #include <KBookmarkManager> | ||
27 | #include <KConfig> | 27 | #include <KConfig> | ||
28 | #include <KConfigGroup> | 28 | #include <KConfigGroup> | ||
29 | #include <KAboutData> | 29 | #include <KAboutData> | ||
30 | #include <KFilePlacesModel> | 30 | #include <KFilePlacesModel> | ||
31 | #include <KProtocolInfo> | ||||
31 | 32 | | |||
32 | #include "dolphin_generalsettings.h" | 33 | #include "dolphin_generalsettings.h" | ||
33 | #include "panels/places/placesitemmodel.h" | 34 | #include "panels/places/placesitemmodel.h" | ||
34 | #include "panels/places/placesitem.h" | 35 | #include "panels/places/placesitem.h" | ||
35 | #include "views/viewproperties.h" | 36 | #include "views/viewproperties.h" | ||
36 | 37 | | |||
37 | Q_DECLARE_METATYPE(KItemRangeList) | 38 | Q_DECLARE_METATYPE(KItemRangeList) | ||
38 | Q_DECLARE_METATYPE(KItemRange) | 39 | Q_DECLARE_METATYPE(KItemRange) | ||
Show All 35 Lines | 50 | private slots: | |||
74 | void testHideDevices(); | 75 | void testHideDevices(); | ||
75 | void testDuplicatedEntries(); | 76 | void testDuplicatedEntries(); | ||
76 | void renameAfterCreation(); | 77 | void renameAfterCreation(); | ||
77 | 78 | | |||
78 | private: | 79 | private: | ||
79 | PlacesItemModel* m_model; | 80 | PlacesItemModel* m_model; | ||
80 | QSet<int> m_tobeRemoved; | 81 | QSet<int> m_tobeRemoved; | ||
81 | QMap<QString, QDBusInterface *> m_interfacesMap; | 82 | QMap<QString, QDBusInterface *> m_interfacesMap; | ||
82 | int m_expectedModelCount = 14; | 83 | int m_expectedModelCount = qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused")) ? 16 : 14; | ||
83 | bool m_hasDesktopFolder = false; | 84 | bool m_hasDesktopFolder = false; | ||
84 | bool m_hasDocumentsFolder = false; | 85 | bool m_hasDocumentsFolder = false; | ||
85 | bool m_hasDownloadsFolder = false; | 86 | bool m_hasDownloadsFolder = false; | ||
86 | 87 | | |||
87 | void setBalooEnabled(bool enabled); | 88 | void setBalooEnabled(bool enabled); | ||
88 | int indexOf(const QUrl &url); | 89 | int indexOf(const QUrl &url); | ||
89 | QDBusInterface *fakeManager(); | 90 | QDBusInterface *fakeManager(); | ||
90 | QDBusInterface *fakeDevice(const QString &udi); | 91 | QDBusInterface *fakeDevice(const QString &udi); | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 162 | if (urls.isEmpty()) { | |||
170 | } | 171 | } | ||
171 | 172 | | |||
172 | if (m_hasDownloadsFolder) { | 173 | if (m_hasDownloadsFolder) { | ||
173 | urls << QDir::homePath() + QStringLiteral("/Downloads"); | 174 | urls << QDir::homePath() + QStringLiteral("/Downloads"); | ||
174 | } | 175 | } | ||
175 | 176 | | |||
176 | urls << QStringLiteral("trash:/") | 177 | urls << QStringLiteral("trash:/") | ||
177 | << QStringLiteral("remote:/") | 178 | << QStringLiteral("remote:/") | ||
178 | << QStringLiteral("/media/nfs") | 179 | << QStringLiteral("/media/nfs"); | ||
179 | << QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday") | 180 | | ||
181 | if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) { | ||||
182 | urls << QStringLiteral("recentlyused:/files"); | ||||
183 | urls << QStringLiteral("recentlyused:/locations"); | ||||
184 | } | ||||
185 | | ||||
186 | urls << QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday") | ||||
180 | << QStringLiteral("search:/documents") << QStringLiteral("search:/images") << QStringLiteral("search:/audio") << QStringLiteral("search:/videos") | 187 | << QStringLiteral("search:/documents") << QStringLiteral("search:/images") << QStringLiteral("search:/audio") << QStringLiteral("search:/videos") | ||
181 | << QStringLiteral("/foreign") | 188 | << QStringLiteral("/foreign") | ||
182 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | 189 | << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom"); | ||
183 | } | 190 | } | ||
184 | return urls; | 191 | return urls; | ||
185 | } | 192 | } | ||
186 | 193 | | |||
187 | void PlacesItemModelTest::createPlaceItem(const QString &text, const QUrl &url, const QString &icon) | 194 | void PlacesItemModelTest::createPlaceItem(const QString &text, const QUrl &url, const QString &icon) | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 303 | { | |||
310 | 317 | | |||
311 | QCOMPARE(groups.at(0).first, 0); | 318 | QCOMPARE(groups.at(0).first, 0); | ||
312 | QCOMPARE(groups.at(0).second.toString(), QStringLiteral("Places")); | 319 | QCOMPARE(groups.at(0).second.toString(), QStringLiteral("Places")); | ||
313 | 320 | | |||
314 | QCOMPARE(groups.at(1).first, expectedRemoteIndex); | 321 | QCOMPARE(groups.at(1).first, expectedRemoteIndex); | ||
315 | QCOMPARE(groups.at(1).second.toString(), QStringLiteral("Remote")); | 322 | QCOMPARE(groups.at(1).second.toString(), QStringLiteral("Remote")); | ||
316 | 323 | | |||
317 | QCOMPARE(groups.at(2).first, expectedRemoteIndex + 2); | 324 | QCOMPARE(groups.at(2).first, expectedRemoteIndex + 2); | ||
318 | QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recently Saved")); | 325 | QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recent")); | ||
326 | | ||||
327 | if (qEnvironmentVariableIsSet("KDE_FULL_SESSION") && KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) { | ||||
328 | expectedRemoteIndex += 2; | ||||
329 | } | ||||
319 | 330 | | |||
320 | QCOMPARE(groups.at(3).first, expectedRemoteIndex + 4); | 331 | QCOMPARE(groups.at(3).first, expectedRemoteIndex + 4); | ||
321 | QCOMPARE(groups.at(3).second.toString(), QStringLiteral("Search For")); | 332 | QCOMPARE(groups.at(3).second.toString(), QStringLiteral("Search For")); | ||
322 | 333 | | |||
323 | QCOMPARE(groups.at(4).first, expectedRemoteIndex + 8); | 334 | QCOMPARE(groups.at(4).first, expectedRemoteIndex + 8); | ||
324 | QCOMPARE(groups.at(4).second.toString(), QStringLiteral("Devices")); | 335 | QCOMPARE(groups.at(4).second.toString(), QStringLiteral("Devices")); | ||
325 | 336 | | |||
326 | QCOMPARE(groups.at(5).first, expectedRemoteIndex + 9); | 337 | QCOMPARE(groups.at(5).first, expectedRemoteIndex + 9); | ||
Show All 10 Lines | 342 | { | |||
337 | 348 | | |||
338 | // places | 349 | // places | ||
339 | QTest::newRow("Places - Home") << QUrl::fromLocalFile(QDir::homePath()) << false << true << QStringLiteral("Places") << false; | 350 | QTest::newRow("Places - Home") << QUrl::fromLocalFile(QDir::homePath()) << false << true << QStringLiteral("Places") << false; | ||
340 | 351 | | |||
341 | // baloo -search | 352 | // baloo -search | ||
342 | QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << false << true << QStringLiteral("Search For") << false; | 353 | QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << false << true << QStringLiteral("Search For") << false; | ||
343 | 354 | | |||
344 | // baloo - timeline | 355 | // baloo - timeline | ||
345 | QTest::newRow("Baloo - Today") << QUrl("timeline:/today") << false << true << QStringLiteral("Recently Saved") << false; | 356 | QTest::newRow("Baloo - Today") << QUrl("timeline:/today") << false << true << QStringLiteral("Recent") << false; | ||
346 | 357 | | |||
347 | // devices | 358 | // devices | ||
348 | QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << false << false << QStringLiteral("Removable Devices") << false; | 359 | QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << false << false << QStringLiteral("Removable Devices") << false; | ||
349 | } | 360 | } | ||
350 | 361 | | |||
351 | void PlacesItemModelTest::testPlaceItem() | 362 | void PlacesItemModelTest::testPlaceItem() | ||
352 | { | 363 | { | ||
353 | QFETCH(QUrl, url); | 364 | QFETCH(QUrl, url); | ||
▲ Show 20 Lines • Show All 618 Lines • Show Last 20 Lines |