diff options
Diffstat (limited to 'tests/auto/corelib')
5 files changed, 91 insertions, 50 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index dc83cf2fc4..c5a9b421ee 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -507,32 +507,26 @@ void tst_QSettings::ctor() QCOMPARE(settings1.value("%General/%General").toInt(), 11); /* - Test that the organization and product parameters is - case-insensitive on Windows and Mac, case-sensitive on - Unix. + Test that the organization and product parameters are + case-insensitive on case-insensitive file systems. */ QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp"); + + bool caseSensitive = true; +#if defined(Q_OS_MAC) if (format == QSettings::NativeFormat) { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) -# ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("native", "See QTBUG-32655", Continue); -# endif // Q_OS_OSX - QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); -#else - QVERIFY(!settings5.contains("key 1")); -#endif + // more details in QMacSettingsPrivate::QMacSettingsPrivate(), organization was comify()-ed + caseSensitive = settings5.fileName().contains("SoftWare.ORG");; } else { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) -# ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("", "See QTBUG-32655", Continue); -# endif // Q_OS_OSX - QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); -#else - QVERIFY(!settings5.contains("key 1")); -#endif + caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE); } +#elif defined(Q_OS_WIN32) + caseSensitive = false; +#endif + if (caseSensitive) + QVERIFY(!settings5.contains("key 1")); + else + QVERIFY(settings5.contains("key 1")); } { @@ -3168,6 +3162,11 @@ void tst_QSettings::rainersSyncBugOnMac() { QFETCH(QSettings::Format, format); +#ifdef Q_OS_OSX + if (format == QSettings::NativeFormat) + QSKIP("OSX does not support direct reads from and writes to .plist files, due to caching and background syncing. See QTBUG-34899."); +#endif + QString fileName; { @@ -3183,10 +3182,6 @@ void tst_QSettings::rainersSyncBugOnMac() { QSettings s3(format, QSettings::UserScope, "software.org", "KillerAPP"); -#ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("native", "See QTBUG-32655", Continue); -#endif QCOMPARE(s3.value("key1", 30).toInt(), 25); } } diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp index d2b6848dab..9e33f56a34 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp @@ -65,6 +65,7 @@ private slots: void basicacquire(); void complexacquire(); + void release(); #ifndef QT_NO_PROCESS void basicProcesses(); @@ -145,12 +146,37 @@ void tst_QSystemSemaphore::complexacquire() { QSystemSemaphore sem("QSystemSemaphore_complexacquire", 2, QSystemSemaphore::Create); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QCOMPARE(sem.errorString(), QString()); +} + +void tst_QSystemSemaphore::release() +{ + QSystemSemaphore sem("QSystemSemaphore_release", 0, QSystemSemaphore::Create); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); QCOMPARE(sem.error(), QSystemSemaphore::NoError); QCOMPARE(sem.errorString(), QString()); diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index 7d041e69cb..ac8d433f96 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -49,9 +49,13 @@ #ifdef Q_OS_UNIX #include <unistd.h> #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) -#include <windows.h> -#define sleep(X) Sleep(X) +#if defined(Q_OS_WIN) +# include <qt_windows.h> +# ifndef Q_OS_WINRT +# define sleep(X) Sleep(X) +# else +# define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE); +# endif #endif //on solaris, threads that loop on the release bool variable diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index 07f8ddfc8e..2b30b0486b 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -69,9 +69,18 @@ int main(int argc, char *argv[]) // An option with a longer description, to test wrapping QCommandLineOption noImplicitIncludesOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-implicit-includes")); - noImplicitIncludesOption.setDescription(QStringLiteral("Disable automatic generation of implicit #include-directives.")); + noImplicitIncludesOption.setDescription(QStringLiteral("Disable magic generation of implicit #include-directives.")); parser.addOption(noImplicitIncludesOption); + QCommandLineOption newlineOption(QStringList() << QStringLiteral("newline")); + newlineOption.setDescription(QString::fromLatin1("This is an option with a rather long\n" + "description using explicit newline characters " + "(but testing automatic wrapping too). In addition, " + "here, we test breaking after a comma. Testing -option. " + "Long URL: http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application " + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + parser.addOption(newlineOption); + // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. parser.parse(QCoreApplication::arguments()); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index d8965dee5d..f37e192ad3 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -459,27 +459,40 @@ void tst_QCommandLineParser::testVersionOption() #endif // !QT_NO_PROCESS } +static const char expectedOptionsHelp[] = + "Options:\n" + " -h, --help Displays this help.\n" + " -v, --version Displays version information.\n" + " --load <url> Load file from URL.\n" + " -o, --output <file> Set output file.\n" + " -D <key=value> Define macro.\n" + " -n, --no-implicit-includes Disable magic generation of implicit\n" + " #include-directives.\n" + " --newline This is an option with a rather long\n" + " description using explicit newline characters (but\n" + " testing automatic wrapping too). In addition,\n" + " here, we test breaking after a comma. Testing\n" + " -option. Long URL:\n" + " http://qt-project.org/wiki/How_to_create_a_library\n" + " _with_Qt_and_use_it_in_an_application\n" + " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n" + " yzabcdefghijklmnopqrstuvwxyz\n"; + void tst_QCommandLineParser::testHelpOption_data() { QTest::addColumn<QCommandLineParser::SingleDashWordOptionMode>("parsingMode"); QTest::addColumn<QString>("expectedHelpOutput"); - QString expectedOutput = + QString expectedOutput = QString::fromLatin1( "Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n" "Test helper\n" - "\n" - "Options:\n" - " -h, --help Displays this help.\n" - " -v, --version Displays version information.\n" - " --load <url> Load file from URL.\n" - " -o, --output <file> Set output file.\n" - " -D <key=value> Define macro.\n" - " -n, --no-implicit-includes Disable automatic generation of implicit #include\n" - " -directives.\n" + "\n") + + QString::fromLatin1(expectedOptionsHelp) + + QString::fromLatin1( "\n" "Arguments:\n" " parsingMode The parsing mode to test.\n" - " command The command to execute.\n"; + " command The command to execute.\n"); #ifdef Q_OS_WIN expectedOutput.replace(" -h, --help Displays this help.\n", " -?, -h, --help Displays this help.\n"); @@ -510,6 +523,7 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WIN output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif + QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure QCOMPARE(output, expectedHelpOutput); process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help"); @@ -519,18 +533,11 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WIN output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif - QByteArray expectedResizeHelp = + QByteArray expectedResizeHelp = QByteArrayLiteral( "Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n" "Test helper\n" - "\n" - "Options:\n" - " -h, --help Displays this help.\n" - " -v, --version Displays version information.\n" - " --load <url> Load file from URL.\n" - " -o, --output <file> Set output file.\n" - " -D <key=value> Define macro.\n" - " -n, --no-implicit-includes Disable automatic generation of implicit #include\n" - " -directives.\n" + "\n") + + expectedOptionsHelp + " --size <size> New size.\n" "\n" "Arguments:\n" |