|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
Helpers shared by the Sonde unit tests: event-loop waiting and in-process MCP clients for the local-socket and HTTP transports. More...
#include <QtCore/QByteArray>#include <QtCore/QCoreApplication>#include <QtCore/QElapsedTimer>#include <QtCore/QEventLoop>#include <QtCore/QHash>#include <QtCore/QJsonArray>#include <QtCore/QJsonDocument>#include <QtCore/QJsonObject>#include <QtCore/QList>#include <QtCore/QTimer>#include <QtNetwork/QLocalSocket>#include <QtNetwork/QTcpSocket>#include <functional>#include <memory>Go to the source code of this file.
Classes | |
| class | SondeTest::LocalClient |
| Minimal MCP client speaking newline-delimited JSON over QLocalSocket. More... | |
| struct | SondeTest::HttpResponse |
| A parsed HTTP response. More... | |
| class | SondeTest::HttpClient |
| MCP client for the Streamable HTTP transport. More... | |
| class | SondeTest::SseStream |
| An open server-sent-events stream (GET /mcp). More... | |
Functions | |
| void | SondeTest::reportCrashesOnStderr () |
| For the tests' main(): on Windows, sends the C runtime's reports (qFatal() and failed assertions in a debug build) to stderr, and stops abort() from asking Windows Error Reporting, so a test that dies (a death test, or an assertion) ends at once instead of waiting for a click on a dialog. | |
| bool | SondeTest::waitUntil (const std::function< bool()> &predicate, int timeoutMs=5000) |
Runs the event loop until predicate is true or timeoutMs expires. | |
| void | SondeTest::spin (int ms) |
Runs the event loop for ms milliseconds. | |
| QString | SondeTest::uniqueName (const QString &prefix) |
| Returns a process-unique name with the given prefix (for sockets). | |
| QString | SondeTest::resultText (const QJsonObject &toolResult) |
| Concatenates the text blocks of a tool result's content array. | |
| QList< HttpResponse > | SondeTest::rawHttp (quint16 port, const QByteArray &request, int count=1, int timeoutMs=5000) |
Sends raw request bytes over a fresh connection and reads count responses. | |
| HttpResponse | SondeTest::http (quint16 port, const QByteArray &method, const QByteArray &path, const QList< QPair< QByteArray, QByteArray > > &headers={ }, const QByteArray &body={ }, int timeoutMs=5000) |
| Sends one HTTP request and returns its response. | |
Helpers shared by the Sonde unit tests: event-loop waiting and in-process MCP clients for the local-socket and HTTP transports.
| void SondeTest::reportCrashesOnStderr | ( | ) |
For the tests' main(): on Windows, sends the C runtime's reports (qFatal() and failed assertions in a debug build) to stderr, and stops abort() from asking Windows Error Reporting, so a test that dies (a death test, or an assertion) ends at once instead of waiting for a click on a dialog.
Does nothing elsewhere.
| bool SondeTest::waitUntil | ( | const std::function< bool()> & | predicate, |
| int | timeoutMs = 5000 ) |
Runs the event loop until predicate is true or timeoutMs expires.