Changeset View
Changeset View
Standalone View
Standalone View
autotests/kurifiltertest.cpp
Show First 20 Lines • Show All 251 Lines • ▼ Show 20 Line(s) | 248 | { | |||
---|---|---|---|---|---|
252 | addRow("//", QStringLiteral("/"), KUriFilterData::LocalDir); | 252 | addRow("//", QStringLiteral("/"), KUriFilterData::LocalDir); | ||
253 | addRow("///", QStringLiteral("/"), KUriFilterData::LocalDir); | 253 | addRow("///", QStringLiteral("/"), KUriFilterData::LocalDir); | ||
254 | addRow("////", QStringLiteral("/"), KUriFilterData::LocalDir); | 254 | addRow("////", QStringLiteral("/"), KUriFilterData::LocalDir); | ||
255 | addRow("///tmp", QStringLiteral("/tmp"), KUriFilterData::LocalDir); | 255 | addRow("///tmp", QStringLiteral("/tmp"), KUriFilterData::LocalDir); | ||
256 | 256 | | |||
257 | if (QFile::exists(QDir::homePath() + QLatin1String("/.bashrc"))) { | 257 | if (QFile::exists(QDir::homePath() + QLatin1String("/.bashrc"))) { | ||
258 | addRow("~/.bashrc", QDir::homePath() + QStringLiteral("/.bashrc"), KUriFilterData::LocalFile, QStringList(QStringLiteral("kshorturifilter"))); | 258 | addRow("~/.bashrc", QDir::homePath() + QStringLiteral("/.bashrc"), KUriFilterData::LocalFile, QStringList(QStringLiteral("kshorturifilter"))); | ||
259 | } | 259 | } | ||
260 | addRow("~", QDir::homePath().toLocal8Bit(), KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter")), QStringLiteral("/tmp")); | 260 | addRow("~", QDir::homePath(), KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter")), QStringLiteral("/tmp")); | ||
261 | addRow("~bin", nullptr, KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter"))); | 261 | addRow("~bin", nullptr, KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter"))); | ||
262 | addRow("~does_not_exist", nullptr, KUriFilterData::Error, QStringList(QStringLiteral("kshorturifilter"))); | 262 | addRow("~does_not_exist", nullptr, KUriFilterData::Error, QStringList(QStringLiteral("kshorturifilter"))); | ||
263 | addRow("~/does_not_exist", QDir::homePath() + "/does_not_exist", KUriFilterData::LocalFile, QStringList(QStringLiteral("kshorturifilter"))); | ||||
263 | 264 | | |||
264 | // Absolute Path tests for kshorturifilter | 265 | // Absolute Path tests for kshorturifilter | ||
265 | const QStringList kshorturifilter(QStringLiteral("kshorturifilter")); | 266 | const QStringList kshorturifilter(QStringLiteral("kshorturifilter")); | ||
266 | addRow("./", datahome, KUriFilterData::LocalDir, kshorturifilter, datahome + QStringLiteral("/")); // cleanPath removes the trailing slash | 267 | addRow("./", datahome, KUriFilterData::LocalDir, kshorturifilter, datahome + QStringLiteral("/")); // cleanPath removes the trailing slash | ||
267 | const QString parentDir = QDir().cleanPath(datahome + QStringLiteral("/..")); | 268 | const QString parentDir = QDir().cleanPath(datahome + QStringLiteral("/..")); | ||
268 | addRow("../", QFile::encodeName(parentDir), KUriFilterData::LocalDir, kshorturifilter, datahome); | 269 | addRow("../", QFile::encodeName(parentDir), KUriFilterData::LocalDir, kshorturifilter, datahome); | ||
269 | addRow("share", datahome, KUriFilterData::LocalDir, kshorturifilter, QFile::encodeName(parentDir)); | 270 | addRow("share", datahome, KUriFilterData::LocalDir, kshorturifilter, QFile::encodeName(parentDir)); | ||
270 | // Invalid URLs | 271 | // Invalid URLs | ||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | |||||
371 | 372 | | |||
372 | void KUriFilterTest::executables_data() | 373 | void KUriFilterTest::executables_data() | ||
373 | { | 374 | { | ||
374 | setupColumns(); | 375 | setupColumns(); | ||
375 | // Executable tests - No IKWS in minicli | 376 | // Executable tests - No IKWS in minicli | ||
376 | addRow("cp", QStringLiteral("cp"), KUriFilterData::Executable, minicliFilters); | 377 | addRow("cp", QStringLiteral("cp"), KUriFilterData::Executable, minicliFilters); | ||
377 | addRow("kbuildsycoca5", QStringLiteral("kbuildsycoca5"), KUriFilterData::Executable, minicliFilters); | 378 | addRow("kbuildsycoca5", QStringLiteral("kbuildsycoca5"), KUriFilterData::Executable, minicliFilters); | ||
378 | addRow("KDE", QStringLiteral("KDE"), NO_FILTERING, minicliFilters); | 379 | addRow("KDE", QStringLiteral("KDE"), NO_FILTERING, minicliFilters); | ||
379 | addRow("I/dont/exist", QStringLiteral("I/dont/exist"), NO_FILTERING, minicliFilters); //krazy:exclude=spelling | 380 | addRow("does/not/exist", QStringLiteral("does/not/exist"), NO_FILTERING, minicliFilters); | ||
380 | addRow("/I/dont/exist", nullptr, KUriFilterData::Error, minicliFilters); //krazy:exclude=spelling | 381 | addRow("/does/not/exist", QStringLiteral("/does/not/exist"), KUriFilterData::LocalFile, minicliFilters); | ||
381 | addRow("/I/dont/exist#a", nullptr, KUriFilterData::Error, minicliFilters); //krazy:exclude=spelling | 382 | addRow("/does/not/exist#a", QStringLiteral("/does/not/exist#a"), KUriFilterData::LocalFile, minicliFilters); | ||
382 | addRow("kbuildsycoca5 --help", QStringLiteral("kbuildsycoca5 --help"), KUriFilterData::Executable, minicliFilters); // the args are in argsAndOptions() | 383 | addRow("kbuildsycoca5 --help", QStringLiteral("kbuildsycoca5 --help"), KUriFilterData::Executable, minicliFilters); // the args are in argsAndOptions() | ||
383 | addRow("/bin/sh", QStringLiteral("/bin/sh"), KUriFilterData::Executable, minicliFilters); | 384 | addRow("/bin/sh", QStringLiteral("/bin/sh"), KUriFilterData::Executable, minicliFilters); | ||
384 | addRow("/bin/sh -q -option arg1", QStringLiteral("/bin/sh -q -option arg1"), KUriFilterData::Executable, minicliFilters); // the args are in argsAndOptions() | 385 | addRow("/bin/sh -q -option arg1", QStringLiteral("/bin/sh -q -option arg1"), KUriFilterData::Executable, minicliFilters); // the args are in argsAndOptions() | ||
385 | 386 | | |||
386 | // Typing 'cp' or any other valid unix command in konq's location bar should result in | 387 | // Typing 'cp' or any other valid unix command in konq's location bar should result in | ||
387 | // a search using the default search engine | 388 | // a search using the default search engine | ||
388 | // 'ls' is a bit of a special case though, due to the toplevel domain called 'ls' | 389 | // 'ls' is a bit of a special case though, due to the toplevel domain called 'ls' | ||
389 | addRow("cp", QStringLiteral("https://www.google.com/search?q=cp&ie=UTF-8"), KUriFilterData::NetProtocol, | 390 | addRow("cp", QStringLiteral("https://www.google.com/search?q=cp&ie=UTF-8"), KUriFilterData::NetProtocol, | ||
390 | QStringList(), nullptr, false /* don't check for executables, see konq_misc.cc */); | 391 | QStringList(), nullptr, false /* don't check for executables, see konq_misc.cc */); | ||
391 | } | 392 | } | ||
392 | 393 | | |||
393 | void KUriFilterTest::executables() | 394 | void KUriFilterTest::executables() | ||
394 | { | 395 | { | ||
395 | runFilterTest(); | 396 | runFilterTest(); | ||
396 | } | 397 | } | ||
397 | 398 | | |||
398 | void KUriFilterTest::environmentVariables_data() | 399 | void KUriFilterTest::environmentVariables_data() | ||
399 | { | 400 | { | ||
400 | setupColumns(); | 401 | setupColumns(); | ||
401 | // ENVIRONMENT variable | 402 | // ENVIRONMENT variable | ||
402 | qputenv("SOMEVAR", "/somevar"); | 403 | qputenv("SOMEVAR", "/somevar"); | ||
403 | qputenv("ETC", "/etc"); | 404 | qputenv("ETC", "/etc"); | ||
404 | 405 | | |||
405 | addRow("$SOMEVAR/kdelibs/kio", nullptr, KUriFilterData::Error); // note: this dir doesn't exist... | 406 | addRow("$SOMEVAR/kdelibs/kio", "/somevar/kdelibs/kio", KUriFilterData::LocalFile); // note: this dir doesn't exist... | ||
406 | addRow("$ETC/passwd", QStringLiteral("/etc/passwd"), KUriFilterData::LocalFile); | 407 | addRow("$ETC/passwd", QStringLiteral("/etc/passwd"), KUriFilterData::LocalFile); | ||
407 | QString qtdocPath = qtdir + QStringLiteral("/doc/html/functions.html"); | 408 | QString qtdocPath = qtdir + QStringLiteral("/doc/html/functions.html"); | ||
408 | if (QFile::exists(qtdocPath)) { | 409 | if (QFile::exists(qtdocPath)) { | ||
409 | QString expectedUrl = QUrl::fromLocalFile(qtdocPath).toString() + "#s"; | 410 | QString expectedUrl = QUrl::fromLocalFile(qtdocPath).toString() + "#s"; | ||
410 | addRow("$QTDIR/doc/html/functions.html#s", expectedUrl.toUtf8(), KUriFilterData::LocalFile); | 411 | addRow("$QTDIR/doc/html/functions.html#s", expectedUrl.toUtf8(), KUriFilterData::LocalFile); | ||
411 | } | 412 | } | ||
412 | addRow("http://www.kde.org/$USER", QStringLiteral("http://www.kde.org/$USER"), KUriFilterData::NetProtocol); // no expansion | 413 | addRow("http://www.kde.org/$USER", QStringLiteral("http://www.kde.org/$USER"), KUriFilterData::NetProtocol); // no expansion | ||
413 | 414 | | |||
Show All 13 Lines | |||||
427 | // but let's check that a directory with * in the name still works | 428 | // but let's check that a directory with * in the name still works | ||
428 | QDir().mkpath(datahome + QStringLiteral("/share/Dir*With*Stars")); | 429 | QDir().mkpath(datahome + QStringLiteral("/share/Dir*With*Stars")); | ||
429 | addRow("$DATAHOME/Dir*With*Stars", datahome + QStringLiteral("/Dir*With*Stars"), KUriFilterData::LocalDir); | 430 | addRow("$DATAHOME/Dir*With*Stars", datahome + QStringLiteral("/Dir*With*Stars"), KUriFilterData::LocalDir); | ||
430 | QDir().mkpath(datahome + QStringLiteral("/Dir?QuestionMark")); | 431 | QDir().mkpath(datahome + QStringLiteral("/Dir?QuestionMark")); | ||
431 | addRow("$DATAHOME/Dir?QuestionMark", datahome + QStringLiteral("/Dir?QuestionMark"), KUriFilterData::LocalDir); | 432 | addRow("$DATAHOME/Dir?QuestionMark", datahome + QStringLiteral("/Dir?QuestionMark"), KUriFilterData::LocalDir); | ||
432 | QDir().mkpath(datahome + QStringLiteral("/Dir[Bracket")); | 433 | QDir().mkpath(datahome + QStringLiteral("/Dir[Bracket")); | ||
433 | addRow("$DATAHOME/Dir[Bracket", datahome + QStringLiteral("/Dir[Bracket"), KUriFilterData::LocalDir); | 434 | addRow("$DATAHOME/Dir[Bracket", datahome + QStringLiteral("/Dir[Bracket"), KUriFilterData::LocalDir); | ||
434 | 435 | | |||
435 | addRow("$HOME/$KDEDIR/kdebase/kcontrol/ebrowsing", nullptr, KUriFilterData::Error); | 436 | addRow("$HOME/$KDEDIR/kdebase/kcontrol/ebrowsing", "", KUriFilterData::LocalFile); | ||
436 | addRow("$1/$2/$3", QStringLiteral("https://www.google.com/search?q=%241%2F%242%2F%243&ie=UTF-8"), KUriFilterData::NetProtocol); // can be used as bogus or valid test. Currently triggers default search, i.e. google | 437 | addRow("$1/$2/$3", QStringLiteral("https://www.google.com/search?q=%241%2F%242%2F%243&ie=UTF-8"), KUriFilterData::NetProtocol); // can be used as bogus or valid test. Currently triggers default search, i.e. google | ||
437 | addRow("$$$$", QStringLiteral("https://www.google.com/search?q=%24%24%24%24&ie=UTF-8"), KUriFilterData::NetProtocol); // worst case scenarios. | 438 | addRow("$$$$", QStringLiteral("https://www.google.com/search?q=%24%24%24%24&ie=UTF-8"), KUriFilterData::NetProtocol); // worst case scenarios. | ||
438 | 439 | | |||
439 | if (!qtdir.isEmpty()) { | 440 | if (!qtdir.isEmpty()) { | ||
440 | addRow("$QTDIR", qtdir, KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter"))); //use specific filter. | 441 | addRow("$QTDIR", qtdir, KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter"))); //use specific filter. | ||
441 | } | 442 | } | ||
442 | addRow("$HOME", home, KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter"))); //use specific filter. | 443 | addRow("$HOME", home, KUriFilterData::LocalDir, QStringList(QStringLiteral("kshorturifilter"))); //use specific filter. | ||
443 | } | 444 | } | ||
Show All 35 Lines |