Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #22185 from dmarcos/bug1039629
Browse files Browse the repository at this point in the history
Bug 1039629 - [B2G] [Camera] Placeholder warning text is shown when Came...
  • Loading branch information
dmarcos committed Jul 26, 2014
2 parents 55f572e + 0e25a4f commit f708ba1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/camera/js/controllers/battery.js
Expand Up @@ -75,6 +75,12 @@ BatteryController.prototype.notifications = {
BatteryController.prototype.updateStatus = function () {
var previous = this.app.get('batteryStatus');
var current = this.getStatus(this.battery);
// We need the app to be first localized
// before showing the battery status message
if (!this.app.localized()) {
this.app.on('localized', this.updateStatus);
return;
}
if (current !== previous) {
this.app.set('batteryStatus', current);
}
Expand Down
12 changes: 12 additions & 0 deletions apps/camera/test/unit/controllers/battery_test.js
Expand Up @@ -34,6 +34,7 @@ suite('controllers/battery', function() {
this.app.settings.battery = sinon.createStubInstance(this.Setting);
this.app.settings.battery.get.withArgs('levels').returns(levels);
this.app.l10n = { get: sinon.stub() };
this.app.localized = sinon.stub().returns(true);
this.app.views = {
notification: sinon.createStubInstance(this.NotificationView)
};
Expand Down Expand Up @@ -126,6 +127,17 @@ suite('controllers/battery', function() {
this.controller.updateStatus();
assert.ok(this.app.set.calledWith('batteryStatus', 'healthy'));
});

test('should wait for the app to be localized', function() {
this.app.battery.level = 0.06;
this.app.localized.returns(false);
this.controller.app.get
.withArgs('batteryStatus')
.returns('critical');

this.controller.updateStatus();
assert.ok(this.app.on.calledWith('localized'));
});
});

suite('BatteryController#onStatusChange()', function() {
Expand Down

0 comments on commit f708ba1

Please sign in to comment.