diff --git a/dom/telephony/test/marionette/head.js b/dom/telephony/test/marionette/head.js index 0c5169226c33..0bf7972c46f1 100644 --- a/dom/telephony/test/marionette/head.js +++ b/dom/telephony/test/marionette/head.js @@ -501,11 +501,6 @@ let emulator = (function() { let promises = []; - let promise = waitForNamedStateEvent(call, "connecting") - .then(() => waitForNamedStateEvent(call, "connected")); - - promises.push(promise); - // incoming call triggers conference state change. We should wait for // |conference.onstatechange| before checking the state of the conference // call. @@ -520,8 +515,8 @@ let emulator = (function() { promises.push(promise); } - promise = call.answer(); - promises.push(promise); + promises.push(waitForNamedStateEvent(call, "connected")); + promises.push(call.answer()); return Promise.all(promises).then(() => call); } @@ -538,12 +533,8 @@ let emulator = (function() { let promises = []; - let promise = waitForNamedStateEvent(call, "holding") - .then(() => waitForNamedStateEvent(call, "held")); - promises.push(promise); - - promise = call.hold(); - promises.push(promise); + promises.push(waitForNamedStateEvent(call, "held")); + promises.push(call.hold()); return Promise.all(promises).then(() => call); } @@ -560,12 +551,8 @@ let emulator = (function() { let promises = []; - let promise = waitForNamedStateEvent(call, "resuming") - .then(() => waitForNamedStateEvent(call, "connected")); - promises.push(promise); - - promise = call.resume(); - promises.push(promise); + promises.push(waitForNamedStateEvent(call, "connected")); + promises.push(call.resume()); return Promise.all(promises).then(() => call); } @@ -582,12 +569,8 @@ let emulator = (function() { let promises = []; - let promise = waitForNamedStateEvent(call, "disconnecting") - .then(() => waitForNamedStateEvent(call, "disconnected")); - promises.push(promise); - - promise = call.hangUp(); - promises.push(promise); + promises.push(waitForNamedStateEvent(call, "disconnected")); + promises.push(call.hangUp()); return Promise.all(promises).then(() => call); } @@ -728,9 +711,7 @@ let emulator = (function() { let promises = []; for (let call of callsInConference) { - let promise = waitForNamedStateEvent(call, "holding") - .then(() => waitForNamedStateEvent(call, "held")); - promises.push(promise); + promises.push(waitForNamedStateEvent(call, "held")); } let promise = waitForNamedStateEvent(conference, "holding") @@ -763,9 +744,7 @@ let emulator = (function() { let promises = []; for (let call of callsInConference) { - let promise = waitForNamedStateEvent(call, "resuming") - .then(() => waitForNamedStateEvent(call, "connected")); - promises.push(promise); + promises.push(waitForNamedStateEvent(call, "connected")); } let promise = waitForNamedStateEvent(conference, "resuming") diff --git a/dom/telephony/test/marionette/manifest.ini b/dom/telephony/test/marionette/manifest.ini index 370115850ae4..b63055ee818d 100644 --- a/dom/telephony/test/marionette/manifest.ini +++ b/dom/telephony/test/marionette/manifest.ini @@ -29,7 +29,6 @@ qemu = true [test_incoming_already_held.js] [test_incoming_answer_hangup_oncallschanged.js] [test_incoming_basic_operations.js] -[test_incoming_connecting_hangup.js] [test_incoming_onstatechange.js] [test_mmi.js] [test_mmi_call_forwarding.js] diff --git a/dom/telephony/test/marionette/test_incoming_connecting_hangup.js b/dom/telephony/test/marionette/test_incoming_connecting_hangup.js deleted file mode 100644 index 8b4a6423f252..000000000000 --- a/dom/telephony/test/marionette/test_incoming_connecting_hangup.js +++ /dev/null @@ -1,58 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -MARIONETTE_TIMEOUT = 60000; -MARIONETTE_HEAD_JS = 'head.js'; - -const inNumber = "5555552222"; -const inInfo = gInCallStrPool(inNumber); -let inCall; - -function incoming() { - return gRemoteDial(inNumber) - .then(call => inCall = call) - .then(() => gCheckAll(null, [inCall], "", [], [inInfo.incoming])); -} - -function connecting() { - let promises = [ - gWaitForNamedStateEvent(inCall, "connecting"), - inCall.answer() - ]; - return Promise.all(promises).then(() => inCall); -} - -function hangUp() { - return gHangUp(inCall) - .then(() => gCheckAll(null, [], "", [], [])); -} - -function remoteHangUp() { - return gRemoteHangUp(inCall) - .then(() => gCheckAll(null, [], "", [], [])); -} - -// Test cases. - -function testConnectingHangUp() { - log("= testConnectingHangUp ="); - return incoming() - .then(() => connecting()) - .then(() => hangUp()); -} - -function testConnectingRemoteHangUp() { - log("= testConnectingRemoteHangUp ="); - return incoming() - .then(() => connecting()) - .then(() => remoteHangUp()); -} - -startTest(function() { - Promise.resolve() - .then(() => testConnectingHangUp()) - .then(() => testConnectingRemoteHangUp()) - - .catch(error => ok(false, "Promise reject: " + error)) - .then(finish); -}); diff --git a/dom/telephony/test/marionette/test_incoming_onstatechange.js b/dom/telephony/test/marionette/test_incoming_onstatechange.js index 2b1625af94a5..a35a93722283 100644 --- a/dom/telephony/test/marionette/test_incoming_onstatechange.js +++ b/dom/telephony/test/marionette/test_incoming_onstatechange.js @@ -14,39 +14,19 @@ startTest(function() { .then(() => gCheckAll(null, [inCall], "", [], [inInfo.incoming])) // Answer incoming call - .then(() => { - let p1 = gWaitForStateChangeEvent(inCall, "connecting") - .then(() => gWaitForStateChangeEvent(inCall, "connected")); - let p2 = gAnswer(inCall); - return Promise.all([p1, p2]); - }) + .then(() => gAnswer(inCall)) .then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active])) // Hold the call. - .then(() => { - let p1 = gWaitForStateChangeEvent(inCall, "holding") - .then(() => gWaitForStateChangeEvent(inCall, "held")); - let p2 = gHold(inCall); - return Promise.all([p1, p2]); - }) + .then(() => gHold(inCall)) .then(() => gCheckAll(null, [inCall], "", [], [inInfo.held])) // Resume the call. - .then(() => { - let p1 = gWaitForStateChangeEvent(inCall, "resuming") - .then(() => gWaitForStateChangeEvent(inCall, "connected")); - let p2 = gResume(inCall); - return Promise.all([p1, p2]); - }) + .then(() => gResume(inCall)) .then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active])) // Hang-up call - .then(() => { - let p1 = gWaitForStateChangeEvent(inCall, "disconnecting") - .then(() => gWaitForStateChangeEvent(inCall, "disconnected")); - let p2 = gHangUp(inCall); - return Promise.all([p1, p2]); - }) + .then(() => gHangUp(inCall)) .then(() => gCheckAll(null, [], "", [], [])) .catch(error => ok(false, "Promise reject: " + error)) diff --git a/dom/telephony/test/marionette/test_outgoing_onstatechange.js b/dom/telephony/test/marionette/test_outgoing_onstatechange.js index 11e51b53fd6e..85d443e5560c 100644 --- a/dom/telephony/test/marionette/test_outgoing_onstatechange.js +++ b/dom/telephony/test/marionette/test_outgoing_onstatechange.js @@ -22,30 +22,15 @@ startTest(function() { .then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active])) // Hold the call. - .then(() => { - let p1 = gWaitForStateChangeEvent(outCall, "holding") - .then(() => gWaitForStateChangeEvent(outCall, "held")); - let p2 = gHold(outCall); - return Promise.all([p1, p2]); - }) + .then(() => gHold(outCall)) .then(() => gCheckAll(null, [outCall], "", [], [outInfo.held])) // Resume the call. - .then(() => { - let p1 = gWaitForStateChangeEvent(outCall, "resuming") - .then(() => gWaitForStateChangeEvent(outCall, "connected")); - let p2 = gResume(outCall); - return Promise.all([p1, p2]); - }) + .then(() => gResume(outCall)) .then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active])) // Hang-up call - .then(() => { - let p1 = gWaitForStateChangeEvent(outCall, "disconnecting") - .then(() => gWaitForStateChangeEvent(outCall, "disconnected")); - let p2 = gHangUp(outCall); - return Promise.all([p1, p2]); - }) + .then(() => gHangUp(outCall)) .then(() => gCheckAll(null, [], "", [], [])) .catch(error => ok(false, "Promise reject: " + error)) diff --git a/dom/telephony/test/marionette/test_redundant_operations.js b/dom/telephony/test/marionette/test_redundant_operations.js index c195ebdde4a6..33133095c759 100644 --- a/dom/telephony/test/marionette/test_redundant_operations.js +++ b/dom/telephony/test/marionette/test_redundant_operations.js @@ -8,23 +8,17 @@ const inNumber = "5555552222"; const inInfo = gInCallStrPool(inNumber); let inCall; -function error(event, action) { - ok(false, "Received '" + event + "' event when " + action); +function error(aEvent, aAction) { + ok(false, "Received '" + aEvent + "' event when " + aAction); } -function checkUnexpected(msg, call, event1, event2, actionCallback) { - let error1 = error.bind(this, event1, msg); - let error2 = error.bind(this, event2, msg); +function checkUnexpected(aMsg, aCall, aEvent, aActionCallback) { + let handler = error.bind(this, aEvent, aMsg); + aCall.addEventListener(aEvent, handler); - call.addEventListener(event1, error1); - call.addEventListener(event2, error2); - - return actionCallback().then( + return aActionCallback().then( () => ok(false, msg + "should be rejected."), - () => gDelay(2000).then(() => { - call.removeEventListener(event1, error1); - call.removeEventListener(event2, error2); - })); + () => gDelay(2000).then(() => aCall.removeEventListener(aEvent, handler))); } startTest(function() { @@ -32,36 +26,24 @@ startTest(function() { .then(call => inCall = call) .then(() => gAnswer(inCall)) .then(() => checkUnexpected("answered an active call", inCall, - "connecting", "connected", - () => inCall.answer())) - + "connected", () => inCall.answer())) .then(() => gHold(inCall)) .then(() => checkUnexpected("held a held call", inCall, - "holding", "held", - () => inCall.hold())) + "held", () => inCall.hold())) .then(() => checkUnexpected("answered a held call", inCall, - "connecting", "connected", - () => inCall.answer())) - + "connected", () => inCall.answer())) .then(() => gResume(inCall)) .then(() => checkUnexpected("resumed non-held call", inCall, - "resuming", "connected", - () => inCall.resume())) - + "connected", () => inCall.resume())) .then(() => gHangUp(inCall)) .then(() => checkUnexpected("answered a disconnected call", inCall, - "connecting", "connected", - () => inCall.answer())) + "connected", () => inCall.answer())) .then(() => checkUnexpected("held a disconnected call", inCall, - "holding", "held", - () => inCall.hold())) + "held", () => inCall.hold())) .then(() => checkUnexpected("resumed a disconnected call", inCall, - "resuming", "connected", - () => inCall.resume())) + "connected", () => inCall.resume())) .then(() => checkUnexpected("hang-up a disconnected call", inCall, - "disconnecting", "disconnected", - () => inCall.hangUp())) - + "disconnected", () => inCall.hangUp())) .catch(error => ok(false, "Promise reject: " + error)) .then(finish); });