blob: ebcfd18cee3a50cc9223b8b88fb418166bc2660b (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
* Copyright (C) 2008-2019 The QXmpp developers
*
* Authors:
* Linus Jahn <lnj@kaidan.im>
*
* Source:
* https://github.com/qxmpp-project/qxmpp
*
* This file is a part of QXmpp library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#include <QObject>
#include "QXmppClient.h"
#include "QXmppMessageReceiptManager.h"
#include "util.h"
class tst_QXmppMessageReceiptManager : public QObject
{
Q_OBJECT
private slots:
void initTestCase();
void testReceipt_data();
void testReceipt();
void handleMessageDelivered(const QString&, const QString&)
{
m_messageDelivered = true;
}
private:
QXmppMessageReceiptManager m_manager;
bool m_messageDelivered = false;
};
void tst_QXmppMessageReceiptManager::initTestCase()
{
connect(&m_manager, &QXmppMessageReceiptManager::messageDelivered,
this, &tst_QXmppMessageReceiptManager::handleMessageDelivered);
}
void tst_QXmppMessageReceiptManager::testReceipt_data()
{
QTest::addColumn<QByteArray>("xml");
QTest::addColumn<bool>("accept");
QTest::newRow("correct")
<< QByteArray(
"<message id=\"bi29sg183b4v\" "
"to=\"northumberland@shakespeare.lit/westminster\" "
"from=\"kingrichard@royalty.england.lit/throne\" "
"type=\"normal\">"
"<received xmlns=\"urn:xmpp:receipts\" id=\"richard2-4.1.247\"/>"
"</message>"
)
<< true;
QTest::newRow("from-to-equal")
<< QByteArray(
"<message id=\"bi29sg183b4v\" "
"to=\"kingrichard@royalty.england.lit/westminster\" "
"from=\"kingrichard@royalty.england.lit/throne\" "
"type=\"normal\">"
"<received xmlns=\"urn:xmpp:receipts\" id=\"richard2-4.1.247\"/>"
"</message>"
)
<< false;
}
void tst_QXmppMessageReceiptManager::testReceipt()
{
m_messageDelivered = false;
QFETCH(QByteArray, xml);
QFETCH(bool, accept);
QDomDocument doc;
QCOMPARE(doc.setContent(xml, true), true);
QDomElement element = doc.documentElement();
QVERIFY(m_manager.handleStanza(element));
QCOMPARE(m_messageDelivered, accept);
}
QTEST_MAIN(tst_QXmppMessageReceiptManager)
#include "tst_qxmppmessagereceiptmanager.moc"
|