diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index cfc786b292..810e2ceb84 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -17,7 +17,6 @@ #if defined(Q_OS_WIN) #include -#include "../../../network-settings.h" #endif #if defined(Q_OS_WIN) && !defined(_WIN32_WINNT) @@ -627,7 +626,7 @@ void tst_QDir::exists_data() QTest::newRow("simple dir") << (m_dataPath + "/resources") << true; QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true; #if defined(Q_OS_WIN) - const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString uncRoot = QStringLiteral("//") + QTest::uncServerName(); QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; QTest::newRow("unc 3") << uncRoot + "/testshare" << true; @@ -1020,7 +1019,7 @@ void tst_QDir::entryListSimple_data() QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2; #if defined(Q_OS_WIN) - const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString uncRoot = QStringLiteral("//") + QTest::uncServerName(); QTest::newRow("unc 1") << uncRoot << 2; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2; QTest::newRow("unc 3") << uncRoot + "/testshare" << 2; @@ -2393,7 +2392,7 @@ void tst_QDir::cdBelowRoot_data() const QString systemRoot = QString::fromLocal8Bit(qgetenv("SystemRoot")); QTest::newRow("windows-drive") << systemDrive << systemRoot.mid(3) << QDir::cleanPath(systemRoot); - const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString uncRoot = QStringLiteral("//") + QTest::uncServerName(); const QString testDirectory = QStringLiteral("testshare"); QTest::newRow("windows-share") << uncRoot << testDirectory << QDir::cleanPath(uncRoot + QLatin1Char('/') + testDirectory); diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index 628f1acad6..bed78e7529 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -18,9 +18,7 @@ #define Q_NO_SYMLINKS #endif -#if defined(Q_OS_WIN) -# include "../../../network-settings.h" -#endif +#include "../../../../shared/filesystem.h" #ifdef Q_OS_ANDROID #include @@ -563,11 +561,11 @@ void tst_QDirIterator::uncPaths_data() { QTest::addColumn("dirName"); QTest::newRow("uncserver") - < #include -#if defined(Q_OS_WIN) -#include "../../../network-settings.h" -#endif #include #include "../../../../shared/filesystem.h" @@ -383,7 +380,7 @@ void tst_QFileInfo::isDir_data() //QTest::newRow("drive 2") << "t:s" << false; #endif #if defined(Q_OS_WIN) - const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString uncRoot = QStringLiteral("//") + QTest::uncServerName(); QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; QTest::newRow("unc 3") << uncRoot + "/testshare" << true; @@ -426,7 +423,7 @@ void tst_QFileInfo::isRoot_data() #endif #if defined(Q_OS_WIN) - const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString uncRoot = QStringLiteral("//") + QTest::uncServerName(); QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; QTest::newRow("unc 3") << uncRoot + "/testshare" << false; @@ -470,7 +467,7 @@ void tst_QFileInfo::exists_data() QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << true; #if defined(Q_OS_WIN) - const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName(); + const QString uncRoot = QStringLiteral("//") + QTest::uncServerName(); QTest::newRow("unc 1") << uncRoot << true; QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true; QTest::newRow("unc 3") << uncRoot + "/testshare" << true; @@ -1732,7 +1729,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() { // Symlink to UNC share pwd.mkdir("unc"); - QString uncTarget = QStringLiteral("//") + QtNetworkSettings::winServerName() + "/testshare"; + QString uncTarget = QStringLiteral("//") + QTest::uncServerName() + "/testshare"; QString uncSymlink = QDir::toNativeSeparators(pwd.absolutePath().append("\\unc\\link_to_unc")); QTest::newRow("UNC symlink") << NtfsTestResource(NtfsTestResource::SymLink, uncSymlink, uncTarget) diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp index 6e98eb06ac..f8dc03ac22 100644 --- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp @@ -35,9 +35,7 @@ #include #include -#if defined(Q_OS_WIN) -#include "../../../network-settings.h" -#endif +#include "../../../../shared/filesystem.h" #if defined QT_BUILD_INTERNAL QT_BEGIN_NAMESPACE @@ -256,7 +254,7 @@ void tst_QFileDialog2::unc() { #if defined(Q_OS_WIN) // Only test UNC on Windows./ - QString dir("\\\\" + QtNetworkSettings::winServerName() + "\\testsharewritable"); + QString dir("\\\\" + QTest::uncServerName() + "\\testsharewritable"); #else QString dir(QDir::currentPath()); #endif diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index 45ee41c85b..b59baf69b6 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -25,6 +25,9 @@ #ifndef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE // MinGW #define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE (0x2) #endif +namespace QTest { + static QString uncServerName() { return qgetenv("COMPUTERNAME"); } +} #endif // QTemporaryDir-based helper class for creating file-system hierarchies and cleaning up.