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 36 Lines | |||||
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 | | |||
79 | const QDate currentDate = QDate::currentDate(); | 80 | const QDate currentDate = QDate::currentDate(); | ||
80 | const QDate yesterdayDate = currentDate.addDays(-1); | 81 | const QDate yesterdayDate = currentDate.addDays(-1); | ||
81 | QTest::newRow("Today") << 3 << QStringLiteral("timeline:/today"); | 82 | int idx = 3; | ||
82 | QTest::newRow("Yesterday") << 4 << QString("timeline:/%1-%2/%1-%2-%3") | 83 | if (KProtocolInfo::isKnownProtocol(QStringLiteral("recentlyused"))) { | ||
84 | QTest::newRow("Recently Used") << idx++ << QStringLiteral("recentlyused:/"); | ||||
85 | } | ||||
86 | QTest::newRow("Today") << idx++ << QStringLiteral("timeline:/today"); | ||||
87 | QTest::newRow("Yesterday") << idx++ << QString("timeline:/%1-%2/%1-%2-%3") | ||||
83 | .arg(yesterdayDate.year()) | 88 | .arg(yesterdayDate.year()) | ||
84 | .arg(yesterdayDate.month(), 2, 10, QChar('0')) | 89 | .arg(yesterdayDate.month(), 2, 10, QChar('0')) | ||
85 | .arg(yesterdayDate.day(), 2, 10, QChar('0')); | 90 | .arg(yesterdayDate.day(), 2, 10, QChar('0')); | ||
86 | 91 | | |||
87 | // search | 92 | // search | ||
88 | QTest::newRow("Documents") << 5 << QStringLiteral("baloosearch:/documents"); | 93 | QTest::newRow("Documents") << idx++ << QStringLiteral("baloosearch:/documents"); | ||
89 | QTest::newRow("Images") << 6 << QStringLiteral("baloosearch:/images"); | 94 | QTest::newRow("Images") << idx++ << QStringLiteral("baloosearch:/images"); | ||
90 | QTest::newRow("Audio Files") << 7 << QStringLiteral("baloosearch:/audio"); | 95 | QTest::newRow("Audio Files") << idx++ << QStringLiteral("baloosearch:/audio"); | ||
91 | QTest::newRow("Videos") << 8 << QStringLiteral("baloosearch:/videos"); | 96 | QTest::newRow("Videos") << idx++ << QStringLiteral("baloosearch:/videos"); | ||
92 | } | 97 | } | ||
93 | 98 | | |||
94 | void KFilePlacesViewTest::testUrlChanged() | 99 | void KFilePlacesViewTest::testUrlChanged() | ||
95 | { | 100 | { | ||
96 | QFETCH(int, row); | 101 | QFETCH(int, row); | ||
97 | QFETCH(QString, expectedUrl); | 102 | QFETCH(QString, expectedUrl); | ||
98 | 103 | | |||
99 | KFilePlacesView pv; | 104 | KFilePlacesView pv; | ||
Show All 17 Lines |