2 * This file is part of ofono-qt
4 * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <QtTest/QtTest>
25 #include <QtCore/QObject>
27 #include <ofonovoicecallmanager.h>
32 class TestOfonoVoiceCallManager : public QObject
39 m = new OfonoVoiceCallManager(OfonoModem::ManualSelect, "/phonesim", this);
40 QCOMPARE(m->modem()->isValid(), true);
42 if (!m->modem()->powered()) {
43 m->modem()->setPowered(true);
46 if (!m->modem()->online()) {
47 m->modem()->setOnline(true);
50 QCOMPARE(m->isValid(), true);
53 void testOfonoVoiceCallManager()
55 QVERIFY(m->emergencyNumbers().count() > 0);
57 QSignalSpy emergencyNumbers(m, SIGNAL(emergencyNumbersChanged(QStringList)));
58 QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
59 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
60 QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
61 QSignalSpy tonereg(m,SIGNAL(sendTonesComplete(bool)));
62 QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));
64 m->modem()->setPowered(false);
66 m->modem()->setPowered(true);
68 m->modem()->setOnline(true);
71 QCOMPARE(emergencyNumbers.count(), 1);
72 QVERIFY(emergencyNumbers.takeFirst().at(0).toStringList().count() > 0);
75 qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
77 QCOMPARE(dialreg.count(), 1);
78 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
79 QCOMPARE(dspy.count(), 1);
84 QCOMPARE(tonereg.count(), 1);
85 QCOMPARE(tonereg.takeFirst().at(0).toBool(),true);
87 QStringList calls = m->getCalls();
88 QVERIFY(calls.size()>0);
92 QCOMPARE(hupreg.count(), 1);
93 QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
94 QCOMPARE(hspy.count(), 1);
98 void testoFonoVoiceCallManagerStep2()
100 // test dial failure and hangup of incoming alerting call
101 QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
102 QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
103 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
104 QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));
109 QCOMPARE(dialreg.count(), 1);
110 QCOMPARE(dialreg.takeFirst().at(0).toBool(),false);
112 QCOMPARE(dspy.count(), 1);
114 //hangup the alerting call
117 QCOMPARE(hupreg.count(), 1);
118 QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
121 QCOMPARE(hspy.count(), 1);
125 void cleanupTestCase()
132 OfonoVoiceCallManager *m;
135 QTEST_MAIN(TestOfonoVoiceCallManager)
136 #include "test_ofonovoicecallmanager.moc"