2 * This file is part of ofono-qt
4 * Copyright (C) 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>
28 #include <ofonovoicecall.h>
32 class TestOfonoVoiceCall : public QObject
39 m = new OfonoVoiceCallManager(OfonoModem::ManualSelect, "/phonesim", this);
40 QCOMPARE(m->modem()->isValid(), true);
41 if (!m->modem()->powered()) {
42 m->modem()->setPowered(true);
45 if (!m->modem()->online()) {
46 m->modem()->setOnline(true);
49 QCOMPARE(m->isValid(), true);
52 void testOfonoVoiceCall()
54 QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
55 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
61 QCOMPARE(dialreg.count(), 1);
62 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
63 QCOMPARE(dspy.count(), 1);
64 QString callid = dspy.takeFirst().at(0).toString();
66 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
68 QSignalSpy state(call, SIGNAL(stateChanged(const QString)));
69 QSignalSpy discreason(call,SIGNAL(disconnectReason(const QString)));
70 QSignalSpy hspy(call, SIGNAL(hangupComplete(bool)));
71 QSignalSpy li (call, SIGNAL(lineIdentificationChanged(QString)));
72 QSignalSpy name (call, SIGNAL(nameChanged(QString)));
73 QSignalSpy info (call, SIGNAL(informationChanged(QString)));
74 QSignalSpy mp (call, SIGNAL(multipartyChanged(bool)));
75 QSignalSpy em (call, SIGNAL(emergencyChanged(bool)));
76 QSignalSpy st (call, SIGNAL(startTimeChanged(QString)));
77 QSignalSpy ic (call, SIGNAL(iconChanged(quint8)));
79 qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
82 QVERIFY(state.count()>0);
83 QVERIFY(st.count()>0);
84 QVERIFY(ic.count()==0);
85 QVERIFY(em.count()==0);
86 QVERIFY(mp.count()==0);
87 QVERIFY(info.count()==0);
88 QVERIFY(name.count()==0);
89 QVERIFY(li.count()==0);
91 QCOMPARE(call->state(),QString("active"));
92 QCOMPARE(call->lineIdentification(),QString("123"));
93 QCOMPARE(call->emergency(),false);
94 QCOMPARE(call->multiparty(),false);
95 QCOMPARE(call->name(),QString(""));
96 QCOMPARE(call->information(),QString(""));
100 QCOMPARE(hspy.count(), 1);
101 QCOMPARE(hspy.takeFirst().at(0).toBool(),true);
102 QCOMPARE(discreason.count(), 1);
103 QCOMPARE(discreason.takeFirst().at(0).toString(), QString("local"));
107 void testOfonoVoiceCallStep2()
109 //Dial failure, incoming, answer and local hangup
110 QSignalSpy callsignal(m, SIGNAL(callAdded(const QString)));
115 QCOMPARE(callsignal.count(),1);
116 QString callid = callsignal.takeFirst().at(0).toString();
118 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
119 QSignalSpy state(call, SIGNAL(stateChanged(const QString)));
120 QSignalSpy time(call,SIGNAL(startTimeChanged(const QString)));
121 QSignalSpy discreason(call,SIGNAL(disconnectReason(const QString)));
122 QSignalSpy hspy(call, SIGNAL(hangupComplete(bool)));
123 QSignalSpy aspy(call, SIGNAL(answerComplete(bool)));
125 QSignalSpy li (call, SIGNAL(lineIdentificationChanged(QString)));
126 QSignalSpy name (call, SIGNAL(nameChanged(QString)));
127 QSignalSpy info (call, SIGNAL(informationChanged(QString)));
128 QSignalSpy mp (call, SIGNAL(multipartyChanged(bool)));
129 QSignalSpy em (call, SIGNAL(emergencyChanged(bool)));
130 QSignalSpy ic (call, SIGNAL(iconChanged(quint8)));
134 QCOMPARE(call->state(),QString("incoming"));
137 QVERIFY(state.count()>0);
138 QCOMPARE(call->lineIdentification(),QString("1234567")); //PhoneSim specific value
139 QVERIFY(time.count()>0);
140 QCOMPARE(aspy.count(), 1);
141 QCOMPARE(aspy.takeFirst().at(0).toBool(),true);
143 QVERIFY(ic.count()==0);
144 QVERIFY(em.count()==0);
145 QVERIFY(mp.count()==0);
146 QVERIFY(info.count()==0);
147 QVERIFY(name.count()==0);
148 QVERIFY(li.count()==0);
152 QCOMPARE(hspy.count(), 1);
153 QCOMPARE(hspy.takeFirst().at(0).toBool(), true);
154 QCOMPARE(discreason.count(), 1);
155 QCOMPARE(discreason.takeFirst().at(0).toString(), QString("local"));
159 void testOfonoVoiceCallStep3()
161 //Dial failed, incoming, no answer and state change to disconnect
162 QSignalSpy callsignal(m, SIGNAL(callAdded(const QString)));
167 QCOMPARE(callsignal.count(),1);
168 QString callid = callsignal.takeFirst().at(0).toString();
170 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
171 QSignalSpy state(call, SIGNAL(stateChanged(const QString)));
172 QSignalSpy discreason(call,SIGNAL(disconnectReason(const QString)));
175 QCOMPARE(call->state(),QString("incoming"));
177 QVERIFY(state.count()>0);
178 QCOMPARE(discreason.count(), 1);
179 QCOMPARE(discreason.takeFirst().at(0).toString(), QString("remote"));
183 void testOfonoVoiceCallStep4()
186 QSignalSpy callsignal(m, SIGNAL(callAdded(const QString)));
190 QCOMPARE(callsignal.count(),1);
191 QString callid = callsignal.takeFirst().at(0).toString();
193 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
194 QSignalSpy dfspy(call, SIGNAL(deflectComplete(bool)));
197 QCOMPARE(call->state(),QString("incoming"));
198 QCOMPARE(call->lineIdentification(),QString("1234567")); //PhoneSim specific value
199 call->deflect("2345");
201 QCOMPARE(dfspy.count(), 1);
202 QCOMPARE(dfspy.takeFirst().at(0).toBool(), true);
208 void cleanupTestCase()
215 OfonoVoiceCallManager *m;
218 QTEST_MAIN(TestOfonoVoiceCall)
219 #include "test_ofonovoicecall.moc"