Bug 1045643 Part 1 - Notify the Loop server when the desktop client accepts the call, so that it can update the call status. r=nperriault

This commit is contained in:
Mark Banner 2014-08-29 11:22:18 +01:00
parent df8b15570b
commit e63272d14f
5 changed files with 49 additions and 1 deletions

View File

@ -240,6 +240,7 @@ loop.conversation = (function(OT, mozL10n) {
*/
accept: function() {
navigator.mozLoop.stopAlerting();
this._websocket.accept();
this._conversation.incoming();
},

View File

@ -240,6 +240,7 @@ loop.conversation = (function(OT, mozL10n) {
*/
accept: function() {
navigator.mozLoop.stopAlerting();
this._websocket.accept();
this._conversation.incoming();
},

View File

@ -127,6 +127,16 @@ loop.CallConnectionWebSocket = (function() {
});
},
/**
* Notifies the server that the user has accepted the call.
*/
accept: function() {
this._send({
messageType: "action",
event: "accept"
});
},
/**
* Sends data on the websocket.
*

View File

@ -37,6 +37,7 @@ describe("loop.conversation", function() {
},
setLoopCharPref: sandbox.stub(),
getLoopCharPref: sandbox.stub(),
getLoopBoolPref: sandbox.stub(),
startAlerting: function() {},
stopAlerting: function() {},
ensureRegistered: function() {},
@ -311,14 +312,35 @@ describe("loop.conversation", function() {
});
describe("#accept", function() {
beforeEach(function() {
conversation.setIncomingSessionData({
sessionId: "sessionId",
sessionToken: "sessionToken",
apiKey: "apiKey",
callType: "callType",
callId: "Hello",
progressURL: "http://progress.example.com",
websocketToken: 123
});
router._setupWebSocketAndCallView();
sandbox.stub(router._websocket, "accept");
sandbox.stub(navigator.mozLoop, "stopAlerting");
});
it("should initiate the conversation", function() {
router.accept();
sinon.assert.calledOnce(conversation.incoming);
});
it("should notify the websocket of the user acceptance", function() {
router.accept();
sinon.assert.calledOnce(router._websocket.accept);
});
it("should stop alerting", function() {
sandbox.stub(navigator.mozLoop, "stopAlerting");
router.accept();
sinon.assert.calledOnce(navigator.mozLoop.stopAlerting);

View File

@ -148,6 +148,20 @@ describe("loop.CallConnectionWebSocket", function() {
});
});
describe("#accept", function() {
it("should send an accept message to the server", function() {
callWebSocket.promiseConnect();
callWebSocket.accept();
sinon.assert.calledOnce(dummySocket.send);
sinon.assert.calledWithExactly(dummySocket.send, JSON.stringify({
messageType: "action",
event: "accept"
}));
});
});
describe("Events", function() {
beforeEach(function() {
sandbox.stub(callWebSocket, "trigger");