blob: f8059a6cf340cfcc5844bbd51af3bb409b51141a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// SPDX-FileCopyrightText: 2020 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef PUBSUBUTIL_H
#define PUBSUBUTIL_H
#include "QXmppPubSubBaseItem.h"
#include <QDomElement>
#include <QXmlStreamWriter>
#include <QtTest/QTest>
class TestItem : public QXmppPubSubBaseItem
{
public:
TestItem(const QString &id = {})
: QXmppPubSubBaseItem(id)
{
}
void parsePayload(const QDomElement &payloadElement) override
{
parseCalled = true;
QCOMPARE(payloadElement.tagName(), QStringLiteral("test-payload"));
}
void serializePayload(QXmlStreamWriter *writer) const override
{
serializeCalled = true;
writer->writeEmptyElement("test-payload");
}
static bool isItem(const QDomElement &element)
{
isItemCalled = true;
return QXmppPubSubBaseItem::isItem(element, [](const QDomElement &payload) {
return payload.tagName() == "test-payload";
});
}
bool parseCalled = false;
mutable bool serializeCalled = false;
static bool isItemCalled;
};
bool TestItem::isItemCalled = false;
#endif // PUBSUBUTIL_H
|