diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qglthreads/tst_qglthreads.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qstyle/tst_qstyle.cpp | 51 | ||||
-rw-r--r-- | tests/auto/qtcpserver/tst_qtcpserver.cpp | 53 | ||||
-rw-r--r-- | tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 72 | ||||
-rw-r--r-- | tests/auto/qthreadstorage/crashOnExit.cpp | 64 | ||||
-rw-r--r-- | tests/auto/qthreadstorage/crashOnExit.pro | 4 | ||||
-rw-r--r-- | tests/auto/qthreadstorage/qthreadstorage.pro | 8 | ||||
-rw-r--r-- | tests/auto/qthreadstorage/tst_qthreadstorage.cpp | 17 | ||||
-rw-r--r-- | tests/auto/qthreadstorage/tst_qthreadstorage.pro | 4 | ||||
-rw-r--r-- | tests/benchmarks/corelib/corelib.pro | 3 | ||||
-rw-r--r-- | tests/benchmarks/corelib/plugin/plugin.pro | 2 | ||||
-rw-r--r-- | tests/benchmarks/corelib/plugin/quuid/quuid.pro | 6 | ||||
-rw-r--r-- | tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp | 66 |
13 files changed, 350 insertions, 5 deletions
diff --git a/tests/auto/qglthreads/tst_qglthreads.cpp b/tests/auto/qglthreads/tst_qglthreads.cpp index 38b0dab..9441406 100644 --- a/tests/auto/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/qglthreads/tst_qglthreads.cpp @@ -45,6 +45,10 @@ #include <QtOpenGL/QtOpenGL> #include "tst_qglthreads.h" +#ifdef Q_OS_SYMBIAN +#include <unistd.h> // for usleep +#endif + #define RUNNING_TIME 5000 tst_QGLThreads::tst_QGLThreads(QObject *parent) @@ -203,6 +207,7 @@ public: p.drawText(image.rect(), Qt::AlignCenter, "This is an autotest"); p.end(); m_gl->bindTexture(image, GL_TEXTURE_2D, GL_RGBA, QGLContext::InternalBindOption); + createdAndUploaded(image); } } diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index a76c82d..ba24225 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -53,6 +53,7 @@ #include <qscrollbar.h> #include <qprogressbar.h> #include <qtoolbutton.h> +#include <qtoolbar.h> #include <qplastiquestyle.h> #include <qwindowsstyle.h> @@ -146,6 +147,7 @@ private slots: void pixelMetric(); void progressBarChangeStyle(); void defaultFont(); + void testDrawingShortcuts(); private: void lineUpLayoutTest(QStyle *); QWidget *testWidget; @@ -781,5 +783,54 @@ void tst_QStyle::defaultFont() qApp->setFont(defaultFont); } +class DrawTextStyle : public QProxyStyle +{ + Q_OBJECT +public: + DrawTextStyle(QStyle *base = 0) : QProxyStyle(), alignment(0) { setBaseStyle(base); } + void drawItemText(QPainter *painter, const QRect &rect, + int flags, const QPalette &pal, bool enabled, + const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const + { + DrawTextStyle *that = (DrawTextStyle *)this; + that->alignment = flags; + QProxyStyle::drawItemText(painter, rect, flags, pal, enabled, text, textRole); + } + int alignment; +}; + +void tst_QStyle::testDrawingShortcuts() +{ + { + QWidget w; + QToolButton *tb = new QToolButton(&w); + tb->setText("&abc"); + DrawTextStyle *dts = new DrawTextStyle; + w.show(); + tb->setStyle(dts); + QPixmap::grabWidget(tb); + QStyleOptionToolButton sotb; + sotb.initFrom(tb); + bool showMnemonic = dts->styleHint(QStyle::SH_UnderlineShortcut, &sotb, tb); + QVERIFY(dts->alignment & (showMnemonic ? Qt::TextShowMnemonic : Qt::TextHideMnemonic)); + delete dts; + } + { + QToolBar w; + QToolButton *tb = new QToolButton(&w); + tb->setText("&abc"); + DrawTextStyle *dts = new DrawTextStyle; + w.addWidget(tb); + w.show(); + tb->setStyle(dts); + QPixmap::grabWidget(tb); + QStyleOptionToolButton sotb; + sotb.initFrom(tb); + bool showMnemonic = dts->styleHint(QStyle::SH_UnderlineShortcut, &sotb, tb); + QVERIFY(dts->alignment & (showMnemonic ? Qt::TextShowMnemonic : Qt::TextHideMnemonic)); + delete dts; + } +} + QTEST_MAIN(tst_QStyle) #include "tst_qstyle.moc" diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp index b2151b9..ab2a32d 100644 --- a/tests/auto/qtcpserver/tst_qtcpserver.cpp +++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp @@ -105,6 +105,8 @@ private slots: void invalidProxy(); void proxyFactory_data(); void proxyFactory(); + + void qtbug14268_peek(); }; // Testing get/set functions @@ -662,5 +664,56 @@ void tst_QTcpServer::proxyFactory() QTEST(int(server.serverError()), "expectedError"); } +class Qtbug14268Helper : public QObject +{ + Q_OBJECT +public: + QByteArray lastDataPeeked; +public slots: + void newConnection() { + QTcpServer* server=static_cast<QTcpServer*>(sender()); + QTcpSocket* s=server->nextPendingConnection(); + connect(s,SIGNAL(readyRead()),this,SLOT(onServerReadyRead())); + } + void onServerReadyRead() { + QTcpSocket* clientSocket=static_cast<QTcpSocket*>(sender()); + lastDataPeeked = clientSocket->peek(128*1024).toHex(); + QTestEventLoop::instance().exitLoop(); + } +}; + +// there is a similar test inside tst_qtcpsocket that uses the waitFor* functions instead +void tst_QTcpServer::qtbug14268_peek() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QTcpServer server; + server.listen(); + + Qtbug14268Helper helper; + QObject::connect(&server, SIGNAL(newConnection()), &helper, SLOT(newConnection())); + + QTcpSocket client; + client.connectToHost(QHostAddress::LocalHost, server.serverPort()); + QVERIFY(client.waitForConnected(2000)); + + client.write("abc\n"); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(helper.lastDataPeeked == QByteArray("6162630a")); + + client.write("def\n"); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a")); + + client.write("ghi\n"); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(helper.lastDataPeeked == QByteArray("6162630a6465660a6768690a")); +} + QTEST_MAIN(tst_QTcpServer) #include "tst_qtcpserver.moc" diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 31cae40..2dbe5b7 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -201,6 +201,9 @@ private slots: void proxyFactory_data(); void proxyFactory(); + void qtbug14268_peek(); + + protected slots: void nonBlockingIMAP_hostFound(); void nonBlockingIMAP_connected(); @@ -251,6 +254,41 @@ enum ProxyTests { int tst_QTcpSocket::loopLevel = 0; +class SocketPair: public QObject +{ + Q_OBJECT +public: + QTcpSocket *endPoints[2]; + + SocketPair(QObject *parent = 0) + : QObject(parent) + { + endPoints[0] = endPoints[1] = 0; + } + + bool create() + { + QTcpServer server; + server.listen(); + + QTcpSocket *active = new QTcpSocket(this); + active->connectToHost("127.0.0.1", server.serverPort()); + + if (!active->waitForConnected(1000)) + return false; + + if (!server.waitForNewConnection(1000)) + return false; + + QTcpSocket *passive = server.nextPendingConnection(); + passive->setParent(this); + + endPoints[0] = active; + endPoints[1] = passive; + return true; + } +}; + tst_QTcpSocket::tst_QTcpSocket() { Q_SET_DEFAULT_IAP @@ -2467,6 +2505,40 @@ void tst_QTcpSocket::proxyFactory() delete socket; } +// there is a similar test inside tst_qtcpserver that uses the event loop instead +void tst_QTcpSocket::qtbug14268_peek() +{ + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + SocketPair socketPair; + QVERIFY(socketPair.create()); + QTcpSocket *outgoing = socketPair.endPoints[0]; + QTcpSocket *incoming = socketPair.endPoints[1]; + + QVERIFY(incoming->state() == QTcpSocket::ConnectedState); + QVERIFY(outgoing->state() == QTcpSocket::ConnectedState); + + outgoing->write("abc\n"); + QVERIFY(outgoing->waitForBytesWritten(2000)); + QVERIFY(incoming->waitForReadyRead(2000)); + QVERIFY(incoming->peek(128*1024) == QByteArray("abc\n")); + + outgoing->write("def\n"); + QVERIFY(outgoing->waitForBytesWritten(2000)); + QVERIFY(incoming->waitForReadyRead(2000)); + QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\n")); + + outgoing->write("ghi\n"); + QVERIFY(outgoing->waitForBytesWritten(2000)); + QVERIFY(incoming->waitForReadyRead(2000)); + QVERIFY(incoming->peek(128*1024) == QByteArray("abc\ndef\nghi\n")); + + QVERIFY(incoming->read(128*1024) == QByteArray("abc\ndef\nghi\n")); +} + + QTEST_MAIN(tst_QTcpSocket) #include "tst_qtcpsocket.moc" diff --git a/tests/auto/qthreadstorage/crashOnExit.cpp b/tests/auto/qthreadstorage/crashOnExit.cpp new file mode 100644 index 0000000..96515a0 --- /dev/null +++ b/tests/auto/qthreadstorage/crashOnExit.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QtCore> + +class Class +{ +public: + ~Class() + { + // trigger creation of a new QThreadStorage, after the previous QThreadStorage from main() was destructed + static QThreadStorage<int *> threadstorage; + threadstorage.setLocalData(new int); + threadstorage.setLocalData(new int); + } +}; + +int main() +{ + // instantiate the class that will use QThreadStorage from its destructor, it's destructor will be run last + static Class instance; + // instantiate QThreadStorage, it's destructor (and the global destructors for QThreadStorages internals) will run first + static QThreadStorage<int *> threadstorage; + threadstorage.setLocalData(new int); + threadstorage.setLocalData(new int); +} diff --git a/tests/auto/qthreadstorage/crashOnExit.pro b/tests/auto/qthreadstorage/crashOnExit.pro new file mode 100644 index 0000000..918ef39 --- /dev/null +++ b/tests/auto/qthreadstorage/crashOnExit.pro @@ -0,0 +1,4 @@ +SOURCES += crashOnExit.cpp +QT = core +CONFIG-=app_bundle +CONFIG+=console diff --git a/tests/auto/qthreadstorage/qthreadstorage.pro b/tests/auto/qthreadstorage/qthreadstorage.pro index 3071098..a06f89c 100644 --- a/tests/auto/qthreadstorage/qthreadstorage.pro +++ b/tests/auto/qthreadstorage/qthreadstorage.pro @@ -1,4 +1,4 @@ -load(qttest_p4) -SOURCES += tst_qthreadstorage.cpp -QT = core -symbian:LIBS += -llibpthread +TEMPLATE = subdirs +SUBDIRS = \ + tst_qthreadstorage.pro \ + crashOnExit.pro diff --git a/tests/auto/qthreadstorage/tst_qthreadstorage.cpp b/tests/auto/qthreadstorage/tst_qthreadstorage.cpp index d8b404f..ed86165 100644 --- a/tests/auto/qthreadstorage/tst_qthreadstorage.cpp +++ b/tests/auto/qthreadstorage/tst_qthreadstorage.cpp @@ -76,6 +76,7 @@ private slots: void autoDelete(); void adoptedThreads(); void ensureCleanupOrder(); + void QTBUG13877_crashOnExit(); }; class Pointer @@ -293,5 +294,21 @@ void tst_QThreadStorage::ensureCleanupOrder() QVERIFY(First::order < Second::order); } +void tst_QThreadStorage::QTBUG13877_crashOnExit() +{ + QProcess process; +#ifdef Q_OS_WIN +# ifdef QT_NO_DEBUG + process.start("release/crashOnExit"); +# else + process.start("debug/crashOnExit"); +# endif +#else + process.start("./crashOnExit"); +#endif + QVERIFY(process.waitForFinished()); + QVERIFY(process.exitStatus() != QProcess::CrashExit); +} + QTEST_MAIN(tst_QThreadStorage) #include "tst_qthreadstorage.moc" diff --git a/tests/auto/qthreadstorage/tst_qthreadstorage.pro b/tests/auto/qthreadstorage/tst_qthreadstorage.pro new file mode 100644 index 0000000..3071098 --- /dev/null +++ b/tests/auto/qthreadstorage/tst_qthreadstorage.pro @@ -0,0 +1,4 @@ +load(qttest_p4) +SOURCES += tst_qthreadstorage.cpp +QT = core +symbian:LIBS += -llibpthread diff --git a/tests/benchmarks/corelib/corelib.pro b/tests/benchmarks/corelib/corelib.pro index 7669e0a..8a6941b 100644 --- a/tests/benchmarks/corelib/corelib.pro +++ b/tests/benchmarks/corelib/corelib.pro @@ -4,4 +4,5 @@ SUBDIRS = \ kernel \ thread \ tools \ - codecs + codecs \ + plugin diff --git a/tests/benchmarks/corelib/plugin/plugin.pro b/tests/benchmarks/corelib/plugin/plugin.pro new file mode 100644 index 0000000..2afd7f3 --- /dev/null +++ b/tests/benchmarks/corelib/plugin/plugin.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = quuid diff --git a/tests/benchmarks/corelib/plugin/quuid/quuid.pro b/tests/benchmarks/corelib/plugin/quuid/quuid.pro new file mode 100644 index 0000000..4e502fc --- /dev/null +++ b/tests/benchmarks/corelib/plugin/quuid/quuid.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_quuid + +SOURCES += tst_quuid.cpp +QT -= gui diff --git a/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp new file mode 100644 index 0000000..e9d4b44 --- /dev/null +++ b/tests/benchmarks/corelib/plugin/quuid/tst_quuid.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** 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. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QCoreApplication> +#include <QtCore/QUuid> +#include <QtTest/QtTest> + +class tst_bench_QUuid : public QObject +{ + Q_OBJECT + +public: + tst_bench_QUuid() + { } + +private slots: + void createUuid(); +}; + +void tst_bench_QUuid::createUuid() +{ + QBENCHMARK { + QUuid::createUuid(); + } +} + +QTEST_MAIN(tst_bench_QUuid); +#include "tst_quuid.moc" |