1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_dsds_connection_conflict.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +MARIONETTE_TIMEOUT = 60000; 1.8 +MARIONETTE_HEAD_JS = 'head.js'; 1.9 + 1.10 +function muxModem(id) { 1.11 + let deferred = Promise.defer(); 1.12 + 1.13 + emulator.run("mux modem " + id, function() { 1.14 + deferred.resolve(); 1.15 + }); 1.16 + 1.17 + return deferred.promise; 1.18 +} 1.19 + 1.20 +function testNewCallWhenOtherConnectionInUse(firstServiceId, secondServiceId) { 1.21 + log("= testNewCallWhenOtherConnectionInUse ="); 1.22 + log("1st call on " + firstServiceId + ", 2nd call on " + secondServiceId); 1.23 + 1.24 + let outCall; 1.25 + 1.26 + return Promise.resolve() 1.27 + .then(() => muxModem(firstServiceId)) 1.28 + .then(() => { 1.29 + return telephony.dial("0912345000", firstServiceId); 1.30 + }) 1.31 + .then(call => { 1.32 + outCall = call; 1.33 + is(outCall.serviceId, firstServiceId); 1.34 + }) 1.35 + .then(() => gRemoteAnswer(outCall)) 1.36 + .then(() => { 1.37 + return telephony.dial("0912345001", secondServiceId); 1.38 + }) 1.39 + .then(() => { 1.40 + log("The promise should not be resolved"); 1.41 + ok(false); 1.42 + }, cause => { 1.43 + is(cause, "OtherConnectionInUse"); 1.44 + }) 1.45 + .then(() => gRemoteHangUp(outCall)); 1.46 +} 1.47 + 1.48 +startDSDSTest(function() { 1.49 + testNewCallWhenOtherConnectionInUse(0, 1) 1.50 + .then(() => testNewCallWhenOtherConnectionInUse(1, 0)) 1.51 + .then(() => muxModem(0)) 1.52 + .then(null, () => { 1.53 + ok(false, "promise rejects during test."); 1.54 + }) 1.55 + .then(finish); 1.56 +});