diff options
| -rw-r--r-- | src/client/QXmppRegistrationManager.cpp | 2 | ||||
| -rw-r--r-- | tests/qxmppregistrationmanager/tst_qxmppregistrationmanager.cpp | 24 |
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; } |
