diff options
Diffstat (limited to 'tests/auto/qsettings')
-rw-r--r-- | tests/auto/qsettings/.gitattributes | 5 | ||||
-rw-r--r-- | tests/auto/qsettings/tst_qsettings.cpp | 66 |
2 files changed, 47 insertions, 24 deletions
diff --git a/tests/auto/qsettings/.gitattributes b/tests/auto/qsettings/.gitattributes new file mode 100644 index 0000000..a4ad8d7 --- /dev/null +++ b/tests/auto/qsettings/.gitattributes @@ -0,0 +1,5 @@ +resourcefile.ini -crlf +resourcefile2.ini -crlf +resourcefile3.ini -crlf +resourcefile4.ini -crlf +resourcefile5.ini -crlf diff --git a/tests/auto/qsettings/tst_qsettings.cpp b/tests/auto/qsettings/tst_qsettings.cpp index bfd29c4..af17785 100644 --- a/tests/auto/qsettings/tst_qsettings.cpp +++ b/tests/auto/qsettings/tst_qsettings.cpp @@ -1,7 +1,6 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. @@ -21,9 +20,10 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this +** package. ** ** If you have questions regarding the use of this file, please contact ** Nokia at qt-info@nokia.com. @@ -52,7 +52,9 @@ #include <QtCore/QtDebug> #include <QtCore/QString> -#include <cctype> +#if !defined(Q_OS_SYMBIAN) +# include <cctype> +#endif #if defined(Q_OS_WIN) && defined(Q_CC_GNU) // need for unlink on mingw #include <io.h> @@ -122,7 +124,7 @@ private slots: void setPath(); void setDefaultFormat(); void dontCreateNeedlessPaths(); -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) void dontReorderIniKeysNeedlessly(); #endif @@ -209,7 +211,7 @@ void tst_QSettings::getSetCheck() Q_DECLARE_METATYPE(QSettings::Format) -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) static void removePath(const QString& _path) { QString path = _path; @@ -341,7 +343,7 @@ void tst_QSettings::init() #if defined(Q_OS_WINCE) removePath(settingsPath()); #else - if (qWinVersion() & Qt::WV_NT_based) + if (QSysInfo::windowsVersion() & QSysInfo::WV_NT_based) system(QString("rmdir /Q /S %1").arg(settingsPath()).toLatin1()); else system(QString("deltree /Y %1").arg(settingsPath()).toLatin1()); @@ -356,9 +358,11 @@ void tst_QSettings::init() QSettings(QSettings::SystemScope, "software.org").clear(); QSettings(QSettings::UserScope, "other.software.org").clear(); QSettings(QSettings::SystemScope, "other.software.org").clear(); +#elif defined(Q_OS_SYMBIAN) + removePath(settingsPath()); #endif -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) system(QString("chmod -R u+rw %1 2> /dev/null").arg(settingsPath()).toLatin1()); system(QString("rm -fr %1 2> /dev/null").arg(settingsPath()).toLatin1()); #endif @@ -540,13 +544,13 @@ void tst_QSettings::ctor() */ QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp"); if (format == QSettings::NativeFormat) { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) +#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_SYMBIAN) QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); #else QVERIFY(!settings5.contains("key 1")); #endif } else { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) +#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_SYMBIAN) QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); #else QVERIFY(!settings5.contains("key 1")); @@ -713,8 +717,14 @@ void tst_QSettings::testErrorHandling_data() void tst_QSettings::testErrorHandling() { +#ifdef QT_BUILD_INTERNAL #ifdef Q_OS_WIN QSKIP("Windows doesn't support most file modes, including read-only directories, so this test is moot.", SkipAll); +#elif defined(Q_OS_SYMBIAN) + QSKIP("Symbian/Open C doesn't support execute or write only file modes, or directory permissions, so this test is mostly moot.", SkipAll); +#elif defined(Q_OS_UNIX) + if (::getuid() == 0) + QSKIP("Running this test as root doesn't work, since file perms do not bother him", SkipAll); #else QFETCH(int, filePerms); QFETCH(int, dirPerms); @@ -723,8 +733,7 @@ void tst_QSettings::testErrorHandling() QFETCH(int, statusAfterGet); QFETCH(int, statusAfterSetAndSync); - - system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); + system(QString("chmod 700 %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); system(QString("chmod -R u+rwx %1 2>/dev/null").arg(settingsPath("someDir")).toLatin1()); system(QString("rm -fr %1").arg(settingsPath("someDir")).toLatin1()); @@ -776,6 +785,7 @@ void tst_QSettings::testErrorHandling() QCOMPARE((int)settings.status(), statusAfterSetAndSync); } #endif // !Q_OS_WIN +#endif } Q_DECLARE_METATYPE(QVariant) @@ -821,6 +831,7 @@ void tst_QSettings::testIniParsing_data() void tst_QSettings::testIniParsing() { +#ifdef QT_BUILD_INTERNAL qRegisterMetaType<QVariant>("QVariant"); qRegisterMetaType<QSettings::Status>("QSettings::Status"); @@ -854,6 +865,7 @@ void tst_QSettings::testIniParsing() } QCOMPARE(settings.status(), status); +#endif } /* @@ -1058,6 +1070,7 @@ void tst_QSettings::testVariantTypes_data() void tst_QSettings::testVariantTypes() { +#ifdef QT_BUILD_INTERNAL #define testVal(key, val, tp, rtype) \ { \ QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \ @@ -1141,6 +1154,7 @@ void tst_QSettings::testVariantTypes() } #undef testVal +#endif } void tst_QSettings::remove() @@ -1491,7 +1505,7 @@ void tst_QSettings::sync() // Now "some other app" will change other.software.org.ini QString userConfDir = settingsPath("__user__") + QDir::separator(); -#if !defined(Q_OS_WINCE) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN) unlink((userConfDir + "other.software.org.ini").toLatin1()); rename((userConfDir + "software.org.ini").toLatin1(), (userConfDir + "other.software.org.ini").toLatin1()); @@ -1801,9 +1815,7 @@ void tst_QSettings::testNormalizedKey_data() void tst_QSettings::testNormalizedKey() { -#ifdef QTEST_REDUCED_EXPORTS - QSKIP("We can't test QSettingsPrivate on Windows", SkipAll); -#else +#ifdef QT_BUILD_INTERNAL QFETCH(QString, inKey); QFETCH(QString, outKey); @@ -1981,6 +1993,7 @@ void tst_QSettings::fromFile() void tst_QSettings::setIniCodec() { +#ifdef QT_BUILD_INTERNAL QByteArray expeContents4, expeContents5; QByteArray actualContents4, actualContents5; @@ -2040,6 +2053,7 @@ void tst_QSettings::setIniCodec() QCOMPARE(settings4.allKeys().first(), settings5.allKeys().first()); QCOMPARE(settings4.value(settings4.allKeys().first()).toString(), settings5.value(settings5.allKeys().first()).toString()); +#endif } static bool containsSubList(QStringList mom, QStringList son) @@ -2316,6 +2330,7 @@ void tst_QSettings::testArrays() settings1.endArray(); } +#ifdef QT_BUILD_INTERNAL static QByteArray iniEscapedKey(const QString &str) { QByteArray result; @@ -2360,6 +2375,7 @@ static QStringList iniUnescapedStringList(const QByteArray &ba) #endif return result; } +#endif QString escapeWeirdChars(const QString &s) { @@ -2383,6 +2399,7 @@ QString escapeWeirdChars(const QString &s) void tst_QSettings::testEscapes() { +#ifdef QT_BUILD_INTERNAL QSettings settings(QSettings::UserScope, "software.org", "KillerAPP"); #define testEscapedKey(plainKey, escKey) \ @@ -2505,6 +2522,7 @@ void tst_QSettings::testEscapes() testBadEscape("@Rect)", "@Rect)"); testBadEscape("@Rect(1 2 3)", "@Rect(1 2 3)"); testBadEscape("@@Rect(1 2 3)", "@Rect(1 2 3)"); +#endif } void tst_QSettings::testCompatFunctions() @@ -3010,12 +3028,6 @@ void tst_QSettings::oldWriteEntry_QString_QString() QSettings readSettings("software.org", "KillerAPP"); QFETCH( QString, s ); bool ok = FALSE; -#ifdef Q_OS_WIN - if (qWinVersion() & Qt::WV_DOS_based) { - QEXPECT_FAIL("data2", "Windows 9x does not support unicode characters in the registry", Abort); - QEXPECT_FAIL("data5", "Windows 9x does not support unicode characters in the registry", Abort); - } -#endif QCOMPARE( readSettings.readEntry( "/Trolltech/QSettingsTesting/String", QString::null, &ok ), s ); QVERIFY( ok ); } @@ -3361,6 +3373,7 @@ void tst_QSettings::childGroups_data() void tst_QSettings::childGroups() { +#ifdef QT_BUILD_INTERNAL QFETCH(QSettings::Format, format); { @@ -3414,6 +3427,7 @@ void tst_QSettings::childGroups() QCOMPARE(settings.childGroups(), QStringList() << "alpha" << "gamma" << "omicron" << "zeta"); } +#endif } void tst_QSettings::childKeys_data() @@ -3423,6 +3437,7 @@ void tst_QSettings::childKeys_data() void tst_QSettings::childKeys() { +#ifdef QT_BUILD_INTERNAL QFETCH(QSettings::Format, format); { @@ -3476,6 +3491,7 @@ void tst_QSettings::childKeys() QCOMPARE(settings.childKeys(), QStringList() << "alpha" << "beta" << "gamma"); } +#endif } void tst_QSettings::allKeys_data() @@ -3485,6 +3501,7 @@ void tst_QSettings::allKeys_data() void tst_QSettings::allKeys() { +#ifdef QT_BUILD_INTERNAL QFETCH(QSettings::Format, format); QStringList allKeys; @@ -3533,6 +3550,7 @@ void tst_QSettings::allKeys() QCOMPARE(settings.allKeys(), allKeys); } +#endif } void tst_QSettings::registerFormat() @@ -3667,7 +3685,7 @@ void tst_QSettings::dontCreateNeedlessPaths() QVERIFY(!fileInfo.dir().exists()); } -#ifndef Q_OS_WIN +#if !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) void tst_QSettings::dontReorderIniKeysNeedlessly() { #ifdef QT_QSETTINGS_ALWAYS_CASE_SENSITIVE_AND_FORGET_ORIGINAL_KEY_ORDER |