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);
76 QCOMPARE(dialreg.count(), 1);
77 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
78 QCOMPARE(dspy.count(), 1);
83 QCOMPARE(tonereg.count(), 1);
84 QCOMPARE(tonereg.takeFirst().at(0).toBool(),true);
86 QStringList calls = m->getCalls();
87 QVERIFY(calls.size()>0);
91 QCOMPARE(hupreg.count(), 1);
92 QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
93 QCOMPARE(hspy.count(), 1);
97 void testoFonoVoiceCallManagerStep2()
99 // test dial failure and hangup of incoming alerting call
100 QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
101 QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool)));
102 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
103 QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));
108 QCOMPARE(dialreg.count(), 1);
109 QCOMPARE(dialreg.takeFirst().at(0).toBool(),false);
111 QCOMPARE(dspy.count(), 1);
113 //hangup the alerting call
116 QCOMPARE(hupreg.count(), 1);
117 QCOMPARE(hupreg.takeFirst().at(0).toBool(),true);
120 QCOMPARE(hspy.count(), 1);
123 void testOfonoVoiceCallmanagerStep3()
125 // MO call and MT hangup
126 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
127 QSignalSpy hspy(m, SIGNAL(callRemoved(QString)));
130 m->dial("0512305","");
132 QCOMPARE(dspy.count(), 1);
134 QCOMPARE(hspy.count(), 1);
137 void cleanupTestCase()
144 OfonoVoiceCallManager *m;
147 QTEST_MAIN(TestOfonoVoiceCallManager)
148 #include "test_ofonovoicecallmanager.moc"