summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 00e45354ba..67a4f71f54 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -53,7 +53,9 @@
#include <QHostInfo>
#endif
#include <QProcess>
-#ifndef Q_OS_WIN
+#ifdef Q_OS_WIN
+# include <qt_windows.h>
+#else
# include <sys/types.h>
# include <unistd.h>
#endif
@@ -476,8 +478,16 @@ void tst_QFile::open_data()
QTest::newRow("noreadfile") << QString("noreadfile") << int(QIODevice::ReadOnly)
<< false << QFile::OpenError;
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- QTest::newRow("//./PhysicalDrive0") << QString("//./PhysicalDrive0") << int(QIODevice::ReadOnly)
- << true << QFile::NoError;
+ //opening devices requires administrative privileges (and elevation).
+ HANDLE hTest = CreateFile(_T("\\\\.\\PhysicalDrive0"), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ if (hTest != INVALID_HANDLE_VALUE) {
+ CloseHandle(hTest);
+ QTest::newRow("//./PhysicalDrive0") << QString("//./PhysicalDrive0") << int(QIODevice::ReadOnly)
+ << true << QFile::NoError;
+ } else {
+ QTest::newRow("//./PhysicalDrive0") << QString("//./PhysicalDrive0") << int(QIODevice::ReadOnly)
+ << false << QFile::OpenError;
+ }
QTest::newRow("uncFile") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" << int(QIODevice::ReadOnly)
<< true << QFile::NoError;
#endif