diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qcombobox/tst_qcombobox.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qobjectrace/tst_qobjectrace.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp | 11 | ||||
-rw-r--r-- | tests/auto/qsslsocket/qsslsocket.pro | 6 | ||||
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 30 | ||||
-rw-r--r-- | tests/auto/utf8/tst_utf8.cpp | 2 |
7 files changed, 79 insertions, 27 deletions
diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 6a87e3c..2fff6d0 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -76,6 +76,7 @@ #endif #include <qabstractitemview.h> #include "../../shared/util.h" +#include <qstyleditemdelegate.h> //TESTED_CLASS= //TESTED_FILES= @@ -141,6 +142,8 @@ private slots: void setModelColumn(); void noScrollbar_data(); void noScrollbar(); + void setItemDelegate(); + void task253944_itemDelegateIsReset(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2206,5 +2209,26 @@ void tst_QComboBox::noScrollbar() } } +void tst_QComboBox::setItemDelegate() +{ + QComboBox comboBox; + QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; + comboBox.setItemDelegate(itemDelegate); + QCOMPARE(comboBox.itemDelegate(), itemDelegate); +} + +void tst_QComboBox::task253944_itemDelegateIsReset() +{ + QComboBox comboBox; + QStyledItemDelegate *itemDelegate = new QStyledItemDelegate; + comboBox.setItemDelegate(itemDelegate); + + comboBox.setEditable(true); + QCOMPARE(comboBox.itemDelegate(), itemDelegate); + + comboBox.setStyleSheet("QComboBox { border: 1px solid gray; }"); + QCOMPARE(comboBox.itemDelegate(), itemDelegate); +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index b22397f..eb30147 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -42,6 +42,7 @@ #include <QtTest/QtTest> #include "private/qhttpnetworkconnection_p.h" +#include "private/qnoncontiguousbytedevice_p.h" #include <QAuthenticator> #include "../network-settings.h" @@ -303,8 +304,8 @@ void tst_QHttpNetworkConnection::put() QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Put); QByteArray array = data.toLatin1(); - QBuffer buffer(&array); - request.setData(&buffer); + QNonContiguousByteDevice *bd = QNonContiguousByteDeviceFactory::create(&array); + request.setUploadByteDevice(bd); finishedCalled = false; finishedWithErrorCalled = false; @@ -393,8 +394,8 @@ void tst_QHttpNetworkConnection::post() QHttpNetworkRequest request(protocol + host + path, QHttpNetworkRequest::Post); QByteArray array = data.toLatin1(); - QBuffer buffer(&array); - request.setData(&buffer); + QNonContiguousByteDevice *bd = QNonContiguousByteDeviceFactory::create(&array); + request.setUploadByteDevice(bd); QHttpNetworkReply *reply = connection.sendRequest(request); diff --git a/tests/auto/qobjectrace/tst_qobjectrace.cpp b/tests/auto/qobjectrace/tst_qobjectrace.cpp index fcfd528..aa80534 100644 --- a/tests/auto/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/qobjectrace/tst_qobjectrace.cpp @@ -43,6 +43,7 @@ #include <QtCore> #include <QtTest/QtTest> + enum { OneMinute = 60 * 1000, TwoMinutes = OneMinute * 2 }; class tst_QObjectRace: public QObject @@ -70,12 +71,18 @@ public: public slots: void theSlot() { - enum { step = 1000 }; + enum { step = 35 }; if ((++count % step) == 0) { QThread *nextThread = threads.at((count / step) % threads.size()); moveToThread(nextThread); } } + + void destroSlot() { + emit theSignal(); + } +signals: + void theSignal(); }; class RaceThread : public QThread @@ -120,6 +127,10 @@ private slots: if (stopWatch.elapsed() >= OneMinute / 2) #endif quit(); + + QObject o; + connect(&o, SIGNAL(destroyed()) , object, SLOT(destroSlot())); + connect(object, SIGNAL(destroyed()) , &o, SLOT(deleteLater())); } }; @@ -138,10 +149,17 @@ void tst_QObjectRace::moveToThreadRace() for (int i = 0; i < ThreadCount; ++i) threads[i]->start(); - QVERIFY(threads[0]->wait(TwoMinutes)); + + while(!threads[0]->isFinished()) { + QPointer<RaceObject> foo (object); + QObject o; + connect(&o, SIGNAL(destroyed()) , object, SLOT(destroSlot())); + connect(object, SIGNAL(destroyed()) , &o, SLOT(deleteLater())); + QTest::qWait(10); + } // the other threads should finish pretty quickly now for (int i = 1; i < ThreadCount; ++i) - QVERIFY(threads[i]->wait(30000)); + QVERIFY(threads[i]->wait(300)); for (int i = 0; i < ThreadCount; ++i) delete threads[i]; diff --git a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp index f501e78..5ab5064 100644 --- a/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp +++ b/tests/auto/qsocks5socketengine/tst_qsocks5socketengine.cpp @@ -795,14 +795,14 @@ void tst_QSocks5SocketEngine::downloadBigFile() if (QTestEventLoop::instance().timeout()) QFAIL("Network operation timed out"); - QCOMPARE(bytesAvailable, qint64(10000309)); + QCOMPARE(bytesAvailable, qint64(10000000)); QVERIFY(tmpSocket->state() == QAbstractSocket::ConnectedState); - qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s", + /*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s", bytesAvailable / (1024.0 * 1024.0), stopWatch.elapsed() / 1024.0, - (bytesAvailable / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024)); + (bytesAvailable / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));*/ delete tmpSocket; tmpSocket = 0; @@ -816,7 +816,10 @@ void tst_QSocks5SocketEngine::exitLoopSlot() void tst_QSocks5SocketEngine::downloadBigFileSlot() { - bytesAvailable += tmpSocket->readAll().size(); + QByteArray tmp=tmpSocket->readAll(); + int correction=tmp.indexOf((char)0,0); //skip header + if (correction==-1) correction=0; + bytesAvailable += (tmp.size()-correction); if (bytesAvailable >= 10000000) QTestEventLoop::instance().exitLoop(); } diff --git a/tests/auto/qsslsocket/qsslsocket.pro b/tests/auto/qsslsocket/qsslsocket.pro index 147b40d..c29fc68 100644 --- a/tests/auto/qsslsocket/qsslsocket.pro +++ b/tests/auto/qsslsocket/qsslsocket.pro @@ -7,6 +7,12 @@ QT -= gui TARGET = tst_qsslsocket +!wince* { +DEFINES += SRCDIR=\\\"$$PWD/\\\" +} else { +DEFINES += SRCDIR=\\\"./\\\" +} + win32 { CONFIG(debug, debug|release) { DESTDIR = debug diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index d87ab7b..40840bd 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -578,7 +578,7 @@ void tst_QSslSocket::connectToHostEncrypted() QSslSocketPtr socket = newSocket(); this->socket = socket; - socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + QVERIFY(socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem"))); #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(untrustedWorkaroundSlot(QList<QSslError>))); @@ -675,7 +675,7 @@ void tst_QSslSocket::peerCertificateChain() QSslSocketPtr socket = newSocket(); this->socket = socket; - QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String("certs/qt-test-server-cacert.pem")); + QList<QSslCertificate> caCertificates = QSslCertificate::fromPath(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); QVERIFY(caCertificates.count() == 1); socket->addCaCertificates(caCertificates); @@ -736,7 +736,7 @@ void tst_QSslSocket::protocol() QSslSocketPtr socket = newSocket(); this->socket = socket; - QList<QSslCertificate> certs = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> certs = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"); // qDebug() << "certs:" << certs.at(0).issuerInfo(QSslCertificate::CommonName); socket->setCaCertificates(certs); @@ -819,7 +819,7 @@ void tst_QSslSocket::setCaCertificates() QSslSocket socket; QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates()); - socket.setCaCertificates(QSslCertificate::fromPath("certs/qt-test-server-cacert.pem")); + socket.setCaCertificates(QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem")); QCOMPARE(socket.caCertificates().size(), 1); socket.setCaCertificates(socket.defaultCaCertificates()); QCOMPARE(socket.caCertificates(), QSslSocket::defaultCaCertificates()); @@ -850,13 +850,13 @@ protected: socket = new QSslSocket(this); connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); - QFile file("certs/fluke.key"); + QFile file(SRCDIR "certs/fluke.key"); QVERIFY(file.open(QIODevice::ReadOnly)); QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); QVERIFY(!key.isNull()); socket->setPrivateKey(key); - QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -957,7 +957,7 @@ void tst_QSslSocket::addDefaultCaCertificate() // Reset the global CA chain QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates()); - QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath("certs/qt-test-server-cacert.pem"); + QList<QSslCertificate> flukeCerts = QSslCertificate::fromPath(SRCDIR "certs/qt-test-server-cacert.pem"); QCOMPARE(flukeCerts.size(), 1); QList<QSslCertificate> globalCerts = QSslSocket::defaultCaCertificates(); QVERIFY(!globalCerts.contains(flukeCerts.first())); @@ -1041,7 +1041,7 @@ void tst_QSslSocket::wildcard() // responds with the wildcard, and QSslSocket should accept that as a // valid connection. This was broken in 4.3.0. QSslSocketPtr socket = newSocket(); - socket->addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + socket->addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); this->socket = socket; #ifdef QSSLSOCKET_CERTUNTRUSTED_WORKAROUND connect(socket, SIGNAL(sslErrors(QList<QSslError>)), @@ -1067,7 +1067,7 @@ protected: socket->ignoreSslErrors(); // Only set the certificate - QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -1226,13 +1226,13 @@ protected: socket = new QSslSocket(this); connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); - QFile file("certs/fluke.key"); + QFile file(SRCDIR "certs/fluke.key"); QVERIFY(file.open(QIODevice::ReadOnly)); QSslKey key(file.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey); QVERIFY(!key.isNull()); socket->setPrivateKey(key); - QList<QSslCertificate> localCert = QSslCertificate::fromPath("certs/fluke.cert"); + QList<QSslCertificate> localCert = QSslCertificate::fromPath(SRCDIR "certs/fluke.cert"); QVERIFY(!localCert.isEmpty()); QVERIFY(localCert.first().handle()); socket->setLocalCertificate(localCert.first()); @@ -1392,8 +1392,8 @@ protected: { socket = new QSslSocket(this); - socket->setPrivateKey("certs/fluke.key"); - socket->setLocalCertificate("certs/fluke.cert"); + socket->setPrivateKey(SRCDIR "certs/fluke.key"); + socket->setLocalCertificate(SRCDIR "certs/fluke.cert"); socket->setSocketDescriptor(socketDescriptor); socket->startServerEncryption(); } @@ -1516,7 +1516,7 @@ void tst_QSslSocket::resetProxy() // make sure the connection works, and then set a nonsense proxy, and then // make sure it does not work anymore QSslSocket socket; - socket.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + socket.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); socket.setProxy(goodProxy); socket.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY2(socket.waitForConnected(10000), qPrintable(socket.errorString())); @@ -1529,7 +1529,7 @@ void tst_QSslSocket::resetProxy() // set the nonsense proxy and make sure the connection does not work, // and then set the right proxy and make sure it works QSslSocket socket2; - socket2.addCaCertificates(QLatin1String("certs/qt-test-server-cacert.pem")); + socket2.addCaCertificates(QLatin1String(SRCDIR "certs/qt-test-server-cacert.pem")); socket2.setProxy(badProxy); socket2.connectToHostEncrypted(QtNetworkSettings::serverName(), 443); QVERIFY(! socket2.waitForConnected(10000)); diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp index 3aef69f..e21e5a3 100644 --- a/tests/auto/utf8/tst_utf8.cpp +++ b/tests/auto/utf8/tst_utf8.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. |