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); }
void Tst_qofonoTest::testContextConnection() { QOfonoManager manager; QOfonoModem modem; QStringList modems = manager.modems(); modem.setModemPath(manager.modems()[0]); qDebug() << Q_FUNC_INFO << manager.modems()[0] << modem.online(); if (!modem.online()) { QSignalSpy spy_bogusContext(&modem, SIGNAL(onlineChanged(bool))); modem.setOnline(true); ::waitForSignal(&modem,SIGNAL(onlineChanged(bool)),3000); QCOMPARE(spy_bogusContext.count(),1); }
void testQOfonoCallVolume() { QSignalSpy mutedChanged(m, SIGNAL(mutedChanged(const bool))); QSignalSpy speakerVolumeChanged(m, SIGNAL(speakerVolumeChanged(const quint8))); QSignalSpy microphoneVolumeChanged(m, SIGNAL(microphoneVolumeChanged(const quint8))); QSignalSpy spfail(m, SIGNAL(setSpeakerVolumeFailed())); QSignalSpy mvfail(m, SIGNAL(setMicrophoneVolumeFailed())); QOfonoModem modem; modem.setModemPath(m->modemPath()); modem.setPowered(false); QTest::qWait(5000); modem.setPowered(true); QTest::qWait(5000); modem.setOnline(true); QTest::qWait(5000); m->setMuted(true); QTest::qWait(2000); QCOMPARE(mutedChanged.count(), 1); QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(true)); QVERIFY(m->muted()==bool(true)); m->setMuted(false); QTest::qWait(2000); QCOMPARE(mutedChanged.count(), 1); QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(false)); QVERIFY(m->muted()==bool(false)); m->setSpeakerVolume(quint8(15)); QTest::qWait(2000); QCOMPARE(speakerVolumeChanged.count(), 1); QCOMPARE(quint8(speakerVolumeChanged.takeFirst().at(0).toUInt()), quint8(15)); QCOMPARE(m->speakerVolume(),quint8(15)); m->setSpeakerVolume(quint8(250)); QTest::qWait(2000); QCOMPARE(spfail.count(), 1); m->setMicrophoneVolume(quint8(10)); QTest::qWait(2000); QCOMPARE(mvfail.count(), 1); }
void testQOfonoManagerAddRemove() { QSignalSpy add(mm, SIGNAL(modemAdded(const QString &))); QSignalSpy remove(mm, SIGNAL(modemRemoved(const QString &))); qDebug() << "Please stop oFono and then start it again"; for (int i=0; i<30; i++) { if (add.count() > 0 && remove.count() > 0) break; QTest::qWait(1000); } QVERIFY(mm->modems().contains("/phonesim") == true); QOfonoModem *m = new QOfonoModem(this); m->setModemPath("/phonesim"); m->setPowered(true); QTest::qWait(5000); m->setOnline(true); QTest::qWait(5000); QVERIFY(remove.count() > 0); QVERIFY(add.count() > 0); }
void Tst_qofonoTest::testConnectionManager() { QOfonoManager manager; QOfonoConnectionManager connman; QOfonoModem modem; modem.setModemPath(manager.modems()[0]); if (!modem.online()) { modem.setOnline(true); } QVERIFY(modem.online()); connman.setModemPath(manager.modems()[0]); QVERIFY(!connman.modemPath().isEmpty()); QSignalSpy spy(&connman, SIGNAL(contextAdded(QString))); connman.addContext("internet"); ::waitForSignal(&connman,SIGNAL(contextAdded(QString)),1000); QCOMPARE(spy.count(),1); // QList<QVariant> arguments ; // arguments = spy.takeFirst(); // attached // bearer // suspended // roamingAllowed // QSignalSpy spy_roaming(&connman, SIGNAL(roamingAllowedChanged(bool))); // bool expected = !connman.roamingAllowed(); // connman.setRoamingAllowed(expected); // QTest::qWait(3000); // QCOMPARE(spy_roaming.count(),1); // QList<QVariant> argumentsspy_roaming; // argumentsspy_roaming = spy_roaming.takeFirst(); // QCOMPARE(argumentsspy_roaming[0].toBool(), expected); // connman.setRoamingAllowed(false); // QTest::qWait(3000); // QCOMPARE(spy_roaming.count(),1); // QList<QVariant> argumentsspy_roaming2; // argumentsspy_roaming2 = spy_roaming.takeFirst(); // if (manager.modems()[0].contains("phonesim")) // QEXPECT_FAIL("","seems to nt work on phonesim",Continue); // QCOMPARE(argumentsspy_roaming[0].toBool(), false); // // powered // QSignalSpy spy_powered(&connman, SIGNAL(poweredChanged(bool))); // QList<QVariant> argumentsspy_powered; // bool isPowered = connman.powered(); // qDebug() << Q_FUNC_INFO << "modem powered" << connman.powered(); // connman.setPowered(!isPowered); // QTest::qWait(3000); // QCOMPARE(spy_powered.count(),2); //powers itself back on // argumentsspy_powered = spy_powered.takeFirst(); // QCOMPARE(argumentsspy_powered[0].toBool(), !isPowered); // if(!connman.powered()) { // connman.setPowered(true); // QTest::qWait(3000); // QVERIFY(connman.powered()); // } //TODO other signals }