Bug 1093014 - Part 2: Test in call MMI. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-12-10 15:40:43 +08:00
parent 99e215a109
commit 813a26d070
5 changed files with 261 additions and 0 deletions

View File

@ -1025,6 +1025,9 @@ let emulator = (function() {
this.gDelay = delay;
this.gWaitForEvent = waitForEvent;
this.gWaitForCallsChangedEvent = waitForCallsChangedEvent;
this.gWaitForNamedStateEvent = waitForNamedStateEvent;
this.gWaitForStateChangeEvent = waitForStateChangeEvent;
this.gCheckInitialState = checkInitialState;
this.gClearCalls = clearCalls;
this.gOutCallStrPool = outCallStrPool;

View File

@ -67,3 +67,6 @@ disabled = Bug 821958
[test_mmi.js]
[test_mmi_change_pin.js]
[test_mmi_call_forwarding.js]
[test_incall_mmi_call_waiting.js]
[test_incall_mmi_call_hold.js]
[test_incall_mmi_conference.js]

View File

@ -0,0 +1,88 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const call1Number = "0900000001";
const call2Number = "0900000002";
const call1Info = gOutCallStrPool(call1Number);
const call2Info = gOutCallStrPool(call2Number);
// call1 is held, call2 is active
function setupTwoCalls() {
let call1;
let call2;
return gDial(call1Number)
.then(call => call1 = call)
.then(() => gRemoteAnswer(call1))
.then(() => gDial(call2Number))
.then(call => call2 = call)
.then(() => gRemoteAnswer(call2))
.then(() => gCheckAll(call2, [call1, call2], "", [],
[call1Info.held, call2Info.active]))
.then(() => [call1, call2]);
}
function testInCallMMI_0() {
log('= testInCallMMI_0 =');
return setupTwoCalls()
.then(calls => [call1, call2] = calls)
// Hangup held call.
.then(() => gSendMMI("0"))
.then(() => gWaitForNamedStateEvent(call1, "disconnected"))
.then(() => gCheckAll(call2, [call2], "", [], [call2Info.active]))
.then(() => gRemoteHangUpCalls([call2]));
}
function testInCallMMI_1() {
log('= testInCallMMI_1 =');
return setupTwoCalls()
.then(calls => [call1, call2] = calls)
// Hangup current call, resume held call.
.then(() => gSendMMI("1"))
.then(() => {
let p1 = gWaitForNamedStateEvent(call1, "connected");
let p2 = gWaitForNamedStateEvent(call2, "disconnected");
return Promise.all([p1, p2]);
})
.then(() => gCheckAll(call1, [call1], "", [], [call1Info.active]))
.then(() => gRemoteHangUpCalls([call1]));
}
function testInCallMMI_2() {
log('= testInCallMMI_2 =');
return setupTwoCalls()
.then(calls => [call1, call2] = calls)
// Hold current call, resume held call.
.then(() => gSendMMI("2"))
.then(() => {
let p1 = gWaitForNamedStateEvent(call1, "connected");
let p2 = gWaitForNamedStateEvent(call2, "held");
return Promise.all([p1, p2]);
})
.then(() => gCheckAll(call1, [call1, call2], "", [],
[call1Info.active, call2Info.held]))
// Hold current call, resume held call.
.then(() => gSendMMI("2"))
.then(() => {
let p1 = gWaitForNamedStateEvent(call1, "held");
let p2 = gWaitForNamedStateEvent(call2, "connected");
return Promise.all([p1, p2]);
})
.then(() => gCheckAll(call2, [call1, call2], "", [],
[call1Info.held, call2Info.active]))
.then(() => gRemoteHangUpCalls([call1, call2]));
}
startTest(function() {
testInCallMMI_0()
.then(() => testInCallMMI_1())
.then(() => testInCallMMI_2())
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -0,0 +1,77 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const outNumber = "0900000001";
const inNumber = "0900000002";
const outInfo = gOutCallStrPool(outNumber);
const inInfo = gInCallStrPool(inNumber);
function setupTwoCalls() {
let outCall;
let inCall;
return gDial(outNumber)
.then(call => outCall = call)
.then(() => gRemoteAnswer(outCall))
.then(() => gRemoteDial(inNumber))
.then(call => inCall = call)
.then(() => gCheckAll(outCall, [outCall, inCall], "", [],
[outInfo.active, inInfo.waiting]))
.then(() => [outCall, inCall]);
}
function testInCallMMI_0() {
log('= testInCallMMI_0 =');
return setupTwoCalls()
.then(calls => [outCall, inCall] = calls)
// Hangup waiting call.
.then(() => gSendMMI("0"))
.then(() => gWaitForNamedStateEvent(inCall, "disconnected"))
.then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active]))
.then(() => gRemoteHangUpCalls([outCall]));
}
function testInCallMMI_1() {
log('= testInCallMMI_1 =');
return setupTwoCalls()
.then(calls => [outCall, inCall] = calls)
// Hangup current call, accept waiting call.
.then(() => gSendMMI("1"))
.then(() => {
let p1 = gWaitForNamedStateEvent(outCall, "disconnected");
let p2 = gWaitForNamedStateEvent(inCall, "connected");
return Promise.all([p1, p2]);
})
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
.then(() => gRemoteHangUpCalls([inCall]));
}
function testInCallMMI_2() {
log('= testInCallMMI_2 =');
return setupTwoCalls()
.then(calls => [outCall, inCall] = calls)
// Hold current call, accept waiting call.
.then(() => gSendMMI("2"))
.then(() => {
let p1 = gWaitForNamedStateEvent(outCall, "held");
let p2 = gWaitForNamedStateEvent(inCall, "connected");
return Promise.all([p1, p2]);
})
.then(() => gCheckAll(inCall, [outCall, inCall], "", [],
[outInfo.held, inInfo.active]))
.then(() => gRemoteHangUpCalls([outCall, inCall]));
}
startTest(function() {
testInCallMMI_0()
.then(() => testInCallMMI_1())
.then(() => testInCallMMI_2())
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -0,0 +1,90 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const call1Number = "0900000001";
const call2Number = "0900000002";
const call3Number = "0900000003";
const call1Info = gOutCallStrPool(call1Number);
const call2Info = gOutCallStrPool(call2Number);
const call3Info = gOutCallStrPool(call3Number);
function setupTwoCalls() {
let call1;
let call2;
return gDial(call1Number)
.then(call => call1 = call)
.then(() => gRemoteAnswer(call1))
.then(() => gDial(call2Number))
.then(call => call2 = call)
.then(() => gRemoteAnswer(call2))
.then(() => gCheckAll(call2, [call1, call2], "", [],
[call1Info.held, call2Info.active]))
.then(() => [call1, call2]);
}
function testInCallMMI() {
log('= testInCallMMI =');
return setupTwoCalls()
.then(calls => [call1, call2] = calls)
// Conference two calls.
.then(() => log("- Conference two calls."))
.then(() => gSendMMI("3"))
.then(() => gWaitForNamedStateEvent(conference, "connected"))
.then(() => gCheckAll(conference, [], "connected", [call1, call2],
[call1Info.active, call2Info.active]))
// Make third call.
.then(() => log("- Make third call."))
.then(() => gDial(call3Number))
.then(call => call3 = call)
.then(() => gRemoteAnswer(call3))
.then(() => gCheckAll(call3, [call3], "held", [call1, call2],
[call1Info.held, call2Info.held, call3Info.active]))
// Enlarge the conference.
.then(() => log("- Enlarge the conference."))
.then(() => gSendMMI("3"))
.then(() => gWaitForNamedStateEvent(conference, "connected"))
.then(() => gCheckAll(conference, [], "connected", [call1, call2, call3],
[call1Info.active, call2Info.active, call3Info.active]))
// Separate call 2.
.then(() => log("- Separate call 2."))
.then(() => gSendMMI("22"))
.then(() => gWaitForNamedStateEvent(conference, "held"))
.then(() => gCheckAll(call2, [call2], "held", [call1, call3],
[call1Info.held, call2Info.active, call3Info.held]))
// Switch active.
.then(() => log("- Switch active."))
.then(() => gSendMMI("2"))
.then(() => gWaitForNamedStateEvent(conference, "connected"))
.then(() => gCheckAll(conference, [call2], "connected", [call1, call3],
[call1Info.active, call2Info.held, call3Info.active]))
// Release call 2.
.then(() => log("- Release call 2."))
.then(() => gSendMMI("12"))
.then(() => gWaitForNamedStateEvent(call2, "disconnected"))
.then(() => gCheckAll(conference, [], "connected", [call1, call3],
[call1Info.active, call3Info.active]))
// Release call 1.
.then(() => log("- Release call 1."))
.then(() => gSendMMI("11"))
.then(() => gWaitForStateChangeEvent(conference, ""))
.then(() => gCheckAll(call3, [call3], "", [], [call3Info.active]))
.then(() => gRemoteHangUpCalls([call3]));
}
startTest(function() {
testInCallMMI()
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});