Changeset View
Changeset View
Standalone View
Standalone View
autotests/kurlnavigatortest.cpp
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 197 | { | |||
---|---|---|---|---|---|
198 | QTest::addColumn<QString>("input"); | 198 | QTest::addColumn<QString>("input"); | ||
199 | QTest::addColumn<QUrl>("url"); | 199 | QTest::addColumn<QUrl>("url"); | ||
200 | // due to a bug in the KF5 porting input such as '/home/foo/.config' was parsed as 'http:///home/foo/.config/'. | 200 | // due to a bug in the KF5 porting input such as '/home/foo/.config' was parsed as 'http:///home/foo/.config/'. | ||
201 | QTest::newRow("hiddenFile") << QStringLiteral("/home/foo/.config") << QUrl::fromLocalFile(QStringLiteral("/home/foo/.config")); | 201 | QTest::newRow("hiddenFile") << QStringLiteral("/home/foo/.config") << QUrl::fromLocalFile(QStringLiteral("/home/foo/.config")); | ||
202 | // TODO: test this on windows: e.g. 'C:/foo/.config' or 'C:\foo\.config' | 202 | // TODO: test this on windows: e.g. 'C:/foo/.config' or 'C:\foo\.config' | ||
203 | QTest::newRow("homeDir") << QStringLiteral("~") << QUrl::fromLocalFile(QDir::homePath()); | 203 | QTest::newRow("homeDir") << QStringLiteral("~") << QUrl::fromLocalFile(QDir::homePath()); | ||
204 | KUser user(KUser::UseRealUserID); | 204 | KUser user(KUser::UseRealUserID); | ||
205 | QTest::newRow("userHomeDir") << (QStringLiteral("~") + user.loginName()) << QUrl::fromLocalFile(user.homeDir()); | 205 | QTest::newRow("userHomeDir") << (QStringLiteral("~") + user.loginName()) << QUrl::fromLocalFile(user.homeDir()); | ||
206 | QTest::newRow("relativeFile") << QStringLiteral(".dotfile") << QUrl::fromLocalFile(QStringLiteral("/home/foo/.dotfile")); | ||||
207 | QTest::newRow("relativeDir") << QStringLiteral("some_directory") << QUrl::fromLocalFile(QStringLiteral("/home/foo/some_directory")); | ||||
dfaure: I think this should have a clear expected value, not the same call as the implementation, which… | |||||
208 | QTest::newRow("tildePath") << QStringLiteral("~/dir") << QUrl::fromUserInput(QStringLiteral("dir"), QDir::homePath(), QUrl::AssumeLocalFile); | ||||
209 | QTest::newRow("pathwithtilde") << QStringLiteral("/home/user/dir/~/subdir") << QUrl::fromLocalFile(QStringLiteral("/home/user/dir/~/subdir")); | ||||
210 | QTest::newRow("dotslash") << QStringLiteral("./~") << QUrl::fromLocalFile(QStringLiteral("/home/foo/~")); | ||||
206 | } | 211 | } | ||
207 | 212 | | |||
208 | void KUrlNavigatorTest::testUrlParsing() | 213 | void KUrlNavigatorTest::testUrlParsing() | ||
209 | { | 214 | { | ||
210 | QFETCH(QString, input); | 215 | QFETCH(QString, input); | ||
211 | QFETCH(QUrl, url); | 216 | QFETCH(QUrl, url); | ||
212 | 217 | | |||
213 | m_navigator->setLocationUrl(QUrl()); | 218 | m_navigator->setLocationUrl(QUrl()); | ||
Does this line have any effect? This is only for the "go home" functionality, says the API docs, not for resolving relative paths, right? dfaure: Does this line have any effect? This is only for the "go home" functionality, says the API docs… | |||||
214 | m_navigator->setUrlEditable(true); | 219 | m_navigator->setUrlEditable(true); | ||
215 | m_navigator->editor()->setCurrentText(input); | 220 | m_navigator->editor()->setCurrentText(input); | ||
221 | m_navigator->setDirectory(QUrl::fromLocalFile("/home/foo")); | ||||
216 | QCOMPARE(m_navigator->uncommittedUrl(), url); | 222 | QCOMPARE(m_navigator->uncommittedUrl(), url); | ||
217 | QTest::keyClick(m_navigator->editor(), Qt::Key_Enter); | 223 | QTest::keyClick(m_navigator->editor(), Qt::Key_Enter); | ||
218 | QCOMPARE(m_navigator->locationUrl(), url); | 224 | QCOMPARE(m_navigator->locationUrl(), url); | ||
219 | } | 225 | } | ||
220 | 226 | | |||
221 | void KUrlNavigatorTest::testButtonUrl_data() | 227 | void KUrlNavigatorTest::testButtonUrl_data() | ||
222 | { | 228 | { | ||
223 | QTest::addColumn<QUrl>("locationUrl"); | 229 | QTest::addColumn<QUrl>("locationUrl"); | ||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
I think this should have a clear expected value, not the same call as the implementation, which is then not testing the actual behavior; it's like checking that a==a, but not the value of a.
I mean, to me it's unclear what fromUserInput(3 args) does when the 2nd arg is QLatin1String("") (yes, even though I actually wrote that method!).
Why QLatin1String("")? Does it behave any different when called with QString() instead? In any case, these are questions for the implementation. Here it should be a clear hardcoded expected value (well using QDir::homePath and QUrl::fromLocalFile if necessary, of course).