summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2024-03-15 15:11:56 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-03-21 05:49:54 +0200
commit56ef55eda0b197e975de155815885f310dc2e661 (patch)
treeb06748fccceb53d82062a755f69b96e0002da7c0
parentb97bcdd7743485418c26cf37d6ed6ea31ce94376 (diff)
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 <thiago.macieira@intel.com>
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp14
1 files changed, 8 insertions, 6 deletions
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)