diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-06-09 00:34:04 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-06-09 00:34:04 (GMT) |
commit | b8c8c87587bcc0312f0efbb2028885adb8419fee (patch) | |
tree | 4857b4ff79acb48953c9a2a7c3a62c6dfeafdda3 /tests | |
parent | 9410eb0630e0f3b80ffd335002efbd7ce532e826 (diff) | |
parent | 70283a0a87e46a8aa9d2e6296f4ed7c93cc230d6 (diff) | |
download | Qt-b8c8c87587bcc0312f0efbb2028885adb8419fee.zip Qt-b8c8c87587bcc0312f0efbb2028885adb8419fee.tar.gz Qt-b8c8c87587bcc0312f0efbb2028885adb8419fee.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-declarativeui
Conflicts:
configure.exe
tools/qdoc3/htmlgenerator.cpp
tools/qdoc3/tree.cpp
Diffstat (limited to 'tests')
27 files changed, 546 insertions, 39 deletions
diff --git a/tests/auto/_networkselftest/tst_networkselftest.cpp b/tests/auto/_networkselftest/tst_networkselftest.cpp index dab4433..eac603f 100644 --- a/tests/auto/_networkselftest/tst_networkselftest.cpp +++ b/tests/auto/_networkselftest/tst_networkselftest.cpp @@ -190,12 +190,6 @@ static void netChat(int port, const QList<Chat> &chat) // now start the chat QList<Chat>::ConstIterator it = chat.constBegin(); for (int i = 1; it != chat.constEnd(); ++it, ++i) { - if (it->type != Chat::Reconnect - && socket.state() != QAbstractSocket::ConnectedState - && socket.state() != QAbstractSocket::ClosingState) - QFAIL(QString("Internal error: socket is in invalid state %1 in step %2") - .arg(socket.state()).arg(i).toLocal8Bit()); - switch (it->type) { case Chat::Expect: { qDebug() << i << "Expecting" << prettyByteArray(it->data); @@ -463,7 +457,7 @@ void tst_NetworkSelfTest::httpsServer() << Chat::expect("200 ") << Chat::DiscardUntilDisconnect); #else - QSKIP("SSL not enabled, cannot test"); + QSKIP("SSL not enabled, cannot test", SkipAll); #endif } diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp index 607d655..7e32deb 100644 --- a/tests/auto/headers/tst_headers.cpp +++ b/tests/auto/headers/tst_headers.cpp @@ -135,6 +135,9 @@ void tst_Headers::licenseCheck() QByteArray data = f.readAll(); QStringList content = QString::fromLocal8Bit(data.replace('\r',"")).split("\n"); + if (content.first().contains("generated")) + content.takeFirst(); + QVERIFY(licensePattern.exactMatch(content.at(7)) || licensePattern.exactMatch(content.at(4))); QString licenseType = licensePattern.cap(1); diff --git a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp index ad1a1b8..58bfabc 100644 --- a/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp +++ b/tests/auto/qdbusmarshall/tst_qdbusmarshall.cpp @@ -84,6 +84,8 @@ private slots: void sendArgument_data(); void sendArgument(); + void sendErrors(); + private: QProcess proc; }; @@ -782,5 +784,28 @@ void tst_QDBusMarshall::sendArgument() QCOMPARE(extracted, value); } +void tst_QDBusMarshall::sendErrors() +{ + QDBusConnection con = QDBusConnection::sessionBus(); + + QVERIFY(con.isConnected()); + QDBusMessage msg = QDBusMessage::createSignal("/foo", "local.interfaceName", + "signalName"); + msg << qVariantFromValue(QDBusObjectPath()); + + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\""); + QVERIFY(!con.send(msg)); + + msg.setArguments(QVariantList()); + QDBusObjectPath path; + + QTest::ignoreMessage(QtWarningMsg, "QDBusObjectPath: invalid path \"abc\""); + path.setPath("abc"); + msg << qVariantFromValue(path); + + QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: error: could not send signal path \"/foo\" interface \"local.interfaceName\" member \"signalName\""); + QVERIFY(!con.send(msg)); +} + QTEST_MAIN(tst_QDBusMarshall) #include "tst_qdbusmarshall.moc" diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index f70db14..8338ffa 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -52,6 +52,7 @@ #include <math.h> #include <QtGui/QScrollBar> #include <QtGui/QDialog> +#include <QtGui/QStyledItemDelegate> #if defined(Q_OS_WIN) || defined(Q_OS_WINCE) #include <windows.h> #endif @@ -107,6 +108,7 @@ private slots: void task248430_crashWith0SizedItem(); void task250446_scrollChanged(); void task196118_visualRegionForSelection(); + void task254449_draggingItemToNegativeCoordinates(); void keyboardSearch(); }; @@ -1580,6 +1582,55 @@ void tst_QListView::task196118_visualRegionForSelection() QVERIFY(view.visualRegionForSelection().isEmpty()); } +void tst_QListView::task254449_draggingItemToNegativeCoordinates() +{ + //we'll check that the items are painted correctly + class MyListView : public QListView + { + public: + void setPositionForIndex(const QPoint &position, const QModelIndex &index) + { QListView::setPositionForIndex(position, index); } + + } list; + + QStandardItemModel model(1,1); + QModelIndex index = model.index(0,0); + model.setData(index, QLatin1String("foo")); + list.setModel(&model); + list.setViewMode(QListView::IconMode); + list.show(); + QTest::qWait(200); //makes sure the layout is done + + const QPoint topLeft(-6, 0); + + + list.setPositionForIndex(topLeft, index); + + class MyItemDelegate : public QStyledItemDelegate + { + public: + MyItemDelegate() : numPaints(0) { } + void paint(QPainter *painter, + const QStyleOptionViewItem &option, const QModelIndex &index) const + { + numPaints++; + QStyledItemDelegate::paint(painter, option, index); + } + + mutable int numPaints; + } delegate; + + list.setItemDelegate(&delegate); + + //we'll make sure the item is repainted + delegate.numPaints = 0; + list.viewport()->repaint(); + + QCOMPARE(list.visualRect(index).topLeft(), topLeft); + QCOMPARE(delegate.numPaints, 1); +} + + void tst_QListView::keyboardSearch() { QStringList items; diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 785eab0..ac26075 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -115,8 +115,6 @@ tst_QLocalSocket::tst_QLocalSocket() #endif )) qWarning() << "lackey executable doesn't exists!"; - - QLocalServer::removeServer("tst_localsocket"); } tst_QLocalSocket::~tst_QLocalSocket() @@ -141,7 +139,13 @@ public: LocalServer() : QLocalServer() { connect(this, SIGNAL(newConnection()), this, SLOT(slotNewConnection())); - }; + } + + bool listen(const QString &name) + { + removeServer(name); + return QLocalServer::listen(name); + } QList<int> hits; @@ -530,7 +534,7 @@ void tst_QLocalSocket::sendData() // QLocalSocket/Server can take a name or path, check that it works as expected void tst_QLocalSocket::fullPath() { - QLocalServer server; + LocalServer server; QString name = "qlocalsocket_pathtest"; #if defined(QT_LOCALSOCKET_TCP) QString path = "QLocalServer"; @@ -824,7 +828,7 @@ void tst_QLocalSocket::removeServer() void tst_QLocalSocket::recycleServer() { - QLocalServer server; + LocalServer server; QLocalSocket client; QVERIFY(server.listen("recycletest1")); diff --git a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp index 2383767..2f6180f 100644 --- a/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp +++ b/tests/auto/qnetworkdiskcache/tst_qnetworkdiskcache.cpp @@ -76,7 +76,7 @@ private slots: void oldCacheVersionFile_data(); void oldCacheVersionFile(); - + void sync(); }; @@ -486,7 +486,7 @@ public: void run() { QByteArray longString = "Hello World, this is some long string, well not really that long"; - for (int i = 0; i < 10; ++i) + for (int j = 0; j < 10; ++j) longString += longString; QByteArray longString2 = "Help, I am stuck in an autotest!"; QUrl url(EXAMPLE_URL); diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index b76a4e6..43b4ea9 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -161,6 +161,10 @@ private Q_SLOTS: void putToHttp(); void postToHttp_data(); void postToHttp(); + void deleteFromHttp_data(); + void deleteFromHttp(); + void putGetDeleteGetFromHttp_data(); + void putGetDeleteGetFromHttp(); void ioGetFromData_data(); void ioGetFromData(); @@ -903,6 +907,10 @@ QString tst_QNetworkReply::runSimpleRequest(QNetworkAccessManager::Operation op, reply = manager.post(request, data); break; + case QNetworkAccessManager::DeleteOperation: + reply = manager.deleteResource(request); + break; + default: Q_ASSERT_X(false, "tst_QNetworkReply", "Invalid/unknown operation requested"); } @@ -1478,6 +1486,97 @@ void tst_QNetworkReply::postToHttp() QCOMPARE(uploadedData, md5sum.toHex()); } +void tst_QNetworkReply::deleteFromHttp_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<int>("resultCode"); + QTest::addColumn<QNetworkReply::NetworkError>("error"); + + // for status codes to expect, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html + + QTest::newRow("405-method-not-allowed") << QUrl("http://" + QtNetworkSettings::serverName() + "/index.html") << 405 << QNetworkReply::ContentOperationNotPermittedError; + QTest::newRow("200-ok") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?200-ok") << 200 << QNetworkReply::NoError; + QTest::newRow("202-accepted") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?202-accepted") << 202 << QNetworkReply::NoError; + QTest::newRow("204-no-content") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?204-no-content") << 204 << QNetworkReply::NoError; + QTest::newRow("404-not-found") << QUrl("http://" + QtNetworkSettings::serverName() + "/cgi-bin/http-delete.cgi?404-not-found") << 404 << QNetworkReply::ContentNotFoundError; +} + +void tst_QNetworkReply::deleteFromHttp() +{ + QFETCH(QUrl, url); + QFETCH(int, resultCode); + QFETCH(QNetworkReply::NetworkError, error); + QNetworkRequest request(url); + QNetworkReplyPtr reply; + runSimpleRequest(QNetworkAccessManager::DeleteOperation, request, reply, 0); + QCOMPARE(reply->url(), url); + QCOMPARE(reply->error(), error); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), resultCode); +} + +void tst_QNetworkReply::putGetDeleteGetFromHttp_data() +{ + QTest::addColumn<QUrl>("putUrl"); + QTest::addColumn<int>("putResultCode"); + QTest::addColumn<QNetworkReply::NetworkError>("putError"); + QTest::addColumn<QUrl>("deleteUrl"); + QTest::addColumn<int>("deleteResultCode"); + QTest::addColumn<QNetworkReply::NetworkError>("deleteError"); + QTest::addColumn<QUrl>("get2Url"); + QTest::addColumn<int>("get2ResultCode"); + QTest::addColumn<QNetworkReply::NetworkError>("get2Error"); + + QUrl url("http://" + QtNetworkSettings::serverName()); + url.setPath(QString("/dav/qnetworkaccess-putToHttp-%1-%2") + .arg(QTest::currentDataTag()) + .arg(uniqueExtension)); + + // first use case: put, get (to check it is there), delete, get (to check it is not there anymore) + QTest::newRow("success") << url << 201 << QNetworkReply::NoError << url << 204 << QNetworkReply::NoError << url << 404 << QNetworkReply::ContentNotFoundError; + + QUrl wrongUrl("http://" + QtNetworkSettings::serverName()); + wrongUrl.setPath(QString("/dav/qnetworkaccess-thisURLisNotAvailable")); + + // second use case: put, get (to check it is there), delete wrong URL, get (to check it is still there) + QTest::newRow("delete-error") << url << 201 << QNetworkReply::NoError << wrongUrl << 404 << QNetworkReply::ContentNotFoundError << url << 200 << QNetworkReply::NoError; + +} + +void tst_QNetworkReply::putGetDeleteGetFromHttp() +{ + QFETCH(QUrl, putUrl); + QFETCH(int, putResultCode); + QFETCH(QNetworkReply::NetworkError, putError); + QFETCH(QUrl, deleteUrl); + QFETCH(int, deleteResultCode); + QFETCH(QNetworkReply::NetworkError, deleteError); + QFETCH(QUrl, get2Url); + QFETCH(int, get2ResultCode); + QFETCH(QNetworkReply::NetworkError, get2Error); + + QNetworkRequest putRequest(putUrl); + QNetworkRequest deleteRequest(deleteUrl); + QNetworkRequest get2Request(get2Url); + QNetworkReplyPtr reply; + + RUN_REQUEST(runSimpleRequest(QNetworkAccessManager::PutOperation, putRequest, reply, 0)); + QCOMPARE(reply->error(), putError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), putResultCode); + + runSimpleRequest(QNetworkAccessManager::GetOperation, putRequest, reply, 0); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); + + runSimpleRequest(QNetworkAccessManager::DeleteOperation, deleteRequest, reply, 0); + QCOMPARE(reply->error(), deleteError); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), deleteResultCode); + + runSimpleRequest(QNetworkAccessManager::GetOperation, get2Request, reply, 0); + QCOMPARE(reply->error(), get2Error); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), get2ResultCode); + +} + void tst_QNetworkReply::ioGetFromData_data() { QTest::addColumn<QString>("urlStr"); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 399d021..d76c7d4 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -106,6 +106,7 @@ private slots: void childDeletesItsSibling(); void dynamicProperties(); void floatProperty(); + void qrealProperty(); void property(); void recursiveSignalEmission(); void blockingQueuedConnection(); @@ -1113,6 +1114,7 @@ class PropertyObject : public QObject Q_PROPERTY(QVariant variant READ variant WRITE setVariant) Q_PROPERTY(CustomType* custom READ custom WRITE setCustom) Q_PROPERTY(float myFloat READ myFloat WRITE setMyFloat) + Q_PROPERTY(qreal myQReal READ myQReal WRITE setMyQReal) public: enum Alpha { @@ -1148,6 +1150,9 @@ public: void setMyFloat(float value) { m_float = value; } inline float myFloat() const { return m_float; } + void setMyQReal(qreal value) { m_qreal = value; } + qreal myQReal() const { return m_qreal; } + private: Alpha m_alpha; Priority m_priority; @@ -1156,6 +1161,7 @@ private: QVariant m_variant; CustomType *m_custom; float m_float; + qreal m_qreal; }; Q_DECLARE_METATYPE(PropertyObject::Priority) @@ -2348,6 +2354,27 @@ void tst_QObject::floatProperty() QVERIFY(qVariantValue<float>(v) == 128.0f); } +void tst_QObject::qrealProperty() +{ + PropertyObject obj; + const int idx = obj.metaObject()->indexOfProperty("myQReal"); + QVERIFY(idx > 0); + QMetaProperty prop = obj.metaObject()->property(idx); + QVERIFY(prop.isValid()); + QVERIFY(prop.type() == uint(QMetaType::type("qreal"))); + QVERIFY(!prop.write(&obj, QVariant("Hello"))); + + QVERIFY(prop.write(&obj, qVariantFromValue(128.0f))); + QVariant v = prop.read(&obj); + QCOMPARE(v.userType(), qMetaTypeId<qreal>()); + QVERIFY(qVariantValue<qreal>(v) == 128.0); + + QVERIFY(prop.write(&obj, qVariantFromValue(double(127)))); + v = prop.read(&obj); + QCOMPARE(v.userType(), qMetaTypeId<qreal>()); + QVERIFY(qVariantValue<qreal>(v) == 127.0); +} + class DynamicPropertyObject : public PropertyObject { public: diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index af0f6cf..c0f9935 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -215,6 +215,7 @@ private slots: void imageCoordinateLimit(); void imageBlending_data(); void imageBlending(); + void imageBlending_clipped(); void paintOnNullPixmap(); void checkCompositionMode(); @@ -3793,6 +3794,31 @@ void tst_QPainter::imageBlending() } } +void tst_QPainter::imageBlending_clipped() +{ + QImage src(20, 20, QImage::Format_RGB16); + QPainter p(&src); + p.fillRect(src.rect(), Qt::red); + p.end(); + + QImage dst(40, 20, QImage::Format_RGB16); + p.begin(&dst); + p.fillRect(dst.rect(), Qt::white); + p.end(); + + QImage expected = dst; + + p.begin(&dst); + p.setClipRect(QRect(23, 0, 20, 20)); + + // should be completely clipped + p.drawImage(QRectF(3, 0, 20, 20), src); + p.end(); + + // dst should be left unchanged + QCOMPARE(dst, expected); +} + void tst_QPainter::paintOnNullPixmap() { QPixmap pix(16, 16); diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp index d6379d3..cb037e0 100644 --- a/tests/auto/qprogressbar/tst_qprogressbar.cpp +++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp @@ -63,6 +63,7 @@ private slots: void setValueRepaint(); void sizeHint(); + void task245201_testChangeStyleAndDelete_data(); void task245201_testChangeStyleAndDelete(); }; @@ -224,15 +225,30 @@ void tst_QProgressBar::sizeHint() QCOMPARE(barSize.height(), size.height()); } +void tst_QProgressBar::task245201_testChangeStyleAndDelete_data() +{ + QTest::addColumn<QString>("style1_str"); + QTest::addColumn<QString>("style2_str"); + + QTest::newRow("plastique-windows") << QString::fromLatin1("plastique") << QString::fromLatin1("windows"); + QTest::newRow("mlotif-windows") << QString::fromLatin1("motif") << QString::fromLatin1("windows"); + QTest::newRow("cleanlooks-cde") << QString::fromLatin1("cleanlooks") << QString::fromLatin1("cde"); + QTest::newRow("gtk-plastique") << QString::fromLatin1("gtk") << QString::fromLatin1("plastique"); +} + void tst_QProgressBar::task245201_testChangeStyleAndDelete() { + QFETCH(QString, style1_str); + QFETCH(QString, style2_str); + QProgressBar *bar = new QProgressBar; - QStyle *style = QStyleFactory::create("plastique"); + QStyle *style = QStyleFactory::create(style1_str); bar->setStyle(style); bar->show(); - QStyle *style2 = QStyleFactory::create("windows"); + QStyle *style2 = QStyleFactory::create(style2_str); bar->setStyle(style2); + QTest::qWait(10); delete bar; QTest::qWait(100); //should not crash diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp index 1025d2a..2c47c49 100644 --- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp +++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp @@ -333,6 +333,10 @@ public: { emit mySignalWithDefaultArg(arg); } void emitMySignalWithDefaultArg() { emit mySignalWithDefaultArg(); } + void emitMySignalWithVariantArg(const QVariant &arg) + { emit mySignalWithVariantArg(arg); } + void emitMySignalWithScriptEngineArg(QScriptEngine *arg) + { emit mySignalWithScriptEngineArg(arg); } public Q_SLOTS: void mySlot() @@ -395,6 +399,8 @@ Q_SIGNALS: void myOtherOverloadedSignal(const QString &arg); void myOtherOverloadedSignal(int arg); void mySignalWithDefaultArg(int arg = 123); + void mySignalWithVariantArg(const QVariant &arg); + void mySignalWithScriptEngineArg(QScriptEngine *arg); protected: void connectNotify(const char *signal) { @@ -1553,6 +1559,29 @@ void tst_QScriptExtQObject::connectAndDisconnect() m_myObject->emitMyOtherOverloadedSignal(123); QVERIFY(!m_engine->evaluate("gotSignal").toBoolean()); + // signal with QVariant arg: argument conversion should work + m_myObject->clearConnectedSignal(); + QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.connect(myHandler)").isUndefined()); + QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithVariantArg(QVariant))); + m_engine->evaluate("gotSignal = false"); + m_myObject->emitMySignalWithVariantArg(123); + QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); + QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0); + QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined()); + + // signal with argument type that's unknown to the meta-type system + m_myObject->clearConnectedSignal(); + QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.connect(myHandler)").isUndefined()); + QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithScriptEngineArg(QScriptEngine*))); + m_engine->evaluate("gotSignal = false"); + QTest::ignoreMessage(QtWarningMsg, "QScriptEngine: Unable to handle unregistered datatype 'QScriptEngine*' when invoking handler of signal MyQObject::mySignalWithScriptEngineArg(QScriptEngine*)"); + m_myObject->emitMySignalWithScriptEngineArg(m_engine); + QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); + QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QVERIFY(m_engine->evaluate("signalArgs[0]").isUndefined()); + QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.disconnect(myHandler)").isUndefined()); + // connect(object, function) m_engine->evaluate("otherObject = { name:'foo' }"); QVERIFY(m_engine->evaluate("myObject.mySignal.connect(otherObject, myHandler)").isUndefined()); diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index bf91001..ad1080a 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -1301,6 +1301,27 @@ void tst_QScriptValue::toVariant() QCOMPARE(str.toVariant(), QVariant(QString("ciao"))); QCOMPARE(qscriptvalue_cast<QVariant>(str), QVariant(QString("ciao"))); } + + // array + { + QVariantList listIn; + listIn << 123 << "hello"; + QScriptValue array = qScriptValueFromValue(&eng, listIn); + QVERIFY(array.isArray()); + QCOMPARE(array.property("length").toInt32(), 2); + QVariant ret = array.toVariant(); + QCOMPARE(ret.type(), QVariant::List); + QVariantList listOut = ret.toList(); + QCOMPARE(listOut.size(), listIn.size()); + for (int i = 0; i < listIn.size(); ++i) + QVERIFY(listOut.at(i) == listIn.at(i)); + // round-trip conversion + QScriptValue array2 = qScriptValueFromValue(&eng, ret); + QVERIFY(array2.isArray()); + QCOMPARE(array2.property("length").toInt32(), array.property("length").toInt32()); + for (int i = 0; i < array.property("length").toInt32(); ++i) + QVERIFY(array2.property(i).strictlyEquals(array.property(i))); + } } // unfortunately, this is necessary in order to do qscriptvalue_cast<QPushButton*>(...) diff --git a/tests/auto/qstringbuilder/qstringbuilder.pro b/tests/auto/qstringbuilder/qstringbuilder.pro new file mode 100644 index 0000000..c5a26d3 --- /dev/null +++ b/tests/auto/qstringbuilder/qstringbuilder.pro @@ -0,0 +1,5 @@ + +TEMPLATE = subdirs +SUBDIRS = scenario1.pro scenario2.pro scenario3.pro scenario4.pro + + diff --git a/tests/auto/qstringbuilder/scenario1.cpp b/tests/auto/qstringbuilder/scenario1.cpp new file mode 100644 index 0000000..26b4ed3 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario1.cpp @@ -0,0 +1 @@ +#include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario1.pro b/tests/auto/qstringbuilder/scenario1.pro new file mode 100644 index 0000000..4ce7156 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario1.pro @@ -0,0 +1,8 @@ +load(qttest_p4) + +QT = core + +SOURCES += scenario1.cpp + +DEFINES += SCENARIO=1 + diff --git a/tests/auto/qstringbuilder/scenario2.cpp b/tests/auto/qstringbuilder/scenario2.cpp new file mode 100644 index 0000000..26b4ed3 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario2.cpp @@ -0,0 +1 @@ +#include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario2.pro b/tests/auto/qstringbuilder/scenario2.pro new file mode 100644 index 0000000..64c46e2 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario2.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +QT = core + +SOURCES += scenario2.cpp + +DEFINES += SCENARIO=2 diff --git a/tests/auto/qstringbuilder/scenario3.cpp b/tests/auto/qstringbuilder/scenario3.cpp new file mode 100644 index 0000000..26b4ed3 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario3.cpp @@ -0,0 +1 @@ +#include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario3.pro b/tests/auto/qstringbuilder/scenario3.pro new file mode 100644 index 0000000..beedffd --- /dev/null +++ b/tests/auto/qstringbuilder/scenario3.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +QT = core + +SOURCES += scenario3.cpp + +DEFINES += SCENARIO=3 diff --git a/tests/auto/qstringbuilder/scenario4.cpp b/tests/auto/qstringbuilder/scenario4.cpp new file mode 100644 index 0000000..26b4ed3 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario4.cpp @@ -0,0 +1 @@ +#include "tst_qstringbuilder.cpp" diff --git a/tests/auto/qstringbuilder/scenario4.pro b/tests/auto/qstringbuilder/scenario4.pro new file mode 100644 index 0000000..1c45a70 --- /dev/null +++ b/tests/auto/qstringbuilder/scenario4.pro @@ -0,0 +1,7 @@ +load(qttest_p4) + +QT = core + +SOURCES += scenario4.cpp + +DEFINES += SCENARIO=4 diff --git a/tests/auto/qstringbuilder/tst_qstringbuilder.cpp b/tests/auto/qstringbuilder/tst_qstringbuilder.cpp new file mode 100644 index 0000000..5501204 --- /dev/null +++ b/tests/auto/qstringbuilder/tst_qstringbuilder.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** 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. +** +** $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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// This is included in various .cpp files as a compile test for various scenarios +// depending on NO_CAST_* and QT_USE_FAST_OPERATOR_PLUS and QT_USE_FAST_CONCATENATION + +#if SCENARIO == 1 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII +#endif + + +#if SCENARIO == 2 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * defined +#define P + +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#define QT_NO_CAST_FROM_ASCII +#define QT_NO_CAST_TO_ASCII +#endif + +#if SCENARIO == 3 +// this is the "no harm done" version. Only operator% is active, +// with NO_CAST * _not_ defined +#define P % +#undef QT_USE_FAST_OPERATOR_PLUS +#undef QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII +#endif + +#if SCENARIO == 4 +// this is the "full" version. Operator+ is replaced by a QStringBuilder +// based version +// with NO_CAST * _not_ defined +#define P + +#define QT_USE_FAST_OPERATOR_PLUS +#define QT_USE_FAST_CONCATENATION +#undef QT_NO_CAST_FROM_ASCII +#undef QT_NO_CAST_TO_ASCII +#endif + + +#include <QtTest/QtTest> + +//TESTED_CLASS=QStringBuilder +//TESTED_FILES=qstringbuilder.cpp + +#include <qtest.h> + +#define LITERAL "some literal" + +class tst_QStringBuilder : public QObject +{ + Q_OBJECT + +public: + tst_QStringBuilder() {} + ~tst_QStringBuilder() {} + +public slots: + void init() {} + void cleanup() {} + + void scenario(); +}; + +void tst_QStringBuilder::scenario() +{ + QLatin1Literal l1literal(LITERAL); + QLatin1String l1string(LITERAL); + QString string(l1string); + QStringRef stringref(&string, 2, 10); + QLatin1Char achar('c'); + QString r2(QLatin1String(LITERAL LITERAL)); + QString r; + + r = l1literal P l1literal; + QCOMPARE(r, r2); + r = string P string; + QCOMPARE(r, r2); + r = stringref P stringref; + QCOMPARE(r, QString(stringref.toString() + stringref.toString())); + r = string P l1literal; + QCOMPARE(r, r2); + r = string P l1string; + QCOMPARE(r, r2); + r = string + achar; + QCOMPARE(r, QString(string P achar)); + r = achar + string; + QCOMPARE(r, QString(achar P string)); +#ifndef QT_NO_CAST_FROM_ASCII + r = string P LITERAL; + QCOMPARE(r, r2); + r = LITERAL P string; + QCOMPARE(r, r2); +#endif +} + +QTEST_APPLESS_MAIN(tst_QStringBuilder) + +#include "tst_qstringbuilder.moc" diff --git a/tests/auto/qtextcodec/tst_qtextcodec.cpp b/tests/auto/qtextcodec/tst_qtextcodec.cpp index 22f9557..97c409b 100644 --- a/tests/auto/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/qtextcodec/tst_qtextcodec.cpp @@ -1540,7 +1540,7 @@ void tst_QTextCodec::utfHeaders_data() << QByteArray("\xef\xbb\xbfhello") << (QString(QChar(0xfeff)) + QString::fromLatin1("hello")) << true; - QTest::newRow("utf8 nobom") + QTest::newRow("utf8 nobom ignore header") << QByteArray("UTF-8") << (int)QTextCodec::IgnoreHeader << QByteArray("hello") @@ -1721,14 +1721,23 @@ void tst_QTextCodec::utfHeaders() QFETCH(bool, toUnicode); + QLatin1String ignoreReverseTestOn = (QSysInfo::ByteOrder == QSysInfo::BigEndian) ? QLatin1String(" le") : QLatin1String(" be"); + QString rowName(QTest::currentDataTag()); + for (int i = 0; i < encoded.length(); ++i) qDebug() << hex << " " << (uint)(uchar)encoded.at(i); if (toUnicode) { QString result = codec->toUnicode(encoded.constData(), encoded.length(), &state); - for (int i = 0; i < result.length(); ++i) - qDebug() << hex << " " << (uint)result.at(i).unicode(); + for (int i = 0; i < result.length(); ++i) + qDebug() << hex << " " << (uint)result.at(i).unicode(); QCOMPARE(result.length(), unicode.length()); QCOMPARE(result, unicode); + + if (!rowName.endsWith("nobom") && !rowName.contains(ignoreReverseTestOn)) { + QTextCodec::ConverterState state2(cFlags); + QByteArray reencoded = codec->fromUnicode(unicode.unicode(), unicode.length(), &state2); + QCOMPARE(reencoded, encoded); + } } else { QByteArray result = codec->fromUnicode(unicode.unicode(), unicode.length(), &state); QCOMPARE(result, encoded); diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp index 63a172b..27be372 100644 --- a/tests/auto/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp @@ -163,6 +163,8 @@ private slots: void testUndoBlocks(); + void receiveCursorPositionChangedAfterContentsChange(); + private: void backgroundImage_checkExpectedHtml(const QTextDocument &doc); @@ -2453,5 +2455,35 @@ void tst_QTextDocument::testUndoBlocks() QCOMPARE(doc->toPlainText(), QString("")); } +class Receiver : public QObject +{ + Q_OBJECT + public: + QString first; + public slots: + void cursorPositionChanged() { + if (first.isEmpty()) + first = QLatin1String("cursorPositionChanged"); + } + + void contentsChange() { + if (first.isEmpty()) + first = QLatin1String("contentsChanged"); + } +}; + +void tst_QTextDocument::receiveCursorPositionChangedAfterContentsChange() +{ + QVERIFY(doc); + doc->setDocumentLayout(new MyAbstractTextDocumentLayout(doc)); + Receiver rec; + connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)), + &rec, SLOT(cursorPositionChanged())); + connect(doc, SIGNAL(contentsChange(int,int,int)), + &rec, SLOT(contentsChange())); + cursor.insertText("Hello World"); + QCOMPARE(rec.first, QString("contentsChanged")); +} + QTEST_MAIN(tst_QTextDocument) #include "tst_qtextdocument.moc" diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index 906332c..32a2c40 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -2434,6 +2434,10 @@ void tst_QTreeWidget::itemOperatorLessThan() item1.setText(0, "b"); item2.setText(0, "a"); QCOMPARE(item1 < item2, true); + tw.sortItems(0, Qt::AscendingOrder); + item1.setData(0, Qt::DisplayRole, 11); + item2.setData(0, Qt::DisplayRole, 2); + QCOMPARE(item1 < item2, false); } } diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 3fad366..041aa7a 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -351,7 +351,6 @@ private slots: void toplevelLineEditFocus(); void focusWidget_task254563(); - void focusWidget_mixed_widget_hierarchy(); private: bool ensureScreenSize(int width, int height); @@ -8995,22 +8994,5 @@ void tst_QWidget::focusWidget_task254563() QVERIFY(top.focusWidget() != widget); //dangling pointer } -void tst_QWidget::focusWidget_mixed_widget_hierarchy() -{ - QWidget top; - top.show(); - QWidget notvisible(&top); - QWidget *visible = new QWidget(¬visible); - visible->show(); - - visible->setFocus(); - notvisible.setFocus(); - notvisible.show(); - QCOMPARE(top.focusWidget(), visible); - QCOMPARE(notvisible.focusWidget(), visible); - QCOMPARE(visible->focusWidget(), visible); -} - - QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp b/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp index f3c1134..9dafff5 100644 --- a/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp +++ b/tests/benchmarks/qpixmapcache/tst_qpixmapcache.cpp @@ -156,9 +156,9 @@ struct styleStruct { int height; bool operator==(const styleStruct &str) const { - return str.key == key && str.state == state && str.direction == direction + return str.state == state && str.direction == direction && str.complex == complex && str.palette == palette && str.width == width - && str.height == height; + && str.height == height && str.key == key; } }; |