Changeset View
Standalone View
autotests/jobtest.cpp
Show First 20 Lines • Show All 978 Lines • ▼ Show 20 Line(s) | 961 | #endif | |||
---|---|---|---|---|---|
979 | QVERIFY(!QFile::exists(dest)); | 979 | QVERIFY(!QFile::exists(dest)); | ||
980 | 980 | | |||
981 | // Cleanup | 981 | // Cleanup | ||
982 | QVERIFY(QFile(subdir).setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner))); | 982 | QVERIFY(QFile(subdir).setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner))); | ||
983 | QVERIFY(QFile::exists(src)); | 983 | QVERIFY(QFile::exists(src)); | ||
984 | QVERIFY(QDir(subdir).removeRecursively()); | 984 | QVERIFY(QDir(subdir).removeRecursively()); | ||
985 | } | 985 | } | ||
986 | 986 | | |||
987 | void JobTest::moveDirectoryToInaccessibleFilesystem() | ||||
988 | { | ||||
989 | #ifdef Q_OS_WIN | ||||
990 | QSKIP("Skipping unaccessible folder test on Windows, cannot remove all permissions from a folder"); | ||||
991 | #endif | ||||
992 | const QString src_dir = homeTmpDir() + "srcHome"; | ||||
993 | const QString dst_dir = homeTmpDir() + "mdnp"; | ||||
994 | | ||||
995 | createTestDirectory(src_dir); | ||||
996 | QString inaccessible = dst_dir; | ||||
997 | createTestDirectory(inaccessible); | ||||
998 | | ||||
999 | QFile(src_dir).setPermissions(QFile::Permissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner)); | ||||
1000 | QFile(inaccessible).setPermissions(QFile::Permissions()); // Make it inaccessible, moving should throw some errors | ||||
1001 | | ||||
1002 | KIO::CopyJob *job = KIO::move(QUrl::fromLocalFile(src_dir), QUrl::fromLocalFile(dst_dir), KIO::HideProgressInfo); | ||||
1003 | | ||||
1004 | QSignalSpy spy(job, &KJob::error); | ||||
dfaure: At runtime, Qt says:
QSignalSpy: Not a valid signal: ''
Indeed this is the getter, not a… | |||||
1005 | job->setUiDelegate(nullptr); | ||||
1006 | QVERIFY(!job->exec()); | ||||
1007 | QCOMPARE(job->error(), (int)KIO::ERR_CANNOT_WRITE); | ||||
FAIL! : JobTest::moveDirectoryToInaccessibleFilesystem() Compared values are not the same Actual (job->error()) : 115 Expected ((int)KIO::ERR_CANNOT_WRITE): 129 115 is ERR_ACCESS_DENIED, see grep -w 15 src/core/global.h I think that's because you went too far (due to copy/pasting). The dest dir shouldn't be inaccessible, it should only be readonly. Also you forgot the cleanup at the end of the method, which breaks running the test multiple times. OK, even with all this the test doesn't pass. Changing dst_dir to use otherTmpDir() ... ok, the error code changes, now it's 137, i.e. ERR_COULD_NOT_MKDIR :-) dfaure: FAIL! : JobTest::moveDirectoryToInaccessibleFilesystem() Compared values are not the same… | |||||
1008 | QCOMPARE(spy.count(), 1); // one error should be emitted by the move job | ||||
1009 | } | ||||
1010 | | ||||
987 | void JobTest::listRecursive() | 1011 | void JobTest::listRecursive() | ||
988 | { | 1012 | { | ||
989 | // Note: many other tests must have been run before since we rely on the files they created | 1013 | // Note: many other tests must have been run before since we rely on the files they created | ||
990 | 1014 | | |||
991 | const QString src = homeTmpDir(); | 1015 | const QString src = homeTmpDir(); | ||
992 | #ifndef Q_OS_WIN | 1016 | #ifndef Q_OS_WIN | ||
993 | // Add a symlink to a dir, to make sure we don't recurse into those | 1017 | // Add a symlink to a dir, to make sure we don't recurse into those | ||
994 | bool symlinkOk = symlink("dirFromHome", QFile::encodeName(src + "/dirFromHome_link").constData()) == 0; | 1018 | bool symlinkOk = symlink("dirFromHome", QFile::encodeName(src + "/dirFromHome_link").constData()) == 0; | ||
▲ Show 20 Lines • Show All 1005 Lines • Show Last 20 Lines |
At runtime, Qt says:
Indeed this is the getter, not a signal. result() is the signal, but you don't really need to connect to it anyway.