aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelvin Keskin <melvo@olomono.de>2020-02-24 11:20:30 +0100
committerLNJ <lnj@kaidan.im>2020-03-24 20:15:21 +0100
commit0b616178800ccb4e5d344cd66b8f1ab9f5d3b698 (patch)
tree530a603ad9c3eaeade672fbac41e09b4295b6e9c
parente32f3c6c226b6dba6d84c0401b5587d0356ea7be (diff)
downloadqxmpp-0b616178800ccb4e5d344cd66b8f1ab9f5d3b698.tar.gz
Fix switch statement when handling IQ stanza for registration
-rw-r--r--src/client/QXmppRegistrationManager.cpp2
-rw-r--r--tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp24
2 files changed, 15 insertions, 11 deletions
diff --git a/src/client/QXmppRegistrationManager.cpp b/src/client/QXmppRegistrationManager.cpp
index d43a82e5..da220bf0 100644
--- a/src/client/QXmppRegistrationManager.cpp
+++ b/src/client/QXmppRegistrationManager.cpp
@@ -228,9 +228,11 @@ bool QXmppRegistrationManager::handleStanza(const QDomElement &stanza)
case QXmppIq::Result:
info(QStringLiteral("Successfully registered with the service."));
emit registrationSucceeded();
+ break;
case QXmppIq::Error:
warning(QStringLiteral("Registering with the service failed: ").append(iq.error().text()));
emit registrationFailed(iq.error());
+ break;
default:
break; // should never occur
}
diff --git a/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp b/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp
index 077b65d4..15ecde95 100644
--- a/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp
+++ b/tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp
@@ -350,17 +350,17 @@ void tst_QXmppRegistrationManager::testRegistrationResult()
registrationRequestForm.setEmail(QStringLiteral("1234@example.org"));
registrationRequestForm.setId(QStringLiteral("register1"));
- bool signalCalled = false;
+ bool succeededSignalCalled = false;
+ bool failedSignalCalled = false;
+
QObject *context = new QObject(this);
- if (isSuccess) {
- connect(manager, &QXmppRegistrationManager::registrationSucceeded, context, [&]() {
- signalCalled = true;
- });
- } else {
- connect(manager, &QXmppRegistrationManager::registrationFailed, context, [&](const QXmppStanza::Error &) {
- signalCalled = true;
- });
- }
+
+ connect(manager, &QXmppRegistrationManager::registrationSucceeded, context, [&]() {
+ succeededSignalCalled = true;
+ });
+ connect(manager, &QXmppRegistrationManager::registrationFailed, context, [&](const QXmppStanza::Error &) {
+ failedSignalCalled = true;
+ });
manager->setRegistrationFormToSend(registrationRequestForm);
manager->sendCachedRegistrationForm();
@@ -370,7 +370,9 @@ void tst_QXmppRegistrationManager::testRegistrationResult()
manager->handleStanza(writePacketToDom(serverResult));
- QVERIFY(signalCalled);
+ QCOMPARE(succeededSignalCalled, isSuccess);
+ QCOMPARE(failedSignalCalled, !isSuccess);
+
delete context;
}