~mterry/telephony-service/start-on

« back to all changes in this revision

Viewing changes to handler/tests/HandlerTest.cpp

  • Committer: CI bot
  • Author(s): Gustavo Pichorim Boiko
  • Date: 2014-04-02 12:41:29 UTC
  • mfrom: (765.2.24 telephony-service-conf_call)
  • Revision ID: ps-jenkins@lists.canonical.com-20140402124129-oywt8u6u9f4253bg
Add support for handling conference calls. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    void testHangUpCall();
34
34
    void testCallHold();
35
35
    void testCallProperties();
 
36
    void testConferenceCall();
36
37
    void testSendMessage();
37
38
 
38
39
private:
143
144
    mApprover->acceptCall();
144
145
 
145
146
    // wait until the call properties are changed
146
 
    QTRY_COMPARE(handlerCallPropertiesSpy.count(), 1);
147
 
    QString objectPath = handlerCallPropertiesSpy.first()[0].toString();
148
 
    QVariantMap propsFromSignal = handlerCallPropertiesSpy.first()[1].toMap();
 
147
    QTRY_VERIFY(handlerCallPropertiesSpy.count() > 0);
 
148
    QString objectPath = handlerCallPropertiesSpy.last()[0].toString();
 
149
    QVariantMap propsFromSignal = handlerCallPropertiesSpy.last()[1].toMap();
149
150
    QVERIFY(!propsFromSignal.isEmpty());
150
151
    QDateTime activeTimestampFromSignal;
151
152
    QDateTime timestampFromSignal;
181
182
    HandlerController::instance()->hangUpCall(objectPath);
182
183
}
183
184
 
 
185
void HandlerTest::testConferenceCall()
 
186
{
 
187
    QString callerId1("55555555");
 
188
    QString callerId2("66666666");
 
189
    QString callerId3("77777777");
 
190
 
 
191
    QVariantMap properties;
 
192
    properties["Caller"] = callerId1;
 
193
    properties["State"] = "incoming";
 
194
 
 
195
    QSignalSpy approverCallSpy(mApprover, SIGNAL(newCall()));
 
196
    QString call1 = MockController::instance()->placeCall(properties);
 
197
 
 
198
    // wait for the channel to hit the approver
 
199
    QTRY_COMPARE(approverCallSpy.count(), 1);
 
200
    mApprover->acceptCall();
 
201
    approverCallSpy.clear();
 
202
    waitForCallActive(callerId1);
 
203
 
 
204
    // make a second call
 
205
    properties["Caller"] = callerId2;
 
206
    QString call2 = MockController::instance()->placeCall(properties);
 
207
    // wait for the channel to hit the approver
 
208
    QTRY_COMPARE(approverCallSpy.count(), 1);
 
209
    mApprover->acceptCall();
 
210
    approverCallSpy.clear();
 
211
    waitForCallActive(callerId2);
 
212
 
 
213
    // now create the conf call
 
214
    QSignalSpy conferenceCreatedSpy(MockController::instance(), SIGNAL(conferenceCreated(QString)));
 
215
    HandlerController::instance()->createConferenceCall(QStringList() << call1 << call2);
 
216
    QTRY_COMPARE(conferenceCreatedSpy.count(), 1);
 
217
    QString conferenceObjectPath = conferenceCreatedSpy.first().first().toString();
 
218
 
 
219
    // now place a third call and try to merge it
 
220
    properties["Caller"] = callerId3;
 
221
    QString call3 = MockController::instance()->placeCall(properties);
 
222
    QTRY_COMPARE(approverCallSpy.count(), 1);
 
223
    mApprover->acceptCall();
 
224
    approverCallSpy.clear();
 
225
    waitForCallActive(callerId3);
 
226
 
 
227
    // merge that call on the conference
 
228
    QSignalSpy channelMergedSpy(MockController::instance(), SIGNAL(channelMerged(QString)));
 
229
    HandlerController::instance()->mergeCall(conferenceObjectPath, call3);
 
230
    QTRY_COMPARE(channelMergedSpy.count(), 1);
 
231
    QCOMPARE(channelMergedSpy.first().first().toString(), call3);
 
232
 
 
233
    // now try to split one of the channels
 
234
    QSignalSpy channelSplittedSpy(MockController::instance(), SIGNAL(channelSplitted(QString)));
 
235
    HandlerController::instance()->splitCall(call2);
 
236
    QTRY_COMPARE(channelSplittedSpy.count(), 1);
 
237
    QCOMPARE(channelSplittedSpy.first().first().toString(), call2);
 
238
 
 
239
    // now hangup the conference and the individual channels
 
240
    HandlerController::instance()->hangUpCall(conferenceObjectPath);
 
241
    HandlerController::instance()->hangUpCall(call1);
 
242
    HandlerController::instance()->hangUpCall(call2);
 
243
    HandlerController::instance()->hangUpCall(call3);
 
244
}
 
245
 
184
246
void HandlerTest::testSendMessage()
185
247
{
186
248
    QString recipient("22222222");