From 56ef55eda0b197e975de155815885f310dc2e661 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Fri, 15 Mar 2024 15:11:56 +0200 Subject: tst_qtemporarydir: refactor a test Instead of using ~/Downloads, which we have no control over (OK for the CI, but not locally), create a parent temp dir, then another temp dir inside it. Also rename it to nestedTempDirs, the issue from the bug report wasn't tested because it relied on a dir being created, then failing to set permissions on it. The code has changed a lot since then. Pick-to: 6.7 6.6 6.5 6.2 Change-Id: I2b03d5d761117aaf436041c13c0dc394b106bf89 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp') diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 1ba1ae64fe..737317a8fb 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -53,7 +53,7 @@ private slots: void QTBUG_4796_data(); void QTBUG_4796(); - void QTBUG43352_failedSetPermissions(); + void nestedTempDirs(); private: QString m_previousCurrent; @@ -555,16 +555,18 @@ void tst_QTemporaryDir::QTBUG_4796() // unicode support cleaner.reset(); } -void tst_QTemporaryDir::QTBUG43352_failedSetPermissions() +void tst_QTemporaryDir::nestedTempDirs() { - QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + QStringLiteral("/"); - int count = QDir(path).entryList().size(); + QTemporaryDir parentDir; + const QString &parentPath = parentDir.path(); { - QTemporaryDir dir(path); + QTemporaryDir tempdir(parentPath); } - QCOMPARE(QDir(path).entryList().size(), count); + QDir dir(parentPath); + dir.setFilter(QDir::NoDotAndDotDot); + QCOMPARE(dir.count(), 0); } QTEST_MAIN(tst_QTemporaryDir) -- cgit v1.2.3