summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTarja Sundqvist <[email protected]>2025-01-16 20:54:09 +0200
committerTarja Sundqvist <[email protected]>2025-01-16 20:54:09 +0200
commita62a93331ff59e762b0f7d26051a8cb6afdd2ce5 (patch)
tree6745bacbe14b85a4d81000e8770d34a248165dea /tests
parent77c4670a926c461d182db33242edac779f9e44d2 (diff)
parent45c01c6e389f639948db46d627b0b378565aeda6 (diff)
Merge branch 'tqtc/lts-6.2-opensource' into 6.2.116.2.11
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/auto/core/CMakeLists.txt2
-rw-r--r--tests/auto/core/certificateerror/tst_certificateerror.cpp1
-rw-r--r--tests/auto/httpserver/httpserver.cpp3
-rw-r--r--tests/auto/httpserver/httpsserver.h71
-rw-r--r--tests/auto/quick/qmltests/tst_qmltests.cpp2
-rw-r--r--tests/auto/widgets/accessibility/tst_accessibility.cpp53
-rw-r--r--tests/manual/quick/touchbrowser/touchmockingapplication.cpp32
8 files changed, 106 insertions, 62 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 9e02c40ca..a8f031a5d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,3 +1 @@
-if(Qt6Core_VERSION VERSION_GREATER_EQUAL "6.5")
- qt_build_tests()
-endif()
+qt_build_tests()
diff --git a/tests/auto/core/CMakeLists.txt b/tests/auto/core/CMakeLists.txt
index 5615d6b2d..4e8d5f128 100644
--- a/tests/auto/core/CMakeLists.txt
+++ b/tests/auto/core/CMakeLists.txt
@@ -7,7 +7,7 @@ add_subdirectory(qwebengineurlrequestinterceptor)
add_subdirectory(origins)
add_subdirectory(devtools)
-if(QT_FEATURE_ssl)
+if(QT_FEATURE_ssl AND QT_VERSION VERSION_GREATER_EQUAL "6.4")
add_subdirectory(qwebengineclientcertificatestore)
add_subdirectory(certificateerror)
endif()
diff --git a/tests/auto/core/certificateerror/tst_certificateerror.cpp b/tests/auto/core/certificateerror/tst_certificateerror.cpp
index 67e2d8ae4..fd22f5d63 100644
--- a/tests/auto/core/certificateerror/tst_certificateerror.cpp
+++ b/tests/auto/core/certificateerror/tst_certificateerror.cpp
@@ -105,7 +105,6 @@ void tst_CertificateError::handleError()
QTRY_COMPARE_WITH_TIMEOUT(page.loadSpy.size(), 1, 30000);
QCOMPARE(page.loadSpy.takeFirst().value(0).toBool(), acceptCertificate);
QCOMPARE(toPlainTextSync(&page), expectedContent);
- QVERIFY(server.stop());
}
void tst_CertificateError::fatalError()
diff --git a/tests/auto/httpserver/httpserver.cpp b/tests/auto/httpserver/httpserver.cpp
index e08af77e7..c65d68ce7 100644
--- a/tests/auto/httpserver/httpserver.cpp
+++ b/tests/auto/httpserver/httpserver.cpp
@@ -24,8 +24,7 @@ HttpServer::HttpServer(QTcpServer *tcpServer, const QString &protocol,
{
m_url.setHost(hostAddress.toString());
m_url.setScheme(protocol);
- connect(tcpServer, &QTcpServer::pendingConnectionAvailable, this,
- &HttpServer::handleNewConnection);
+ connect(tcpServer, &QTcpServer::newConnection, this, &HttpServer::handleNewConnection);
}
HttpServer::~HttpServer()
diff --git a/tests/auto/httpserver/httpsserver.h b/tests/auto/httpserver/httpsserver.h
index 10deeb322..d064c1416 100644
--- a/tests/auto/httpserver/httpsserver.h
+++ b/tests/auto/httpserver/httpsserver.h
@@ -7,56 +7,51 @@
#include "httpserver.h"
#include <QDebug>
-#include <QtCore/qfile.h>
-#include <QtNetwork/qsslkey.h>
-#include <QtNetwork/qsslsocket.h>
-#include <QtNetwork/qsslconfiguration.h>
-#include <QtNetwork/qsslserver.h>
+#include <QFile>
+#include <QSslKey>
+#include <QSslSocket>
+#include <QSslConfiguration>
+#include <QTcpServer>
-static QSslServer *createServer(const QString &certificateFileName, const QString &keyFileName,
- const QString &ca)
+struct SslTcpServer : QTcpServer
{
- QSslConfiguration configuration(QSslConfiguration::defaultConfiguration());
+ SslTcpServer(const QString &certPath, const QString &keyPath) {
+ sslconf.setLocalCertificateChain(QSslCertificate::fromPath(certPath));
+ sslconf.setPrivateKey(readKey(keyPath));
+ }
+
+ void incomingConnection(qintptr d) override {
+ auto socket = new QSslSocket(this);
+ socket->setSslConfiguration(sslconf);
- QFile keyFile(keyFileName);
- if (keyFile.open(QIODevice::ReadOnly)) {
- QSslKey key(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
- if (!key.isNull()) {
- configuration.setPrivateKey(key);
- } else {
- qCritical() << "Could not parse key: " << keyFileName;
+ if (!socket->setSocketDescriptor(d)) {
+ qWarning() << "Failed to setup ssl socket!";
+ delete socket;
+ return;
}
- } else {
- qCritical() << "Could not find key: " << keyFileName;
- }
- QList<QSslCertificate> localCerts = QSslCertificate::fromPath(certificateFileName);
- if (!localCerts.isEmpty()) {
- configuration.setLocalCertificateChain(localCerts);
- } else {
- qCritical() << "Could not find certificate: " << certificateFileName;
+ connect(socket, QOverload<QSslSocket::SocketError>::of(&QSslSocket::errorOccurred),
+ [] (QSslSocket::SocketError e) { qWarning() << "! Socket Error:" << e; });
+ connect(socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors),
+ [] (const QList<QSslError> &le) { qWarning() << "! SSL Errors:\n" << le; });
+
+ addPendingConnection(socket);
+ socket->startServerEncryption();
}
- if (!ca.isEmpty()) {
- QList<QSslCertificate> caCerts = QSslCertificate::fromPath(ca);
- if (!caCerts.isEmpty()) {
- configuration.addCaCertificates(caCerts);
- configuration.setPeerVerifyMode(QSslSocket::VerifyPeer);
- } else {
- qCritical() << "Could not find certificate: " << certificateFileName;
- }
+ QSslKey readKey(const QString &path) const {
+ QFile file(path);
+ file.open(QIODevice::ReadOnly);
+ return QSslKey(file.readAll(), QSsl::Rsa, QSsl::Pem);
}
- QSslServer *server = new QSslServer();
- server->setSslConfiguration(configuration);
- return server;
-}
+ QSslConfiguration sslconf;
+};
struct HttpsServer : HttpServer
{
- HttpsServer(const QString &certPath, const QString &keyPath, const QString &ca,
- QObject *parent = nullptr)
- : HttpServer(createServer(certPath, keyPath, ca), "https", QHostAddress::LocalHost, 0,
+ HttpsServer(const QString &certPath, const QString &keyPath, QObject *parent = nullptr)
+ : HttpServer(new SslTcpServer(certPath, keyPath), "https", QHostAddress::LocalHost, 0,
parent)
{
}
diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp
index 9e928157e..d27ef269d 100644
--- a/tests/auto/quick/qmltests/tst_qmltests.cpp
+++ b/tests/auto/quick/qmltests/tst_qmltests.cpp
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
#if QT_CONFIG(ssl)
qmlRegisterSingletonType<HttpsServer>(
"Test.Shared", 1, 0, "HttpsServer", [&](QQmlEngine *, QJSEngine *) {
- return new HttpsServer(":/resources/server.pem", ":/resources/server.key", "");
+ return new HttpsServer(":/resources/server.pem", ":/resources/server.key");
});
#endif
Setup setup;
diff --git a/tests/auto/widgets/accessibility/tst_accessibility.cpp b/tests/auto/widgets/accessibility/tst_accessibility.cpp
index 68566c082..f2cd4d05d 100644
--- a/tests/auto/widgets/accessibility/tst_accessibility.cpp
+++ b/tests/auto/widgets/accessibility/tst_accessibility.cpp
@@ -50,6 +50,7 @@ private Q_SLOTS:
void roles();
void objectName();
void crossTreeParent();
+ void tableCellInterface();
};
// This will be called before the first test function is executed.
@@ -605,6 +606,58 @@ void tst_Accessibility::crossTreeParent()
QCOMPARE(p->object()->objectName(), QStringLiteral("my_id"));
}
+void tst_Accessibility::tableCellInterface()
+{
+ QWebEngineView webView;
+ webView.resize(400, 400);
+ webView.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&webView));
+
+ QSignalSpy spyFinished(&webView, &QWebEngineView::loadFinished);
+ webView.setHtml(QLatin1String(
+ "<html><body>"
+ " <ul>"
+ " <li><a href='#link1' id='link1'>Link in ListItem</a></li>"
+ " </ul>"
+ ""
+ " <div role='rowgroup'>"
+ " <div role='row'>"
+ " <span role='cell'><a href='#link2' id='link2'>Link in Cell</a></span>"
+ " </div>"
+ " </div>"
+ "</body></html>"));
+ QTRY_COMPARE(spyFinished.size(), 1);
+
+ QAccessibleInterface *view = QAccessible::queryAccessibleInterface(&webView);
+ QAccessibleInterface *document = view->child(0);
+ QTRY_COMPARE(document->childCount(), 2);
+
+ // ListItem without Table parent.
+ {
+ QAccessibleInterface *list = document->child(0);
+ QAccessibleInterface *listItem = list->child(0);
+ QVERIFY(!listItem->tableCellInterface());
+
+ // Should not crash.
+ QPoint linkCenter = elementCenter(webView.page(), QLatin1String("link1"));
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, linkCenter);
+ QTRY_COMPARE(webView.url().fragment(), QLatin1String("link1"));
+ }
+
+ // Cell without Table parent.
+ {
+ QAccessibleInterface *rowgroup = document->child(1);
+ QAccessibleInterface *row = rowgroup->child(0);
+ QAccessibleInterface *cell = row->child(0);
+ QVERIFY(!cell->tableCellInterface());
+
+ // Should not crash.
+ QPoint linkCenter = elementCenter(webView.page(), QLatin1String("link2"));
+ QTest::mouseClick(webView.focusProxy(), Qt::LeftButton, {}, linkCenter);
+ QTRY_COMPARE(webView.url().fragment(), QLatin1String("link2"));
+ }
+}
+
static QByteArrayList params = QByteArrayList()
<< "--force-renderer-accessibility"
<< "--enable-features=AccessibilityExposeARIAAnnotations";
diff --git a/tests/manual/quick/touchbrowser/touchmockingapplication.cpp b/tests/manual/quick/touchbrowser/touchmockingapplication.cpp
index 4fad86d33..2a17757dc 100644
--- a/tests/manual/quick/touchbrowser/touchmockingapplication.cpp
+++ b/tests/manual/quick/touchbrowser/touchmockingapplication.cpp
@@ -66,10 +66,10 @@ bool TouchMockingApplication::notify(QObject* target, QEvent* event)
if (event->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Control) {
foreach (int id, m_heldTouchPoints)
if (m_touchPoints.contains(id) && !QGuiApplication::mouseButtons().testFlag(Qt::MouseButton(id))) {
- QMutableEventPoint::setState(m_touchPoints[id], QEventPoint::Released);
+ QMutableEventPoint::from(m_touchPoints[id]).setState(QEventPoint::Released);
m_heldTouchPoints.remove(id);
} else
- QMutableEventPoint::setState(m_touchPoints[id], QEventPoint::Stationary);
+ QMutableEventPoint::from(m_touchPoints[id]).setState(QEventPoint::Stationary);
sendTouchEvent(window, m_heldTouchPoints.isEmpty() ? QEvent::TouchEnd : QEvent::TouchUpdate, static_cast<QKeyEvent*>(event)->timestamp());
}
@@ -78,18 +78,18 @@ bool TouchMockingApplication::notify(QObject* target, QEvent* event)
const QMouseEvent* const mouseEvent = static_cast<QMouseEvent*>(event);
QEventPoint touchPoint;
- QMutableEventPoint::setPressure(touchPoint, 1);
+ QMutableEventPoint::from(touchPoint).setPressure(1);
QEvent::Type touchType = QEvent::None;
switch (mouseEvent->type()) {
case QEvent::MouseButtonPress:
- QMutableEventPoint::setId(touchPoint, mouseEvent->button());
+ QMutableEventPoint::from(touchPoint).setId(mouseEvent->button());
if (m_touchPoints.contains(touchPoint.id())) {
- QMutableEventPoint::setState(touchPoint, QEventPoint::Updated);
+ QMutableEventPoint::from(touchPoint).setState(QEventPoint::Updated);
touchType = QEvent::TouchUpdate;
} else {
- QMutableEventPoint::setState(touchPoint, QEventPoint::Pressed);
+ QMutableEventPoint::from(touchPoint).setState(QEventPoint::Pressed);
// Check if more buttons are held down than just the event triggering one.
if (mouseEvent->buttons() > mouseEvent->button())
touchType = QEvent::TouchUpdate;
@@ -107,8 +107,8 @@ bool TouchMockingApplication::notify(QObject* target, QEvent* event)
return true;
}
touchType = QEvent::TouchUpdate;
- QMutableEventPoint::setId(touchPoint, mouseEvent->buttons());
- QMutableEventPoint::setState(touchPoint, QEventPoint::Updated);
+ QMutableEventPoint::from(touchPoint).setId(mouseEvent->buttons());
+ QMutableEventPoint::from(touchPoint).setState(QEventPoint::Updated);
break;
case QEvent::MouseButtonRelease:
// Check if any buttons are still held down after this event.
@@ -116,8 +116,8 @@ bool TouchMockingApplication::notify(QObject* target, QEvent* event)
touchType = QEvent::TouchUpdate;
else
touchType = QEvent::TouchEnd;
- QMutableEventPoint::setId(touchPoint, mouseEvent->button());
- QMutableEventPoint::setState(touchPoint, QEventPoint::Released);
+ QMutableEventPoint::from(touchPoint).setId(mouseEvent->button());
+ QMutableEventPoint::from(touchPoint).setState(QEventPoint::Released);
break;
case QEvent::MouseButtonDblClick:
// Eat double-clicks, their accompanying press event is all we need.
@@ -146,7 +146,7 @@ bool TouchMockingApplication::notify(QObject* target, QEvent* event)
// Update states for all other touch-points
for (QHash<int, QEventPoint>::iterator it = m_touchPoints.begin(), end = m_touchPoints.end(); it != end; ++it) {
if (!(it.value().id() & touchPoint.id()))
- QMutableEventPoint::setState(it.value(), QEventPoint::Stationary);
+ QMutableEventPoint::from(it.value()).setState(QEventPoint::Stationary);
}
Q_ASSERT(touchType != QEvent::None);
@@ -177,18 +177,18 @@ void TouchMockingApplication::updateTouchPoint(const QMouseEvent* mouseEvent, QE
// but since the canvas translates touch events we actually need to pass
// the screen position as the scene position to deliver the appropriate
// coordinates to the target.
- QMutableEventPoint::setPosition(touchPoint, mouseEvent->position());
- QMutableEventPoint::setScenePosition(touchPoint, mouseEvent->globalPosition());
+ QMutableEventPoint::from(touchPoint).setPosition(mouseEvent->position());
+ QMutableEventPoint::from(touchPoint).setScenePosition(mouseEvent->globalPosition());
if (touchPoint.state() == QEventPoint::Pressed)
- QMutableEventPoint::setScenePosition(touchPoint, mouseEvent->scenePosition());
+ QMutableEventPoint::from(touchPoint).setScenePosition(mouseEvent->scenePosition());
else {
const QEventPoint& oldTouchPoint = m_touchPoints[mouseButton];
- QMutableEventPoint::setGlobalLastPosition(touchPoint, oldTouchPoint.globalPosition());
+ QMutableEventPoint::from(touchPoint).setGlobalLastPosition(oldTouchPoint.globalPosition());
}
// Update current touch-point.
- QMutableEventPoint::setId(touchPoint, mouseButton);
+ QMutableEventPoint::from(touchPoint).setId(mouseButton);
m_touchPoints.insert(mouseButton, touchPoint);
}