summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qdbusconnection/tst_qdbusconnection.cpp66
-rw-r--r--tests/auto/qftp/tst_qftp.cpp19
-rw-r--r--tests/auto/qhttp/tst_qhttp.cpp2
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp60
-rw-r--r--tests/auto/qtcpserver/tst_qtcpserver.cpp2
-rw-r--r--tests/auto/qtextedit/tst_qtextedit.cpp19
7 files changed, 140 insertions, 30 deletions
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 1e7f424..263c957 100644
--- a/tests/auto/qftp/tst_qftp.cpp
+++ b/tests/auto/qftp/tst_qftp.cpp
@@ -618,7 +618,7 @@ void tst_QFtp::get()
}
addCommand( QFtp::Close, ftp->close() );
- QTestEventLoop::instance().enterLoop( 30 );
+ QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1020,7 +1020,7 @@ void tst_QFtp::renameInit( const QString &host, const QString &user, const QStri
addCommand( QFtp::Put, ftp->put( QByteArray(), createFile ) );
addCommand( QFtp::Close, ftp->close() );
- QTestEventLoop::instance().enterLoop( 30 );
+ QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
@@ -1295,14 +1295,18 @@ void tst_QFtp::abort_data()
// Qt/CE and Symbian test environment has to less memory for this test
#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
QByteArray bigData( 10*1024*1024, 0 );
+#else
+ QByteArray bigData( 1*1024*1024, 0 );
+#endif
bigData.fill( 'B' );
-
QTest::newRow( "put_fluke01" ) << QtNetworkSettings::serverName() << (uint)21 << QString("qtest/upload/abort_put") << bigData;
-#endif
}
void tst_QFtp::abort()
{
+ // In case you wonder where the abort() actually happens, look into
+ // tst_QFtp::dataTransferProgress
+ //
QFETCH( QString, host );
QFETCH( uint, port );
QFETCH( QString, file );
@@ -1324,7 +1328,7 @@ void tst_QFtp::abort()
addCommand( QFtp::Close, ftp->close() );
for(int time = 0; time <= uploadData.length() / 30000; time += 30) {
- QTestEventLoop::instance().enterLoop( 30 );
+ QTestEventLoop::instance().enterLoop( 50 );
if(ftp->currentCommand() == QFtp::None)
break;
}
@@ -1493,7 +1497,7 @@ void tst_QFtp::proxy()
addCommand( QFtp::Cd, ftp->cd( dir ) );
addCommand( QFtp::List, ftp->list() );
- QTestEventLoop::instance().enterLoop( 30 );
+ QTestEventLoop::instance().enterLoop( 50 );
delete ftp;
if ( QTestEventLoop::instance().timeout() ) {
@@ -1921,7 +1925,7 @@ bool tst_QFtp::fileExists( const QString &host, quint16 port, const QString &use
delete ftp;
if ( QTestEventLoop::instance().timeout() ) {
// ### make this test work
- qWarning("Network operation timed out");
+ qWarning("tst_QFtp::fileExists: Network operation timed out");
return FALSE;
}
inFileDirExistsFunction = FALSE;
@@ -1972,6 +1976,7 @@ bool tst_QFtp::dirExists( const QString &host, quint16 port, const QString &user
if ( QTestEventLoop::instance().timeout() ) {
// ### make this test work
// QFAIL( "Network operation timed out" );
+ qWarning("tst_QFtp::dirExists: Network operation timed out");
return FALSE;
}
inFileDirExistsFunction = FALSE;
diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp
index 0ea0d15..b4b6ceb 100644
--- a/tests/auto/qhttp/tst_qhttp.cpp
+++ b/tests/auto/qhttp/tst_qhttp.cpp
@@ -363,7 +363,7 @@ void tst_QHttp::get()
}
addRequest( QHttpRequestHeader(), getId );
- QTestEventLoop::instance().enterLoop( 30 );
+ QTestEventLoop::instance().enterLoop( 50 );
if ( QTestEventLoop::instance().timeout() )
QFAIL( "Network operation timed out" );
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index bd83c47..09456ed 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -2622,7 +2622,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
- QTestEventLoop::instance().enterLoop(6);
+ QTestEventLoop::instance().enterLoop(12);
disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
diff --git a/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp b/tests/auto/qscriptengineagent/tst_qscriptengineagent.cpp
index 77ccdb3..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();
@@ -476,7 +477,7 @@ void tst_QScriptEngineAgent::scriptLoadAndUnload_eval()
spy->clear();
eng.evaluate("eval('function foo() { print(123); }')");
- QEXPECT_FAIL("","Eval is threaded in different way that in old backend", Abort);
+ QEXPECT_FAIL("","QTBUG-6140 Eval is threaded in different way that in old backend", Abort);
QCOMPARE(spy->count(), 3);
QCOMPARE(spy->at(0).type, ScriptEngineEvent::ScriptLoad);
@@ -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;
}
@@ -1161,16 +1185,16 @@ void tst_QScriptEngineAgent::positionChange_1()
{
spy->clear();
eng.evaluate(";");
- QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue);
+ QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue);
QCOMPARE(spy->count(), 1);
if (spy->count()) {
- QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue);
+ QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue);
QCOMPARE(spy->at(0).type, ScriptEngineEvent::PositionChange);
- QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue);
+ QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue);
QVERIFY(spy->at(0).scriptId != -1);
- QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue);
+ QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue);
QCOMPARE(spy->at(0).lineNumber, 1);
- QEXPECT_FAIL("","JSC do not evaluate ';' to statemant",Continue);
+ QEXPECT_FAIL("","QTBUG-6142 JSC do not evaluate ';' to statemant",Continue);
QCOMPARE(spy->at(0).columnNumber, 1);
}
}
@@ -1552,7 +1576,7 @@ void tst_QScriptEngineAgent::positionChange_2()
}
{
- QEXPECT_FAIL("","I believe the test is wrong. Expressions shouldn't call positionChange "
+ QEXPECT_FAIL("","QTBUG-6142 I believe the test is wrong. Expressions shouldn't call positionChange "
"because statement '1+2' will call it at least twice, why debugger have to "
"stop here so many times?", Abort);
spy->clear();
@@ -2089,8 +2113,6 @@ void tst_QScriptEngineAgent::syntaxError()
i = 2;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPush);
- QEXPECT_FAIL("","The test is broken, contextPush event do not provide scriptId", Continue);
- QVERIFY(spy->at(i).scriptId == -1);
i = 3;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::FunctionEntry);
QVERIFY(spy->at(i).scriptId == -1);
@@ -2099,14 +2121,12 @@ void tst_QScriptEngineAgent::syntaxError()
QVERIFY(spy->at(i).scriptId == -1);
i = 5;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::ContextPop);
- QEXPECT_FAIL("","The test is broken, contextPop event do not provide scriptId", Continue);
- QVERIFY(spy->at(i).scriptId == -1);
i = 6;
QCOMPARE(spy->at(i).type, ScriptEngineEvent::ExceptionThrow);
QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId);
QVERIFY(!spy->at(i).hasExceptionHandler);
QVERIFY(spy->at(i).value.isError());
- QEXPECT_FAIL("","There are other messages in JSC",Continue);
+ QEXPECT_FAIL("","QTBUG-6137 There are other messages in JSC",Continue);
QCOMPARE(spy->at(i).value.toString(), QString("SyntaxError: Expected `}'"));
QCOMPARE(spy->at(i).scriptId, spy->at(0).scriptId);
i = 7;
@@ -2139,7 +2159,7 @@ void tst_QScriptEngineAgent::extension_invoctaion()
QCOMPARE(spy->at(1).lineNumber, lineNumber);
QCOMPARE(spy->at(1).columnNumber, 1);
- QEXPECT_FAIL("","In JSC Eval('debugger') returns undefined",Abort);
+ QEXPECT_FAIL("","QTBUG-6135 In JSC Eval('debugger') returns undefined",Abort);
QVERIFY(ret.isString());
QCOMPARE(ret.toString(), QString::fromLatin1("extension(DebuggerInvocationRequest)"));
}
diff --git a/tests/auto/qtcpserver/tst_qtcpserver.cpp b/tests/auto/qtcpserver/tst_qtcpserver.cpp
index 2540096..8b86111 100644
--- a/tests/auto/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/qtcpserver/tst_qtcpserver.cpp
@@ -523,7 +523,7 @@ void tst_QTcpServer::waitForConnectionTest()
QTcpSocket findLocalIpSocket;
findLocalIpSocket.connectToHost(QtNetworkSettings::serverName(), 143);
- QVERIFY(findLocalIpSocket.waitForConnected(2000));
+ QVERIFY(findLocalIpSocket.waitForConnected(5000));
QTcpServer server;
bool timeout = false;
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp
index fee030c..bebc4bd 100644
--- a/tests/auto/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/qtextedit/tst_qtextedit.cpp
@@ -200,6 +200,7 @@ private slots:
void pasteFromQt3RichText();
void noWrapBackgrounds();
void preserveCharFormatAfterUnchangingSetPosition();
+ void twoSameInputMethodEvents();
private:
void createSelection();
@@ -2183,5 +2184,23 @@ void tst_QTextEdit::preserveCharFormatAfterUnchangingSetPosition()
QCOMPARE(edit.textColor(), color);
}
+// Regression test for QTBUG-4696
+void tst_QTextEdit::twoSameInputMethodEvents()
+{
+ ed->setText("testLine");
+ ed->show();
+ QList<QInputMethodEvent::Attribute> attributes;
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
+ ed->textCursor().position(),
+ 0,
+ QVariant()));
+
+ QInputMethodEvent event("PreEditText", attributes);
+ QApplication::sendEvent(ed, &event);
+ QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
+ QApplication::sendEvent(ed, &event);
+ QCOMPARE(ed->document()->firstBlock().layout()->lineCount(), 1);
+}
+
QTEST_MAIN(tst_QTextEdit)
#include "tst_qtextedit.moc"