mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 998271 - L10n notifications, r=dmose
This commit is contained in:
parent
c9f831b055
commit
2c444d64ba
@ -9,8 +9,6 @@ loop.shared = loop.shared || {};
|
||||
loop.shared.router = (function(l10n) {
|
||||
"use strict";
|
||||
|
||||
var __ = l10n.get;
|
||||
|
||||
/**
|
||||
* Base Router. Allows defining a main active view and ease toggling it when
|
||||
* the active route changes.
|
||||
@ -114,7 +112,7 @@ loop.shared.router = (function(l10n) {
|
||||
* Session has ended. Notifies the user and ends the call.
|
||||
*/
|
||||
_onSessionEnded: function() {
|
||||
this._notifier.warn(__("call_has_ended"));
|
||||
this._notifier.warnL10n("call_has_ended");
|
||||
this.endCall();
|
||||
},
|
||||
|
||||
@ -127,7 +125,7 @@ loop.shared.router = (function(l10n) {
|
||||
* @param {Object} event
|
||||
*/
|
||||
_onPeerHungup: function() {
|
||||
this._notifier.warn(__("peer_ended_conversation"));
|
||||
this._notifier.warnL10n("peer_ended_conversation");
|
||||
this.endCall();
|
||||
},
|
||||
|
||||
@ -135,7 +133,7 @@ loop.shared.router = (function(l10n) {
|
||||
* Network disconnected. Notifies the user and ends the call.
|
||||
*/
|
||||
_onNetworkDisconnected: function() {
|
||||
this._notifier.warn(__("network_disconnected"));
|
||||
this._notifier.warnL10n("network_disconnected");
|
||||
this.endCall();
|
||||
}
|
||||
});
|
||||
|
@ -138,7 +138,7 @@ loop.shared.views = (function(_, OT, l10n) {
|
||||
/**
|
||||
* Subscribes and attaches each created stream to a DOM element.
|
||||
*
|
||||
* XXX: for now we only support a single remote stream, hence a singe DOM
|
||||
* XXX: for now we only support a single remote stream, hence a single DOM
|
||||
* element.
|
||||
*
|
||||
* http://tokbox.com/opentok/libraries/client/js/reference/StreamEvent.html
|
||||
@ -264,6 +264,20 @@ loop.shared.views = (function(_, OT, l10n) {
|
||||
this.collection.add(notification);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new notification to the stack using an l10n message identifier,
|
||||
* triggering rendering of it.
|
||||
*
|
||||
* @param {String} messageId L10n message id
|
||||
* @param {String} level Notification level
|
||||
*/
|
||||
notifyL10n: function(messageId, level) {
|
||||
this.notify({
|
||||
message: l10n.get(messageId),
|
||||
level: level
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a warning notification to the stack and renders it.
|
||||
*
|
||||
@ -273,6 +287,15 @@ loop.shared.views = (function(_, OT, l10n) {
|
||||
this.notify({level: "warning", message: message});
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a l10n warning notification to the stack and renders it.
|
||||
*
|
||||
* @param {String} messageId L10n message id
|
||||
*/
|
||||
warnL10n: function(messageId) {
|
||||
this.warn(l10n.get(messageId));
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds an error notification to the stack and renders it.
|
||||
*
|
||||
@ -282,6 +305,15 @@ loop.shared.views = (function(_, OT, l10n) {
|
||||
this.notify({level: "error", message: message});
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a l10n rror notification to the stack and renders it.
|
||||
*
|
||||
* @param {String} messageId L10n message id
|
||||
*/
|
||||
errorL10n: function(messageId) {
|
||||
this.error(l10n.get(messageId));
|
||||
},
|
||||
|
||||
/**
|
||||
* Renders this view.
|
||||
*
|
||||
|
@ -80,7 +80,7 @@ loop.webapp = (function($, OT, webl10n) {
|
||||
|
||||
_onSessionError: function(error) {
|
||||
console.error(error);
|
||||
this.notifier.error(__("unable_retrieve_call_info"));
|
||||
this.notifier.errorL10n("unable_retrieve_call_info");
|
||||
},
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ loop.webapp = (function($, OT, webl10n) {
|
||||
*/
|
||||
startCall: function() {
|
||||
if (!this._conversation.get("loopToken")) {
|
||||
this._notifier.error(__("missing_conversation_info"));
|
||||
this._notifier.errorL10n("missing_conversation_info");
|
||||
this.navigate("home", {trigger: true});
|
||||
} else {
|
||||
this.navigate("call/ongoing/" + this._conversation.get("loopToken"), {
|
||||
|
@ -72,7 +72,9 @@ describe("loop.shared.router", function() {
|
||||
notifier = {
|
||||
notify: sandbox.spy(),
|
||||
warn: sandbox.spy(),
|
||||
error: sandbox.spy()
|
||||
warnL10n: sandbox.spy(),
|
||||
error: sandbox.spy(),
|
||||
errorL10n: sandbox.spy()
|
||||
};
|
||||
});
|
||||
|
||||
@ -117,10 +119,21 @@ describe("loop.shared.router", function() {
|
||||
sinon.assert.calledOnce(router.endCall);
|
||||
});
|
||||
|
||||
it("should warn the user that the session has ended", function() {
|
||||
conversation.trigger("session:ended");
|
||||
|
||||
sinon.assert.calledOnce(notifier.warnL10n);
|
||||
sinon.assert.calledWithExactly(notifier.warnL10n,
|
||||
"call_has_ended");
|
||||
});
|
||||
|
||||
it("should warn the user when peer hangs up", function() {
|
||||
conversation.trigger("session:peer-hungup");
|
||||
|
||||
sinon.assert.calledOnce(notifier.warn);
|
||||
sinon.assert.calledOnce(notifier.warnL10n);
|
||||
sinon.assert.calledWithExactly(notifier.warnL10n,
|
||||
"peer_ended_conversation");
|
||||
|
||||
});
|
||||
|
||||
it("should call endCall() when peer hangs up", function() {
|
||||
@ -132,7 +145,9 @@ describe("loop.shared.router", function() {
|
||||
it("should warn the user when network disconnects", function() {
|
||||
conversation.trigger("session:network-disconnected");
|
||||
|
||||
sinon.assert.calledOnce(notifier.warn);
|
||||
sinon.assert.calledOnce(notifier.warnL10n);
|
||||
sinon.assert.calledWithExactly(notifier.warnL10n,
|
||||
"network_disconnected");
|
||||
});
|
||||
|
||||
it("should call endCall() when network disconnects", function() {
|
||||
|
@ -215,6 +215,9 @@ describe("loop.shared.views", function() {
|
||||
var coll, notifData, testNotif;
|
||||
|
||||
beforeEach(function() {
|
||||
sandbox.stub(l10n, "get", function(x) {
|
||||
return "translated:" + x;
|
||||
});
|
||||
notifData = {level: "error", message: "plop"};
|
||||
testNotif = new sharedModels.NotificationModel(notifData);
|
||||
coll = new sharedModels.NotificationCollection();
|
||||
@ -269,6 +272,33 @@ describe("loop.shared.views", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#notifyL10n", function() {
|
||||
var view;
|
||||
|
||||
beforeEach(function() {
|
||||
view = new sharedViews.NotificationListView({collection: coll});
|
||||
});
|
||||
|
||||
it("should translate a message string identifier", function() {
|
||||
view.notifyL10n("fakeId", "warning");
|
||||
|
||||
sinon.assert.calledOnce(l10n.get);
|
||||
sinon.assert.calledWithExactly(l10n.get, "fakeId");
|
||||
});
|
||||
|
||||
it("should notify end user with the provided message", function() {
|
||||
sandbox.stub(view, "notify");
|
||||
|
||||
view.notifyL10n("fakeId", "warning");
|
||||
|
||||
sinon.assert.calledOnce(view.notify);
|
||||
sinon.assert.calledWithExactly(view.notify, {
|
||||
message: "translated:fakeId",
|
||||
level: "warning"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#warn", function() {
|
||||
it("should add a warning notification to the stack", function() {
|
||||
var view = new sharedViews.NotificationListView({collection: coll});
|
||||
@ -281,6 +311,21 @@ describe("loop.shared.views", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#warnL10n", function() {
|
||||
it("should warn using a l10n string id", function() {
|
||||
var view = new sharedViews.NotificationListView({collection: coll});
|
||||
sandbox.stub(view, "notify");
|
||||
|
||||
view.warnL10n("fakeId");
|
||||
|
||||
sinon.assert.called(view.notify);
|
||||
sinon.assert.calledWithExactly(view.notify, {
|
||||
message: "translated:fakeId",
|
||||
level: "warning"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#error", function() {
|
||||
it("should add an error notification to the stack", function() {
|
||||
var view = new sharedViews.NotificationListView({collection: coll});
|
||||
@ -293,6 +338,21 @@ describe("loop.shared.views", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#errorL10n", function() {
|
||||
it("should notify an error using a l10n string id", function() {
|
||||
var view = new sharedViews.NotificationListView({collection: coll});
|
||||
sandbox.stub(view, "notify");
|
||||
|
||||
view.errorL10n("fakeId");
|
||||
|
||||
sinon.assert.called(view.notify);
|
||||
sinon.assert.calledWithExactly(view.notify, {
|
||||
message: "translated:fakeId",
|
||||
level: "error"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Collection events", function() {
|
||||
var view;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user