2014-12-17 18:47:54 +03:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
MARIONETTE_TIMEOUT = 90000;
|
|
|
|
MARIONETTE_HEAD_JS = 'head.js';
|
|
|
|
|
|
|
|
const inNumber = "5555552222";
|
|
|
|
const inInfo = gInCallStrPool(inNumber);
|
|
|
|
let inCall;
|
|
|
|
|
|
|
|
function incoming() {
|
|
|
|
return gRemoteDial(inNumber)
|
|
|
|
.then(call => inCall = call)
|
2015-03-26 11:39:40 +03:00
|
|
|
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.incoming]))
|
|
|
|
.then(() => is(inCall.disconnectedReason, null));
|
2014-12-17 18:47:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function answer() {
|
|
|
|
return gAnswer(inCall)
|
2015-03-26 11:39:40 +03:00
|
|
|
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
|
|
|
|
.then(() => is(inCall.disconnectedReason, null));
|
2014-12-17 18:47:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function hold() {
|
|
|
|
return gHold(inCall)
|
2015-03-26 11:39:40 +03:00
|
|
|
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.held]))
|
|
|
|
.then(() => is(inCall.disconnectedReason, null));
|
2014-12-17 18:47:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function resume() {
|
|
|
|
return gResume(inCall)
|
2015-03-26 11:39:40 +03:00
|
|
|
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
|
|
|
|
.then(() => is(inCall.disconnectedReason, null));
|
2014-12-17 18:47:54 +03:00
|
|
|
}
|
|
|
|
|
2014-12-17 18:47:55 +03:00
|
|
|
function hangUp() {
|
|
|
|
return gHangUp(inCall)
|
2015-03-26 11:39:40 +03:00
|
|
|
.then(() => gCheckAll(null, [], "", [], []))
|
|
|
|
.then(() => is(inCall.disconnectedReason, "NormalCallClearing"));
|
2014-12-17 18:47:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function remoteHangUp() {
|
|
|
|
return gRemoteHangUp(inCall)
|
2015-03-26 11:39:40 +03:00
|
|
|
.then(() => gCheckAll(null, [], "", [], []))
|
|
|
|
.then(() => is(inCall.disconnectedReason, "NormalCallClearing"));
|
2014-12-17 18:47:55 +03:00
|
|
|
}
|
|
|
|
|
2014-12-17 18:47:54 +03:00
|
|
|
// Test cases.
|
|
|
|
|
|
|
|
function testIncomingReject() {
|
|
|
|
log("= testIncomingReject =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => hangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingCancel() {
|
|
|
|
log("= testIncomingCancel =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => remoteHangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingAnswerHangUp() {
|
|
|
|
log("= testIncomingAnswerHangUp =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => answer())
|
|
|
|
.then(() => hangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingAnswerRemoteHangUp() {
|
|
|
|
log("= testIncomingAnswerRemoteHangUp =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => answer())
|
|
|
|
.then(() => remoteHangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingAnswerHoldHangUp() {
|
|
|
|
log("= testIncomingAnswerHoldHangUp =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => answer())
|
|
|
|
.then(() => hold())
|
|
|
|
.then(() => hangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingAnswerHoldRemoteHangUp() {
|
|
|
|
log("= testIncomingAnswerHoldRemoteHangUp =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => answer())
|
|
|
|
.then(() => hold())
|
|
|
|
.then(() => remoteHangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingAnswerHoldResumeHangUp() {
|
|
|
|
log("= testIncomingAnswerHoldResumeHangUp =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => answer())
|
|
|
|
.then(() => hold())
|
|
|
|
.then(() => resume())
|
|
|
|
.then(() => hangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testIncomingAnswerHoldResumeRemoteHangUp() {
|
|
|
|
log("= testIncomingAnswerHoldResumeRemoteHangUp =");
|
|
|
|
return incoming()
|
|
|
|
.then(() => answer())
|
|
|
|
.then(() => hold())
|
|
|
|
.then(() => resume())
|
|
|
|
.then(() => remoteHangUp());
|
|
|
|
}
|
|
|
|
|
|
|
|
startTest(function() {
|
|
|
|
Promise.resolve()
|
|
|
|
.then(() => testIncomingReject())
|
|
|
|
.then(() => testIncomingCancel())
|
|
|
|
.then(() => testIncomingAnswerHangUp())
|
|
|
|
.then(() => testIncomingAnswerRemoteHangUp())
|
|
|
|
.then(() => testIncomingAnswerHoldHangUp())
|
|
|
|
.then(() => testIncomingAnswerHoldRemoteHangUp())
|
|
|
|
.then(() => testIncomingAnswerHoldResumeHangUp())
|
|
|
|
.then(() => testIncomingAnswerHoldResumeRemoteHangUp())
|
|
|
|
|
|
|
|
.catch(error => ok(false, "Promise reject: " + error))
|
|
|
|
.then(finish);
|
|
|
|
});
|