Changeset View
Changeset View
Standalone View
Standalone View
autotests/kdiroperatortest.cpp
Show All 18 Lines | |||||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include <QtTest/QtTest> | 21 | #include <QtTest/QtTest> | ||
22 | #include <kdiroperator.h> | 22 | #include <kdiroperator.h> | ||
23 | #include <kconfiggroup.h> | 23 | #include <kconfiggroup.h> | ||
24 | #include <ksharedconfig.h> | 24 | #include <ksharedconfig.h> | ||
25 | #include <qtreeview.h> | 25 | #include <qtreeview.h> | ||
26 | #include <QSignalSpy> | 26 | #include <QSignalSpy> | ||
27 | #include <QDir> | ||||
27 | 28 | | |||
28 | /** | 29 | /** | ||
29 | * Unit test for KDirOperator | 30 | * Unit test for KDirOperator | ||
30 | */ | 31 | */ | ||
31 | class KDirOperatorTest : public QObject | 32 | class KDirOperatorTest : public QObject | ||
32 | { | 33 | { | ||
33 | Q_OBJECT | 34 | Q_OBJECT | ||
34 | private Q_SLOTS: | 35 | private Q_SLOTS: | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | 111 | { | |||
111 | QFETCH(QUrl, url); | 112 | QFETCH(QUrl, url); | ||
112 | QFETCH(QUrl, expectedUrl); | 113 | QFETCH(QUrl, expectedUrl); | ||
113 | 114 | | |||
114 | KDirOperator dirOp; | 115 | KDirOperator dirOp; | ||
115 | QSignalSpy spy(&dirOp, SIGNAL(urlEntered(QUrl))); | 116 | QSignalSpy spy(&dirOp, SIGNAL(urlEntered(QUrl))); | ||
116 | dirOp.setUrl(url, true); | 117 | dirOp.setUrl(url, true); | ||
117 | QCOMPARE(spy.takeFirst().at(0).toUrl(), expectedUrl); | 118 | QCOMPARE(spy.takeFirst().at(0).toUrl(), expectedUrl); | ||
118 | } | 119 | } | ||
120 | | ||||
121 | void testSupportedSchemes() | ||||
122 | { | ||||
123 | KDirOperator dirOp; | ||||
124 | QSignalSpy spy(&dirOp, &KDirOperator::urlEntered); | ||||
125 | QCOMPARE(dirOp.supportedSchemes(), QStringList()); | ||||
126 | dirOp.setSupportedSchemes({"file"}); | ||||
127 | QCOMPARE(dirOp.supportedSchemes(), QStringList("file")); | ||||
128 | dirOp.setUrl(QUrl("smb://foo/bar"), true); | ||||
129 | QCOMPARE(spy.count(), 0); | ||||
130 | const auto fileUrl = QUrl::fromLocalFile(QDir::homePath() + QLatin1Char('/')); | ||||
131 | dirOp.setUrl(fileUrl, true); | ||||
132 | QCOMPARE(spy.count(), 1); | ||||
133 | QCOMPARE(spy.first().at(0).toUrl(), fileUrl); | ||||
134 | } | ||||
119 | }; | 135 | }; | ||
120 | 136 | | |||
121 | QTEST_MAIN(KDirOperatorTest) | 137 | QTEST_MAIN(KDirOperatorTest) | ||
122 | 138 | | |||
123 | #include "kdiroperatortest.moc" | 139 | #include "kdiroperatortest.moc" |