summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2009-11-17 14:22:03 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2009-11-17 14:22:03 +0100
commitfaf6d0de6e3b8168fbd6f04c5380f47d350e2a22 (patch)
treed3c35778ad9c7abe68b681b39dd004027fd50880 /tests
parent3a92f40e1faf4d81f5071a66558b051a9fda727e (diff)
parent499a9aaabad0756cbca7b39751684308a6ba88ea (diff)
Merge remote branch 'staging/4.6' into 4.6
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/networkselftest/tst_networkselftest.cpp12
-rw-r--r--tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp3
-rw-r--r--tests/auto/qdbusinterface/tst_qdbusinterface.cpp3
-rw-r--r--tests/auto/qdbusperformance/tst_qdbusperformance.cpp22
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp3
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp43
-rw-r--r--tests/auto/qtcpsocket/tst_qtcpsocket.cpp43
-rw-r--r--tests/auto/qurl/tst_qurl.cpp8
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp59
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt2
-rw-r--r--tests/auto/xmlpatterns/tst_xmlpatterns.cpp4
11 files changed, 178 insertions, 24 deletions
diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp
index a09d9988c4..f13bcad89a 100644
--- a/tests/auto/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/networkselftest/tst_networkselftest.cpp
@@ -80,6 +80,9 @@ private slots:
void httpProxyNtlmAuth();
void socks5Proxy();
void socks5ProxyAuth();
+
+ // ssl supported test
+ void supportsSsl();
};
class Chat
@@ -717,5 +720,14 @@ void tst_NetworkSelfTest::socks5ProxyAuth()
);
}
+void tst_NetworkSelfTest::supportsSsl()
+{
+#ifdef QT_NO_OPENSSL
+ QFAIL("SSL not compiled in");
+#else
+ QVERIFY(QSslSocket::supportsSsl());
+#endif
+}
+
QTEST_MAIN(tst_NetworkSelfTest)
#include "tst_networkselftest.moc"
diff --git a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
index 91050f56ec..a2c4758ebc 100644
--- a/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
+++ b/tests/auto/qdbusabstractinterface/tst_qdbusabstractinterface.cpp
@@ -133,7 +133,7 @@ tst_QDBusAbstractInterface::tst_QDBusAbstractInterface()
void tst_QDBusAbstractInterface::initTestCase()
{
// enable debugging temporarily:
- putenv("QDBUS_DEBUG=1");
+ //putenv("QDBUS_DEBUG=1");
// register the object
QDBusConnection con = QDBusConnection::sessionBus();
@@ -465,6 +465,7 @@ void tst_QDBusAbstractInterface::followSignal()
QDBusConnectionInterface::DontAllowReplacement);
QVERIFY(r.isValid() && r.value() == QDBusConnectionInterface::ServiceRegistered);
QVERIFY(con.interface()->isServiceRegistered(serviceToFollow));
+ QCoreApplication::instance()->processEvents();
// emit the signal again:
emit targetObj.voidSignal();
diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
index 62d634265b..bcd5bd97e1 100644
--- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
+++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp
@@ -234,6 +234,7 @@ void tst_QDBusInterface::notValid()
void tst_QDBusInterface::invalidAfterServiceOwnerChanged()
{
+ // this test is technically the same as tst_QDBusAbstractInterface::followSignal
QDBusConnection conn = QDBusConnection::sessionBus();
QDBusConnectionInterface *connIface = conn.interface();
@@ -249,7 +250,7 @@ void tst_QDBusInterface::invalidAfterServiceOwnerChanged()
QTestEventLoop::instance().enterLoop(5);
QVERIFY(!QTestEventLoop::instance().timeout());
- QVERIFY(!invalidInterface.isValid());
+ QVERIFY(invalidInterface.isValid());
}
void tst_QDBusInterface::introspect()
diff --git a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp b/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
index 7227d5d991..066b5b28f4 100644
--- a/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
+++ b/tests/auto/qdbusperformance/tst_qdbusperformance.cpp
@@ -80,6 +80,14 @@ Q_DECLARE_METATYPE(QVariant)
void tst_QDBusPerformance::initTestCase()
{
+ QDBusConnection con = QDBusConnection::sessionBus();
+ QVERIFY(con.isConnected());
+
+ QDBusServiceWatcher watcher(serviceName, con,
+ QDBusServiceWatcher::WatchForRegistration);
+ connect(&watcher, SIGNAL(serviceRegistered(QString)),
+ &QTestEventLoop::instance(), SLOT(exitLoop()));
+
#ifdef Q_OS_WIN
proc.start("server");
#else
@@ -87,19 +95,7 @@ void tst_QDBusPerformance::initTestCase()
#endif
QVERIFY(proc.waitForStarted());
- QDBusConnection con = QDBusConnection::sessionBus();
- QVERIFY(con.isConnected());
-
- connect(con.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
- &QTestEventLoop::instance(), SLOT(exitLoop()));
- QTime timer;
- timer.start();
-
- while (timer.elapsed() < 5000) {
- QTestEventLoop::instance().enterLoop(5);
- if (con.interface()->isServiceRegistered(serviceName))
- break;
- }
+ QTestEventLoop::instance().enterLoop(5);
QVERIFY(con.interface()->isServiceRegistered(serviceName));
remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 27c6809110..db80db6baf 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -4078,8 +4078,11 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsTextItem()
QCOMPARE(text->pos(), QPointF(10, 10));
+ text->setTextInteractionFlags(Qt::NoTextInteraction);
+ QVERIFY(!(text->flags() & QGraphicsItem::ItemAcceptsInputMethod));
text->setTextInteractionFlags(Qt::TextEditorInteraction);
QCOMPARE(text->textInteractionFlags(), Qt::TextInteractionFlags(Qt::TextEditorInteraction));
+ QVERIFY(text->flags() & QGraphicsItem::ItemAcceptsInputMethod);
{
QGraphicsSceneMouseEvent event2(QEvent::GraphicsSceneMouseMove);
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 0b61dcd6f6..bd83c47370 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -225,6 +225,9 @@ private Q_SLOTS:
void ioPostToHttpUploadProgress();
void ioPostToHttpEmtpyUploadProgress();
+ void lastModifiedHeaderForFile();
+ void lastModifiedHeaderForHttp();
+
void rateControl_data();
void rateControl();
@@ -2619,12 +2622,7 @@ void tst_QNetworkReply::ioPostToHttpFromSocket()
QSignalSpy authenticationRequiredSpy(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)));
QSignalSpy proxyAuthenticationRequiredSpy(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
-#ifdef Q_OS_SYMBIAN
QTestEventLoop::instance().enterLoop(6);
-#else
- QTestEventLoop::instance().enterLoop(3);
-#endif
-
disconnect(&manager, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
disconnect(&manager, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
@@ -2969,6 +2967,41 @@ void tst_QNetworkReply::ioPostToHttpEmtpyUploadProgress()
server.close();
}
+void tst_QNetworkReply::lastModifiedHeaderForFile()
+{
+ QFileInfo fileInfo(SRCDIR "./bigfile");
+ QUrl url = QUrl::fromLocalFile(fileInfo.filePath());
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply = manager.head(request);
+ QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
+ QCOMPARE(header, fileInfo.lastModified());
+}
+
+void tst_QNetworkReply::lastModifiedHeaderForHttp()
+{
+ // Tue, 22 May 2007 12:04:57 GMT according to webserver
+ QUrl url = "http://" + QtNetworkSettings::serverName() + "/gif/fluke.gif";
+
+ QNetworkRequest request(url);
+ QNetworkReplyPtr reply = manager.head(request);
+ QSignalSpy spy(reply, SIGNAL(uploadProgress(qint64,qint64)));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ QDateTime header = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime();
+ QDateTime realDate = QDateTime::fromString("2007-05-22T12:04:57", Qt::ISODate);
+ realDate.setTimeSpec(Qt::UTC);
+
+ QCOMPARE(header, realDate);
+}
+
void tst_QNetworkReply::rateControl_data()
{
QTest::addColumn<int>("rate");
diff --git a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
index 55779030ee..4ed9fcaf88 100644
--- a/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/qtcpsocket/tst_qtcpsocket.cpp
@@ -192,6 +192,8 @@ private slots:
void connectToMultiIP();
void moveToThread0();
void increaseReadBufferSize();
+ void taskQtBug5799ConnectionErrorWaitForConnected();
+ void taskQtBug5799ConnectionErrorEventLoop();
#ifdef TEST_QNETWORK_PROXY
void invalidProxy_data();
void invalidProxy();
@@ -2214,6 +2216,47 @@ void tst_QTcpSocket::increaseReadBufferSize()
delete active;
}
+void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ // check that we get a proper error connecting to port 12346
+ // use waitForConnected, e.g. this should use a synchronous select() on the OS level
+
+ QTcpSocket socket;
+ socket.connectToHost(QtNetworkSettings::serverName(), 12346);
+ QTime timer;
+ timer.start();
+ socket.waitForConnected(10000);
+ QVERIFY2(timer.elapsed() < 9900, "Connection to closed port timed out instead of refusing, something is wrong");
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+ QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
+ QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
+}
+
+void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
+{
+ QFETCH_GLOBAL(bool, setProxy);
+ if (setProxy)
+ return;
+
+ // check that we get a proper error connecting to port 12346
+ // This testcase uses an event loop
+ QTcpSocket socket;
+ connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
+ socket.connectToHost(QtNetworkSettings::serverName(), 12346);
+
+ QTestEventLoop::instance().enterLoop(10);
+ QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
+ QVERIFY2(socket.state() == QAbstractSocket::UnconnectedState, "Socket connected unexpectedly!");
+ QVERIFY2(socket.error() == QAbstractSocket::ConnectionRefusedError,
+ QString("Could not reach server: %1").arg(socket.errorString()).toLocal8Bit());
+}
+
+
+
#ifdef TEST_QNETWORK_PROXY
void tst_QTcpSocket::invalidProxy_data()
{
diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp
index c8fe4e57b0..03e77aa94f 100644
--- a/tests/auto/qurl/tst_qurl.cpp
+++ b/tests/auto/qurl/tst_qurl.cpp
@@ -3713,7 +3713,7 @@ void tst_QUrl::fromUserInput_data()
QTest::newRow("add scheme-0") << "example.org" << QUrl("http://example.org");
QTest::newRow("add scheme-1") << "www.example.org" << QUrl("http://www.example.org");
QTest::newRow("add scheme-2") << "ftp.example.org" << QUrl("ftp://ftp.example.org");
- QTest::newRow("add scheme-3") << "webkit" << QUrl("webkit");
+ QTest::newRow("add scheme-3") << "hostname" << QUrl("http://hostname");
// QUrl's tolerant parser should already handle this
QTest::newRow("not-encoded-0") << "http://example.org/test page.html" << QUrl::fromEncoded("http://example.org/test%20page.html");
@@ -3723,6 +3723,9 @@ void tst_QUrl::fromUserInput_data()
portUrl.setPort(80);
QTest::newRow("port-0") << "example.org:80" << portUrl;
QTest::newRow("port-1") << "http://example.org:80" << portUrl;
+ portUrl.setPath("path");
+ QTest::newRow("port-1") << "example.org:80/path" << portUrl;
+ QTest::newRow("port-1") << "http://example.org:80/path" << portUrl;
// mailto doesn't have a ://, but is valid
QUrl mailto("ben@example.net");
@@ -3730,10 +3733,11 @@ void tst_QUrl::fromUserInput_data()
QTest::newRow("mailto") << "mailto:ben@example.net" << mailto;
// misc
- QTest::newRow("localhost-0") << "localhost" << QUrl("http://localhost");
QTest::newRow("localhost-1") << "localhost:80" << QUrl("http://localhost:80");
QTest::newRow("spaces-0") << " http://example.org/test page.html " << QUrl("http://example.org/test%20page.html");
QTest::newRow("trash-0") << "example.org/test?someData=42%&someOtherData=abcde#anchor" << QUrl::fromEncoded("http://example.org/test?someData=42%25&someOtherData=abcde#anchor");
+ QTest::newRow("other-scheme-0") << "spotify:track:0hO542doVbfGDAGQULMORT" << QUrl("spotify:track:0hO542doVbfGDAGQULMORT");
+ QTest::newRow("other-scheme-1") << "weirdscheme:80:otherstuff" << QUrl("weirdscheme:80:otherstuff");
// FYI: The scheme in the resulting url user
QUrl authUrl("user:pass@domain.com");
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index e027dd1bf4..9692c6e4cf 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -388,6 +388,8 @@ private slots:
void cbaVisibility();
#endif
+ void focusProxyAndInputMethods();
+
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
@@ -9619,5 +9621,62 @@ void tst_QWidget::cbaVisibility()
}
#endif
+class InputContextTester : public QInputContext
+{
+ Q_OBJECT
+public:
+ QString identifierName() { return QString(); }
+ bool isComposing() const { return false; }
+ QString language() { return QString(); }
+ void reset() { ++resets; }
+ int resets;
+};
+
+void tst_QWidget::focusProxyAndInputMethods()
+{
+ InputContextTester *inputContext = new InputContextTester;
+ QWidget *toplevel = new QWidget(0, Qt::X11BypassWindowManagerHint);
+ toplevel->setAttribute(Qt::WA_InputMethodEnabled, true);
+ toplevel->setInputContext(inputContext); // ownership is transferred
+
+ QWidget *child = new QWidget(toplevel);
+ child->setFocusProxy(toplevel);
+ child->setAttribute(Qt::WA_InputMethodEnabled, true);
+
+ toplevel->setFocusPolicy(Qt::WheelFocus);
+ child->setFocusPolicy(Qt::WheelFocus);
+
+ QVERIFY(!child->hasFocus());
+ QVERIFY(!toplevel->hasFocus());
+
+ toplevel->show();
+ QTest::qWaitForWindowShown(toplevel);
+ QApplication::setActiveWindow(toplevel);
+ QVERIFY(toplevel->hasFocus());
+ QVERIFY(child->hasFocus());
+
+ // verify that toggling input methods on the child widget
+ // correctly propagate to the focus proxy's input method
+ // and that the input method gets the focus proxy passed
+ // as the focus widget instead of the child widget.
+ // otherwise input method queries go to the wrong widget
+
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+
+ child->setAttribute(Qt::WA_InputMethodEnabled, false);
+ QVERIFY(!inputContext->focusWidget());
+
+ child->setAttribute(Qt::WA_InputMethodEnabled, true);
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+
+ child->setEnabled(false);
+ QVERIFY(!inputContext->focusWidget());
+
+ child->setEnabled(true);
+ QCOMPARE(inputContext->focusWidget(), toplevel);
+
+ delete toplevel;
+}
+
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
index a7945f05f8..b620e0504f 100644
--- a/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
+++ b/tests/auto/xmlpatterns/stderrBaselines/Anunboundexternalvariable.txt
@@ -1 +1 @@
-Error XPST0008 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/externalVariable.xq, at line 1, column 69: No variable by name externalVariable exists
+Error XPST0008 in file:///home/fenglich/dev/qt-xslt/tests/auto/xmlpatterns/queries/externalVariable.xq, at line 1, column 69: No variable with name externalVariable exists
diff --git a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
index 22f66930ee..ff7c8c0b04 100644
--- a/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
+++ b/tests/auto/xmlpatterns/tst_xmlpatterns.cpp
@@ -160,7 +160,9 @@ void tst_XmlPatterns::xquerySupport()
QCOMPARE(process.exitCode(), expectedExitCode);
const QByteArray rawProducedStderr((process.readAllStandardError()));
- const QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr));
+ QString fixedStderr(QString::fromLocal8Bit(rawProducedStderr).remove(m_filenameInStderr));
+ // convert Windows line endings to Unix ones
+ fixedStderr.replace("\r\n", "\n");
const QString errorFileName(inputFile(QLatin1String(SRCDIR "stderrBaselines/") +
QString::fromUtf8(QTest::currentDataTag()).remove(m_normalizeTestName) +