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 | | ||||
207 | QTest::newRow("relativeFile") << QStringLiteral(".some_dotfile") << QUrl::fromUserInput(".some_dotfile", QLatin1String(""), QUrl::AssumeLocalFile); | ||||
dfaure: I think this should have a clear expected value, not the same call as the implementation, which… | |||||
208 | QTest::newRow("relativeDir") << QStringLiteral("some_directory") << QUrl::fromUserInput("some_directory", QLatin1String(""), QUrl::AssumeLocalFile); | ||||
206 | } | 209 | } | ||
207 | 210 | | |||
208 | void KUrlNavigatorTest::testUrlParsing() | 211 | void KUrlNavigatorTest::testUrlParsing() | ||
209 | { | 212 | { | ||
210 | QFETCH(QString, input); | 213 | QFETCH(QString, input); | ||
211 | QFETCH(QUrl, url); | 214 | QFETCH(QUrl, url); | ||
212 | 215 | | |||
213 | m_navigator->setLocationUrl(QUrl()); | 216 | 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); | 217 | m_navigator->setUrlEditable(true); | ||
215 | m_navigator->editor()->setCurrentText(input); | 218 | m_navigator->editor()->setCurrentText(input); | ||
216 | QCOMPARE(m_navigator->uncommittedUrl(), url); | 219 | QCOMPARE(m_navigator->uncommittedUrl(), url); | ||
217 | QTest::keyClick(m_navigator->editor(), Qt::Key_Enter); | 220 | QTest::keyClick(m_navigator->editor(), Qt::Key_Enter); | ||
218 | QCOMPARE(m_navigator->locationUrl(), url); | 221 | QCOMPARE(m_navigator->locationUrl(), url); | ||
219 | } | 222 | } | ||
220 | 223 | | |||
221 | void KUrlNavigatorTest::testButtonUrl_data() | 224 | void KUrlNavigatorTest::testButtonUrl_data() | ||
▲ Show 20 Lines • Show All 44 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).