Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qtest_network.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTEST_NETWORK_H
5#define QTEST_NETWORK_H
6
7#include <QtTest/qtesttostring.h>
8
9// enable NETWORK features
10#ifndef QT_NETWORK_LIB
11#define QT_NETWORK_LIB
12#endif
13
14#if 0
15#pragma qt_class(QtTestNetwork)
16#endif
17
18#include <QtNetwork/QHostAddress>
19#include <QtNetwork/QNetworkCookie>
20#include <QtNetwork/QNetworkReply>
21
22#if 0
23// inform syncqt
24#pragma qt_no_master_include
25#endif
26
28
29namespace QTest
30{
31template<>
33{
34 switch (addr.protocol()) {
36 return qstrdup("<unknown address (parse error)>");
38 return qstrdup("QHostAddress::Any");
41 break;
42 }
43
44 return toString(addr.toString());
45}
46} // namespace QTest
47
49{
50 const QMetaObject *mo = &QNetworkReply::staticMetaObject;
51 int index = mo->indexOfEnumerator("NetworkError");
52 if (index == -1)
53 return qstrdup("");
54
55 QMetaEnum qme = mo->enumerator(index);
56 return qstrdup(qme.valueToKey(code));
57}
58
59inline char *toString(const QNetworkCookie &cookie)
60{
61 return QTest::toString(cookie.toRawForm());
62}
63
64inline char *toString(const QList<QNetworkCookie> &list)
65{
66 QByteArray result = "QList(";
67 if (!list.isEmpty()) {
68 for (const QNetworkCookie &cookie : list)
69 result += "QNetworkCookie(" + cookie.toRawForm() + "), ";
70 result.chop(2); // remove trailing ", "
71 }
72 result.append(')');
73 return QTest::toString(result);
74}
75
77
78#endif
static constexpr auto IPv4Protocol
static constexpr auto UnknownNetworkLayerProtocol
static constexpr auto AnyIPProtocol
static constexpr auto IPv6Protocol
\inmodule QtCore
Definition qbytearray.h:57
void chop(qsizetype n)
Removes n bytes from the end of the byte array.
The QHostAddress class provides an IP address.
bool isEmpty() const noexcept
Definition qlist.h:401
\inmodule QtCore
The QNetworkCookie class holds one network cookie.
QByteArray toRawForm(RawForm form=Full) const
Returns the raw form of this QNetworkCookie.
NetworkError
Indicates all possible error conditions found during the processing of the request.
auto mo
[7]
Combined button and popup list for selecting options.
char * toString(const MyPoint &point)
char * toString< QHostAddress >(const QHostAddress &addr)
Q_CORE_EXPORT char * qstrdup(const char *)
GLuint index
[2]
GLenum const void * addr
GLuint64EXT * result
[6]
char * toString(QNetworkReply::NetworkError code)
QList< int > list
[14]
\inmodule QtCore