|
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 testOutgoingCallForServiceId(number, serviceId) { |
|
18 let outCall; |
|
19 let outInfo = gOutCallStrPool(number); |
|
20 |
|
21 return Promise.resolve() |
|
22 .then(() => gDial(number, serviceId)) |
|
23 .then(call => { |
|
24 outCall = call; |
|
25 is(outCall.serviceId, serviceId); |
|
26 }) |
|
27 .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.ringing])) |
|
28 .then(() => gRemoteAnswer(outCall)) |
|
29 .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.active])) |
|
30 .then(() => gRemoteHangUp(outCall)) |
|
31 .then(() => gCheckAll(null, [], '', [], [])); |
|
32 } |
|
33 |
|
34 function testIncomingCallForServiceId(number, serviceId) { |
|
35 let inCall; |
|
36 let inInfo = gInCallStrPool(number); |
|
37 |
|
38 return Promise.resolve() |
|
39 .then(() => gRemoteDial(number)) |
|
40 .then(call => { |
|
41 inCall = call; |
|
42 is(inCall.serviceId, serviceId); |
|
43 }) |
|
44 .then(() => gCheckAll(null, [inCall], '', [], [inInfo.incoming])) |
|
45 .then(() => gAnswer(inCall)) |
|
46 .then(() => gCheckAll(inCall, [inCall], '', [], [inInfo.active])) |
|
47 .then(() => gRemoteHangUp(inCall)) |
|
48 .then(() => gCheckAll(null, [], '', [], [])); |
|
49 } |
|
50 |
|
51 function testOutgoingCall() { |
|
52 log("= testOutgoingCall ="); |
|
53 |
|
54 return Promise.resolve() |
|
55 .then(() => muxModem(0)) |
|
56 .then(() => testOutgoingCallForServiceId("0912345000", 0)) |
|
57 .then(() => muxModem(1)) |
|
58 .then(() => testOutgoingCallForServiceId("0912345001", 1)) |
|
59 .then(() => muxModem(0)); |
|
60 } |
|
61 |
|
62 function testIncomingCall() { |
|
63 log("= testIncomingCall ="); |
|
64 |
|
65 return Promise.resolve() |
|
66 .then(() => muxModem(0)) |
|
67 .then(() => testIncomingCallForServiceId("0912345000", 0)) |
|
68 .then(() => muxModem(1)) |
|
69 .then(() => testIncomingCallForServiceId("0912345001", 1)) |
|
70 .then(() => muxModem(0)); |
|
71 } |
|
72 |
|
73 startDSDSTest(function() { |
|
74 testOutgoingCall() |
|
75 .then(testIncomingCall) |
|
76 .then(null, () => { |
|
77 ok(false, "promise rejects during test."); |
|
78 }) |
|
79 .then(finish); |
|
80 }); |