Bug 1079811 - A new call won't start if the outgoing call window is opened (showing feedback or retry/cancel). r=Standard8

This commit is contained in:
Romain Gauthier 2014-10-17 16:11:41 +01:00
parent 28373a8448
commit e3b0b8f9ab
2 changed files with 47 additions and 0 deletions

View File

@ -406,6 +406,12 @@ loop.store.ConversationStore = (function() {
this._websocket.close();
delete this._websocket;
}
// XXX: The internal callId is different from
// this.get("callId"), see bug 1084228 for more info.
var locationHash = new loop.shared.utils.Helper().locationHash();
var callId = locationHash.match(/\#outgoing\/(.*)/)[1];
navigator.mozLoop.releaseCallData(callId);
},
/**

View File

@ -36,6 +36,11 @@ describe("loop.store.ConversationStore", function () {
}]
};
navigator.mozLoop = {
getLoopBoolPref: sandbox.stub(),
releaseCallData: sandbox.stub()
};
dispatcher = new loop.Dispatcher();
client = {
setupOutgoingCall: sinon.stub(),
@ -120,6 +125,8 @@ describe("loop.store.ConversationStore", function () {
describe("#connectionFailure", function() {
beforeEach(function() {
store._websocket = fakeWebsocket;
sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash")
.returns("#outgoing/42");
});
it("should disconnect the session", function() {
@ -145,6 +152,14 @@ describe("loop.store.ConversationStore", function () {
expect(store.get("callState")).eql(CALL_STATES.TERMINATED);
expect(store.get("callStateReason")).eql("fake");
});
it("should release mozLoop callsData", function() {
dispatcher.dispatch(
new sharedActions.ConnectionFailure({reason: "fake"}));
sinon.assert.calledOnce(navigator.mozLoop.releaseCallData);
sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42");
});
});
describe("#connectionProgress", function() {
@ -481,6 +496,8 @@ describe("loop.store.ConversationStore", function () {
close: wsCloseSpy
};
store.set({callState: CALL_STATES.ONGOING});
sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash")
.returns("#outgoing/42");
});
it("should disconnect the session", function() {
@ -506,6 +523,13 @@ describe("loop.store.ConversationStore", function () {
expect(store.get("callState")).eql(CALL_STATES.FINISHED);
});
it("should release mozLoop callsData", function() {
dispatcher.dispatch(new sharedActions.HangupCall());
sinon.assert.calledOnce(navigator.mozLoop.releaseCallData);
sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42");
});
});
describe("#peerHungupCall", function() {
@ -519,6 +543,8 @@ describe("loop.store.ConversationStore", function () {
close: wsCloseSpy
};
store.set({callState: CALL_STATES.ONGOING});
sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash")
.returns("#outgoing/42");
});
it("should disconnect the session", function() {
@ -538,6 +564,13 @@ describe("loop.store.ConversationStore", function () {
expect(store.get("callState")).eql(CALL_STATES.FINISHED);
});
it("should release mozLoop callsData", function() {
dispatcher.dispatch(new sharedActions.PeerHungupCall());
sinon.assert.calledOnce(navigator.mozLoop.releaseCallData);
sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42");
});
});
describe("#cancelCall", function() {
@ -545,6 +578,8 @@ describe("loop.store.ConversationStore", function () {
store._websocket = fakeWebsocket;
store.set({callState: CALL_STATES.CONNECTING});
sandbox.stub(loop.shared.utils.Helper.prototype, "locationHash")
.returns("#outgoing/42");
});
it("should disconnect the session", function() {
@ -579,6 +614,12 @@ describe("loop.store.ConversationStore", function () {
expect(store.get("callState")).eql(CALL_STATES.CLOSE);
});
it("should release mozLoop callsData", function() {
dispatcher.dispatch(new sharedActions.CancelCall());
sinon.assert.calledOnce(navigator.mozLoop.releaseCallData);
sinon.assert.calledWithExactly(navigator.mozLoop.releaseCallData, "42");
});
});
describe("#retryCall", function() {