From 0b9fb0c1c3e41e13b5448594d9436cf33b99afd1 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 17 Nov 2010 18:04:22 +0200 Subject: [PATCH] Rewrite ModemManager test --- tests/test_ofonomodemmanager.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/test_ofonomodemmanager.cpp b/tests/test_ofonomodemmanager.cpp index 424507b..691ffeb 100644 --- a/tests/test_ofonomodemmanager.cpp +++ b/tests/test_ofonomodemmanager.cpp @@ -25,6 +25,7 @@ #include #include +#include #include @@ -34,29 +35,35 @@ class TestOfonoModemManager : public QObject Q_OBJECT private slots: - void modemAdded(QString modem) - { - qDebug() << "Modem added" << modem; - } - - void modemRemoved(QString modem) - { - qDebug() << "Modem removed" << modem; - } - void initTestCase() { mm = new OfonoModemManager(this); - connect(mm, SIGNAL(modemAdded(QString)), this, SLOT(modemAdded(QString))); - connect(mm, SIGNAL(modemRemoved(QString)), this, SLOT(modemRemoved(QString))); } void testOfonoModemManager() { - qDebug() << mm->modems(); - QTest::qWait(30000); + QVERIFY(mm->modems().contains("/phonesim") == true); } + void testOfonoModemManagerAddRemove() + { + 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); + OfonoModem *m = new OfonoModem(OfonoModem::ManualSelect, "/phonesim", this); + m->setPowered(true); + QTest::qWait(5000); + m->setOnline(true); + QTest::qWait(5000); + QVERIFY(remove.count() > 0); + QVERIFY(add.count() > 0); + } void cleanupTestCase() { -- 2.7.4