diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-08 11:24:47 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-08 11:24:47 (GMT) |
commit | 9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6 (patch) | |
tree | 36687843f30efa62a4ac37e863da6d3984626be3 /tests/auto | |
parent | 0f3fd01523081656c27ebb7b495c4f1a1c927117 (diff) | |
parent | 29ec793147054ea4beb1ad4adeebbbe1fe07b260 (diff) | |
download | Qt-9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6.zip Qt-9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6.tar.gz Qt-9d0dff2d9d49f59b5c6cd0e53cd4d7f042e5d6a6.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (64 commits)
Carbon: usage of menu bars can cause exceptions to be thrown
Mac: compile fix
Fix build
JPEG plugin: Use switch() instead of if()
don't try to build corewlan plugin when corewlan was not found at configure
Avoid conversion to/from QChar in the cn codec to unicode
Avoid memory allocations in conversion from Gb2312/Gb18030 to unicode
fix corewlan detection error when building for 10.5 when 10.6 is also
fixed treatment of zlib on Mac when crossbuilding
Partial overloading support for qdbus cli tool.
Allow empty authority in QUrl::setAuthority as per docs.
Added test for QTBUG-6962: Empty authority ignored by QUrl::setAuthority.
fixed case of GL include directory
check in MAC_APPLICATION_MENU translations
Re-generate the Unicode tables after updates to the program that generates them
Fix the code after merge: DerivedNormalizationProps has two or more columns
add some usefull definitions to qunicodetables_p.h
qchar.cpp: fix identation
finish last commit
prefer DerivedNormalizationProps.txt over CompositionExclusions.txt
...
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qchar/tst_qchar.cpp | 13 | ||||
-rw-r--r-- | tests/auto/qnetworksession/test/tst_qnetworksession.cpp | 63 | ||||
-rw-r--r-- | tests/auto/qurl/tst_qurl.cpp | 9 | ||||
-rw-r--r-- | tests/auto/utf8/tst_utf8.cpp | 85 |
4 files changed, 157 insertions, 13 deletions
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp index 547147c..6227c2e 100644 --- a/tests/auto/qchar/tst_qchar.cpp +++ b/tests/auto/qchar/tst_qchar.cpp @@ -72,6 +72,7 @@ private slots: void toLower(); void toTitle(); void toCaseFolded(); + void isPrint(); void isUpper(); void isLower(); void category(); @@ -218,6 +219,12 @@ void tst_QChar::toCaseFolded() QVERIFY(QChar::toCaseFolded((ushort)0xb5) == 0x3bc); } +void tst_QChar::isPrint() +{ + QVERIFY(QChar('A').isPrint()); + QVERIFY(!QChar(0x1aff).isPrint()); // General_Gategory =Cn +} + void tst_QChar::isUpper() { QVERIFY(QChar('A').isUpper()); @@ -259,6 +266,12 @@ void tst_QChar::category() QVERIFY(QChar::category(0xd900u) == QChar::Other_Surrogate); QVERIFY(QChar::category(0xdc00u) == QChar::Other_Surrogate); QVERIFY(QChar::category(0xdc01u) == QChar::Other_Surrogate); + + QVERIFY(QChar::category((uint)0x10fffdu) == QChar::Other_PrivateUse); + QVERIFY(QChar::category((uint)0x110000u) == QChar::NoCategory); + + QVERIFY(QChar::category((uint)0x1aff) == QChar::Other_NotAssigned); + QVERIFY(QChar::category((uint)0x10ffffu) == QChar::Other_NotAssigned); } void tst_QChar::direction() diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 58b1a48..4b56f77 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -85,6 +85,9 @@ private slots: void sessionOpenCloseStop_data(); void sessionOpenCloseStop(); + void sessionAutoClose_data(); + void sessionAutoClose(); + private: QNetworkConfigurationManager manager; @@ -1202,7 +1205,67 @@ bool closeSession(QNetworkSession *session, bool lastSessionOnConfiguration) { return true; } +void tst_QNetworkSession::sessionAutoClose_data() +{ + QTest::addColumn<QNetworkConfiguration>("configuration"); + + bool testData = false; + foreach (const QNetworkConfiguration &config, + manager.allConfigurations(QNetworkConfiguration::Discovered)) { + QNetworkSession session(config); + if (!session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")).isValid()) + continue; + + testData = true; + + const QString name = config.name().isEmpty() ? QString("<Hidden>") : config.name(); + QTest::newRow(name.toLocal8Bit().constData()) << config; + } + + if (!testData) + QSKIP("No applicable configurations to test", SkipAll); +} + +void tst_QNetworkSession::sessionAutoClose() +{ + QFETCH(QNetworkConfiguration, configuration); + + QNetworkSession session(configuration); + + QVERIFY(session.configuration() == configuration); + QVariant autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); + + QVERIFY(autoCloseSession.isValid()); + + // property defaults to false + QCOMPARE(autoCloseSession.toInt(), -1); + + QSignalSpy closeSpy(&session, SIGNAL(closed())); + + session.open(); + session.waitForOpened(); + + if (!session.isOpen()) + QSKIP("Session not open", SkipSingle); + + // set session to auto close at next polling interval. + session.setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 0); + + QTRY_VERIFY(!closeSpy.isEmpty()); + + QCOMPARE(session.state(), QNetworkSession::Connected); + + QVERIFY(!session.isOpen()); + + QVERIFY(session.configuration() == configuration); + + autoCloseSession = session.sessionProperty(QLatin1String("AutoCloseSessionTimeout")); + + QVERIFY(autoCloseSession.isValid()); + + QCOMPARE(autoCloseSession.toInt(), -1); +} QTEST_MAIN(tst_QNetworkSession) diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 83109b5..b7cbdb8 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -193,6 +193,7 @@ private slots: void fromUserInput(); void task_199967(); void task_240612(); + void taskQTBUG_6962(); #ifdef QT3_SUPPORT void dirPath(); @@ -3860,5 +3861,13 @@ void tst_QUrl::resolvedWithAbsoluteSchemes_data() const << QUrl::fromEncoded("http://www.foo.com:8080/newfile.html"); } +void tst_QUrl::taskQTBUG_6962() +{ + //bug 6962: empty authority ignored by setAuthority + QUrl url("http://example.com/something"); + url.setAuthority(QString()); + QCOMPARE(url.authority(), QString()); +} + QTEST_MAIN(tst_QUrl) #include "tst_qurl.moc" diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp index 1183b81..7bbbfab 100644 --- a/tests/auto/utf8/tst_utf8.cpp +++ b/tests/auto/utf8/tst_utf8.cpp @@ -73,6 +73,9 @@ private slots: void invalidUtf8_data(); void invalidUtf8(); + + void nonCharacters_data(); + void nonCharacters(); }; void tst_Utf8::initTestCase() @@ -134,8 +137,8 @@ void tst_Utf8::roundTrip_data() static const uint utf32_5[] = { 0x010203 }; QTest::newRow("utf8_5") << QByteArray(utf8_5) << QString::fromUcs4(utf32_5, 1); - static const char utf8_6[] = "\364\217\277\277"; // U+10FFFF - static const uint utf32_6[] = { 0x10FFFF }; + static const char utf8_6[] = "\364\217\277\275"; // U+10FFFD + static const uint utf32_6[] = { 0x10FFFD }; QTest::newRow("utf8_6") << QByteArray(utf8_6) << QString::fromUcs4(utf32_6, 1); static const char utf8_7[] = "abc\302\240\303\241\303\251\307\275 \342\202\254def"; @@ -144,10 +147,10 @@ void tst_Utf8::roundTrip_data() ' ', 0x20AC, 'd', 'e', 'f', 0 }; QTest::newRow("utf8_7") << QByteArray(utf8_7) << QString::fromUtf16(utf16_7); - static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\277 \342\202\254def"; + static const char utf8_8[] = "abc\302\240\303\241\303\251\307\275 \364\217\277\275 \342\202\254def"; static const uint utf32_8[] = { 'a', 'b', 'c', 0x00A0, 0x00E1, 0x00E9, 0x01FD, - ' ', 0x10FFFF, ' ', + ' ', 0x10FFFD, ' ', 0x20AC, 'd', 'e', 'f', 0 }; QTest::newRow("utf8_8") << QByteArray(utf8_8) << QString::fromUcs4(utf32_8); } @@ -214,14 +217,6 @@ void tst_Utf8::invalidUtf8_data() QTest::newRow("4chars-2") << QByteArray("\xF0\x90\xC0\x80"); QTest::newRow("4chars-3") << QByteArray("\xF0\xC0\x80\x80"); - // U+FFFE and U+FFFF are non-characters and must not be present - // U+FFFE: 1111 11 1111 11 1110 - // encoding: xxxz:1111 xz11:1111 xz11:1110 - QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE"); - // U+FFFF: 1111 11 1111 11 1111 - // encoding: xxxz:1111 xz11:1111 xz11:1111 - QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF"); - // Surrogate pairs must now be present either // U+D800: 1101 10 0000 00 0000 // encoding: xxxz:1101 xz10:0000 xz00:0000 @@ -302,7 +297,7 @@ void tst_Utf8::invalidUtf8() QFETCH_GLOBAL(bool, useLocale); QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); - QString decoded = decoder->toUnicode(utf8); + decoder->toUnicode(utf8); // Only enforce correctness on our UTF-8 decoder // The system's UTF-8 codec is sometimes buggy @@ -314,5 +309,69 @@ void tst_Utf8::invalidUtf8() qWarning("System codec does not report failure when it should. Should report bug upstream."); } +void tst_Utf8::nonCharacters_data() +{ + QTest::addColumn<QByteArray>("utf8"); + QTest::addColumn<QString>("utf16"); + + // Unicode has a couple of "non-characters" that one can use internally, + // but are not allowed to be used for text interchange. + // + // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF, + // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and + // U+FDEF (inclusive) + + // U+FDD0 through U+FDEF + for (int i = 0; i < 16; ++i) { + char utf8[] = { 0357, 0267, 0220 + i, 0 }; + QString utf16 = QChar(0xfdd0 + i); + QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16; + } + + // the last two in Planes 1 through 16 + for (uint plane = 1; plane <= 16; ++plane) { + for (uint lower = 0xfffe; lower < 0x10000; ++lower) { + uint ucs4 = (plane << 16) | lower; + char utf8[] = { 0xf0 | uchar(ucs4 >> 18), + 0x80 | (uchar(ucs4 >> 12) & 0x3f), + 0x80 | (uchar(ucs4 >> 6) & 0x3f), + 0x80 | (uchar(ucs4) & 0x3f), + 0 }; + ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 }; + + QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16); + } + } + + QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe)); + QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff)); +} + +void tst_Utf8::nonCharacters() +{ + QFETCH(QByteArray, utf8); + QFETCH(QString, utf16); + QFETCH_GLOBAL(bool, useLocale); + + QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder()); + decoder->toUnicode(utf8); + + // Only enforce correctness on our UTF-8 decoder + // The system's UTF-8 codec is sometimes buggy + // GNU libc's iconv is known to accept U+FFFF and U+FFFE encoded as UTF-8 + // OS X's iconv is known to accept those, plus surrogates and codepoints above U+10FFFF + if (!useLocale) + QVERIFY(decoder->hasFailure()); + else if (!decoder->hasFailure()) + qWarning("System codec does not report failure when it should. Should report bug upstream."); + + QSharedPointer<QTextEncoder> encoder(codec->makeEncoder()); + encoder->fromUnicode(utf16); + if (!useLocale) + QVERIFY(encoder->hasFailure()); + else if (!encoder->hasFailure()) + qWarning("System codec does not report failure when it should. Should report bug upstream."); +} + QTEST_MAIN(tst_Utf8) #include "tst_utf8.moc" |