void testQOfonoMessageWaitingSet() { QSignalSpy waiting(m, SIGNAL(voicemailWaitingChanged(bool))); QSignalSpy messageCount(m, SIGNAL(voicemailMessageCountChanged(int))); QSignalSpy mailboxNumber(m, SIGNAL(voicemailMailboxNumberChanged(QString))); QSignalSpy setNumberComplete(m, SIGNAL(voicemailMailboxComplete(bool))); QString number = m->voicemailMailboxNumber(); m->setVoicemailMailboxNumber(""); QTRY_COMPARE(setNumberComplete.count(), 1); QCOMPARE(setNumberComplete.takeFirst().at(0).toBool(), false); m->setVoicemailMailboxNumber("1234"); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), QString("1234")); QTRY_COMPARE(setNumberComplete.count(), 1); QCOMPARE(setNumberComplete.takeFirst().at(0).toBool(), true); m->setVoicemailMailboxNumber(number); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), number); QTRY_COMPARE(setNumberComplete.count(), 1); QCOMPARE(setNumberComplete.takeFirst().at(0).toBool(), true); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(waiting.count(), 0); QCOMPARE(messageCount.count(), 0); QCOMPARE(mailboxNumber.count(), 0); }
void QOfonoMessageWaiting::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("VoicemailWaiting")) { Q_EMIT voicemailWaitingChanged(value.toBool()); } else if (property == QLatin1String("VoicemailMessageCount")) { Q_EMIT voicemailMessageCountChanged(value.toInt()); } else if (property == QLatin1String("VoicemailMailboxNumber")) { Q_EMIT voicemailMailboxNumberChanged(value.toString()); } }
void QOfonoMessageWaiting::updateProperty(const QString& property, const QVariant& value) { QVariant old = d_ptr->properties.value(property); d_ptr->properties.insert(property,value); if (qofono::safeVariantEq(old, value)) return; if (property == QLatin1String("VoicemailWaiting")) { Q_EMIT voicemailWaitingChanged(value.value<bool>()); } else if (property == QLatin1String("VoicemailMessageCount")) { Q_EMIT voicemailMessageCountChanged(value.value<int>()); } else if (property == QLatin1String("VoicemailMailboxNumber")) { Q_EMIT voicemailMailboxNumberChanged(value.value<QString>()); } }
void testQOfonoMessageWaiting() { QOfonoModem modem; modem.setModemPath(m->modemPath()); QSignalSpy modemOnline(&modem, SIGNAL(onlineChanged(bool))); QSignalSpy waiting(m, SIGNAL(voicemailWaitingChanged(bool))); QSignalSpy messageCount(m, SIGNAL(voicemailMessageCountChanged(int))); QSignalSpy mailboxNumber(m, SIGNAL(voicemailMailboxNumberChanged(QString))); QSignalSpy setNumberComplete(m, SIGNAL(voicemailMailboxComplete(bool))); // Wait for modem to become ready QTRY_COMPARE(modemOnline.count(), 1); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), true); QCOMPARE(m->voicemailWaiting(), true); QCOMPARE(m->voicemailMessageCount(), 1); QCOMPARE(m->voicemailMailboxNumber(), QString("6789")); modem.setOnline(false); QTRY_COMPARE(modemOnline.count(), 1); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), false); QTest::qWait(REASONABLE_TIMEOUT); QTRY_COMPARE(waiting.count(), 1); QTRY_COMPARE(messageCount.count(), 1); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(setNumberComplete.count(), 0); QCOMPARE(waiting.takeFirst().at(0).toInt(), 0); QCOMPARE(messageCount.takeFirst().at(0).toInt(), 0); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), QString("")); modem.setOnline(true); QTRY_COMPARE(modemOnline.count(), 1); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), true); // FIXME: This does not seem to be correct. These properties actually // do not change. QTRY_COMPARE(waiting.count(), 1); QCOMPARE(waiting.takeFirst().at(0).toBool(), true); QTRY_COMPARE(messageCount.count(), 1); QCOMPARE(messageCount.takeFirst().at(0).toInt(), 1); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), QString("6789")); QTRY_COMPARE(setNumberComplete.count(), 0); }