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 * Portions of this file are Copyright (C) 2011 Intel Corporation
9 * Contact: Shane Bryan <shane.bryan@linux.intel.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * version 2.1 as published by the Free Software Foundation.
15 * This library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 #include <QtTest/QtTest>
28 #include <QtCore/QObject>
30 #include <ofonovoicecallmanager.h>
31 #include <ofonovoicecall.h>
34 class TestOfonoMultipartyCall : public QObject
41 m = new OfonoVoiceCallManager(OfonoModem::ManualSelect, "/phonesim", this);
42 QCOMPARE(m->modem()->isValid(), true);
43 if (!m->modem()->powered()) {
44 m->modem()->setPowered(true);
47 if (!m->modem()->online()) {
48 m->modem()->setOnline(true);
51 QCOMPARE(m->isValid(), true);
54 void testOfonoMultipartyCalls()
56 // Test for hangupMultiparty():
58 // 2. Receive a call (dial "199" to trigger phonesim callback)
59 // 3. Combine into multiparty call (2 participants)
60 // 4. Verify createMultiparty() works as expected
61 // 5. Put multiparty call on hold
63 // 7. Combine into multiparty call (3 participants)
64 // 8. Split one call off to "private chat"
65 // 9. Verify privateChat() works as expected
66 // 10. Hangup multiparty call
67 // 11. Verify hangupMultiparty() works as expected
68 // 12. Hangup all calls
70 QVariantList variantList;
72 // VoiceCallManager Spy's
73 QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
74 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
75 QSignalSpy rspy(m, SIGNAL(callRemoved(QString)));
76 QSignalSpy haspy(m, SIGNAL(hangupAllComplete(bool)));
77 QSignalSpy haaspy(m, SIGNAL(holdAndAnswerComplete(bool)));
78 QSignalSpy cmspy(m, SIGNAL(createMultipartyComplete(bool, QStringList)));
79 QSignalSpy hmspy(m, SIGNAL(hangupMultipartyComplete(bool)));
80 QSignalSpy scspy(m, SIGNAL(swapCallsComplete(bool)));
81 QSignalSpy pcspy(m, SIGNAL(privateChatComplete(bool, QStringList)));
83 // 1. Dial a call (outgoing)
87 QCOMPARE(dialreg.count(), 1);
88 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
89 QCOMPARE(dspy.count(), 1);
90 QString c1id = dspy.takeFirst().at(0).toString();
92 OfonoVoiceCall* c1 = new OfonoVoiceCall(c1id);
94 QSignalSpy c1state(c1, SIGNAL(stateChanged(const QString)));
95 QSignalSpy c1discreason(c1,SIGNAL(disconnectReason(const QString)));
96 QSignalSpy c1li (c1, SIGNAL(lineIdentificationChanged(QString)));
97 QSignalSpy c1name (c1, SIGNAL(nameChanged(QString)));
98 QSignalSpy c1info (c1, SIGNAL(informationChanged(QString)));
99 QSignalSpy c1mp (c1, SIGNAL(multipartyChanged(bool)));
100 QSignalSpy c1em (c1, SIGNAL(emergencyChanged(bool)));
101 QSignalSpy c1st (c1, SIGNAL(startTimeChanged(QString)));
102 QSignalSpy c1ic (c1, SIGNAL(iconChanged(quint8)));
104 qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
106 // - new call should have a state change, and be in "active" state
107 QVERIFY(c1state.count()>0);
108 QVERIFY(c1st.count()>0);
109 QVERIFY(c1ic.count()==0);
110 QVERIFY(c1em.count()==0);
111 QVERIFY(c1mp.count()==0);
112 QVERIFY(c1info.count()==0);
113 QVERIFY(c1name.count()==0);
114 QVERIFY(c1li.count()==0);
116 QCOMPARE(c1->state(),QString("active"));
117 QCOMPARE(c1->lineIdentification(),QString("123"));
118 QCOMPARE(c1->emergency(),false);
119 QCOMPARE(c1->multiparty(),false);
120 QCOMPARE(c1->name(),QString(""));
121 QCOMPARE(c1->information(),QString(""));
124 // - dial "199" to trigger phonesim callback
128 QCOMPARE(dialreg.count(), 1);
129 QCOMPARE(dialreg.takeFirst().at(0).toBool(),false);
130 QCOMPARE(dspy.count(),1);
131 QString c2id = dspy.takeFirst().at(0).toString();
133 OfonoVoiceCall* c2 = new OfonoVoiceCall(c2id);
134 QSignalSpy c2state(c2, SIGNAL(stateChanged(const QString)));
135 QSignalSpy c2time(c2,SIGNAL(startTimeChanged(const QString)));
136 QSignalSpy c2discreason(c2,SIGNAL(disconnectReason(const QString)));
138 QSignalSpy c2li (c2, SIGNAL(lineIdentificationChanged(QString)));
139 QSignalSpy c2name (c2, SIGNAL(nameChanged(QString)));
140 QSignalSpy c2info (c2, SIGNAL(informationChanged(QString)));
141 QSignalSpy c2mp (c2, SIGNAL(multipartyChanged(bool)));
142 QSignalSpy c2em (c2, SIGNAL(emergencyChanged(bool)));
143 QSignalSpy c2ic (c2, SIGNAL(iconChanged(quint8)));
146 QCOMPARE(c2->state(),QString("waiting"));
148 // - accept incoming call, placing first call on hold
152 QCOMPARE(haaspy.count(),1);
153 QCOMPARE(haaspy.takeFirst().at(0).toBool(),true);
156 // - call #1 should be in "held" state
157 QVERIFY(c1state.count()>0);
158 QCOMPARE(c1->state(),QString("held"));
160 // - call #2 should be in "active" state
161 QVERIFY(c2state.count()>0);
162 QCOMPARE(c2->state(),QString("active"));
163 QCOMPARE(c2->lineIdentification(),QString("1234567"));
164 QVERIFY(c2time.count()>0);
166 QVERIFY(c2ic.count()==0);
167 QVERIFY(c2em.count()==0);
168 QVERIFY(c2mp.count()==0);
169 QVERIFY(c2info.count()==0);
170 QVERIFY(c2name.count()==0);
171 QVERIFY(c2li.count()==0);
173 // 3. Combine into multiparty call (2 participants)
174 m->createMultiparty();
176 QCOMPARE(cmspy.count(),1);
177 variantList = cmspy.takeFirst();
178 QCOMPARE(variantList.at(0).toBool(),true);
179 QVERIFY(variantList.at(1).toStringList().length() > 0);
182 // 4. Verify createMultiparty() works as expected
183 // - call #1 should have a stateChanged signal triggered
184 QVERIFY(c1state.count()>0);
185 // - both calls should have a multipartyChanged signal triggered,
186 // be in "active" state and have multiparty property set to "true"
187 QVERIFY(c1mp.count()>0);
188 QVERIFY(c2mp.count()>0);
189 QCOMPARE(c1->state(),QString("active"));
190 QCOMPARE(c2->state(),QString("active"));
191 QCOMPARE(c1->multiparty(),true);
192 QCOMPARE(c2->multiparty(),true);
194 // 5. Put multiparty call on hold
198 QCOMPARE(scspy.count(),1);
199 QCOMPARE(scspy.takeFirst().at(0).toBool(),true);
202 // - both calls should have a stateChanged signal triggered
203 // and be in "held" state
204 QVERIFY(c1state.count()>0);
205 QVERIFY(c2state.count()>0);
206 QCOMPARE(c1->state(),QString("held"));
207 QCOMPARE(c2->state(),QString("held"));
209 // 6. Dial a 3rd call
213 QCOMPARE(dialreg.count(), 1);
214 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
215 QCOMPARE(dspy.count(), 1);
216 QString c3id = dspy.takeFirst().at(0).toString();
218 OfonoVoiceCall* c3 = new OfonoVoiceCall(c3id);
220 QSignalSpy c3state(c3, SIGNAL(stateChanged(const QString)));
221 QSignalSpy c3discreason(c3,SIGNAL(disconnectReason(const QString)));
222 QSignalSpy c3li (c3, SIGNAL(lineIdentificationChanged(QString)));
223 QSignalSpy c3name (c3, SIGNAL(nameChanged(QString)));
224 QSignalSpy c3info (c3, SIGNAL(informationChanged(QString)));
225 QSignalSpy c3mp (c3, SIGNAL(multipartyChanged(bool)));
226 QSignalSpy c3em (c3, SIGNAL(emergencyChanged(bool)));
227 QSignalSpy c3st (c3, SIGNAL(startTimeChanged(QString)));
228 QSignalSpy c3ic (c3, SIGNAL(iconChanged(quint8)));
230 qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
232 // - 3rd call should have a state change, and be in "active" state
233 QVERIFY(c3state.count()>0);
234 QVERIFY(c3st.count()>0);
235 QVERIFY(c3ic.count()==0);
236 QVERIFY(c3em.count()==0);
237 QVERIFY(c3mp.count()==0);
238 QVERIFY(c3info.count()==0);
239 QVERIFY(c3name.count()==0);
240 QVERIFY(c3li.count()==0);
242 QCOMPARE(c3->state(),QString("active"));
243 QCOMPARE(c3->lineIdentification(),QString("456"));
244 QCOMPARE(c3->emergency(),false);
245 QCOMPARE(c3->multiparty(),false);
246 QCOMPARE(c3->name(),QString(""));
247 QCOMPARE(c3->information(),QString(""));
249 // 7. Combine into multiparty call (3 participants)
250 m->createMultiparty();
253 QCOMPARE(cmspy.count(),1);
254 variantList = cmspy.takeFirst();
255 QCOMPARE(variantList.at(0).toBool(),true);
256 QVERIFY(variantList.at(1).toStringList().length() > 0);
259 // - calls #1 and #2 should have a stateChanged signal triggered
260 QVERIFY(c1state.count()>0);
261 QVERIFY(c2state.count()>0);
262 // - all calls should have a multipartyChanged signal triggered,
263 // be in "active" state and have multiparty property set to "true"
264 QVERIFY(c1mp.count()>0);
265 QVERIFY(c2mp.count()>0);
266 QVERIFY(c3mp.count()>0);
267 QCOMPARE(c1->state(),QString("active"));
268 QCOMPARE(c2->state(),QString("active"));
269 QCOMPARE(c3->state(),QString("active"));
270 QCOMPARE(c1->multiparty(),true);
271 QCOMPARE(c2->multiparty(),true);
272 QCOMPARE(c3->multiparty(),true);
274 // 8. Split call #1 off to "private chat"
275 m->privateChat(c1id);
278 QCOMPARE(pcspy.count(),1);
279 variantList = pcspy.takeFirst();
280 QCOMPARE(variantList.at(0).toBool(),true);
281 QVERIFY(variantList.at(1).toStringList().length() > 0);
284 // 9. Verify privateChat() works as expected
285 // - call #1 should have a multipartyChanged signal triggered,
286 // it's multiparty property set to false and be in "active" state
287 QVERIFY(c1mp.count()>0);
288 QCOMPARE(c1->multiparty(),false);
289 QCOMPARE(c1->state(),QString("active"));
290 // - calls #2 and #3 should have a stateChanged signal triggered
291 // and be back in "held" state
292 QVERIFY(c2state.count()>0);
293 QVERIFY(c3state.count()>0);
294 QCOMPARE(c2->state(),QString("held"));
295 QCOMPARE(c3->state(),QString("held"));
298 // 10. Hangup multiparty call
299 m->hangupMultiparty();
301 QCOMPARE(hmspy.count(), 1);
302 QCOMPARE(hmspy.takeFirst().at(0).toBool(),true);
305 // 11. Verify hangupMultiparty() works as expected
306 // - two calls should have been removed
307 QVERIFY(rspy.count()==2);
308 QString r2id = rspy.takeFirst().at(0).toString();
309 QString r3id = rspy.takeFirst().at(0).toString();
313 // - call #1 should still be in "active" state
314 QCOMPARE(c1->state(),QString("active"));
316 // - calls #2 and #3 should have a stateChanged signal triggered
317 // and have a disconnect reason of "local"
318 QVERIFY(c2state.count()>0);
319 QVERIFY(c3state.count()>0);
320 QCOMPARE(c2discreason.count(), 1);
321 QCOMPARE(c3discreason.count(), 1);
322 QCOMPARE(c2discreason.takeFirst().at(0).toString(), QString("local"));
323 QCOMPARE(c3discreason.takeFirst().at(0).toString(), QString("local"));
325 // 12. Hangup all calls
328 QCOMPARE(haspy.count(), 1);
329 QCOMPARE(haspy.takeFirst().at(0).toBool(),true);
332 QCOMPARE(c1discreason.count(), 1);
333 QCOMPARE(c1discreason.takeFirst().at(0).toString(), QString("local"));
340 void cleanupTestCase()
347 OfonoVoiceCallManager *m;
350 QTEST_MAIN(TestOfonoMultipartyCall)
351 #include "test_ofonomultipartycall.moc"