diff options
author | David Boddie <dboddie@trolltech.com> | 2009-11-25 15:20:49 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-11-25 15:20:49 (GMT) |
commit | e58b0e2e562f1c5284ced8671d85df748a4a9639 (patch) | |
tree | cd60fd60d504d5613a24dac97a46c8fc4d51ba92 /tests | |
parent | 6b760aa0701bd6dbbd7f2f16db2f554979273c1d (diff) | |
parent | 4d7b7dc0bdd12188d92a5d05a35991af7b53cc81 (diff) | |
download | Qt-e58b0e2e562f1c5284ced8671d85df748a4a9639.zip Qt-e58b0e2e562f1c5284ced8671d85df748a4a9639.tar.gz Qt-e58b0e2e562f1c5284ced8671d85df748a4a9639.tar.bz2 |
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.6
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/networkselftest/tst_networkselftest.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qdbusconnection/tst_qdbusconnection.cpp | 66 | ||||
-rw-r--r-- | tests/auto/qftp/tst_qftp.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp | 38 | ||||
-rw-r--r-- | tests/auto/qudpsocket/tst_qudpsocket.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.ref | 7 | ||||
-rw-r--r-- | tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml | 3 |
9 files changed, 115 insertions, 15 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index f13bcad..b9be5cb 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -156,7 +156,7 @@ static QString prettyByteArray(const QByteArray &array) return result; } -static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 2000) +static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 4000) { QTime timer; timer.start(); @@ -171,7 +171,7 @@ static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout } } -static bool doSocketFlush(QTcpSocket *socket, int timeout = 2000) +static bool doSocketFlush(QTcpSocket *socket, int timeout = 4000) { #ifndef QT_NO_OPENSSL QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket); diff --git a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp index bb034a3..c1976c0 100644 --- a/tests/auto/qdbusconnection/tst_qdbusconnection.cpp +++ b/tests/auto/qdbusconnection/tst_qdbusconnection.cpp @@ -96,6 +96,8 @@ private slots: void registerQObjectChildren(); void callSelf(); + void callSelfByAnotherName_data(); + void callSelfByAnotherName(); void multipleInterfacesInQObject(); void slotsWithLessParameters(); @@ -493,6 +495,70 @@ void tst_QDBusConnection::callSelf() QCOMPARE(reply.arguments().value(0).toInt(), 45); } +void tst_QDBusConnection::callSelfByAnotherName_data() +{ + QTest::addColumn<int>("registerMethod"); + QTest::newRow("connection") << 0; + QTest::newRow("connection-interface") << 1; + QTest::newRow("direct") << 2; +} + +void tst_QDBusConnection::callSelfByAnotherName() +{ + static int counter = 0; + QString sname = serviceName() + QString::number(counter++); + + QDBusConnection con = QDBusConnection::sessionBus(); + QVERIFY(con.isConnected()); + + TestObject testObject; + QVERIFY(con.registerObject("/test", &testObject, + QDBusConnection::ExportAllContents)); + con.connect("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged", + QStringList() << sname << "", + QString(), &QTestEventLoop::instance(), SLOT(exitLoop())); + + // register the name + QFETCH(int, registerMethod); + switch (registerMethod) { + case 0: + QVERIFY(con.registerService(sname)); + break; + + case 1: + QVERIFY(con.interface()->registerService(sname).value() == QDBusConnectionInterface::ServiceRegistered); + break; + + case 2: { + // flag is DBUS_NAME_FLAG_DO_NOT_QUEUE = 0x04 + // reply is DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER = 1 + QDBusReply<uint> reply = con.interface()->call("RequestName", sname, 4u); + QVERIFY(reply.value() == 1); + } + } + + struct Deregisterer { + QDBusConnection con; + QString sname; + Deregisterer(const QDBusConnection &con, const QString &sname) : con(con), sname(sname) {} + ~Deregisterer() { con.interface()->unregisterService(sname); } + } deregisterer(con, sname); + + // give the connection a chance to find out that we're good to go + QTestEventLoop::instance().enterLoop(2); + con.disconnect("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameOwnerChanged", + QStringList() << sname << "", + QString(), &QTestEventLoop::instance(), SLOT(exitLoop())); + QVERIFY(!QTestEventLoop::instance().timeout()); + + // make the call + QDBusMessage msg = QDBusMessage::createMethodCall(sname, "/test", + QString(), "test0"); + QDBusMessage reply = con.call(msg, QDBus::Block, 1000); + + QVERIFY(reply.type() == QDBusMessage::ReplyMessage); +} + void tst_QDBusConnection::multipleInterfacesInQObject() { QDBusConnection con = QDBusConnection::sessionBus(); diff --git a/tests/auto/qftp/tst_qftp.cpp b/tests/auto/qftp/tst_qftp.cpp index 263c957..27c2e13 100644 --- a/tests/auto/qftp/tst_qftp.cpp +++ b/tests/auto/qftp/tst_qftp.cpp @@ -1408,7 +1408,7 @@ void tst_QFtp::bytesAvailable() if ( type != 0 ) addCommand( QFtp::Close, ftp->close() ); - QTestEventLoop::instance().enterLoop( 30 ); + QTestEventLoop::instance().enterLoop( 40 ); if ( QTestEventLoop::instance().timeout() ) QFAIL( "Network operation timed out" ); diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 5ead049..8cabadb 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -695,7 +695,7 @@ public: || socket.error() == QLocalSocket::ConnectionRefusedError) && tries < 1000); if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) { - QVERIFY(socket.waitForConnected(3000)); + QVERIFY(socket.waitForConnected(7000)); QVERIFY(socket.state() == QLocalSocket::ConnectedState); } @@ -725,7 +725,7 @@ public: int done = clients; while (done > 0) { bool timedOut = true; - QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(server.waitForNewConnection(7000, &timedOut)); QVERIFY(!timedOut); QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 09456ed..5fe716a 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -2212,7 +2212,7 @@ void tst_QNetworkReply::ioGetWithManyProxies() connect(&manager, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif - QTestEventLoop::instance().enterLoop(10); + QTestEventLoop::instance().enterLoop(15); QVERIFY(!QTestEventLoop::instance().timeout()); manager.disconnect(SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp index b061eb2..1a02785 100644 --- a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp +++ b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp @@ -85,6 +85,7 @@ private slots: void functionEntryAndExit_native(); void functionEntryAndExit_native2(); void functionEntryAndExit_nativeThrowing(); + void functionEntryAndExit_builtin_data(); void functionEntryAndExit_builtin(); void functionEntryAndExit_objects(); void functionEntryAndExit_slots(); @@ -811,18 +812,42 @@ void tst_QScriptEngineAgent::functionEntryAndExit_nativeThrowing() delete spy; } +void tst_QScriptEngineAgent::functionEntryAndExit_builtin_data() +{ + QTest::addColumn<QString>("script"); + QTest::addColumn<QString>("result"); + + QTest::newRow("string native") << "'ciao'.toString()" << "ciao"; + QTest::newRow("string object") << "String('ciao').toString()" << "ciao"; + QTest::newRow("number native") << "(123).toString()" << "123"; + QTest::newRow("number object") << "Number(123).toString()" << "123"; + QTest::newRow("array native") << "['s','a'].toString()" << "s, a"; + QTest::newRow("array object") << "Array('s', 'a').toString()" << "s,a"; + QTest::newRow("boolean native") << "false.toString()" << "false"; + QTest::newRow("boolean object") << "Boolean(true).toString()" << "true"; + QTest::newRow("regexp native") << "/a/.toString()" << "/a/"; + QTest::newRow("regexp object") << "RegExp('a').toString()" << "/a/"; +} + /** check behaiviour of built-in function */ void tst_QScriptEngineAgent::functionEntryAndExit_builtin() { + QFETCH(QString, script); + QFETCH(QString, result); QScriptEngine eng; ScriptEngineSpy *spy = new ScriptEngineSpy(&eng, ~(ScriptEngineSpy::IgnoreFunctionEntry | ScriptEngineSpy::IgnoreFunctionExit)); { spy->clear(); - eng.evaluate("'ciao'.toString()"); - - if (qt_script_isJITEnabled()) - QEXPECT_FAIL("", "Some events are missing when JIT is enabled", Abort); + eng.evaluate(script); + + if (qt_script_isJITEnabled()) { + QEXPECT_FAIL("string native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("number native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("array native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("boolean native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + QEXPECT_FAIL("regexp native", "QTBUG-6187 Some events are missing when JIT is enabled", Abort); + } QCOMPARE(spy->count(), 4); // evaluate() entry @@ -835,14 +860,13 @@ void tst_QScriptEngineAgent::functionEntryAndExit_builtin() // built-in native function exit QCOMPARE(spy->at(2).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(2).scriptId, qint64(-1)); - QVERIFY(spy->at(2).value.isString()); - QCOMPARE(spy->at(2).value.toString(), QString("ciao")); + QCOMPARE(spy->at(2).value.toString(), QString(result)); // evaluate() exit QCOMPARE(spy->at(3).type, ScriptEngineEvent::FunctionExit); QCOMPARE(spy->at(3).scriptId, spy->at(0).scriptId); QVERIFY(spy->at(3).value.isString()); - QCOMPARE(spy->at(3).value.toString(), QString("ciao")); + QCOMPARE(spy->at(3).value.toString(), QString(result)); } delete spy; } diff --git a/tests/auto/qudpsocket/tst_qudpsocket.cpp b/tests/auto/qudpsocket/tst_qudpsocket.cpp index 9418be0..160d74c 100644 --- a/tests/auto/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/qudpsocket/tst_qudpsocket.cpp @@ -295,8 +295,8 @@ void tst_QUdpSocket::loop() QCOMPARE(paul.writeDatagram(paulMessage.data(), paulMessage.length(), peterAddress, peter.localPort()), qint64(paulMessage.length())); - QVERIFY(peter.waitForReadyRead(5000)); - QVERIFY(paul.waitForReadyRead(5000)); + QVERIFY(peter.waitForReadyRead(9000)); + QVERIFY(paul.waitForReadyRead(9000)); char peterBuffer[16*1024]; char paulBuffer[16*1024]; if (success) { diff --git a/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.ref b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.ref new file mode 100644 index 0000000..ea85e32 --- /dev/null +++ b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.ref @@ -0,0 +1,7 @@ +StartDocument( ) +Comment( text=" Empty markup declaration in a doctype. " ) +DTD( text=" +<!DOCTYPE doc []>" dtdName="doc" ) +StartElement( name="doc" qualifiedName="doc" ) +EndElement( name="doc" qualifiedName="doc" ) +EndDocument( ) diff --git a/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml new file mode 100644 index 0000000..1c66c0c --- /dev/null +++ b/tests/auto/qxmlstream/data/doctypeEmptyMarkupDecl.xml @@ -0,0 +1,3 @@ +<!-- Empty markup declaration in a doctype. --> +<!DOCTYPE doc []> +<doc></doc> |