Changeset View
Changeset View
Standalone View
Standalone View
autotests/kfileplacesviewtest.cpp
Show All 20 Lines | |||||
21 | #include <QStandardPaths> | 21 | #include <QStandardPaths> | ||
22 | #include <QFile> | 22 | #include <QFile> | ||
23 | #include <QTemporaryDir> | 23 | #include <QTemporaryDir> | ||
24 | 24 | | |||
25 | #include <kfileplacesview.h> | 25 | #include <kfileplacesview.h> | ||
26 | #include <kfileplacesmodel.h> | 26 | #include <kfileplacesmodel.h> | ||
27 | #include <kconfig.h> | 27 | #include <kconfig.h> | ||
28 | #include <kconfiggroup.h> | 28 | #include <kconfiggroup.h> | ||
29 | #include <KProtocolInfo> | ||||
29 | 30 | | |||
30 | #include <QTest> | 31 | #include <QTest> | ||
31 | #include <QSignalSpy> | 32 | #include <QSignalSpy> | ||
32 | 33 | | |||
33 | static QString bookmarksFile() | 34 | static QString bookmarksFile() | ||
34 | { | 35 | { | ||
35 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel"; | 36 | return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel"; | ||
36 | } | 37 | } | ||
Show All 34 Lines | 71 | { | |||
71 | QFile::remove(bookmarksFile()); | 72 | QFile::remove(bookmarksFile()); | ||
72 | } | 73 | } | ||
73 | 74 | | |||
74 | void KFilePlacesViewTest::testUrlChanged_data() | 75 | void KFilePlacesViewTest::testUrlChanged_data() | ||
75 | { | 76 | { | ||
76 | QTest::addColumn<int>("row"); | 77 | QTest::addColumn<int>("row"); | ||
77 | QTest::addColumn<QString>("expectedUrl"); | 78 | QTest::addColumn<QString>("expectedUrl"); | ||
78 | 79 | | |||
80 | int idx = 3; | ||||
81 | if (KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) { | ||||
82 | QTest::newRow("Recently Used") << idx++ << QStringLiteral("recentlyused:/files"); | ||||
83 | QTest::newRow("Recently Used") << idx++ << QStringLiteral("recentlyused:/locations"); | ||||
84 | } | ||||
79 | const QDate currentDate = QDate::currentDate(); | 85 | const QDate currentDate = QDate::currentDate(); | ||
80 | const QDate yesterdayDate = currentDate.addDays(-1); | 86 | const QDate yesterdayDate = currentDate.addDays(-1); | ||
81 | QTest::newRow("Today") << 3 << QStringLiteral("timeline:/today"); | 87 | QTest::newRow("Today") << idx++ << QStringLiteral("timeline:/today"); | ||
82 | QTest::newRow("Yesterday") << 4 << QString("timeline:/%1-%2/%1-%2-%3") | 88 | QTest::newRow("Yesterday") << idx++ << QString("timeline:/%1-%2/%1-%2-%3") | ||
83 | .arg(yesterdayDate.year()) | 89 | .arg(yesterdayDate.year()) | ||
84 | .arg(yesterdayDate.month(), 2, 10, QChar('0')) | 90 | .arg(yesterdayDate.month(), 2, 10, QChar('0')) | ||
85 | .arg(yesterdayDate.day(), 2, 10, QChar('0')); | 91 | .arg(yesterdayDate.day(), 2, 10, QChar('0')); | ||
86 | 92 | | |||
87 | // search | 93 | // search | ||
88 | QTest::newRow("Documents") << 5 << QStringLiteral("baloosearch:/documents"); | 94 | QTest::newRow("Documents") << idx++ << QStringLiteral("baloosearch:/documents"); | ||
89 | QTest::newRow("Images") << 6 << QStringLiteral("baloosearch:/images"); | 95 | QTest::newRow("Images") << idx++ << QStringLiteral("baloosearch:/images"); | ||
90 | QTest::newRow("Audio Files") << 7 << QStringLiteral("baloosearch:/audio"); | 96 | QTest::newRow("Audio Files") << idx++ << QStringLiteral("baloosearch:/audio"); | ||
91 | QTest::newRow("Videos") << 8 << QStringLiteral("baloosearch:/videos"); | 97 | QTest::newRow("Videos") << idx++ << QStringLiteral("baloosearch:/videos"); | ||
92 | } | 98 | } | ||
93 | 99 | | |||
94 | void KFilePlacesViewTest::testUrlChanged() | 100 | void KFilePlacesViewTest::testUrlChanged() | ||
95 | { | 101 | { | ||
96 | QFETCH(int, row); | 102 | QFETCH(int, row); | ||
97 | QFETCH(QString, expectedUrl); | 103 | QFETCH(QString, expectedUrl); | ||
98 | 104 | | |||
99 | KFilePlacesView pv; | 105 | KFilePlacesView pv; | ||
Show All 17 Lines |