diff options
author | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-06 14:18:38 (GMT) |
---|---|---|
committer | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-06 14:18:38 (GMT) |
commit | ead212aff40b2edbefb1a10ba14f0afed7236995 (patch) | |
tree | 40c82d4b47a9502b6e032b8df2a94fbeec6cfe44 /tests | |
parent | 913a78a9288bf1f68f4975bec5cc58e699c09f39 (diff) | |
parent | 1b0916db13a52d99dad93322aae0c5c6ba4c2d18 (diff) | |
download | Qt-ead212aff40b2edbefb1a10ba14f0afed7236995.zip Qt-ead212aff40b2edbefb1a10ba14f0afed7236995.tar.gz Qt-ead212aff40b2edbefb1a10ba14f0afed7236995.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qinputcontext/tst_qinputcontext.cpp | 84 | ||||
-rw-r--r-- | tests/auto/qlocalsocket/tst_qlocalsocket.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 17 |
3 files changed, 102 insertions, 9 deletions
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 08bf614..444b400 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -45,6 +45,8 @@ #include <qinputcontext.h> #include <qlineedit.h> #include <qplaintextedit.h> +#include <qlayout.h> +#include <qradiobutton.h> class tst_QInputContext : public QObject { @@ -62,6 +64,8 @@ public slots: private slots: void maximumTextLength(); void filterMouseEvents(); + void requestSoftwareInputPanel(); + void closeSoftwareInputPanel(); }; void tst_QInputContext::maximumTextLength() @@ -82,7 +86,7 @@ void tst_QInputContext::maximumTextLength() class QFilterInputContext : public QInputContext { public: - QFilterInputContext() : successful(false) {} + QFilterInputContext() : lastType(QEvent::None) {} ~QFilterInputContext() {} QString identifierName() { return QString(); } @@ -94,26 +98,98 @@ public: bool filterEvent( const QEvent *event ) { - successful = event->type() == QEvent::MouseButtonRelease; + lastType = event->type(); + return false; } public: - bool successful; + QEvent::Type lastType; }; void tst_QInputContext::filterMouseEvents() { QLineEdit le; le.show(); + QApplication::setActiveWindow(&le); QFilterInputContext *ic = new QFilterInputContext; le.setInputContext(ic); QTest::mouseClick(&le, Qt::LeftButton); - QVERIFY(ic->successful); + QCOMPARE(ic->lastType, QEvent::MouseButtonRelease); le.setInputContext(0); } +void tst_QInputContext::requestSoftwareInputPanel() +{ + QWidget w; + QLayout *layout = new QVBoxLayout; + QLineEdit *le1, *le2; + le1 = new QLineEdit; + le2 = new QLineEdit; + layout->addWidget(le1); + layout->addWidget(le2); + w.setLayout(layout); + + QFilterInputContext *ic1, *ic2; + ic1 = new QFilterInputContext; + ic2 = new QFilterInputContext; + le1->setInputContext(ic1); + le2->setInputContext(ic2); + + w.show(); + QApplication::setActiveWindow(&w); + + // Testing single click panel activation. + QApplication::setTwoClicksToRequestSIP(false); + QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QCOMPARE(ic2->lastType, QEvent::RequestSoftwareInputPanel); + + // Testing double click panel activation. + QApplication::setTwoClicksToRequestSIP(true); + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastType != QEvent::RequestSoftwareInputPanel); + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QCOMPARE(ic1->lastType, QEvent::RequestSoftwareInputPanel); + + // Testing right mouse button + QTest::mouseClick(le1, Qt::RightButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic1->lastType != QEvent::RequestSoftwareInputPanel); +} + +void tst_QInputContext::closeSoftwareInputPanel() +{ + QWidget w; + QLayout *layout = new QVBoxLayout; + QLineEdit *le1, *le2; + QRadioButton *rb; + le1 = new QLineEdit; + le2 = new QLineEdit; + rb = new QRadioButton; + layout->addWidget(le1); + layout->addWidget(le2); + layout->addWidget(rb); + w.setLayout(layout); + + QFilterInputContext *ic1, *ic2; + ic1 = new QFilterInputContext; + ic2 = new QFilterInputContext; + le1->setInputContext(ic1); + le2->setInputContext(ic2); + + w.show(); + QApplication::setActiveWindow(&w); + + // Testing that panel doesn't close between two input methods aware widgets. + QTest::mouseClick(le1, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QTest::mouseClick(le2, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QVERIFY(ic2->lastType != QEvent::CloseSoftwareInputPanel); + + // Testing that panel closes when focusing non-aware widget. + QTest::mouseClick(rb, Qt::LeftButton, Qt::NoModifier, QPoint(5, 5)); + QCOMPARE(ic2->lastType, QEvent::CloseSoftwareInputPanel); +} + QTEST_MAIN(tst_QInputContext) #include "tst_qinputcontext.moc" diff --git a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp index 50ac953..5d73c98 100644 --- a/tests/auto/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/qlocalsocket/tst_qlocalsocket.cpp @@ -493,8 +493,10 @@ void tst_QLocalSocket::sendData() socket.connectToServer(name); bool timedOut = true; QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen); -#if defined(QT_LOCALSOCKET_TCP) || defined (Q_OS_SYMBIAN) +#if defined(QT_LOCALSOCKET_TCP) QTest::qWait(250); +#elif defined(Q_OS_SYMBIAN) + QTest::qWait(10000); #endif QVERIFY(!timedOut); QCOMPARE(spyConnected.count(), canListen ? 1 : 0); @@ -645,7 +647,7 @@ public: || socket.error() == QLocalSocket::ConnectionRefusedError) && tries < 1000); if (tries == 0 && socket.state() != QLocalSocket::ConnectedState) { - QVERIFY(socket.waitForConnected(3000)); + QVERIFY(socket.waitForConnected(30000)); QVERIFY(socket.state() == QLocalSocket::ConnectedState); } @@ -675,7 +677,7 @@ public: int done = clients; while (done > 0) { bool timedOut = true; - QVERIFY(server.waitForNewConnection(3000, &timedOut)); + QVERIFY(server.waitForNewConnection(30000, &timedOut)); QVERIFY(!timedOut); QLocalSocket *serverSocket = server.nextPendingConnection(); QVERIFY(serverSocket); @@ -733,7 +735,7 @@ void tst_QLocalSocket::threadedConnection() server.wait(); while (!clients.isEmpty()) { - QVERIFY(clients.first()->wait(30000)); + QVERIFY(clients.first()->wait(300000)); Client *client =clients.takeFirst(); client->terminate(); delete client; diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index e238526..c9f9cbd 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -1493,12 +1493,27 @@ void tst_QSslSocket::disconnectFromHostWhenConnected() QSslSocketPtr socket = newSocket(); socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 993); socket->ignoreSslErrors(); +#ifndef Q_OS_SYMBIAN QVERIFY(socket->waitForEncrypted(5000)); +#else + QVERIFY(socket->waitForEncrypted(10000)); +#endif socket->write("XXXX LOGOUT\r\n"); QCOMPARE(socket->state(), QAbstractSocket::ConnectedState); socket->disconnectFromHost(); QCOMPARE(socket->state(), QAbstractSocket::ClosingState); - QVERIFY(socket->waitForDisconnected(5000)); +#ifdef Q_OS_SYMBIAN + // I don't understand how socket->waitForDisconnected can work on other platforms + // since socket->write will end to: + // QMetaObject::invokeMethod(this, "_q_flushWriteBuffer", Qt::QueuedConnection); + // In order that _q_flushWriteBuffer will be called the eventloop need to run + // If we just call waitForDisconnected, which blocks the whole thread how that can happen? + connect(socket, SIGNAL(disconnected()), this, SLOT(exitLoop())); + enterLoop(5); + QVERIFY(!timeout()); +#else + QVERIFY(socket->waitForDisconnected(5000)); +#endif QCOMPARE(socket->bytesToWrite(), qint64(0)); } |