|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 60000; |
|
5 MARIONETTE_HEAD_JS = 'head.js'; |
|
6 |
|
7 function muxModem(id) { |
|
8 let deferred = Promise.defer(); |
|
9 |
|
10 emulator.run("mux modem " + id, function() { |
|
11 deferred.resolve(); |
|
12 }); |
|
13 |
|
14 return deferred.promise; |
|
15 } |
|
16 |
|
17 function testNewCallWhenOtherConnectionInUse(firstServiceId, secondServiceId) { |
|
18 log("= testNewCallWhenOtherConnectionInUse ="); |
|
19 log("1st call on " + firstServiceId + ", 2nd call on " + secondServiceId); |
|
20 |
|
21 let outCall; |
|
22 |
|
23 return Promise.resolve() |
|
24 .then(() => muxModem(firstServiceId)) |
|
25 .then(() => { |
|
26 return telephony.dial("0912345000", firstServiceId); |
|
27 }) |
|
28 .then(call => { |
|
29 outCall = call; |
|
30 is(outCall.serviceId, firstServiceId); |
|
31 }) |
|
32 .then(() => gRemoteAnswer(outCall)) |
|
33 .then(() => { |
|
34 return telephony.dial("0912345001", secondServiceId); |
|
35 }) |
|
36 .then(() => { |
|
37 log("The promise should not be resolved"); |
|
38 ok(false); |
|
39 }, cause => { |
|
40 is(cause, "OtherConnectionInUse"); |
|
41 }) |
|
42 .then(() => gRemoteHangUp(outCall)); |
|
43 } |
|
44 |
|
45 startDSDSTest(function() { |
|
46 testNewCallWhenOtherConnectionInUse(0, 1) |
|
47 .then(() => testNewCallWhenOtherConnectionInUse(1, 0)) |
|
48 .then(() => muxModem(0)) |
|
49 .then(null, () => { |
|
50 ok(false, "promise rejects during test."); |
|
51 }) |
|
52 .then(finish); |
|
53 }); |