|
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 handleConferenceRemoveError(callToRemove) { |
|
8 log('Handle conference remove error.'); |
|
9 |
|
10 let deferred = Promise.defer(); |
|
11 |
|
12 conference.onerror = function(evt) { |
|
13 log('Receiving a conference error event.'); |
|
14 conference.onerror = null; |
|
15 |
|
16 is(evt.name, 'removeError', 'conference removeError'); |
|
17 |
|
18 deferred.resolve(); |
|
19 } |
|
20 conference.remove(callToRemove); |
|
21 |
|
22 return deferred.promise; |
|
23 } |
|
24 |
|
25 function testConferenceRemoveError() { |
|
26 log('= testConferenceRemoveError ='); |
|
27 |
|
28 let outCall; |
|
29 let inCall; |
|
30 let inCall2; |
|
31 let outNumber = "5555550101"; |
|
32 let inNumber = "5555550201"; |
|
33 let inNumber2 = "5555550202"; |
|
34 let outInfo = gOutCallStrPool(outNumber); |
|
35 let inInfo = gInCallStrPool(inNumber); |
|
36 let inInfo2 = gInCallStrPool(inNumber2); |
|
37 |
|
38 return Promise.resolve() |
|
39 .then(() => gSetupConferenceTwoCalls(outNumber, inNumber)) |
|
40 .then(calls => { |
|
41 [outCall, inCall] = calls; |
|
42 }) |
|
43 .then(() => gRemoteDial(inNumber2)) |
|
44 .then(call => {inCall2 = call;}) |
|
45 .then(() => gCheckAll(conference, [inCall2], 'connected', [outCall, inCall], |
|
46 [outInfo.active, inInfo.active, inInfo2.incoming])) |
|
47 .then(() => gAnswer(inCall2, function() { |
|
48 gCheckState(inCall2, [inCall2], 'held', [outCall, inCall]); |
|
49 })) |
|
50 .then(() => gCheckAll(inCall2, [inCall2], 'held', [outCall, inCall], |
|
51 [outInfo.held, inInfo.held, inInfo2.active])) |
|
52 .then(() => gResumeConference([outCall, inCall], function() { |
|
53 gCheckState(conference, [inCall2], 'connected', [outCall, inCall]); |
|
54 })) |
|
55 // Not allowed to remove a call when there are one connected and one held |
|
56 // calls. |
|
57 .then(() => handleConferenceRemoveError(outCall)) |
|
58 .then(() => gRemoteHangUpCalls([outCall, inCall, inCall2])); |
|
59 } |
|
60 |
|
61 // Start the test |
|
62 startTest(function() { |
|
63 testConferenceRemoveError() |
|
64 .then(null, error => { |
|
65 ok(false, 'promise rejects during test.'); |
|
66 }) |
|
67 .then(finish); |
|
68 }); |