diff options
Diffstat (limited to 'tests/auto/corelib')
6 files changed, 111 insertions, 16 deletions
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index a96d8706ee..2756fcce50 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -94,20 +94,31 @@ tst_QFileSystemWatcher::tst_QFileSystemWatcher() void tst_QFileSystemWatcher::basicTest_data() { QTest::addColumn<QString>("backend"); - QTest::newRow("native backend") << "native"; - QTest::newRow("poller backend") << "poller"; + QTest::addColumn<QString>("testFileName"); + const QString testFile = QStringLiteral("testfile.txt"); + // QTBUG-31341: Test the UNICODE capabilities; ensure no QString::toLower() + // is in the code path since that will lower case for example + // LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE with context, whereas the Windows file + // system will not. + const QString specialCharacterFile = + QString(QChar(ushort(0x130))) // LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE + + QChar(ushort(0x00DC)) // LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS + + QStringLiteral(".txt"); + + QTest::newRow("native backend-testfile") << "native" << testFile; + QTest::newRow("poller backend-testfile") << "poller" << testFile; + QTest::newRow("native backend-specialchars") << "native" << specialCharacterFile; } void tst_QFileSystemWatcher::basicTest() { QFETCH(QString, backend); + QFETCH(QString, testFileName); // create test file QTemporaryDir temporaryDirectory(m_tempDirPattern); QVERIFY(temporaryDirectory.isValid()); - QFile testFile(temporaryDirectory.path() + QStringLiteral("/testfile.txt")); - testFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner); - testFile.remove(); + QFile testFile(temporaryDirectory.path() + QLatin1Char('/') + testFileName); QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate)); testFile.write(QByteArray("hello")); testFile.close(); diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 613bfd5c17..3862553a4b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -267,15 +267,7 @@ void tst_QProcess::simpleStart() QCOMPARE(process->state(), QProcess::Running); QVERIFY2(process->waitForStarted(5000), qPrintable(process->errorString())); QCOMPARE(process->state(), QProcess::Running); -#if defined(Q_OS_WINCE) - // Note: This actually seems incorrect, it will only exit the while loop when finishing fails - while (process->waitForFinished(5000)) - { } -#else - while (process->waitForReadyRead(5000)) - { } -#endif - QCOMPARE(int(process->state()), int(QProcess::NotRunning)); + QTRY_COMPARE(process->state(), QProcess::NotRunning); delete process; process = 0; diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 698dc5ca72..9b757ab934 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1941,7 +1941,10 @@ void tst_QUrl::strictParser_data() QTest::newRow("invalid-ipvfuture-3") << "http://[v789]" << "Invalid IPvFuture address"; QTest::newRow("unbalanced-brackets") << "http://[ff02::1" << "Expected ']' to match '[' in hostname"; - // invalid IDN hostnames happen in TolerantMode too + // invalid hostnames happen in TolerantMode too + QTest::newRow("invalid-hostname-leading-dot") << "http://.co.uk" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("invalid-hostname-double-dot") << "http://co..uk" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("invalid-hostname-non-LDH") << "http://foo,bar.example.com" << "Invalid hostname (contains invalid characters)"; QTest::newRow("idn-prohibited-char-space") << "http:// " << "Invalid hostname (contains invalid characters)"; QTest::newRow("idn-prohibited-char-nbsp") << "http://\xc2\xa0" << "Invalid hostname (contains invalid characters)"; QTest::newRow("idn-prohibited-char-control-1f") << "http://\x1f" << "Invalid hostname (contains invalid characters)"; diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp index bad77b1e06..0944f32443 100644 --- a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp +++ b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp @@ -175,7 +175,6 @@ void tst_QWinOverlappedIoNotifier::waitForNotified() HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); - QCOMPARE(notifier.waitForNotified(0, 0), false); notifier.setHandle(hFile); notifier.setEnabled(true); QCOMPARE(notifier.waitForNotified(100, 0), false); diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 529ddd95fe..78cb4277b2 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include <QtTest> + #include "qjsonarray.h" #include "qjsonobject.h" #include "qjsonvalue.h" @@ -63,6 +64,8 @@ private Q_SLOTS: void testValueSimple(); void testNumbers(); + void testNumbers_2(); + void testNumbers_3(); void testObjectSimple(); void testObjectSmallKeys(); @@ -332,6 +335,65 @@ void tst_QtJson::testNumbers() } +void tst_QtJson::testNumbers_2() +{ + // test cases from TC39 test suite for ECMAScript + // http://hg.ecmascript.org/tests/test262/file/d067d2f0ca30/test/suite/ch08/8.5/8.5.1.js + + // Fill an array with 2 to the power of (0 ... -1075) + double value = 1; + double floatValues[1076], floatValues_1[1076]; + QJsonObject jObject; + for (int power = 0; power <= 1075; power++) { + floatValues[power] = value; + jObject.insert(QString::number(power), QJsonValue(floatValues[power])); + // Use basic math operations for testing, which are required to support 'gradual underflow' rather + // than Math.pow etc..., which are defined as 'implementation dependent'. + value = value * 0.5; + } + + QJsonDocument jDocument1(jObject); + QByteArray ba(jDocument1.toJson()); + + QJsonDocument jDocument2(QJsonDocument::fromJson(ba)); + for (int power = 0; power <= 1075; power++) { + floatValues_1[power] = jDocument2.object().value(QString::number(power)).toDouble(); + QVERIFY2(floatValues[power] == floatValues_1[power], QString("floatValues[%1] != floatValues_1[%1]").arg(power).toLatin1()); + } + + // The last value is below min denorm and should round to 0, everything else should contain a value + QVERIFY2(floatValues_1[1075] == 0, "Value after min denorm should round to 0"); + + // Validate the last actual value is min denorm + QVERIFY2(floatValues_1[1074] == 4.9406564584124654417656879286822e-324, QString("Min denorm value is incorrect: %1").arg(floatValues_1[1074]).toLatin1()); + + // Validate that every value is half the value before it up to 1 + for (int index = 1074; index > 0; index--) { + QVERIFY2(floatValues_1[index] != 0, QString("2**- %1 should not be 0").arg(index).toLatin1()); + + QVERIFY2(floatValues_1[index - 1] == (floatValues_1[index] * 2), QString("Value should be double adjacent value at index %1").arg(index).toLatin1()); + } +} + +void tst_QtJson::testNumbers_3() +{ + // test case from QTBUG-31926 + double d1 = 1.123451234512345; + double d2 = 1.123451234512346; + + QJsonObject jObject; + jObject.insert("d1", QJsonValue(d1)); + jObject.insert("d2", QJsonValue(d2)); + QJsonDocument jDocument1(jObject); + QByteArray ba(jDocument1.toJson()); + + QJsonDocument jDocument2(QJsonDocument::fromJson(ba)); + + double d1_1(jDocument2.object().value("d1").toDouble()); + double d2_1(jDocument2.object().value("d2").toDouble()); + QVERIFY(d1_1 != d2_1); +} + void tst_QtJson::testObjectSimple() { QJsonObject object; diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index ff1d8b2a36..ccaa2bec4f 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -69,6 +69,7 @@ private slots: void eventLoopExecAfterExit(); void customEventDispatcher(); void testQuitLock(); + void QTBUG31606_QEventDestructorDeadLock(); }; class EventSpy : public QObject @@ -769,6 +770,33 @@ void tst_QCoreApplication::testQuitLock() app.exec(); } + +void tst_QCoreApplication::QTBUG31606_QEventDestructorDeadLock() +{ + class MyEvent : public QEvent + { public: + MyEvent() : QEvent(QEvent::Type(QEvent::User + 1)) {} + ~MyEvent() { + QCoreApplication::postEvent(qApp, new QEvent(QEvent::Type(QEvent::User+2))); + } + }; + + int argc = 1; + char *argv[] = { const_cast<char*>("tst_qcoreapplication") }; + QCoreApplication app(argc, argv); + + EventSpy spy; + app.installEventFilter(&spy); + + QCoreApplication::postEvent(&app, new MyEvent); + QCoreApplication::processEvents(); + QVERIFY(spy.recordedEvents.contains(QEvent::User + 1)); + QVERIFY(!spy.recordedEvents.contains(QEvent::User + 2)); + QCoreApplication::processEvents(); + QVERIFY(spy.recordedEvents.contains(QEvent::User + 2)); +} + + static void createQObjectOnDestruction() { // Make sure that we can create a QObject after the last QObject has been |