aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2020-02-06 11:49:26 +0100
committerLNJ <lnj@kaidan.im>2020-02-06 12:17:01 +0100
commitfd0e02233f925cff699c08b135887a09bdc16e5c (patch)
tree5eeb54d9c5824d372980a3f50571fbb00d03610c /tests
parentdee612210008007a9c011b96081605f6e692287d (diff)
downloadqxmpp-fd0e02233f925cff699c08b135887a09bdc16e5c.tar.gz
QXmppRegistrationManager: Handle result of deleteAccount()
This adds two signals to make the result easily available to the user.
Diffstat (limited to 'tests')
-rw-r--r--tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp63
1 files changed, 60 insertions, 3 deletions
diff --git a/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp b/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp
index a4809ee4..077b65d4 100644
--- a/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp
+++ b/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp
@@ -67,6 +67,8 @@ private slots:
void testRegistrationResult();
void testChangePasswordResult_data();
void testChangePasswordResult();
+ void testDeleteAccountResult_data();
+ void testDeleteAccountResult();
void testRegistrationFormReceived();
void sendStreamFeaturesToManager(bool registrationEnabled = true);
@@ -152,9 +154,7 @@ void tst_QXmppRegistrationManager::testDeleteAccount()
delete context; // disconnects lambda
});
- const QString id = manager->deleteAccount();
- // we're not connnected, so the id should be null
- QVERIFY(id.isNull());
+ manager->deleteAccount();
}
void tst_QXmppRegistrationManager::testRequestRegistrationForm_data()
@@ -431,6 +431,63 @@ void tst_QXmppRegistrationManager::testChangePasswordResult()
delete resultContext;
}
+void tst_QXmppRegistrationManager::testDeleteAccountResult_data()
+{
+ QTest::addColumn<bool>("isSuccess");
+
+#define ROW(name, isSuccess) \
+ QTest::newRow(name) << isSuccess
+
+ ROW("success", true);
+ ROW("error", false);
+
+#undef ROW
+}
+
+void tst_QXmppRegistrationManager::testDeleteAccountResult()
+{
+ QFETCH(bool, isSuccess);
+
+ QString deleteAccountRequestIqId;
+
+ bool requestSentSignalCalled = false;
+ QObject *requestSentSignalContext = new QObject(this);
+ connect(&logger, &QXmppLogger::message, requestSentSignalContext, [&](QXmppLogger::MessageType type, const QString &text) {
+ if (type == QXmppLogger::SentMessage) {
+ requestSentSignalCalled = true;
+
+ QXmppIq parsedIq;
+ parsePacket(parsedIq, text.toUtf8());
+ deleteAccountRequestIqId = parsedIq.id();
+ }
+ });
+
+ manager->deleteAccount();
+ QVERIFY(requestSentSignalCalled);
+ QVERIFY(!deleteAccountRequestIqId.isEmpty());
+ delete requestSentSignalContext;
+
+ bool resultSignalCalled = false;
+ QObject *resultContext = new QObject(this);
+ if (isSuccess) {
+ connect(manager, &QXmppRegistrationManager::accountDeleted, resultContext, [&]() {
+ resultSignalCalled = true;
+ });
+ } else {
+ connect(manager, &QXmppRegistrationManager::accountDeletionFailed, resultContext, [&](QXmppStanza::Error) {
+ resultSignalCalled = true;
+ });
+ }
+
+ QXmppIq serverResult(isSuccess ? QXmppIq::Result : QXmppIq::Error);
+ serverResult.setId(deleteAccountRequestIqId);
+
+ manager->handleStanza(writePacketToDom(serverResult));
+
+ QVERIFY(resultSignalCalled);
+ delete resultContext;
+}
+
void tst_QXmppRegistrationManager::testRegistrationFormReceived()
{
QXmppRegisterIq iq;