diff options
Diffstat (limited to 'tests')
-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/qscriptengine/tst_qscriptengine.cpp | 149 | ||||
-rw-r--r-- | tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp | 86 | ||||
-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 | ||||
-rw-r--r-- | tests/benchmarks/qscriptengine/tst_qscriptengine.cpp | 19 |
12 files changed, 432 insertions, 33 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/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 25ee00f..804534f 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -44,6 +44,7 @@ #include <qscriptengine.h> #include <qscriptengineagent.h> +#include <qscriptprogram.h> #include <qscriptvalueiterator.h> #include <qgraphicsitem.h> #include <qstandarditemmodel.h> @@ -52,6 +53,7 @@ Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QObjectList) +Q_DECLARE_METATYPE(QScriptProgram) //TESTED_CLASS= //TESTED_FILES= @@ -151,6 +153,7 @@ private slots: void installTranslatorFunctions(); void functionScopes(); void nativeFunctionScopes(); + void evaluateProgram(); void qRegExpInport_data(); void qRegExpInport(); @@ -4289,6 +4292,152 @@ void tst_QScriptEngine::nativeFunctionScopes() } } +static QScriptValue createProgram(QScriptContext *ctx, QScriptEngine *eng) +{ + QString code = ctx->argument(0).toString(); + QScriptProgram result(code); + return qScriptValueFromValue(eng, result); +} + +void tst_QScriptEngine::evaluateProgram() +{ + QScriptEngine eng; + + { + QString code("1 + 2"); + QString fileName("hello.js"); + int lineNumber(123); + QScriptProgram program(code, fileName, lineNumber); + QVERIFY(!program.isNull()); + QCOMPARE(program.sourceCode(), code); + QCOMPARE(program.fileName(), fileName); + QCOMPARE(program.firstLineNumber(), lineNumber); + + QScriptValue expected = eng.evaluate(code); + for (int x = 0; x < 10; ++x) { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.equals(expected)); + } + + // operator= + QScriptProgram sameProgram = program; + QVERIFY(sameProgram == program); + QVERIFY(eng.evaluate(sameProgram).equals(expected)); + + // copy constructor + QScriptProgram sameProgram2(program); + QVERIFY(sameProgram2 == program); + QVERIFY(eng.evaluate(sameProgram2).equals(expected)); + + QScriptProgram differentProgram("2 + 3"); + QVERIFY(differentProgram != program); + QVERIFY(!eng.evaluate(differentProgram).equals(expected)); + } + + // Program that accesses variable in the scope + { + QScriptProgram program("a"); + QVERIFY(!program.isNull()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a")); + } + + QScriptValue obj = eng.newObject(); + obj.setProperty("a", 123); + QScriptContext *ctx = eng.currentContext(); + ctx->pushScope(obj); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.equals(obj.property("a"))); + } + + obj.setProperty("a", QScriptValue()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + } + + QScriptValue obj2 = eng.newObject(); + obj2.setProperty("a", 456); + ctx->pushScope(obj2); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.equals(obj2.property("a"))); + } + + ctx->popScope(); + } + + // Program that creates closure + { + QScriptProgram program("(function() { var count = 0; return function() { return count++; }; })"); + QVERIFY(!program.isNull()); + QScriptValue createCounter = eng.evaluate(program); + QVERIFY(createCounter.isFunction()); + QScriptValue counter = createCounter.call(); + QVERIFY(counter.isFunction()); + { + QScriptValue ret = counter.call(); + QVERIFY(ret.isNumber()); + } + QScriptValue counter2 = createCounter.call(); + QVERIFY(counter2.isFunction()); + QVERIFY(!counter2.equals(counter)); + { + QScriptValue ret = counter2.call(); + QVERIFY(ret.isNumber()); + } + } + + // Program created in a function call, then executed later + { + QScriptValue fun = eng.newFunction(createProgram); + QScriptProgram program = qscriptvalue_cast<QScriptProgram>( + fun.call(QScriptValue(), QScriptValueList() << "a + 1")); + QVERIFY(!program.isNull()); + eng.globalObject().setProperty("a", QScriptValue()); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(ret.isError()); + QCOMPARE(ret.toString(), QString::fromLatin1("ReferenceError: Can't find variable: a")); + } + eng.globalObject().setProperty("a", 122); + { + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isError()); + QVERIFY(ret.isNumber()); + QCOMPARE(ret.toInt32(), 123); + } + } + + // Same program run in different engines + { + QString code("1 + 2"); + QScriptProgram program(code); + QVERIFY(!program.isNull()); + double expected = eng.evaluate(program).toNumber(); + for (int x = 0; x < 2; ++x) { + QScriptEngine eng2; + for (int y = 0; y < 2; ++y) { + double ret = eng2.evaluate(program).toNumber(); + QCOMPARE(ret, expected); + } + } + } + + // No program + { + QScriptProgram program; + QVERIFY(program.isNull()); + QScriptValue ret = eng.evaluate(program); + QVERIFY(!ret.isValid()); + } +} + static QRegExp minimal(QRegExp r) { r.setMinimal(true); return r; } void tst_QScriptEngine::qRegExpInport_data() diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index 82c8ccd..032c34b 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -44,6 +44,7 @@ #include <QtScript/qscriptengineagent.h> #include <QtScript/qscriptengine.h> +#include <QtScript/qscriptprogram.h> #include <qscriptvalueiterator.h> //TESTED_CLASS= @@ -110,6 +111,9 @@ private slots: void extension(); void isEvaluatingInExtension(); void hasUncaughtException(); + void evaluateProgram(); + void evaluateProgram_SyntaxError(); + void evaluateNullProgram(); private: double m_testProperty; @@ -2219,6 +2223,88 @@ void tst_QScriptEngineAgent::hasUncaughtException() QVERIFY2(spy->isPass(), "At least one of a functionExit event should set hasUncaughtException flag."); } +void tst_QScriptEngineAgent::evaluateProgram() +{ + QScriptEngine eng; + QScriptProgram program("1 + 2", "foo.js", 123); + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + qint64 scriptId = -1; + for (int x = 0; x < 10; ++x) { + spy->clear(); + (void)eng.evaluate(program); + QCOMPARE(spy->count(), (x == 0) ? 4 : 3); + + if (x == 0) { + // script is only loaded on first execution + QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); + scriptId = spy->at(0).scriptId; + QVERIFY(scriptId != -1); + QCOMPARE(spy->at(0).script, program.sourceCode()); + QCOMPARE(spy->at(0).fileName, program.fileName()); + QCOMPARE(spy->at(0).lineNumber, program.firstLineNumber()); + spy->removeFirst(); + } + + QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); // evaluate() + QCOMPARE(spy->at(0).scriptId, scriptId); + + QCOMPARE(spy->at(1).type, ScriptEngineEvent::PositionChange); + QCOMPARE(spy->at(1).scriptId, scriptId); + QCOMPARE(spy->at(1).lineNumber, program.firstLineNumber()); + + QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); // evaluate() + QCOMPARE(spy->at(2).scriptId, scriptId); + QVERIFY(spy->at(2).value.isNumber()); + QCOMPARE(spy->at(2).value.toNumber(), qsreal(3)); + } +} + +void tst_QScriptEngineAgent::evaluateProgram_SyntaxError() +{ + QScriptEngine eng; + QScriptProgram program("this is not valid syntax", "foo.js", 123); + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + qint64 scriptId = -1; + for (int x = 0; x < 10; ++x) { + spy->clear(); + (void)eng.evaluate(program); + QCOMPARE(spy->count(), (x == 0) ? 8 : 7); + + if (x == 0) { + // script is only loaded on first execution + QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad); + scriptId = spy->at(0).scriptId; + QVERIFY(scriptId != -1); + QCOMPARE(spy->at(0).script, program.sourceCode()); + QCOMPARE(spy->at(0).fileName, program.fileName()); + QCOMPARE(spy->at(0).lineNumber, program.firstLineNumber()); + spy->removeFirst(); + } + + QCOMPARE(spy->at(0).type, ScriptEngineEvent::FunctionEntry); // evaluate() + QCOMPARE(spy->at(0).scriptId, scriptId); + + QCOMPARE(spy->at(1).type, ScriptEngineEvent::ContextPush); // SyntaxError constructor + QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionEntry); // SyntaxError constructor + QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); // SyntaxError constructor + QCOMPARE(spy->at(4).type, ScriptEngineEvent::ContextPop); // SyntaxError constructor + + QCOMPARE(spy->at(5).type, ScriptEngineEvent::ExceptionThrow); + QVERIFY(spy->at(5).value.isError()); + QCOMPARE(spy->at(5).value.toString(), QString::fromLatin1("SyntaxError: Parse error")); + + QCOMPARE(spy->at(6).type, ScriptEngineEvent::FunctionExit); // evaluate() + QCOMPARE(spy->at(6).scriptId, scriptId); + } +} + +void tst_QScriptEngineAgent::evaluateNullProgram() +{ + QScriptEngine eng; + ScriptEngineSpy *spy = new ScriptEngineSpy(&eng); + (void)eng.evaluate(QScriptProgram()); + QCOMPARE(spy->count(), 0); +} QTEST_MAIN(tst_QScriptEngineAgent) #include "tst_qscriptengineagent.moc" 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()); diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp index 4f011c4..8d5f6e6 100644 --- a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp +++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp @@ -60,6 +60,8 @@ private slots: void constructor(); void evaluate_data(); void evaluate(); + void evaluateProgram_data(); + void evaluateProgram(); void connectAndDisconnect(); void newObject(); void newQObject(); @@ -153,6 +155,22 @@ void tst_QScriptEngine::connectAndDisconnect() } } +void tst_QScriptEngine::evaluateProgram_data() +{ + evaluate_data(); +} + +void tst_QScriptEngine::evaluateProgram() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptProgram program(code); + + QBENCHMARK { + (void)engine.evaluate(program); + } +} + void tst_QScriptEngine::newObject() { QScriptEngine engine; @@ -241,6 +259,5 @@ void tst_QScriptEngine::nativeCall() } } - QTEST_MAIN(tst_QScriptEngine) #include "tst_qscriptengine.moc" |