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)));
81 QVERIFY(state.count()>0);
82 QVERIFY(st.count()>0);
83 QVERIFY(ic.count()==0);
84 QVERIFY(em.count()==0);
85 QVERIFY(mp.count()==0);
86 QVERIFY(info.count()==0);
87 QVERIFY(name.count()==0);
88 QVERIFY(li.count()==0);
90 QCOMPARE(call->state(),QString("active"));
91 QCOMPARE(call->lineIdentification(),QString("123"));
92 QCOMPARE(call->emergency(),false);
93 QCOMPARE(call->multiparty(),false);
94 QCOMPARE(call->name(),QString(""));
95 QCOMPARE(call->information(),QString(""));
99 QCOMPARE(hspy.count(), 1);
100 QCOMPARE(hspy.takeFirst().at(0).toBool(),true);
101 QCOMPARE(discreason.count(), 1);
102 QCOMPARE(discreason.takeFirst().at(0).toString(), QString("local"));
106 void testOfonoVoiceCallStep2()
108 //Dial failure, incoming, answer and local hangup
109 QSignalSpy callsignal(m, SIGNAL(callAdded(const QString)));
114 QCOMPARE(callsignal.count(),1);
115 QString callid = callsignal.takeFirst().at(0).toString();
117 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
118 QSignalSpy state(call, SIGNAL(stateChanged(const QString)));
119 QSignalSpy time(call,SIGNAL(startTimeChanged(const QString)));
120 QSignalSpy discreason(call,SIGNAL(disconnectReason(const QString)));
121 QSignalSpy hspy(call, SIGNAL(hangupComplete(bool)));
122 QSignalSpy aspy(call, SIGNAL(answerComplete(bool)));
124 QSignalSpy li (call, SIGNAL(lineIdentificationChanged(QString)));
125 QSignalSpy name (call, SIGNAL(nameChanged(QString)));
126 QSignalSpy info (call, SIGNAL(informationChanged(QString)));
127 QSignalSpy mp (call, SIGNAL(multipartyChanged(bool)));
128 QSignalSpy em (call, SIGNAL(emergencyChanged(bool)));
129 QSignalSpy ic (call, SIGNAL(iconChanged(quint8)));
133 QCOMPARE(call->state(),QString("incoming"));
136 QVERIFY(state.count()>0);
137 QCOMPARE(call->lineIdentification(),QString("1234567")); //PhoneSim specific value
138 QVERIFY(time.count()>0);
139 QCOMPARE(aspy.count(), 1);
140 QCOMPARE(aspy.takeFirst().at(0).toBool(),true);
142 QVERIFY(ic.count()==0);
143 QVERIFY(em.count()==0);
144 QVERIFY(mp.count()==0);
145 QVERIFY(info.count()==0);
146 QVERIFY(name.count()==0);
147 QVERIFY(li.count()==0);
151 QCOMPARE(hspy.count(), 1);
152 QCOMPARE(hspy.takeFirst().at(0).toBool(), true);
153 QCOMPARE(discreason.count(), 1);
154 QCOMPARE(discreason.takeFirst().at(0).toString(), QString("local"));
158 void testOfonoVoiceCallStep3()
160 //Dial failed, incoming, no answer and state change to disconnect
161 QSignalSpy callsignal(m, SIGNAL(callAdded(const QString)));
166 QCOMPARE(callsignal.count(),1);
167 QString callid = callsignal.takeFirst().at(0).toString();
169 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
170 QSignalSpy state(call, SIGNAL(stateChanged(const QString)));
171 QSignalSpy discreason(call,SIGNAL(disconnectReason(const QString)));
174 QCOMPARE(call->state(),QString("incoming"));
176 QVERIFY(state.count()>0);
177 QCOMPARE(discreason.count(), 1);
178 QCOMPARE(discreason.takeFirst().at(0).toString(), QString("remote"));
182 void testOfonoVoiceCallStep4()
185 QSignalSpy callsignal(m, SIGNAL(callAdded(const QString)));
189 QCOMPARE(callsignal.count(),1);
190 QString callid = callsignal.takeFirst().at(0).toString();
192 OfonoVoiceCall* call = new OfonoVoiceCall(callid);
193 QSignalSpy dfspy(call, SIGNAL(deflectComplete(bool)));
196 QCOMPARE(call->state(),QString("incoming"));
197 QCOMPARE(call->lineIdentification(),QString("1234567")); //PhoneSim specific value
198 call->deflect("2345");
200 QCOMPARE(dfspy.count(), 1);
201 QCOMPARE(dfspy.takeFirst().at(0).toBool(), true);
207 void cleanupTestCase()
214 OfonoVoiceCallManager *m;
217 QTEST_MAIN(TestOfonoVoiceCall)
218 #include "test_ofonovoicecall.moc"