summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/access
diff options
context:
space:
mode:
authorMatthias Rauter <matthias.rauter@qt.io>2024-02-20 16:30:59 +0100
committerMatthias Rauter <matthias.rauter@qt.io>2024-03-04 20:14:36 +0100
commit3f26fdebbc75ceb30bd15bf4ef0059aea04c96c4 (patch)
tree5e93f9063fc01548275b602da347600056c6e47a /tests/auto/network/access
parent302823d73b8ca27e67e703de8316092d8b4d5715 (diff)
Implement ping reply in QHttp2Connection and add test
Fixes: QTBUG-122338 Change-Id: I1e8dfa8a93c45dbe12a628d4d5e79d494d8f6032 Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/network/access')
-rw-r--r--tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp b/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp
index d9641c7391..92077efa42 100644
--- a/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp
+++ b/tests/auto/network/access/qhttp2connection/tst_qhttp2connection.cpp
@@ -20,6 +20,7 @@ private slots:
void construct();
void constructStream();
void testSETTINGSFrame();
+ void testPING();
void connectToServer();
void WINDOW_UPDATE();
@@ -257,6 +258,35 @@ void tst_QHttp2Connection::testSETTINGSFrame()
}
}
+void tst_QHttp2Connection::testPING()
+{
+ auto [client, server] = makeFakeConnectedSockets();
+ auto connection = makeHttp2Connection(client.get(), {}, Client);
+ auto serverConnection = makeHttp2Connection(server.get(), {}, Server);
+
+ QVERIFY(waitForSettingsExchange(connection, serverConnection));
+
+ QSignalSpy serverPingSpy{ serverConnection, &QHttp2Connection::pingFrameRecived };
+ QSignalSpy clientPingSpy{ connection, &QHttp2Connection::pingFrameRecived };
+
+ QByteArray data{"pingpong"};
+ connection->sendPing(data);
+
+ QVERIFY(serverPingSpy.wait());
+ QVERIFY(clientPingSpy.wait());
+
+ QCOMPARE(serverPingSpy.last().at(0).toInt(), int(QHttp2Connection::PingState::Ping));
+ QCOMPARE(clientPingSpy.last().at(0).toInt(), int(QHttp2Connection::PingState::PongSignatureIdentical));
+
+ serverConnection->sendPing();
+
+ QVERIFY(clientPingSpy.wait());
+ QVERIFY(serverPingSpy.wait());
+
+ QCOMPARE(clientPingSpy.last().at(0).toInt(), int(QHttp2Connection::PingState::Ping));
+ QCOMPARE(serverPingSpy.last().at(0).toInt(), int(QHttp2Connection::PingState::PongSignatureIdentical));
+}
+
void tst_QHttp2Connection::connectToServer()
{
auto [client, server] = makeFakeConnectedSockets();