Bug 1210513 - Loop's direct calls don't cancel properly if you click the hangup button on the toolbar. r=mikedeboer,a=lhenry
authorMark Banner <standard8@mozilla.com>
Fri, 02 Oct 2015 14:24:09 +0100
changeset 296304 4c88c4270076d54df23f74ba99c7ff318ff0c454
parent 296303 192e84036f5a8bab4bfe6e341c6e14a5b3806fd3
child 296305 f944f0a5170264a2f75ab79cbc4279a068018007
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer, lhenry
bugs1210513
milestone43.0a2
Bug 1210513 - Loop's direct calls don't cancel properly if you click the hangup button on the toolbar. r=mikedeboer,a=lhenry
browser/components/loop/content/shared/js/conversationStore.js
browser/components/loop/test/shared/conversationStore_test.js
--- a/browser/components/loop/content/shared/js/conversationStore.js
+++ b/browser/components/loop/content/shared/js/conversationStore.js
@@ -333,17 +333,20 @@ loop.store = loop.store || {};
      */
     hangupCall: function() {
       if (this._websocket) {
         // Let the server know the user has hung up.
         this._websocket.mediaFail();
       }
 
       this._endSession();
-      this.setStoreState({callState: CALL_STATES.FINISHED});
+      this.setStoreState({
+        callState: this._storeState.callState === CALL_STATES.ONGOING ?
+                   CALL_STATES.FINISHED : CALL_STATES.CLOSE
+      });
     },
 
     /**
      * The remote peer disconnected from the session.
      *
      * @param {sharedActions.RemotePeerDisconnected} actionData
      */
     remotePeerDisconnected: function(actionData) {
--- a/browser/components/loop/test/shared/conversationStore_test.js
+++ b/browser/components/loop/test/shared/conversationStore_test.js
@@ -772,22 +772,32 @@ describe("loop.store.ConversationStore",
     });
 
     it("should ensure the websocket is closed", function() {
       store.hangupCall(new sharedActions.HangupCall());
 
       sinon.assert.calledOnce(wsHangupSpy);
     });
 
-    it("should set the callState to finished", function() {
+    it("should set the callState to finished for ongoing call state", function() {
       store.hangupCall(new sharedActions.HangupCall());
 
       expect(store.getStoreState("callState")).eql(CALL_STATES.FINISHED);
     });
 
+    it("should set the callState to CLOSE for non-ongoing call state", function() {
+      store.setStoreState({
+        callState: CALL_STATES.CONNECTING
+      });
+
+      store.hangupCall(new sharedActions.HangupCall());
+
+      expect(store.getStoreState("callState")).eql(CALL_STATES.CLOSE);
+    });
+
     it("should release mozLoop callsData", function() {
       store.hangupCall(new sharedActions.HangupCall());
 
       sinon.assert.calledOnce(fakeMozLoop.calls.clearCallInProgress);
       sinon.assert.calledWithExactly(
         fakeMozLoop.calls.clearCallInProgress, "42");
     });
   });