diff options
-rw-r--r-- | dist/changes-4.8.0 | 16 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 55 | ||||
-rw-r--r-- | src/corelib/io/qbuffer.cpp | 17 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac.cpp | 77 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_mac_p.h | 7 | ||||
-rw-r--r-- | src/corelib/tools/qstring.h | 1 | ||||
-rw-r--r-- | src/gui/dialogs/qfiledialog_mac.mm | 3 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_mac.mm | 1 | ||||
-rw-r--r-- | src/gui/kernel/qmime_mac.cpp | 4 | ||||
-rw-r--r-- | src/gui/kernel/qt_mac.cpp | 1 | ||||
-rw-r--r-- | src/gui/styles/qcommonstyle.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase_mac.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qauthenticator.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qgl_mac.mm | 1 | ||||
-rw-r--r-- | src/qt3support/dialogs/q3filedialog_mac.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qbuffer/tst_qbuffer.cpp | 50 | ||||
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 58 | ||||
-rw-r--r-- | tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp | 18 | ||||
-rw-r--r-- | tests/benchmarks/corelib/tools/qstring/main.cpp | 100 |
19 files changed, 312 insertions, 105 deletions
diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 02205b3..da3a00a 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -53,6 +53,7 @@ QtCore - QStringBuilder: added support for QByteArray - qSwap now uses std::swap, specialized std::swap for our container to work better with stl algoritms - QVariant: deprecated global function qVariantSetValue, qVariantValue, qVariantCanConvert, qVariantFromValue + - QUrl: add method for retrieving effective top level domain [QTBUG-13601] (MR-1205) QtGui ----- @@ -63,6 +64,21 @@ QtGui - QListView diverses optimisations [QTBUG-11438] - QTreeWidget/QListWidget: use localeAwareCompare for string comparisons [QTBUG-10839] +QtNetwork +--------- + + - SSL: Switch default version to TLS 1.0 + - SSL: enable Server Name Indication (SNI) by default + - QSslCertificate: report fraudulent certificates as invalid ("Comodogate") [QTBUG-18338] + - QSslCertificate: display non-ASCII names from subject and issuerInfo (MR-922) + - QSslCertificate: loat root certificates on demand on Unix (excluding Mac) [QTBUG-14016] + - QNetworkCookie: retain quotes in value attribute [QTBUG-17746] + - QNetworkCookie: allow spaces in unquoted values [QTBUG-18876] + - HTTP API: add support for HTTP multipart messages [QTBUG-6222] + - HTTP cache: do not load resources from cache that must be revalidated [QTBUG-18983] + - HTTP cache: change file organization (MR-2505) + + QtOpenGL -------- - Removed dependency of OpenGL Utility Library (GLU) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index e5626b4..84d68e5 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -1648,64 +1648,13 @@ static const unsigned int qt_one = 1; const int QSysInfo::ByteOrder = ((*((unsigned char *) &qt_one) == 0) ? BigEndian : LittleEndian); #endif -#if !defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) +#if !defined(QWS) && defined(Q_OS_MAC) QT_BEGIN_INCLUDE_NAMESPACE #include "private/qcore_mac_p.h" #include "qnamespace.h" QT_END_INCLUDE_NAMESPACE -Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) -{ - return FSPathMakeRef(reinterpret_cast<const UInt8 *>(file.toUtf8().constData()), fsref, 0); -} - -// Don't use this function, it won't work in 10.5 (Leopard) and up -Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) -{ - FSRef fsref; - OSErr ret = qt_mac_create_fsref(file, &fsref); - if (ret == noErr) - ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); - return ret; -} - -Q_CORE_EXPORT void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1) -{ - if(len == -1) - len = s.length(); -#if 0 - UnicodeMapping mapping; - mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, - kTextEncodingDefaultVariant, - kUnicode16BitFormat); - mapping.otherEncoding = (encoding ? encoding : ); - mapping.mappingVersion = kUnicodeUseLatestMapping; - - UnicodeToTextInfo info; - OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); - if(err != noErr) { - qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", - s.left(len).latin1(), (int)encoding, err); - return; - } - const int unilen = len * 2; - const UniChar *unibuf = (UniChar *)s.unicode(); - ConvertFromUnicodeToPString(info, unilen, unibuf, str); - DisposeUnicodeToTextInfo(&info); -#else - Q_UNUSED(encoding); - CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); -#endif -} - -Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr) { - return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); -} -#endif //!defined(QWS) && !defined(Q_WS_QPA) && defined(Q_OS_MAC) - -#if !defined(QWS) && defined(Q_OS_MAC) - static QSysInfo::MacVersion macVersion() { #ifndef QT_NO_CORESERVICES @@ -2105,7 +2054,7 @@ static void mac_default_handler(const char *msg) { if (qt_is_gui_used) { Str255 pmsg; - qt_mac_to_pascal_string(msg, pmsg); + qt_mac_to_pascal_string(QString::fromAscii(msg), pmsg); DebugStr(pmsg); } else { fprintf(stderr, msg); diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 38e406b..35e7b68 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -333,23 +333,18 @@ bool QBuffer::open(OpenMode flags) { Q_D(QBuffer); - if ((flags & Append) == Append) + if ((flags & (Append | Truncate)) != 0) flags |= WriteOnly; - setOpenMode(flags); - if (!(isReadable() || isWritable())) { - qWarning("QFile::open: File access not specified"); + if ((flags & (ReadOnly | WriteOnly)) == 0) { + qWarning("QBuffer::open: Buffer access not specified"); return false; } - if ((flags & QIODevice::Truncate) == QIODevice::Truncate) { + if ((flags & Truncate) == Truncate) d->buf->resize(0); - } - if ((flags & QIODevice::Append) == QIODevice::Append) // append to end of buffer - seek(d->buf->size()); - else - seek(0); + d->ioIndex = (flags & Append) == Append ? d->buf->size() : 0; - return true; + return QIODevice::open(flags); } /*! diff --git a/src/corelib/kernel/qcore_mac.cpp b/src/corelib/kernel/qcore_mac.cpp index 0814c1a..e705c31 100644 --- a/src/corelib/kernel/qcore_mac.cpp +++ b/src/corelib/kernel/qcore_mac.cpp @@ -41,22 +41,22 @@ #include <private/qcore_mac_p.h> #include <new> -#include "qvarlengtharray.h" QT_BEGIN_NAMESPACE QString QCFString::toQString(CFStringRef str) { - if(!str) + if (!str) return QString(); + CFIndex length = CFStringGetLength(str); - const UniChar *chars = CFStringGetCharactersPtr(str); - if (chars) - return QString(reinterpret_cast<const QChar *>(chars), length); + if (length == 0) + return QString(); + + QString string(length, Qt::Uninitialized); + CFStringGetCharacters(str, CFRangeMake(0, length), reinterpret_cast<UniChar *>(const_cast<QChar *>(string.unicode()))); - QVarLengthArray<UniChar> buffer(length); - CFStringGetCharacters(str, CFRangeMake(0, length), buffer.data()); - return QString(reinterpret_cast<const QChar *>(buffer.constData()), length); + return string; } QCFString::operator QString() const @@ -74,9 +74,66 @@ CFStringRef QCFString::toCFStringRef(const QString &string) QCFString::operator CFStringRef() const { - if (!type) - const_cast<QCFString*>(this)->type = toCFStringRef(string); + if (!type) { + if (string.d->data != string.d->array) + const_cast<QCFString*>(this)->string.realloc(); // ### Qt5: do we really need this stupid user protection? + const_cast<QCFString*>(this)->type = + CFStringCreateWithCharactersNoCopy(0, + reinterpret_cast<const UniChar *>(string.unicode()), + string.length(), + kCFAllocatorNull); + } return type; } + +void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding, int len) +{ + if(len == -1) + len = s.length(); +#if 0 + UnicodeMapping mapping; + mapping.unicodeEncoding = CreateTextEncoding(kTextEncodingUnicodeDefault, + kTextEncodingDefaultVariant, + kUnicode16BitFormat); + mapping.otherEncoding = (encoding ? encoding : ); + mapping.mappingVersion = kUnicodeUseLatestMapping; + + UnicodeToTextInfo info; + OSStatus err = CreateUnicodeToTextInfo(&mapping, &info); + if(err != noErr) { + qDebug("Qt: internal: Unable to create pascal string '%s'::%d [%ld]", + s.left(len).latin1(), (int)encoding, err); + return; + } + const int unilen = len * 2; + const UniChar *unibuf = (UniChar *)s.unicode(); + ConvertFromUnicodeToPString(info, unilen, unibuf, str); + DisposeUnicodeToTextInfo(&info); +#else + Q_UNUSED(encoding); + CFStringGetPascalString(QCFString(s), str, 256, CFStringGetSystemEncoding()); +#endif +} + +QString qt_mac_from_pascal_string(const Str255 pstr) +{ + return QCFString(CFStringCreateWithPascalString(0, pstr, CFStringGetSystemEncoding())); +} + +OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref) +{ + return FSPathMakeRef(reinterpret_cast<const UInt8 *>(file.toUtf8().constData()), fsref, 0); +} + +// Don't use this function, it won't work in 10.5 (Leopard) and up +OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec) +{ + FSRef fsref; + OSErr ret = qt_mac_create_fsref(file, &fsref); + if (ret == noErr) + ret = FSGetCatalogInfo(&fsref, kFSCatInfoNone, 0, 0, spec, 0); + return ret; +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h index adbad83..4b8c16f 100644 --- a/src/corelib/kernel/qcore_mac_p.h +++ b/src/corelib/kernel/qcore_mac_p.h @@ -148,6 +148,13 @@ private: QString string; }; +Q_CORE_EXPORT void qt_mac_to_pascal_string(const QString &s, Str255 str, TextEncoding encoding = 0, int len = -1); +Q_CORE_EXPORT QString qt_mac_from_pascal_string(const Str255 pstr); + +Q_CORE_EXPORT OSErr qt_mac_create_fsref(const QString &file, FSRef *fsref); +// Don't use this function, it won't work in 10.5 (Leopard) and up +Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &file, FSSpec *spec); + QT_END_NAMESPACE #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index c61d09e..bf0a0ad 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -639,6 +639,7 @@ private: static Data *fromAscii_helper(const char *str, int size = -1); void replace_helper(uint *indices, int nIndices, int blen, const QChar *after, int alen); friend class QCharRef; + friend class QCFString; friend class QTextCodec; friend class QStringRef; friend struct QAbstractConcatenable; diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm index 885ce77..fb52274 100644 --- a/src/gui/dialogs/qfiledialog_mac.mm +++ b/src/gui/dialogs/qfiledialog_mac.mm @@ -553,9 +553,6 @@ void QFileDialogPrivate::QNSOpenSavePanelDelegate_filterSelected(int menuIndex) emit q_func()->filterSelected(nameFilters.at(menuIndex)); } -extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp -extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); // qglobal.cpp - void QFileDialogPrivate::setDirectory_sys(const QString &directory) { #ifndef QT_MAC_USE_COCOA diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 343b68f..c5ff799 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -218,7 +218,6 @@ extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.cpp extern QWidget *qt_mac_find_window(OSWindowRef); //qwidget_mac.cpp extern void qt_mac_set_cursor(const QCursor *); //qcursor_mac.cpp extern bool qt_mac_is_macsheet(const QWidget *); //qwidget_mac.cpp -extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp extern void qt_mac_command_set_enabled(MenuRef, UInt32, bool); //qmenu_mac.cpp extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplication.cpp extern void qt_mac_update_cursor(); // qcursor_mac.mm diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp index a1df34e..8b47d8e 100644 --- a/src/gui/kernel/qmime_mac.cpp +++ b/src/gui/kernel/qmime_mac.cpp @@ -119,10 +119,6 @@ const QStringList& qEnabledDraggedTypes() *****************************************************************************/ //#define DEBUG_MIME_MAPS -//functions -extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp -extern void qt_mac_from_pascal_string(QString, Str255, TextEncoding encoding=0, int len=-1); //qglobal.cpp - ScrapFlavorType qt_mac_mime_type = 'CUTE'; CFStringRef qt_mac_mime_typeUTI = CFSTR("com.pasteboard.trolltech.marker"); diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp index 339bc82..69f0034 100644 --- a/src/gui/kernel/qt_mac.cpp +++ b/src/gui/kernel/qt_mac.cpp @@ -61,7 +61,6 @@ QFont qfontForThemeFont(ThemeFontID themeID) SInt16 f_size; Style f_style; GetThemeFont(themeID, Script, f_name, &f_size, &f_style); - extern QString qt_mac_from_pascal_string(const Str255); //qglobal.cpp return QFont(qt_mac_from_pascal_string(f_name), f_size, (f_style & ::bold) ? QFont::Bold : QFont::Normal, (bool)(f_style & ::italic)); diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index e5171d8..ad0e151 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5292,7 +5292,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16); break; case SP_MediaSkipForward: - pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); + pixmap = QIcon::fromTheme(QLatin1String("media-skip-forward")).pixmap(16); break; case SP_MediaSkipBackward: pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/gui/text/qfontdatabase_mac.cpp index 724dbf6..60cf586 100644 --- a/src/gui/text/qfontdatabase_mac.cpp +++ b/src/gui/text/qfontdatabase_mac.cpp @@ -388,7 +388,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) if(fnt->data.isEmpty()) { #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { - extern OSErr qt_mac_create_fsref(const QString &, FSRef *); // qglobal.cpp FSRef ref; if(qt_mac_create_fsref(fnt->fileName, &ref) != noErr) return; @@ -398,7 +397,6 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt) #endif { #ifndef Q_WS_MAC64 - extern Q_CORE_EXPORT OSErr qt_mac_create_fsspec(const QString &, FSSpec *); // global.cpp FSSpec spec; if(qt_mac_create_fsspec(fnt->fileName, &spec) != noErr) return; diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp index 818aab7..4f7f4ed 100644 --- a/src/network/kernel/qauthenticator.cpp +++ b/src/network/kernel/qauthenticator.cpp @@ -223,7 +223,7 @@ void QAuthenticator::setUser(const QString &user) } else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) { //domain name is present d->realm.clear(); - d->userDomain = user.left(separatorPosn); + d->userDomain = user.mid(separatorPosn + 1); d->extractedUser = user.left(separatorPosn); d->user = user; } else { diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm index d4b2a40..c3dac87 100644 --- a/src/opengl/qgl_mac.mm +++ b/src/opengl/qgl_mac.mm @@ -114,7 +114,6 @@ extern int qt_mac_pixmap_get_bytes_per_line(const QPixmap *); extern RgnHandle qt_mac_get_rgn(); //qregion_mac.cpp extern void qt_mac_dispose_rgn(RgnHandle); //qregion_mac.cpp extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp -extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); //qglobal.cpp /* QGLTemporaryContext implementation diff --git a/src/qt3support/dialogs/q3filedialog_mac.cpp b/src/qt3support/dialogs/q3filedialog_mac.cpp index f82a8ac..c5db944 100644 --- a/src/qt3support/dialogs/q3filedialog_mac.cpp +++ b/src/qt3support/dialogs/q3filedialog_mac.cpp @@ -248,8 +248,6 @@ static const NavEventUPP make_navProcUPP() } -extern OSErr qt_mac_create_fsref(const QString &, FSRef *); //qglobal.cpp - QStringList Q3FileDialog::macGetOpenFileNames(const QString &filter, QString *pwd, QWidget *parent, const char* /*name*/, const QString& caption, QString *selectedFilter, diff --git a/tests/auto/qbuffer/tst_qbuffer.cpp b/tests/auto/qbuffer/tst_qbuffer.cpp index 776935d..bf4842f 100644 --- a/tests/auto/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/qbuffer/tst_qbuffer.cpp @@ -56,6 +56,7 @@ public: tst_QBuffer(); private slots: + void open(); void getSetCheck(); void readBlock(); void readBlockPastEnd(); @@ -104,6 +105,55 @@ tst_QBuffer::tst_QBuffer() { } +void tst_QBuffer::open() +{ + QByteArray data(10, 'f'); + + QBuffer b; + + QTest::ignoreMessage(QtWarningMsg, "QBuffer::open: Buffer access not specified"); + QVERIFY(!b.open(QIODevice::NotOpen)); + QVERIFY(!b.isOpen()); + b.close(); + + QTest::ignoreMessage(QtWarningMsg, "QBuffer::open: Buffer access not specified"); + QVERIFY(!b.open(QIODevice::Text)); + QVERIFY(!b.isOpen()); + b.close(); + + QTest::ignoreMessage(QtWarningMsg, "QBuffer::open: Buffer access not specified"); + QVERIFY(!b.open(QIODevice::Unbuffered)); + QVERIFY(!b.isOpen()); + b.close(); + + QVERIFY(b.open(QIODevice::ReadOnly)); + QVERIFY(b.isReadable()); + b.close(); + + QVERIFY(b.open(QIODevice::WriteOnly)); + QVERIFY(b.isWritable()); + b.close(); + + b.setData(data); + QVERIFY(b.open(QIODevice::Append)); + QVERIFY(b.isWritable()); + QCOMPARE(b.size(), qint64(10)); + QCOMPARE(b.pos(), b.size()); + b.close(); + + b.setData(data); + QVERIFY(b.open(QIODevice::Truncate)); + QVERIFY(b.isWritable()); + QCOMPARE(b.size(), qint64(0)); + QCOMPARE(b.pos(), qint64(0)); + b.close(); + + QVERIFY(b.open(QIODevice::ReadWrite)); + QVERIFY(b.isReadable()); + QVERIFY(b.isWritable()); + b.close(); +} + // some status() tests, too void tst_QBuffer::readBlock() { diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 25925bd..45f501c 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -6195,16 +6195,62 @@ void tst_QNetworkReply::synchronousRequestSslFailure() } #endif -void tst_QNetworkReply::httpAbort() +class HttpAbortHelper : public QObject { - // FIXME: Implement a test that aborts a big HTTP reply - // a) after the first readyRead() - // b) immediatly after the get() - // c) after the finished() - // The goal is no crash and no irrelevant signals after the abort + Q_OBJECT +public: + HttpAbortHelper(QNetworkReply *parent) + : QObject(parent) + { + mReply = parent; + connect(parent, SIGNAL(readyRead()), this, SLOT(readyRead())); + } + + ~HttpAbortHelper() + { + } + +public slots: + void readyRead() + { + mReply->abort(); + QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); + } + +private: + QNetworkReply *mReply; +}; +void tst_QNetworkReply::httpAbort() +{ // FIXME Also implement one where we do a big upload and then abort(). // It must not crash either. + + // Abort after the first readyRead() + QNetworkRequest request("http://" + QtNetworkSettings::serverName() + "/qtest/bigfile"); + QNetworkReplyPtr reply; + reply = manager.get(request); + HttpAbortHelper replyHolder(reply); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QCOMPARE(reply->error(), QNetworkReply::OperationCanceledError); + QVERIFY(reply->isFinished()); + + // Abort immediatly after the get() + QNetworkReplyPtr reply2 = manager.get(request); + connect(reply2, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + reply2->abort(); + QCOMPARE(reply2->error(), QNetworkReply::OperationCanceledError); + QVERIFY(reply2->isFinished()); + + // Abort after the finished() + QNetworkRequest request3("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QNetworkReplyPtr reply3 = manager.get(request3); + connect(reply3, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(reply3->isFinished()); + reply3->abort(); + QCOMPARE(reply3->error(), QNetworkReply::NoError); } void tst_QNetworkReply::dontInsertPartialContentIntoTheCache() diff --git a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp index 550cef9..eb9a260 100644 --- a/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/qsocketnotifier/tst_qsocketnotifier.cpp @@ -57,7 +57,7 @@ #include <private/qnet_unix_p.h> #endif #include <limits> -#include <select.h> +#include <sys/select.h> class tst_QSocketNotifier : public QObject { @@ -180,7 +180,7 @@ void tst_QSocketNotifier::unexpectedDisconnection() // we have to wait until sequence value changes // as any event can make us jump out processing QCoreApplication::processEvents(QEventLoop::WaitForMoreEvents); - QVERIFY(timer.isActive); //escape if test would hang + QVERIFY(timer.isActive()); //escape if test would hang } while(tester.sequence <= 0); QVERIFY(readEnd1.state() == QAbstractSocket::ConnectedState); @@ -294,7 +294,7 @@ void tst_QSocketNotifier::posixSockets() QTestEventLoop::instance().enterLoop(3); QCOMPARE(readSpy.count(), 1); - QCOMPARE(writeSpy.count(), 0); + writeSpy.clear(); //depending on OS, write notifier triggers on creation or not. QCOMPARE(errorSpy.count(), 0); char buffer[100]; @@ -315,18 +315,17 @@ void tst_QSocketNotifier::posixSockets() void tst_QSocketNotifier::bogusFds() { -#ifndef Q_OS_WIN +#ifndef Q_OS_SYMBIAN + //behaviour of QSocketNotifier with an invalid fd is totally different across OS + //main point of this test was to check symbian backend doesn't crash + QSKIP("test only for symbian", SkipAll); +#else QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); -#endif QSocketNotifier max(std::numeric_limits<int>::max(), QSocketNotifier::Read); QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Invalid socket specified"); -#ifndef Q_OS_WIN QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); -#endif QSocketNotifier min(std::numeric_limits<int>::min(), QSocketNotifier::Write); -#ifndef Q_OS_WIN QTest::ignoreMessage(QtWarningMsg, "QSocketNotifier: Internal error"); -#endif //bogus magic number is the first pseudo socket descriptor from symbian socket engine. QSocketNotifier bogus(0x40000000, QSocketNotifier::Exception); QSocketNotifier largestlegal(FD_SETSIZE - 1, QSocketNotifier::Read); @@ -350,6 +349,7 @@ void tst_QSocketNotifier::bogusFds() QCOMPARE(minspy.count(), 0); QCOMPARE(bogspy.count(), 0); QCOMPARE(llspy.count(), 0); +#endif } QTEST_MAIN(tst_QSocketNotifier) diff --git a/tests/benchmarks/corelib/tools/qstring/main.cpp b/tests/benchmarks/corelib/tools/qstring/main.cpp index 87322a5..5b5f0f7 100644 --- a/tests/benchmarks/corelib/tools/qstring/main.cpp +++ b/tests/benchmarks/corelib/tools/qstring/main.cpp @@ -48,7 +48,12 @@ #define SRCDIR "" #endif +#if !defined(QWS) && defined(Q_OS_MAC) +#include "private/qcore_mac_p.h" +#endif + #ifdef Q_OS_UNIX +#include <sys/ipc.h> #include <sys/mman.h> #include <unistd.h> #endif @@ -76,6 +81,18 @@ private slots: void fromLatin1Alternatives() const; void fromUtf8Alternatives_data() const; void fromUtf8Alternatives() const; + +#if !defined(QWS) && defined(Q_OS_MAC) + void QCFString_data() const; + void QCFString_toCFStringRef_data() const; + void QCFString_toCFStringRef() const; + void QCFString_operatorCFStringRef_data() const; + void QCFString_operatorCFStringRef() const; + void QCFString_toQString_data() const; + void QCFString_toQString() const; + void QCFString_operatorQString_data() const; + void QCFString_operatorQString() const; +#endif // !defined(QWS) && defined(Q_OS_MAC) }; void tst_QString::equals() const @@ -2596,6 +2613,89 @@ void tst_QString::fromUtf8Alternatives() const } } +#if !defined(QWS) && defined(Q_OS_MAC) +void tst_QString::QCFString_data() const +{ + QTest::addColumn<QString>("string"); + + QString base(QLatin1String("I'm some cool string")); + QTest::newRow("base") << base; + + base = base.repeated(25); + QTest::newRow("25 bases") << base; + + QTest::newRow("raw 25 bases") << QString::fromRawData(base.constData(), base.size()); +} + +void tst_QString::QCFString_toCFStringRef_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_toCFStringRef() const +{ + QFETCH(QString, string); + + QBENCHMARK { + CFStringRef cfstr = QCFString::toCFStringRef(string); + CFRelease(cfstr); + } +} + +void tst_QString::QCFString_operatorCFStringRef_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_operatorCFStringRef() const +{ + QFETCH(QString, string); + + CFStringRef cfstr; + QBENCHMARK { + QCFString qcfstr(string); + cfstr = qcfstr; + } +} + +void tst_QString::QCFString_toQString_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_toQString() const +{ + QFETCH(QString, string); + + QCFString qcfstr(string); + + QString qstr; + QBENCHMARK { + qstr = QCFString::toQString(qcfstr); + } + QVERIFY(qstr == string); +} + +void tst_QString::QCFString_operatorQString_data() const +{ + QCFString_data(); +} + +void tst_QString::QCFString_operatorQString() const +{ + QFETCH(QString, string); + + QCFString qcfstr_base(string); + + QString qstr; + QBENCHMARK { + QCFString qcfstr(qcfstr_base); + qstr = qcfstr; + } + QVERIFY(qstr == string); +} +#endif // !defined(QWS) && defined(Q_OS_MAC) + QTEST_MAIN(tst_QString) #include "main.moc" |