From 8cbae43d2269a056b530e10ae8c11168bc66ebb5 Mon Sep 17 00:00:00 2001 From: Sebastian Englbrecht Date: Mon, 1 Jun 2026 19:29:34 +0200 Subject: tests: exclude two tests on windows dolphinmainwindowtest requires a real window server no_bare_qwait_in_tests requires bash and only serves as lint, so linux only is OK --- src/tests/CMakeLists.txt | 13 +++++++++---- src/tests/viewpropertiestest.cpp | 29 ++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 11 deletions(-) (limited to 'src/tests') diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3ac657215..94bba8e5c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -68,16 +68,20 @@ ecm_add_test(viewpropertiestest.cpp testdir.cpp TEST_NAME viewpropertiestest LINK_LIBRARIES dolphinprivate dolphinstatic Qt6::Test KF6::FileMetaData) -# DolphinMainWindowTest -ecm_add_test(dolphinmainwindowtest.cpp testdir.cpp ${CMAKE_SOURCE_DIR}/src/dolphin.qrc -TEST_NAME dolphinmainwindowtest -LINK_LIBRARIES dolphinprivate dolphinstatic Qt6::Test) +# DolphinMainWindowTest (requires a real window desktop; not reliable on Windows CI) +if(NOT WIN32) + ecm_add_test(dolphinmainwindowtest.cpp testdir.cpp ${CMAKE_SOURCE_DIR}/src/dolphin.qrc + TEST_NAME dolphinmainwindowtest + LINK_LIBRARIES dolphinprivate dolphinstatic Qt6::Test) +endif() # DragAndDropHelperTest ecm_add_test(draganddrophelpertest.cpp LINK_LIBRARIES dolphinprivate Qt6::Test) # Lint: forbid bare QTest::qWait() in test sources without an // UNAVOIDABLE: justification. # Every unavoidable delay must carry a comment explaining why no signal-based wait is possible. +# Requires bash; not run on Windows. +if(NOT WIN32) add_test( NAME no_bare_qwait_in_tests COMMAND bash -c @@ -105,6 +109,7 @@ add_test( exit 1; \ fi" ) +endif() # Smoke test: launch Dolphin, verify it starts without crashing, then quit. if(NOT WIN32) diff --git a/src/tests/viewpropertiestest.cpp b/src/tests/viewpropertiestest.cpp index f90d57b88..1d9e886e1 100644 --- a/src/tests/viewpropertiestest.cpp +++ b/src/tests/viewpropertiestest.cpp @@ -109,30 +109,45 @@ void ViewPropertiesTest::testReadOnlyDirectory() QVERIFY(QFile(localFolder).setPermissions(QFileDevice::ReadOwner)); QScopedPointer props(new ViewProperties(testDirUrl)); - const QString destinationDir = props->destinationDir(QStringLiteral("local")) + localFolder; - QVERIFY(props->isAutoSaveEnabled()); props->setSortRole("someNewSortRole"); props.reset(); +#ifdef Q_OS_WIN + // On Windows the read-only attribute is not honored on directories: files and + // Alternate Data Streams can still be created inside them. The properties are + // therefore stored locally rather than redirected to the destination directory. + KFileMetaData::UserMetaData metadata(localFolder); + if (metadata.isSupported()) { + QVERIFY(metadata.hasAttribute("kde.fm.viewproperties#1")); + } else { + QVERIFY(QFile::exists(dotDirectoryFile)); + } +#else + // On a directory without write permission the properties are redirected to the + // destination directory, leaving the local directory untouched. + const QString destinationDir = props->destinationDir(QStringLiteral("local")) + localFolder; QVERIFY(QDir(destinationDir).exists()); QVERIFY(!QFile::exists(dotDirectoryFile)); KFileMetaData::UserMetaData metadata(localFolder); - const QString viewProperties = metadata.attribute(QStringLiteral("kde.fm.viewproperties#1")); - QVERIFY(viewProperties.isEmpty()); + QVERIFY(metadata.attribute(QStringLiteral("kde.fm.viewproperties#1")).isEmpty()); +#endif + // The stored value round-trips regardless of where it was written. props.reset(new ViewProperties(testDirUrl)); QVERIFY(props->isAutoSaveEnabled()); QCOMPARE(props->sortRole(), "someNewSortRole"); props.reset(); - metadata = KFileMetaData::UserMetaData(destinationDir); - if (metadata.isSupported()) { - QVERIFY(metadata.hasAttribute("kde.fm.viewproperties#1")); +#ifndef Q_OS_WIN + KFileMetaData::UserMetaData destMetadata(destinationDir); + if (destMetadata.isSupported()) { + QVERIFY(destMetadata.hasAttribute("kde.fm.viewproperties#1")); } else { QVERIFY(QFile::exists(destinationDir + "/.directory")); } +#endif // un-restrict write permissions QFile(localFolder).setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner); -- cgit v1.3.1