Bug 1077190 - Part 2: Test case. r=hsinyi
authorSzu-Yu Chen [:aknow] <szchen@mozilla.com>
Thu, 16 Oct 2014 23:41:00 +0200
changeset 211149 515d83408ae7d37b6c264742796804ef0fd65d14
parent 211148 057b2dc0590ea8cc3e7b5aaea850ef23e4bf56aa
child 211150 80a92f907fbd0de7c56aae6f3882f5fa7f157497
push id50654
push usercbook@mozilla.com
push dateMon, 20 Oct 2014 13:15:00 +0000
treeherdermozilla-inbound@ae49e79844e0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1077190
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1077190 - Part 2: Test case. r=hsinyi
dom/telephony/test/marionette/head.js
dom/telephony/test/marionette/test_audiomanager_phonestate.js
--- a/dom/telephony/test/marionette/head.js
+++ b/dom/telephony/test/marionette/head.js
@@ -1,13 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Emulate Promise.jsm semantics.
-Promise.defer = function() { return new Deferred(); }
+Promise.defer = function() { return new Deferred(); };
 function Deferred()  {
   this.promise = new Promise(function(resolve, reject) {
     this.resolve = resolve;
     this.reject = reject;
   }.bind(this));
   Object.freeze(this);
 }
 
@@ -615,16 +615,48 @@ let emulator = (function() {
       deferred.resolve(call);
     };
     call.hold();
 
     return deferred.promise;
   }
 
   /**
+   * Resume a call.
+   *
+   * @param call
+   *        A TelephonyCall object.
+   * @return A deferred promise.
+   */
+  function resume(call) {
+    log("Resuming the held call.");
+
+    let deferred = Promise.defer();
+
+    let gotResuming = false;
+    call.onresuming = function onresuming(event) {
+      log("Received 'resuming' call event");
+      call.onresuming = null;
+      checkEventCallState(event, call, "resuming");
+      gotResuming = true;
+    };
+
+    call.onconnected = function onconnected(event) {
+      log("Received 'connected' call event");
+      call.onconnected = null;
+      checkEventCallState(event, call, "connected");
+      ok(gotResuming);
+      deferred.resolve(call);
+    };
+    call.resume();
+
+    return deferred.promise;
+  }
+
+  /**
    * Locally hang up a call.
    *
    * @param call
    *        A TelephonyCall object.
    * @return A deferred promise.
    */
   function hangUp(call) {
     let deferred = Promise.defer();
@@ -1198,16 +1230,17 @@ let emulator = (function() {
   this.gInCallStrPool = inCallStrPool;
   this.gCheckState = checkState;
   this.gCheckAll = checkAll;
   this.gDial = dial;
   this.gDialEmergency = dialEmergency;
   this.gAnswer = answer;
   this.gHangUp = hangUp;
   this.gHold = hold;
+  this.gResume = resume;
   this.gRemoteDial = remoteDial;
   this.gRemoteAnswer = remoteAnswer;
   this.gRemoteHangUp = remoteHangUp;
   this.gRemoteHangUpCalls = remoteHangUpCalls;
   this.gAddCallsToConference = addCallsToConference;
   this.gHoldConference = holdConference;
   this.gResumeConference = resumeConference;
   this.gRemoveCallInConference = removeCallInConference;
--- a/dom/telephony/test/marionette/test_audiomanager_phonestate.js
+++ b/dom/telephony/test/marionette/test_audiomanager_phonestate.js
@@ -78,16 +78,20 @@ startTest(function() {
     .then(() => check(PHONE_STATE_NORMAL, PHONE_STATE_NORMAL))
 
     // Dial out
     .then(() => gDial(outNumber))
     .then(call => { outCall = call; })
     .then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
     .then(() => gRemoteAnswer(outCall))
     .then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
+    .then(() => gHold(outCall))
+    .then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
+    .then(() => gResume(outCall))
+    .then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
     // Dial out and dial in
     .then(() => gRemoteDial(inNumber))
     .then(call => { inCall = call; })
     .then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
     .then(() => gAnswer(inCall))
     .then(() => check(PHONE_STATE_IN_CALL, PHONE_STATE_IN_CALL))
     // Conference
     .then(() => gAddCallsToConference([outCall, inCall]))