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 // VoiceCallManager Spy's
71 QSignalSpy dialreg(m,SIGNAL(dialComplete(bool)));
72 QSignalSpy dspy(m, SIGNAL(callAdded(QString)));
73 QSignalSpy rspy(m, SIGNAL(callRemoved(QString)));
74 QSignalSpy haspy(m, SIGNAL(hangupAllComplete(bool)));
75 QSignalSpy haaspy(m, SIGNAL(holdAndAnswerComplete(bool)));
76 QSignalSpy cmspy(m, SIGNAL(createMultipartyComplete(bool)));
77 QSignalSpy hmspy(m, SIGNAL(hangupMultipartyComplete(bool)));
78 QSignalSpy scspy(m, SIGNAL(swapCallsComplete(bool)));
79 QSignalSpy pcspy(m, SIGNAL(privateChatComplete(bool)));
81 // 1. Dial a call (outgoing)
85 QCOMPARE(dialreg.count(), 1);
86 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
87 QCOMPARE(dspy.count(), 1);
88 QString c1id = dspy.takeFirst().at(0).toString();
90 OfonoVoiceCall* c1 = new OfonoVoiceCall(c1id);
92 QSignalSpy c1state(c1, SIGNAL(stateChanged(const QString)));
93 QSignalSpy c1discreason(c1,SIGNAL(disconnectReason(const QString)));
94 QSignalSpy c1li (c1, SIGNAL(lineIdentificationChanged(QString)));
95 QSignalSpy c1name (c1, SIGNAL(nameChanged(QString)));
96 QSignalSpy c1info (c1, SIGNAL(informationChanged(QString)));
97 QSignalSpy c1mp (c1, SIGNAL(multipartyChanged(bool)));
98 QSignalSpy c1em (c1, SIGNAL(emergencyChanged(bool)));
99 QSignalSpy c1st (c1, SIGNAL(startTimeChanged(QString)));
100 QSignalSpy c1ic (c1, SIGNAL(iconChanged(quint8)));
102 qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
104 // - new call should have a state change, and be in "active" state
105 QVERIFY(c1state.count()>0);
106 QVERIFY(c1st.count()>0);
107 QVERIFY(c1ic.count()==0);
108 QVERIFY(c1em.count()==0);
109 QVERIFY(c1mp.count()==0);
110 QVERIFY(c1info.count()==0);
111 QVERIFY(c1name.count()==0);
112 QVERIFY(c1li.count()==0);
114 QCOMPARE(c1->state(),QString("active"));
115 QCOMPARE(c1->lineIdentification(),QString("123"));
116 QCOMPARE(c1->emergency(),false);
117 QCOMPARE(c1->multiparty(),false);
118 QCOMPARE(c1->name(),QString(""));
119 QCOMPARE(c1->information(),QString(""));
122 // - dial "199" to trigger phonesim callback
126 QCOMPARE(dialreg.count(), 1);
127 QCOMPARE(dialreg.takeFirst().at(0).toBool(),false);
128 QCOMPARE(dspy.count(),1);
129 QString c2id = dspy.takeFirst().at(0).toString();
131 OfonoVoiceCall* c2 = new OfonoVoiceCall(c2id);
132 QSignalSpy c2state(c2, SIGNAL(stateChanged(const QString)));
133 QSignalSpy c2time(c2,SIGNAL(startTimeChanged(const QString)));
134 QSignalSpy c2discreason(c2,SIGNAL(disconnectReason(const QString)));
136 QSignalSpy c2li (c2, SIGNAL(lineIdentificationChanged(QString)));
137 QSignalSpy c2name (c2, SIGNAL(nameChanged(QString)));
138 QSignalSpy c2info (c2, SIGNAL(informationChanged(QString)));
139 QSignalSpy c2mp (c2, SIGNAL(multipartyChanged(bool)));
140 QSignalSpy c2em (c2, SIGNAL(emergencyChanged(bool)));
141 QSignalSpy c2ic (c2, SIGNAL(iconChanged(quint8)));
144 QCOMPARE(c2->state(),QString("waiting"));
146 // - accept incoming call, placing first call on hold
150 QCOMPARE(haaspy.count(),1);
151 QCOMPARE(haaspy.takeFirst().at(0).toBool(),true);
154 // - call #1 should be in "held" state
155 QVERIFY(c1state.count()>0);
156 QCOMPARE(c1->state(),QString("held"));
158 // - call #2 should be in "active" state
159 QVERIFY(c2state.count()>0);
160 QCOMPARE(c2->state(),QString("active"));
161 QCOMPARE(c2->lineIdentification(),QString("1234567"));
162 QVERIFY(c2time.count()>0);
164 QVERIFY(c2ic.count()==0);
165 QVERIFY(c2em.count()==0);
166 QVERIFY(c2mp.count()==0);
167 QVERIFY(c2info.count()==0);
168 QVERIFY(c2name.count()==0);
169 QVERIFY(c2li.count()==0);
171 // 3. Combine into multiparty call (2 participants)
172 m->createMultiparty();
174 QCOMPARE(cmspy.count(),1);
175 QCOMPARE(cmspy.takeFirst().at(0).toBool(),true);
178 // 4. Verify createMultiparty() works as expected
179 // - call #1 should have a stateChanged signal triggered
180 QVERIFY(c1state.count()>0);
181 // - both calls should have a multipartyChanged signal triggered,
182 // be in "active" state and have multiparty property set to "true"
183 QVERIFY(c1mp.count()>0);
184 QVERIFY(c2mp.count()>0);
185 QCOMPARE(c1->state(),QString("active"));
186 QCOMPARE(c2->state(),QString("active"));
187 QCOMPARE(c1->multiparty(),true);
188 QCOMPARE(c2->multiparty(),true);
190 // 5. Put multiparty call on hold
194 QCOMPARE(scspy.count(),1);
195 QCOMPARE(scspy.takeFirst().at(0).toBool(),true);
198 // - both calls should have a stateChanged signal triggered
199 // and be in "held" state
200 QVERIFY(c1state.count()>0);
201 QVERIFY(c2state.count()>0);
202 QCOMPARE(c1->state(),QString("held"));
203 QCOMPARE(c2->state(),QString("held"));
205 // 6. Dial a 3rd call
209 QCOMPARE(dialreg.count(), 1);
210 QCOMPARE(dialreg.takeFirst().at(0).toBool(),true);
211 QCOMPARE(dspy.count(), 1);
212 QString c3id = dspy.takeFirst().at(0).toString();
214 OfonoVoiceCall* c3 = new OfonoVoiceCall(c3id);
216 QSignalSpy c3state(c3, SIGNAL(stateChanged(const QString)));
217 QSignalSpy c3discreason(c3,SIGNAL(disconnectReason(const QString)));
218 QSignalSpy c3li (c3, SIGNAL(lineIdentificationChanged(QString)));
219 QSignalSpy c3name (c3, SIGNAL(nameChanged(QString)));
220 QSignalSpy c3info (c3, SIGNAL(informationChanged(QString)));
221 QSignalSpy c3mp (c3, SIGNAL(multipartyChanged(bool)));
222 QSignalSpy c3em (c3, SIGNAL(emergencyChanged(bool)));
223 QSignalSpy c3st (c3, SIGNAL(startTimeChanged(QString)));
224 QSignalSpy c3ic (c3, SIGNAL(iconChanged(quint8)));
226 qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button";
228 // - 3rd call should have a state change, and be in "active" state
229 QVERIFY(c3state.count()>0);
230 QVERIFY(c3st.count()>0);
231 QVERIFY(c3ic.count()==0);
232 QVERIFY(c3em.count()==0);
233 QVERIFY(c3mp.count()==0);
234 QVERIFY(c3info.count()==0);
235 QVERIFY(c3name.count()==0);
236 QVERIFY(c3li.count()==0);
238 QCOMPARE(c3->state(),QString("active"));
239 QCOMPARE(c3->lineIdentification(),QString("456"));
240 QCOMPARE(c3->emergency(),false);
241 QCOMPARE(c3->multiparty(),false);
242 QCOMPARE(c3->name(),QString(""));
243 QCOMPARE(c3->information(),QString(""));
245 // 7. Combine into multiparty call (3 participants)
246 m->createMultiparty();
249 QCOMPARE(cmspy.count(),1);
250 QCOMPARE(cmspy.takeFirst().at(0).toBool(),true);
253 // - calls #1 and #2 should have a stateChanged signal triggered
254 QVERIFY(c1state.count()>0);
255 QVERIFY(c2state.count()>0);
256 // - all calls should have a multipartyChanged signal triggered,
257 // be in "active" state and have multiparty property set to "true"
258 QVERIFY(c1mp.count()>0);
259 QVERIFY(c2mp.count()>0);
260 QVERIFY(c3mp.count()>0);
261 QCOMPARE(c1->state(),QString("active"));
262 QCOMPARE(c2->state(),QString("active"));
263 QCOMPARE(c3->state(),QString("active"));
264 QCOMPARE(c1->multiparty(),true);
265 QCOMPARE(c2->multiparty(),true);
266 QCOMPARE(c3->multiparty(),true);
268 // 8. Split call #1 off to "private chat"
269 m->privateChat(c1id);
272 QCOMPARE(pcspy.count(),1);
273 QCOMPARE(pcspy.takeFirst().at(0).toBool(),true);
276 // 9. Verify privateChat() works as expected
277 // - call #1 should have a multipartyChanged signal triggered,
278 // it's multiparty property set to false and be in "active" state
279 QVERIFY(c1mp.count()>0);
280 QCOMPARE(c1->multiparty(),false);
281 QCOMPARE(c1->state(),QString("active"));
282 // - calls #2 and #3 should have a stateChanged signal triggered
283 // and be back in "held" state
284 QVERIFY(c2state.count()>0);
285 QVERIFY(c3state.count()>0);
286 QCOMPARE(c2->state(),QString("held"));
287 QCOMPARE(c3->state(),QString("held"));
290 // 10. Hangup multiparty call
291 m->hangupMultiparty();
293 QCOMPARE(hmspy.count(), 1);
294 QCOMPARE(hmspy.takeFirst().at(0).toBool(),true);
297 // 11. Verify hangupMultiparty() works as expected
298 // - two calls should have been removed
299 QVERIFY(rspy.count()==2);
300 QString r2id = rspy.takeFirst().at(0).toString();
301 QString r3id = rspy.takeFirst().at(0).toString();
305 // - call #1 should still be in "active" state
306 QCOMPARE(c1->state(),QString("active"));
308 // - calls #2 and #3 should have a stateChanged signal triggered
309 // and have a disconnect reason of "local"
310 QVERIFY(c2state.count()>0);
311 QVERIFY(c3state.count()>0);
312 QCOMPARE(c2discreason.count(), 1);
313 QCOMPARE(c3discreason.count(), 1);
314 QCOMPARE(c2discreason.takeFirst().at(0).toString(), QString("local"));
315 QCOMPARE(c3discreason.takeFirst().at(0).toString(), QString("local"));
317 // 12. Hangup all calls
320 QCOMPARE(haspy.count(), 1);
321 QCOMPARE(haspy.takeFirst().at(0).toBool(),true);
324 QCOMPARE(c1discreason.count(), 1);
325 QCOMPARE(c1discreason.takeFirst().at(0).toString(), QString("local"));
332 void cleanupTestCase()
339 OfonoVoiceCallManager *m;
342 QTEST_MAIN(TestOfonoMultipartyCall)
343 #include "test_ofonomultipartycall.moc"