summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-12-30 17:39:21 +0100
committerLars Knoll <lars.knoll@qt.io>2018-01-02 09:58:44 +0100
commit0f315adf9199efcfafa44371464ab6d1fc866774 (patch)
tree35b67591255624c670aff0579e45b2973f56fd81 /tests/auto/corelib/io
parent2b0eb3fac319a17dd92903106d501f0f06df871f (diff)
parent52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: .qmake.conf sc/corelib/io/qfsfileengine_p.h src/corelib/io/qstorageinfo_unix.cpp src/platformsupport/eglconvenience/qeglpbuffer_p.h src/platformsupport/input/libinput/qlibinputkeyboard.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforms/cocoa/qcocoamenu.mm src/plugins/platforms/ios/qiosscreen.h src/plugins/platforms/ios/qioswindow.h src/plugins/platforms/ios/quiview.mm src/printsupport/dialogs/qpagesetupdialog_unix_p.h src/printsupport/dialogs/qprintpreviewdialog.cpp src/printsupport/widgets/qcupsjobwidget_p.h src/widgets/widgets/qmenu.cpp tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'tests/auto/corelib/io')
-rwxr-xr-x[-rw-r--r--]tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp26
-rw-r--r--tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp6
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp20
3 files changed, 41 insertions, 11 deletions
diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
index 44e79985d4..02b70c317e 100644..100755
--- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
+++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
@@ -64,6 +64,15 @@
#define Q_NO_SYMLINKS
#endif
+#if defined(Q_OS_WIN)
+QT_BEGIN_NAMESPACE
+extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
+QT_END_NAMESPACE
+# ifndef Q_OS_WINRT
+bool IsUserAdmin();
+# endif
+#endif
+
inline bool qIsLikelyToBeFat(const QString &path)
{
QByteArray name = QStorageInfo(path).fileSystemType().toLower();
@@ -1592,6 +1601,15 @@ void tst_QFileInfo::isWritable()
QVERIFY2(fi.exists(), msgDoesNotExist(fi.absoluteFilePath()).constData());
QVERIFY(!fi.isWritable());
#endif
+
+#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
+ QScopedValueRollback<int> ntfsMode(qt_ntfs_permission_lookup);
+ qt_ntfs_permission_lookup = 1;
+ QFileInfo fi2(QFile::decodeName(qgetenv("SystemRoot") + "/system.ini"));
+ QVERIFY(fi2.exists());
+ QCOMPARE(fi2.isWritable(), IsUserAdmin());
+#endif
+
#if defined (Q_OS_QNX) // On QNX /etc is usually on a read-only filesystem
QVERIFY(!QFileInfo("/etc/passwd").isWritable());
#elif defined (Q_OS_UNIX) && !defined(Q_OS_VXWORKS) // VxWorks does not have users/groups
@@ -1765,7 +1783,7 @@ void tst_QFileInfo::detachingOperations()
}
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-BOOL IsUserAdmin()
+bool IsUserAdmin()
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
@@ -1783,13 +1801,9 @@ BOOL IsUserAdmin()
FreeSid(AdministratorsGroup);
}
- return(b);
+ return b != FALSE;
}
-QT_BEGIN_NAMESPACE
-extern Q_CORE_EXPORT int qt_ntfs_permission_lookup;
-QT_END_NAMESPACE
-
#endif // Q_OS_WIN && !Q_OS_WINRT
#ifndef Q_OS_WINRT
diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
index 15c63d4acd..a74ea3a89e 100644
--- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
+++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp
@@ -212,7 +212,7 @@ private slots:
qunsetenv("QT_LOGGING_RULES");
qputenv("QT_LOGGING_CONF", QFINDTESTDATA("qtlogging.ini").toLocal8Bit());
- registry.initalizeRules();
+ registry.initializeRules();
QCOMPARE(registry.ruleSets[QLoggingRegistry::ApiRules].size(), 0);
QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 0);
@@ -220,7 +220,7 @@ private slots:
// check that QT_LOGGING_RULES take precedence
qputenv("QT_LOGGING_RULES", "Digia.*=true");
- registry.initalizeRules();
+ registry.initializeRules();
QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].size(), 2);
QCOMPARE(registry.ruleSets[QLoggingRegistry::EnvironmentRules].at(1).enabled, true);
}
@@ -246,7 +246,7 @@ private slots:
file.close();
QLoggingRegistry registry;
- registry.initalizeRules();
+ registry.initializeRules();
QCOMPARE(registry.ruleSets[QLoggingRegistry::ConfigRules].size(), 1);
// remove file again
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index f3ce902bbd..2d87c2193b 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -70,6 +70,7 @@ private slots:
void io();
void openCloseOpenClose();
void removeAndReOpen();
+ void removeUnnamed();
void size();
void resize();
void openOnRootDrives();
@@ -442,11 +443,13 @@ void tst_QTemporaryFile::removeAndReOpen()
{
QTemporaryFile file;
file.open();
- fileName = file.fileName();
+ fileName = file.fileName(); // materializes any unnamed file
QVERIFY(QFile::exists(fileName));
- file.remove();
+ QVERIFY(file.remove());
+ QVERIFY(file.fileName().isEmpty());
QVERIFY(!QFile::exists(fileName));
+ QVERIFY(!file.remove());
QVERIFY(file.open());
QCOMPARE(QFileInfo(file.fileName()).path(), QFileInfo(fileName).path());
@@ -456,6 +459,19 @@ void tst_QTemporaryFile::removeAndReOpen()
QVERIFY(!QFile::exists(fileName));
}
+void tst_QTemporaryFile::removeUnnamed()
+{
+ QTemporaryFile file;
+ file.open();
+
+ // we did not call fileName(), so the file name may not have a name
+ QVERIFY(file.remove());
+ QVERIFY(file.fileName().isEmpty());
+
+ // if it was unnamed, this will succeed again, so we can't check the result
+ file.remove();
+}
+
void tst_QTemporaryFile::size()
{
QTemporaryFile file;