diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-22 11:48:04 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-22 11:48:12 (GMT) |
commit | 43b2248cc3765848ca3763c36b91ed7290fddfe0 (patch) | |
tree | 200e2c52c8e44d43c80400079bd2b038609d87df /tests | |
parent | 9c136d34c1d15d077ab5103a84dfb2449b796d1f (diff) | |
parent | 9dec5247be84ae4606d5d9baf5b99612c5feba8d (diff) | |
download | Qt-43b2248cc3765848ca3763c36b91ed7290fddfe0.zip Qt-43b2248cc3765848ca3763c36b91ed7290fddfe0.tar.gz Qt-43b2248cc3765848ca3763c36b91ed7290fddfe0.tar.bz2 |
Merge branch 'origin/4.6' into widgets-team/4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/linguist/lrelease/testdata/idbased.ts | 7 | ||||
-rw-r--r-- | tests/auto/qdom/tst_qdom.cpp | 1 | ||||
-rw-r--r-- | tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp | 24 | ||||
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 45 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 15 | ||||
-rw-r--r-- | tests/benchmarks/benchmarks.pro | 4 | ||||
-rw-r--r-- | tests/benchmarks/qnetworkreply/qnetworkreply.pro | 2 | ||||
-rw-r--r-- | tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp (renamed from tests/benchmarks/qnetworkreply/main.cpp) | 40 |
10 files changed, 136 insertions, 5 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 8e3ce81..0f7a7f1 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -127,6 +127,7 @@ SUBDIRS += \ qexplicitlyshareddatapointer \ qfile \ qfiledialog \ + qfiledialog2 \ qfileinfo \ qfilesystemwatcher \ qfilesystemmodel \ diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts index 61497de..c7555c8 100644 --- a/tests/auto/linguist/lrelease/testdata/idbased.ts +++ b/tests/auto/linguist/lrelease/testdata/idbased.ts @@ -9,6 +9,7 @@ </message> <message id="untranslated_id"> <source>This has no translation.</source> + <translation type="unfinished"></translation> </message> <message id="this_another_id"> <source>Foo bar.</source> @@ -17,5 +18,11 @@ <message> <source>Drop me!</source> </message> + <message id="one_id"> + <source></source> + </message> + <message id="two_id"> + <source></source> + </message> </context> </TS> diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 6637202..0d58554e 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -322,6 +322,7 @@ void tst_QDom::toString_01_data() */ void tst_QDom::toString_01() { + QFAIL("make test fail instead of timing out, will be fixed later (QT-2357)"); QFETCH(QString, fileName); QFile f(fileName); diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index b407fef..eb5c099 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -88,7 +88,7 @@ static QTransform transform2D(const QGraphicsTransform& t) { QMatrix4x4 m; t.applyTo(&m); - return m.toTransform(); + return m.toTransform(0); } void tst_QGraphicsTransform::scale() diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 320a429..44adf7e 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -317,6 +317,11 @@ public: Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject() { m_qtFunctionInvoked = 57; return this; } + Q_INVOKABLE QObjectList findObjects() const + { return findChildren<QObject *>(); } + Q_INVOKABLE QList<int> myInvokableNumbers() const + { return QList<int>() << 1 << 2 << 3; } + void emitMySignal() { emit mySignal(); } void emitMySignalWithIntArg(int arg) @@ -493,6 +498,7 @@ protected slots: } private slots: + void registeredTypes(); void getSetStaticProperty(); void getSetDynamicProperty(); void getSetChildren(); @@ -543,6 +549,24 @@ void tst_QScriptExtQObject::cleanup() delete m_myObject; } +// this test has to be first and test that some types are automatically registered +void tst_QScriptExtQObject::registeredTypes() +{ + QScriptEngine e; + QObject *t = new MyQObject; + QObject *c = new QObject(t); + c->setObjectName ("child1"); + + e.globalObject().setProperty("MyTest", e.newQObject(t)); + + QScriptValue v1 = e.evaluate("MyTest.findObjects()[0].objectName;"); + QCOMPARE(v1.toString(), c->objectName()); + + QScriptValue v2 = e.evaluate("MyTest.myInvokableNumbers()"); + QCOMPARE(qscriptvalue_cast<QList<int> >(v2), (QList<int>() << 1 << 2 << 3)); +} + + static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *) { if (ctx->argumentCount() != 0) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 6efe440..d576201 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -182,6 +182,7 @@ private slots: void ignoreSslErrorsListWithSlot_data(); void ignoreSslErrorsListWithSlot(); void readFromClosedSocket(); + void writeBigChunk(); static void exitLoop() { @@ -1698,6 +1699,50 @@ void tst_QSslSocket::readFromClosedSocket() QVERIFY(!socket->bytesToWrite()); } +void tst_QSslSocket::writeBigChunk() +{ + if (!QSslSocket::supportsSsl()) + return; + + QSslSocketPtr socket = newSocket(); + this->socket = socket; + + connect(socket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(ignoreErrorSlot())); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + + QByteArray data; + data.resize(1024*1024*10); // 10 MB + // init with garbage. needed so ssl cannot compress it in an efficient way. + for (int i = 0; i < data.size() / sizeof(int); i++) { + int r = qrand(); + data.data()[i*sizeof(int)] = r; + } + + QVERIFY(socket->waitForEncrypted(10000)); + QString errorBefore = socket->errorString(); + + int ret = socket->write(data.constData(), data.size()); + QVERIFY(data.size() == ret); + + // spin the event loop once so QSslSocket::transmit() gets called + QCoreApplication::processEvents(); + QString errorAfter = socket->errorString(); + + // no better way to do this right now since the error is the same as the default error. + if (socket->errorString().startsWith(QLatin1String("Unable to write data"))) + { + qWarning() << socket->error() << socket->errorString(); + QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!"); + } + // also check the error string. If another error (than UnknownError) occured, it should be different than before + QVERIFY(errorBefore == errorAfter); + + // check that everything has been written to OpenSSL + QVERIFY(socket->bytesToWrite() == 0); + + socket->close(); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a03f112..050d1c5 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -4391,12 +4391,27 @@ void tst_QWidget::winIdChangeEvent() { // Changing parent of a native widget + // Should cause winId of child to change, on all platforms QWidget parent1, parent2; WinIdChangeWidget child(&parent1); const WId winIdBefore = child.winId(); QCOMPARE(child.m_winIdChangeEventCount, 1); child.setParent(&parent2); const WId winIdAfter = child.internalWinId(); + QVERIFY(winIdBefore != winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 2); + } + + { + // Changing grandparent of a native widget + // Should cause winId of grandchild to change only on Symbian + QWidget grandparent1, grandparent2; + QWidget parent(&grandparent1); + WinIdChangeWidget child(&parent); + const WId winIdBefore = child.winId(); + QCOMPARE(child.m_winIdChangeEventCount, 1); + parent.setParent(&grandparent2); + const WId winIdAfter = child.internalWinId(); #ifdef Q_OS_SYMBIAN QVERIFY(winIdBefore != winIdAfter); QCOMPARE(child.m_winIdChangeEventCount, 2); diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index ad1920b..a63fb41 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -9,8 +9,8 @@ SUBDIRS = containers-associative \ qiodevice \ qpixmap \ blendbench \ - qstring \ - qstringlist \ + qstring \ + qstringlist \ qmatrix4x4 \ qnetworkreply \ qobject \ diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro index 060acf5..1e67d81 100644 --- a/tests/benchmarks/qnetworkreply/qnetworkreply.pro +++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro @@ -10,4 +10,4 @@ QT += network CONFIG += release # Input -SOURCES += main.cpp +SOURCES += tst_qnetworkreply.cpp diff --git a/tests/benchmarks/qnetworkreply/main.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 666e4f1..993db52 100644 --- a/tests/benchmarks/qnetworkreply/main.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -54,6 +54,10 @@ class tst_qnetworkreply : public QObject private slots: void httpLatency(); +#ifndef QT_NO_OPENSSL + void echoPerformance_data(); + void echoPerformance(); +#endif }; void tst_qnetworkreply::httpLatency() @@ -69,6 +73,40 @@ void tst_qnetworkreply::httpLatency() } } +#ifndef QT_NO_OPENSSL +void tst_qnetworkreply::echoPerformance_data() +{ + QTest::addColumn<bool>("ssl"); + QTest::newRow("no_ssl") << false; + QTest::newRow("ssl") << true; +} + +void tst_qnetworkreply::echoPerformance() +{ + QFETCH(bool, ssl); + QNetworkAccessManager manager; + QNetworkRequest request(QUrl((ssl ? "https://" : "http://") + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi")); + + QByteArray data; + data.resize(1024*1024*10); // 10 MB + // init with garbage. needed so ssl cannot compress it in an efficient way. + for (int i = 0; i < data.size() / sizeof(int); i++) { + int r = qrand(); + data.data()[i*sizeof(int)] = r; + } + + QBENCHMARK{ + QNetworkReply* reply = manager.post(request, data); + connect(reply, SIGNAL(sslErrors( const QList<QSslError> &)), reply, SLOT(ignoreSslErrors())); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(reply->error() == QNetworkReply::NoError); + delete reply; + } +} +#endif + QTEST_MAIN(tst_qnetworkreply) -#include "main.moc" +#include "tst_qnetworkreply.moc" |