Bug 1075509 - Standalone UI needs "call failed" sound. r=nperriault

This commit is contained in:
Romain Gauthier 2014-10-28 14:33:37 +01:00
parent 3b0c878729
commit 83f3648184
4 changed files with 47 additions and 2 deletions

View File

@ -264,7 +264,6 @@ loop.webapp = (function($, _, OT, mozL10n) {
var PendingConversationView = React.createClass({displayName: 'PendingConversationView',
mixins: [sharedMixins.AudioMixin],
getInitialState: function() {
return {
callState: "connecting"
@ -571,6 +570,12 @@ loop.webapp = (function($, _, OT, mozL10n) {
});
var FailedConversationView = React.createClass({displayName: 'FailedConversationView',
mixins: [sharedMixins.AudioMixin],
componentDidMount: function() {
this.play("failure");
},
render: function() {
document.title = mozL10n.get("standalone_title_with_status",
{clientShortname: mozL10n.get("clientShortname2"),

View File

@ -264,7 +264,6 @@ loop.webapp = (function($, _, OT, mozL10n) {
var PendingConversationView = React.createClass({
mixins: [sharedMixins.AudioMixin],
getInitialState: function() {
return {
callState: "connecting"
@ -571,6 +570,12 @@ loop.webapp = (function($, _, OT, mozL10n) {
});
var FailedConversationView = React.createClass({
mixins: [sharedMixins.AudioMixin],
componentDidMount: function() {
this.play("failure");
},
render: function() {
document.title = mozL10n.get("standalone_title_with_status",
{clientShortname: mozL10n.get("clientShortname2"),

View File

@ -501,6 +501,41 @@ describe("loop.webapp", function() {
});
});
});
describe("FailedConversationView", function() {
var view, conversation, client, fakeAudio;
beforeEach(function() {
fakeAudio = {
play: sinon.spy(),
pause: sinon.spy(),
removeAttribute: sinon.spy()
};
sandbox.stub(window, "Audio").returns(fakeAudio);
client = new loop.StandaloneClient({
baseServerUrl: "http://fake.example.com"
});
conversation = new sharedModels.ConversationModel({}, {
sdk: {}
});
conversation.set("loopToken", "fakeToken");
view = React.addons.TestUtils.renderIntoDocument(
loop.webapp.FailedConversationView({
conversation: conversation,
client: client,
notifications: notifications
}));
});
it("should play a failure sound, once", function() {
sinon.assert.calledOnce(window.Audio);
sinon.assert.calledWithExactly(window.Audio,
"shared/sounds/failure.ogg");
expect(fakeAudio.loop).to.equal(false);
});
});
});
describe("WebappRootView", function() {