summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-08-05 08:49:16 -0700
committerThiago Macieira <thiago.macieira@intel.com>2015-08-06 04:53:21 +0000
commit5f1a0cb42a5aa509e0660fc892f2291593fb08ef (patch)
treec4f2730310801dfe6f52d6b4c7b471f1250a6f12 /tests
parent4067bbc24cf7a6d3058387225d9e67ad093991cd (diff)
Seed the random number generator before using QTemporaryDir
Otherwise, on some systems (Windows), we'll always create the same dirs. Change-Id: Id3d5c7bf4d4c45069621ffff13f79ba91e0f974b Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp8
-rw-r--r--tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp7
2 files changed, 14 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 2b01cfd7a9..96ad78a666 100644
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -144,12 +144,18 @@ inline bool qIsLikelyToBeNfs(int /* handle */)
#endif
#endif
+static QString seedAndTemplate()
+{
+ qsrand(QDateTime::currentDateTimeUtc().toTime_t());
+ return QDir::tempPath() + "/tst_qfileinfo-XXXXXX";
+}
class tst_QFileInfo : public QObject
{
Q_OBJECT
public:
- tst_QFileInfo() : m_currentDir(QDir::currentPath()) {}
+ tst_QFileInfo() : m_currentDir(QDir::currentPath()), m_dir(seedAndTemplate())
+ {}
private slots:
void initTestCase();
diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
index 1c9add86f7..99ebf77a3d 100644
--- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
+++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp
@@ -103,7 +103,14 @@ static bool copyResourceFile(const QString &sourceFileName, const QString &targe
// Set LANG before QCoreApplication is created
Q_CONSTRUCTOR_FUNCTION(initializeLang)
+static QString seedAndTemplate()
+{
+ qsrand(QDateTime::currentDateTimeUtc().toTime_t());
+ return QDir::tempPath() + "/tst_qmimedatabase-XXXXXX";
+}
+
tst_QMimeDatabase::tst_QMimeDatabase()
+ : m_temporaryDir(seedAndTemplate())
{
}