Bug 1035130 - Part 2: Add test to send conference request twice. r=hsinyi, a=1.4+
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Wed, 09 Jul 2014 19:39:00 -0400
changeset 209015 69340019902d2a9369a40b0ecf615e8a8b9cbf91
parent 209014 1f50cc1bb505f84a34cd9a7fc7d42cebd552d58b
child 209016 2055e28772b04fe7c19174512ec797c09693dd73
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi, 1
bugs1035130
milestone32.0a2
Bug 1035130 - Part 2: Add test to send conference request twice. r=hsinyi, a=1.4+
dom/telephony/test/marionette/head.js
dom/telephony/test/marionette/manifest.ini
dom/telephony/test/marionette/test_conference_add_twice_error.js
--- a/dom/telephony/test/marionette/head.js
+++ b/dom/telephony/test/marionette/head.js
@@ -593,19 +593,21 @@ let emulator = (function() {
    * Add calls to conference.
    *
    * @param callsToAdd
    *        An array of TelephonyCall objects to be added into conference. The
    *        length of the array should be 1 or 2.
    * @param connectedCallback [optional]
    *        A callback function which is called when conference state becomes
    *        connected.
+   * @param twice [optional]
+   *        To send conference request twice. It is only used for special test.
    * @return A deferred promise.
    */
-  function addCallsToConference(callsToAdd, connectedCallback) {
+  function addCallsToConference(callsToAdd, connectedCallback, twice) {
     log("Add " + callsToAdd.length + " calls into conference.");
 
     let deferred = Promise.defer();
     let done = function() {
       deferred.resolve();
     };
 
     let pending = ["conference.oncallschanged", "conference.onconnected"];
@@ -636,20 +638,23 @@ let emulator = (function() {
       ok(!conference.oncallschanged);
       if (typeof connectedCallback === 'function') {
         connectedCallback();
       }
       receive("conference.onconnected");
     });
 
     // Cannot use apply() through webidl, so just separate the cases to handle.
-    if (callsToAdd.length == 2) {
-      conference.add(callsToAdd[0], callsToAdd[1]);
-    } else {
-      conference.add(callsToAdd[0]);
+    let requestCount = twice ? 2 : 1;
+    for (let i = 0; i < requestCount; ++i) {
+      if (callsToAdd.length == 2) {
+        conference.add(callsToAdd[0], callsToAdd[1]);
+      } else {
+        conference.add(callsToAdd[0]);
+      }
     }
 
     return deferred.promise;
   }
 
   /**
    * Hold the conference.
    *
--- a/dom/telephony/test/marionette/manifest.ini
+++ b/dom/telephony/test/marionette/manifest.ini
@@ -51,10 +51,11 @@ disabled = Bug 821958
 [test_conference_two_calls.js]
 [test_conference_add_error.js]
 [test_conference_remove_error.js]
 [test_conference_two_hangup_one.js]
 [test_conference_two_hold_resume.js]
 [test_conference_two_remove_one.js]
 [test_conference_three_hangup_one.js]
 [test_conference_three_remove_one.js]
+[test_conference_add_twice_error.js]
 [test_outgoing_when_two_calls_on_line.js]
 [test_incomingcall_phonestate_speaker.js]
new file mode 100644
--- /dev/null
+++ b/dom/telephony/test/marionette/test_conference_add_twice_error.js
@@ -0,0 +1,48 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+MARIONETTE_TIMEOUT = 60000;
+MARIONETTE_HEAD_JS = 'head.js';
+
+function testConferenceTwoCallsTwice() {
+  log('= testConferenceTwoCallsTwice =');
+
+  let outCall;
+  let inCall;
+  let outNumber = "5555550101";
+  let inNumber  = "5555550201";
+  let outInfo = gOutCallStrPool(outNumber);
+  let inInfo = gInCallStrPool(inNumber);
+
+  let sendConferenceTwice = true;
+
+  return Promise.resolve()
+    .then(gCheckInitialState)
+    .then(() => gDial(outNumber))
+    .then(call => { outCall = call; })
+    .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.ringing]))
+    .then(() => gRemoteAnswer(outCall))
+    .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.active]))
+    .then(() => gRemoteDial(inNumber))
+    .then(call => { inCall = call; })
+    .then(() => gCheckAll(outCall, [outCall, inCall], '', [],
+                          [outInfo.active, inInfo.incoming]))
+    .then(() => gAnswer(inCall))
+    .then(() => gCheckAll(inCall, [outCall, inCall], '', [],
+                          [outInfo.held, inInfo.active]))
+    .then(() => gAddCallsToConference([outCall, inCall], function() {
+      gCheckState(conference, [], 'connected', [outCall, inCall]);
+    }, sendConferenceTwice))
+    .then(() => gCheckAll(conference, [], 'connected', [outCall, inCall],
+                          [outInfo.active, inInfo.active]))
+    .then(() => gRemoteHangUpCalls([outCall, inCall]));
+}
+
+// Start the test
+startTest(function() {
+  testConferenceTwoCallsTwice()
+    .then(null, error => {
+      ok(false, 'promise rejects during test.');
+    })
+    .then(finish);
+});