diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-28 09:03:39 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-10-28 09:03:39 (GMT) |
commit | 5f444e7a1dd7f22b5546f5225e12355ec5cc4d57 (patch) | |
tree | e90e3d59dfccc347691c7a62aa69fa01b1a94743 /tests/auto | |
parent | a8b5aefc48d619c1fc0ff1e97c8e3a42baccb7c0 (diff) | |
parent | 1583d643285641bf71e6a107331d788acca9850c (diff) | |
download | Qt-5f444e7a1dd7f22b5546f5225e12355ec5cc4d57.zip Qt-5f444e7a1dd7f22b5546f5225e12355ec5cc4d57.tar.gz Qt-5f444e7a1dd7f22b5546f5225e12355ec5cc4d57.tar.bz2 |
Merge remote branch 'origin/4.6' into core-4.6
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/networkselftest/tst_networkselftest.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qabstractslider/tst_qabstractslider.cpp | 16 | ||||
-rw-r--r-- | tests/auto/qapplication/tst_qapplication.cpp | 63 | ||||
-rw-r--r-- | tests/auto/qcompleter/tst_qcompleter.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qpixmap/tst_qpixmap.cpp | 21 | ||||
-rw-r--r-- | tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp | 25 | ||||
-rw-r--r-- | tests/auto/qsqlquery/tst_qsqlquery.cpp | 56 | ||||
-rw-r--r-- | tests/auto/qstring/tst_qstring.cpp | 9 | ||||
-rw-r--r-- | tests/auto/qtcpsocket/tst_qtcpsocket.cpp | 14 |
9 files changed, 179 insertions, 32 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index d58402b..a09d998 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -333,6 +333,11 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress() if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) { // need resolving QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName()); + if(resolved.error() != QHostInfo::NoError || + !resolved.addresses().isEmpty()) { + qWarning("QHostInfo::fromName failed (%d).", resolved.error()); + return QHostAddress(QHostAddress::Null); + } cachedIpAddress = resolved.addresses().first(); } return cachedIpAddress; diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp index 5c70bde..d9574df 100644 --- a/tests/auto/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp @@ -714,11 +714,7 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Vertical) // orientation of slider << int(Qt::Vertical) // orientation of wheel -#ifdef Q_WS_MAC - << 1 // expected position after -#else << 20 // expected position after -#endif << QPoint(0,0); QTest::newRow("Normal data page") << 0 // initial position @@ -777,11 +773,7 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Horizontal) // orientation of slider << int(Qt::Horizontal) // orientation of wheel -#ifdef Q_WS_MAC - << 49 // expected position after -#else << 30 // expected position after -#endif << QPoint(1,1); QTest::newRow("Past end") << 50 // initial position @@ -792,11 +784,7 @@ void tst_QAbstractSlider::wheelEvent_data() << false // inverted controls << 1 // wheel scroll lines << false // with modifiers -#ifdef Q_WS_MAC - << 60 // delta -#else << 2 // delta -#endif << int(Qt::Horizontal) // orientation of slider << int(Qt::Horizontal) // orientation of wheel << 100 // expected position after @@ -810,11 +798,7 @@ void tst_QAbstractSlider::wheelEvent_data() << false // inverted controls << 1 // wheel scroll lines << false // with modifiers -#ifdef Q_WS_MAC - << -60 // delta -#else << -2 // delta -#endif << int(Qt::Horizontal) // orientation of slider << int(Qt::Horizontal) // orientation of wheel << 0 // expected position after diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 97aa092..675e559 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -136,6 +136,9 @@ private slots: void windowsCommandLine(); void touchEventPropagation(); + + void symbianNeedForTraps(); + void symbianLeaveThroughMain(); }; class EventSpy : public QObject @@ -2011,6 +2014,66 @@ void tst_QApplication::touchEventPropagation() } } +#ifdef Q_OS_SYMBIAN +class CBaseDummy : public CBase +{ +public: + CBaseDummy(int *numDestroyed) : numDestroyed(numDestroyed) + { + } + ~CBaseDummy() + { + (*numDestroyed)++; + } + +private: + int *numDestroyed; +}; + +static void fakeMain(int *numDestroyed) +{ + // Push a few objects, just so that the cleanup stack has something to clean up. + CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed)); + int argc = 0; + QApplication app(argc, 0); + CleanupStack::PushL(new (ELeave) CBaseDummy(numDestroyed)); + + User::Leave(KErrGeneral); // Fake error +} +#endif + +void tst_QApplication::symbianNeedForTraps() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian-only test", SkipAll); +#else + int argc = 0; + QApplication app(argc, 0); + int numDestroyed = 0; + + // This next part should not require a trap. If it does, the test will crash. + CleanupStack::PushL(new (ELeave) CBaseDummy(&numDestroyed)); + CleanupStack::PopAndDestroy(); + + QCOMPARE(numDestroyed, 1); + + // No other failure condition. The program will crash if it does not pass. +#endif +} + +void tst_QApplication::symbianLeaveThroughMain() +{ +#ifndef Q_OS_SYMBIAN + QSKIP("This is a Symbian-only test", SkipAll); +#else + int numDestroyed = 0; + TInt err; + TRAP(err, fakeMain(&numDestroyed)); + + QCOMPARE(numDestroyed, 2); +#endif +} + //QTEST_APPLESS_MAIN(tst_QApplication) int main(int argc, char *argv[]) { diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 43205e1..2a17984 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -267,7 +267,7 @@ void tst_QCompleter::filter() //QModelIndex si = completer->currentIndex(); //QCOMPARE(completer->model()->data(si).toString(), completion); - QCOMPARE(completer->currentCompletion(), completionText); + QVERIFY(0 == QString::compare(completer->currentCompletion(), completionText, completer->caseSensitivity())); } // Testing get/set functions diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 9f5aee2..53b6230 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -166,6 +166,7 @@ private slots: void fromImage_crash(); void fromData(); + void loadFromDataNullValues(); void preserveDepth(); }; @@ -1436,6 +1437,26 @@ void tst_QPixmap::fromData() QCOMPARE(img.pixel(0, 1), QRgb(0xff000000)); } +void tst_QPixmap::loadFromDataNullValues() +{ + { + QPixmap pixmap; + pixmap.loadFromData(QByteArray()); + QVERIFY(pixmap.isNull()); + } + { + QPixmap pixmap; + pixmap.loadFromData(0, 123); + QVERIFY(pixmap.isNull()); + } + { + QPixmap pixmap; + const uchar bla[] = "bla"; + pixmap.loadFromData(bla, 0); + QVERIFY(pixmap.isNull()); + } +} + void tst_QPixmap::task_246446() { // This crashed without the bugfix in 246446 diff --git a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp index 6efa85b..87e0533 100644 --- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp +++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp @@ -47,6 +47,10 @@ #include "qdialogbuttonbox.h" #include "private/qsoftkeymanager_p.h" +#ifdef Q_OS_SYMBIAN +#include "qsymbianevent.h" +#endif + #ifdef Q_WS_S60 static const int s60CommandStart = 6000; #endif @@ -69,6 +73,13 @@ private slots: void updateSoftKeysCompressed(); void handleCommand(); void checkSoftkeyEnableStates(); + +private: // utils + inline void simulateSymbianCommand(int command) + { + QSymbianEvent event1(QSymbianEvent::CommandEvent, command); + qApp->symbianProcessEvent(&event1); + }; }; class EventListener : public QObject @@ -167,8 +178,8 @@ void tst_QSoftKeyManager::handleCommand() // QTest::keyPress(&w, Qt::Key_Context1); // QTest::keyPress(&w, Qt::Key_Context2); - qApp->symbianHandleCommand(6000); - qApp->symbianHandleCommand(6001); + simulateSymbianCommand(6000); + simulateSymbianCommand(6001); QApplication::processEvents(); @@ -200,9 +211,9 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() //disabled button gets none. for (int i = 0; i < 10; i++) { //simulate "Restore Defaults" softkey press - qApp->symbianHandleCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart); //simulate "help" softkey press - qApp->symbianHandleCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 1); } QApplication::processEvents(); QCOMPARE(spy0.count(), 10); @@ -212,16 +223,16 @@ void tst_QSoftKeyManager::checkSoftkeyEnableStates() for (int i = 0; i < 10; i++) { //simulate "Restore Defaults" softkey press - qApp->symbianHandleCommand(s60CommandStart); + simulateSymbianCommand(s60CommandStart); //simulate "help" softkey press - qApp->symbianHandleCommand(s60CommandStart + 1); + simulateSymbianCommand(s60CommandStart + 1); //switch enabled button to disabled and vice versa pBHelp->setEnabled(!pBHelp->isEnabled()); pBDefaults->setEnabled(!pBDefaults->isEnabled()); } QApplication::processEvents(); QCOMPARE(spy0.count(), 5); - QCOMPARE(spy1.count(), 5); + QCOMPARE(spy1.count(), 5); } QTEST_MAIN(tst_QSoftKeyManager) diff --git a/tests/auto/qsqlquery/tst_qsqlquery.cpp b/tests/auto/qsqlquery/tst_qsqlquery.cpp index 8fe6f2e..4d9e50f 100644 --- a/tests/auto/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/qsqlquery/tst_qsqlquery.cpp @@ -193,6 +193,8 @@ private slots: void sqlServerReturn0_data() { generic_data(); } void sqlServerReturn0(); + void QTBUG_551_data() { generic_data("QOCI"); } + void QTBUG_551(); private: // returns all database connections @@ -322,6 +324,11 @@ void tst_QSqlQuery::dropTestTables( QSqlDatabase db ) tablenames << qTableName("test141895"); tst_Databases::safeDropTables( db, tablenames ); + + if ( db.driverName().startsWith( "QOCI" ) ) { + QSqlQuery q( db ); + q.exec( "DROP PACKAGE " + qTableName("pkg") ); + } } void tst_QSqlQuery::createTestTables( QSqlDatabase db ) @@ -396,7 +403,7 @@ void tst_QSqlQuery::char1SelectUnicode() QSKIP("Needs someone with more Unicode knowledge than I have to fix", SkipSingle); if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { - QString uniStr( QChar( 'का' ) ); + QString uniStr( QChar(0x0915) ); // DEVANAGARI LETTER KA QSqlQuery q( db ); if ( db.driverName().startsWith( "QMYSQL" ) && tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 ) @@ -2847,5 +2854,52 @@ void tst_QSqlQuery::sqlServerReturn0() QVERIFY_SQL(q, next()); } +void tst_QSqlQuery::QTBUG_551() +{ + QFETCH( QString, dbName ); + QSqlDatabase db = QSqlDatabase::database( dbName ); + CHECK_DATABASE( db ); + QSqlQuery q(db); + QString pkgname=qTableName("pkg"); + QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE "+pkgname+" IS \n\ + \n\ + TYPE IntType IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;\n\ + TYPE VCType IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;\n\ + PROCEDURE P (Inp IN IntType, Outp OUT VCType);\n\ + END "+pkgname+";")); + + QVERIFY_SQL(q, exec("CREATE OR REPLACE PACKAGE BODY "+pkgname+" IS\n\ + PROCEDURE P (Inp IN IntType, Outp OUT VCType)\n\ + IS\n\ + BEGIN\n\ + Outp(1) := '1. Value is ' ||TO_CHAR(Inp(1));\n\ + Outp(2) := '2. Value is ' ||TO_CHAR(Inp(2));\n\ + Outp(3) := '3. Value is ' ||TO_CHAR(Inp(3));\n\ + END p;\n\ + END "+pkgname+";")); + + QVariantList inLst, outLst, res_outLst; + + q.prepare("begin "+pkgname+".p(:inp, :outp); end;"); + + QString StVal; + StVal.reserve(60); + + // loading arrays + for (int Cnt=0; Cnt < 3; Cnt++) { + inLst << Cnt; + outLst << StVal; + } + + q.bindValue(":inp", inLst); + q.bindValue(":outp", outLst, QSql::Out); + + QVERIFY_SQL(q, execBatch(QSqlQuery::ValuesAsColumns) ); + res_outLst = qVariantValue<QVariantList>(q.boundValues()[":outp"]); + QCOMPARE(res_outLst[0].toString(), QLatin1String("1. Value is 0")); + QCOMPARE(res_outLst[1].toString(), QLatin1String("2. Value is 1")); + QCOMPARE(res_outLst[2].toString(), QLatin1String("3. Value is 2")); +} + QTEST_MAIN( tst_QSqlQuery ) #include "tst_qsqlquery.moc" diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index 5dc1da7..2eb3152 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -201,6 +201,7 @@ private slots: void repeatedSignature() const; void repeated() const; void repeated_data() const; + void task262677remove(); }; typedef QList<int> IntList; @@ -4669,6 +4670,14 @@ void tst_QString::repeated_data() const << 4; } +void tst_QString::task262677remove() +{ + QString driveName = QLatin1String("V:\\blahblah\\more_blahblah\\"); + driveName.remove(2, INT_MAX); // should be "V:" - instead, it's "V::\\blahblah\\more_blahblah\\" + QVERIFY(driveName == QLatin1String("V:")); +} + + QTEST_APPLESS_MAIN(tst_QString) #include "tst_qstring.moc" diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp index 8ea137e..5577903 100644 --- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp @@ -2096,7 +2096,7 @@ void tst_QTcpSocket::connectToMultiIP() stopWatch.restart(); socket->connectToHost("multi.dev.troll.no", 81); - QVERIFY(!socket->waitForConnected(1000)); + QVERIFY(!socket->waitForConnected(2000)); QVERIFY(stopWatch.elapsed() < 2000); QCOMPARE(socket->error(), QAbstractSocket::SocketTimeoutError); @@ -2116,7 +2116,7 @@ void tst_QTcpSocket::moveToThread0() QTcpSocket *socket = newSocket();; socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->moveToThread(0); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForDisconnected()); @@ -2127,7 +2127,7 @@ void tst_QTcpSocket::moveToThread0() QTcpSocket *socket = newSocket(); socket->moveToThread(0); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForDisconnected()); @@ -2137,7 +2137,7 @@ void tst_QTcpSocket::moveToThread0() // Case 3: Moved after writing, while waiting for bytes to be written. QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); socket->moveToThread(0); QVERIFY(socket->waitForBytesWritten(5000)); @@ -2148,7 +2148,7 @@ void tst_QTcpSocket::moveToThread0() // Case 4: Moved after writing, while waiting for response. QTcpSocket *socket = newSocket(); socket->connectToHost(QtNetworkSettings::serverName(), 143); - QVERIFY(socket->waitForConnected(1000)); + QVERIFY(socket->waitForConnected(2000)); socket->write("XXX LOGOUT\r\n"); QVERIFY(socket->waitForBytesWritten(5000)); socket->moveToThread(0); @@ -2263,7 +2263,7 @@ void tst_QTcpSocket::invalidProxy() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } else { QCOMPARE(socket->state(), QAbstractSocket::ConnectingState); - QVERIFY(!socket->waitForConnected(1000)); + QVERIFY(!socket->waitForConnected(2000)); } QVERIFY(!socket->errorString().isEmpty()); @@ -2382,7 +2382,7 @@ void tst_QTcpSocket::proxyFactory() QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); } else { QCOMPARE(socket->state(), QAbstractSocket::ConnectingState); - QVERIFY(socket->waitForConnected(10000)); + QVERIFY(socket->waitForConnected(2000)); QCOMPARE(proxyAuthCalled, 1); } QVERIFY(!socket->errorString().isEmpty()); |