From edfe6c71d20733d944343425b5ffd38ba03ada23 Mon Sep 17 00:00:00 2001 From: Ben Hsu Date: Mon, 26 Jan 2015 00:38:00 -0500 Subject: [PATCH] Bug 1103731 - Part 3: Update the related testcase. r=aknow --- .../marionette/test_outgoing_auto_hold.js | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/dom/telephony/test/marionette/test_outgoing_auto_hold.js b/dom/telephony/test/marionette/test_outgoing_auto_hold.js index 352567d5bc0b..af07835d3063 100644 --- a/dom/telephony/test/marionette/test_outgoing_auto_hold.js +++ b/dom/telephony/test/marionette/test_outgoing_auto_hold.js @@ -5,16 +5,21 @@ MARIONETTE_TIMEOUT = 60000; MARIONETTE_HEAD_JS = 'head.js'; function testAutoHoldCall() { + log('= testAutoHoldCall ='); + let outCall1; let outCall2; + const callNumber1 = "0900000001"; + const callNumber2 = "0900000002"; - return gDial("0900000001") + return Promise.resolve() + .then(() => gDial(callNumber1)) .then(call => { outCall1 = call; }) .then(() => gRemoteAnswer(outCall1)) .then(() => { is(outCall1.state, "connected"); }) - .then(() => gDial("0900000002")) + .then(() => gDial(callNumber2)) .then(call => { outCall2 = call; }) .then(() => { is(outCall1.state, "held"); @@ -22,17 +27,50 @@ function testAutoHoldCall() { .then(() => gRemoteHangUpCalls([outCall1, outCall2])); } + +function testAutoHoldCallFailed() { + log('= testAutoHoldCallFailed ='); + + let outCall1; + let outCall2; + const callNumber1 = "0900000011"; + const callNumber2 = "0900000012"; + + return Promise.resolve() + .then(() => emulator.runCmd("gsm disable hold")) + .then(() => gDial(callNumber1)) + .then(call => { outCall1 = call; }) + .then(() => gRemoteAnswer(outCall1)) + .then(() => { + is(outCall1.state, "connected"); + }) + .then(() => gDial(callNumber2)) + .then(call => { + ok(false, "The second |dial()| should be rejected."); + outCall2 = call; + return gRemoteHangUpCalls([outCall2]); + }, () => log("The second |dial()| is rejected as expected.")) + .then(() => gRemoteHangUpCalls([outCall1])) + .then(() => emulator.runCmd("gsm enable hold")); +} + function testAutoHoldConferenceCall() { + log('= testAutoHoldConferenceCall ='); + let subCall1; let subCall2; let outCall; + const subNumber1 = "0900000021"; + const subNumber2 = "0900000022"; + const outNumber = "0900000023"; - return gSetupConference(["0900000001", "0900000002"]) + return Promise.resolve() + .then(() => gSetupConference([subNumber1, subNumber2])) .then(calls => { [subCall1, subCall2] = calls; is(conference.state, "connected"); }) - .then(() => gDial("0900000003")) + .then(() => gDial(outNumber)) .then(call => { outCall = call; }) .then(() => { is(subCall1.state, "held"); @@ -43,8 +81,13 @@ function testAutoHoldConferenceCall() { } startTest(function() { - testAutoHoldCall() + Promise.resolve() + .then(() => testAutoHoldCall()) + .then(() => testAutoHoldCallFailed()) .then(() => testAutoHoldConferenceCall()) - .catch(error => ok(false, "Promise reject: " + error)) + .catch(error => { + ok(false, "Promise reject: " + error); + emulator.runCmd("gsm enable hold"); + }) .then(finish); });