Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
|
|
@ -0,0 +1,101 @@
|
|||
/* global LockScreenClockWidgetSetup */
|
||||
'use strict';
|
||||
|
||||
requireApp('system/lockscreen/js/source/dom_event_source.js');
|
||||
requireApp('system/lockscreen/js/source/source_event.js');
|
||||
requireApp('system/lockscreen/js/stream/process.js');
|
||||
requireApp('system/lockscreen/js/stream/stream.js');
|
||||
requireApp('system/lockscreen/js/state/lockscreen_basic_state.js');
|
||||
requireApp(
|
||||
'system/lockscreen/js/widgets/clock/lockscreen_clock_widget_setup.js');
|
||||
|
||||
suite('LockScreenClockWidgetSetup > ', function() {
|
||||
setup(function() {
|
||||
window.Stream = function() {
|
||||
this.steps = [];
|
||||
};
|
||||
window.Stream.prototype = {
|
||||
start: function() { return this; },
|
||||
ready: function() { return this; },
|
||||
stop: function() { return this; },
|
||||
destroy: function() { return this; },
|
||||
next: function(step) {
|
||||
this.steps.push(step);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
test(`when setup it would do the setup things`,
|
||||
function() {
|
||||
var mockThis = {
|
||||
configs: {},
|
||||
handleSourceEvent: function() {},
|
||||
queryElements: {
|
||||
bind: this.sinon.stub().returns('queryElements')
|
||||
},
|
||||
component: {
|
||||
updateClock: {
|
||||
bind: this.sinon.stub().returns('component.updateClock')
|
||||
},
|
||||
updateFormatters: {
|
||||
bind: this.sinon.stub().returns('component.updateFormatters')
|
||||
},
|
||||
updateAlarm: {
|
||||
bind: this.sinon.stub().returns('component.updateAlarm')
|
||||
},
|
||||
fetchAlarmData: {
|
||||
bind: this.sinon.stub().returns('component.fetchAlarmData')
|
||||
}
|
||||
},
|
||||
transferToTick: {
|
||||
bind: this.sinon.stub().returns('transferToTick')
|
||||
}
|
||||
};
|
||||
var method = LockScreenClockWidgetSetup.prototype.start;
|
||||
method.call(mockThis);
|
||||
assert.include(mockThis.stream.steps, 'queryElements',
|
||||
`it doesn't scheudle to query the elements`);
|
||||
assert.include(mockThis.stream.steps, 'component.updateClock',
|
||||
`it doesn't schedule to update the clock at the setup`);
|
||||
assert.include(mockThis.stream.steps, 'component.updateFormatters',
|
||||
`it doesn't schedule to update the date/time formatters at the setup`);
|
||||
assert.include(mockThis.stream.steps, 'transferToTick',
|
||||
`it doesn't schedule to transfer to the tick state after it's done`);
|
||||
});
|
||||
|
||||
test(`it would transfer to the tick phase`, function() {
|
||||
window.LockScreenClockWidgetTick = {
|
||||
name: 'LockScreenClockWidgetTick'
|
||||
};
|
||||
var mockThis = {
|
||||
transferTo: this.sinon.stub()
|
||||
};
|
||||
var method = LockScreenClockWidgetSetup.prototype.transferToTick;
|
||||
method.call(mockThis);
|
||||
assert.isTrue(mockThis.transferTo.calledWithMatch(
|
||||
sinon.match(function(state) {
|
||||
return 'LockScreenClockWidgetTick' === state.name;
|
||||
})),
|
||||
`it doesn't transfer to the tick state`
|
||||
);
|
||||
});
|
||||
|
||||
test(`it would query elements as the component requires`, function() {
|
||||
var mockThis = {
|
||||
component: {
|
||||
resources: {
|
||||
elements: {
|
||||
date: 'date-query',
|
||||
time: 'time-query'
|
||||
}}}};
|
||||
var dummyDiv = document.createElement('div');
|
||||
this.sinon.stub(document, 'getElementById').returns(dummyDiv);
|
||||
var method = LockScreenClockWidgetSetup.prototype.queryElements;
|
||||
method.call(mockThis);
|
||||
assert.strictEqual(dummyDiv, mockThis.component.resources.elements.date,
|
||||
`the date query hasn't been queried`);
|
||||
assert.strictEqual(dummyDiv, mockThis.component.resources.elements.time,
|
||||
`the time query hasn't been queried`);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/* global LockScreenClockWidgetSuspend */
|
||||
'use strict';
|
||||
|
||||
requireApp('system/lockscreen/js/source/dom_event_source.js');
|
||||
requireApp('system/lockscreen/js/source/source_event.js');
|
||||
requireApp('system/lockscreen/js/stream/process.js');
|
||||
requireApp('system/lockscreen/js/stream/stream.js');
|
||||
requireApp('system/lockscreen/js/state/lockscreen_basic_state.js');
|
||||
requireApp(
|
||||
'system/lockscreen/js/widgets/clock/lockscreen_clock_widget_suspend.js');
|
||||
|
||||
suite('LockScreenClockWidgetSuspend > ', function() {
|
||||
setup(function() {
|
||||
window.Stream = function() {
|
||||
this.steps = [];
|
||||
};
|
||||
window.Stream.prototype = {
|
||||
start: function() { return this; },
|
||||
ready: function() { return this; },
|
||||
stop: function() { return this; },
|
||||
destroy: function() { return this; },
|
||||
next: function(step) {
|
||||
this.steps.push(step);
|
||||
return this;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
test(`when start it should do the setup things`,
|
||||
function() {
|
||||
var mockThis = {
|
||||
configs: {},
|
||||
handleSourceEvent: function() {}
|
||||
};
|
||||
this.sinon.stub(window.Stream.prototype.ready, 'bind').returns('ready');
|
||||
var method = LockScreenClockWidgetSuspend.prototype.start;
|
||||
method.call(mockThis);
|
||||
assert.include(mockThis.stream.steps, 'ready',
|
||||
`it doesn't schedule to become ready`);
|
||||
});
|
||||
|
||||
test(`when stop it should stop things`, function() {
|
||||
var mockThis = {
|
||||
stream: new window.Stream()
|
||||
};
|
||||
var stubStop = this.sinon.stub(mockThis.stream, 'stop');
|
||||
var method = LockScreenClockWidgetSuspend.prototype.stop;
|
||||
method.call(mockThis);
|
||||
assert.isTrue(stubStop.called,
|
||||
`it doesn't stop the stream`);
|
||||
});
|
||||
|
||||
test(`when events it would call the corresponding functions`, function() {
|
||||
var mockThis = {
|
||||
component: { updateClock: this.sinon.stub() },
|
||||
transferToTick: this.sinon.stub()
|
||||
};
|
||||
var method = LockScreenClockWidgetSuspend.prototype.handleSourceEvent;
|
||||
|
||||
method.call(mockThis, {'type': 'screenchange',
|
||||
'detail': {screenEnabled: true} });
|
||||
assert.isTrue(mockThis.transferToTick.called,
|
||||
`when 'screenchange' & screenEnabled it doesn't transfer to tick`);
|
||||
mockThis.transferToSuspend = this.sinon.stub();
|
||||
});
|
||||
|
||||
test(`it would call the component's method to transfer to tick`,
|
||||
function() {
|
||||
window.LockScreenClockWidgetTick = {
|
||||
name: 'LockScreenClockWidgetTick'
|
||||
};
|
||||
var mockThis = {
|
||||
component: {
|
||||
transferTo: this.sinon.stub()
|
||||
}
|
||||
};
|
||||
var method = LockScreenClockWidgetSuspend.prototype.transferToTick;
|
||||
method.call(mockThis);
|
||||
assert.isTrue(mockThis.component.transferTo.calledWithMatch(function(clz) {
|
||||
return 'LockScreenClockWidgetTick' === clz.name;
|
||||
}));
|
||||
});
|
||||
|
||||
test(`it should update the clock before transferring to the Suspend state`,
|
||||
function() {
|
||||
var mockThis = {
|
||||
component: { updateClock: this.sinon.stub() },
|
||||
transferToTick: function() {}
|
||||
};
|
||||
var method = LockScreenClockWidgetSuspend.prototype.handleSourceEvent;
|
||||
method.call(mockThis, {'type': 'screenchange',
|
||||
'detail': { 'screenEnabled': true}});
|
||||
assert.isTrue(mockThis.component.updateClock.called,
|
||||
`it doesn't call updateClock before the transferring`);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/* global LockScreenClockWidget */
|
||||
'use strict';
|
||||
|
||||
requireApp('system/lockscreen/js/component/lockscreen_basic_component.js');
|
||||
requireApp(
|
||||
'system/lockscreen/js/widgets/clock/lockscreen_clock_widget.js');
|
||||
|
||||
suite('LockScreenClockWidget > ', function() {
|
||||
var domAlarm;
|
||||
setup(function() {
|
||||
window.LockScreenClockWidgetSetup = this.sinon.stub();
|
||||
domAlarm = document.createElement('div');
|
||||
});
|
||||
|
||||
test(`when setup it would kick off the state machine`,
|
||||
function() {
|
||||
var method = LockScreenClockWidget.prototype.setup;
|
||||
method.call({});
|
||||
assert.isTrue(window.LockScreenClockWidgetSetup.called,
|
||||
`it doesn't kick off the state machine`);
|
||||
});
|
||||
|
||||
test(`it would update the clock`, function() {
|
||||
var mockThis = {
|
||||
logger: {
|
||||
debug: function() {}
|
||||
},
|
||||
timeFormatter: new Intl.DateTimeFormat('en-US', {
|
||||
hour12: false,
|
||||
hour: 'numeric',
|
||||
minute: 'numeric'
|
||||
}),
|
||||
dateFormatter: new Intl.DateTimeFormat('en-US', {
|
||||
weekday: 'long',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
}),
|
||||
resources: {
|
||||
elements: {
|
||||
time: { firstChild: { data: 'dummy-data' }},
|
||||
date: { firstChild: { data: 'dummy-data' }}
|
||||
}}
|
||||
};
|
||||
var method = LockScreenClockWidget.prototype.updateClock;
|
||||
var now = new Date();
|
||||
method.call(mockThis);
|
||||
assert.equal(mockThis.timeFormatter.format(now),
|
||||
mockThis.resources.elements.time.firstChild.data,
|
||||
`it doesn't update the time.textContent with the time in locale format`);
|
||||
assert.equal(mockThis.dateFormatter.format(now),
|
||||
mockThis.resources.elements.date.firstChild.data,
|
||||
`it doesn't update the date.textContent with the date in locale format`);
|
||||
});
|
||||
|
||||
test(`it would update the alarm info (an alarm is set)`, function(done) {
|
||||
var mockThis = {
|
||||
resources: {
|
||||
elements: {
|
||||
alarm: domAlarm,
|
||||
alarmtime: { textContent: 'dummy-textContent' },
|
||||
}
|
||||
},
|
||||
fetchAlarmData: function() {
|
||||
return new Promise( function(resolve,reject){
|
||||
resolve({hour: '20', minute: '15'});
|
||||
});
|
||||
}
|
||||
};
|
||||
var method = LockScreenClockWidget.prototype.updateAlarm;
|
||||
method.call(mockThis);
|
||||
assert.isFulfilled(mockThis.fetchAlarmData());
|
||||
mockThis.fetchAlarmData().then( function() {
|
||||
assert.equal(mockThis.resources.elements.alarmtime.textContent, '8:15PM');
|
||||
assert.propertyVal( mockThis.resources.elements.alarm.classList,
|
||||
'0', 'has-alarm');
|
||||
})
|
||||
.then(done)
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
test(`it would update the alarm info (an alarm is not set)`, function(done) {
|
||||
var mockThis = {
|
||||
resources: {
|
||||
elements: {
|
||||
alarm: domAlarm,
|
||||
alarmtime: { textContent: 'dummy-textContent' },
|
||||
}
|
||||
},
|
||||
fetchAlarmData: function() {
|
||||
return new Promise( function(resolve,reject){
|
||||
resolve(null);
|
||||
});
|
||||
}
|
||||
};
|
||||
var method = LockScreenClockWidget.prototype.updateAlarm;
|
||||
method.call(mockThis);
|
||||
assert.isFulfilled(mockThis.fetchAlarmData());
|
||||
mockThis.fetchAlarmData().then( function() {
|
||||
assert.propertyVal( mockThis.resources.elements.alarm.classList,
|
||||
'0', 'no-alarms');
|
||||
})
|
||||
.then(done)
|
||||
.catch(done);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
/* global LockScreenClockWidgetTick */
|
||||
'use strict';
|
||||
|
||||
requireApp('system/lockscreen/js/source/dom_event_source.js');
|
||||
requireApp('system/lockscreen/js/source/source_event.js');
|
||||
requireApp('system/lockscreen/js/stream/process.js');
|
||||
requireApp('system/lockscreen/js/stream/stream.js');
|
||||
requireApp('system/lockscreen/js/state/lockscreen_basic_state.js');
|
||||
requireApp(
|
||||
'system/lockscreen/js/widgets/clock/lockscreen_clock_widget_tick.js');
|
||||
|
||||
suite('LockScreenClockWidgetTick > ', function() {
|
||||
setup(function() {
|
||||
window.Stream = function() {
|
||||
this.steps = [];
|
||||
};
|
||||
window.Stream.prototype = {
|
||||
start: function() { return this; },
|
||||
ready: function() { return this; },
|
||||
stop: function() { return this; },
|
||||
destroy: function() { return this; },
|
||||
next: function(step) {
|
||||
if ('function' === typeof step) {
|
||||
this.steps.push(step());
|
||||
} else {
|
||||
this.steps.push(step);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
test(`when start it should do the setup things`,
|
||||
function() {
|
||||
var mockThis = {
|
||||
configs: {},
|
||||
handleSourceEvent: function() {},
|
||||
component: {
|
||||
_previousState: { configs: { name: 'LockScreenClockWidgetSetup' }},
|
||||
updateClock: {
|
||||
bind: this.sinon.stub().returns('component.updateClock')
|
||||
},
|
||||
updateFormatters: {
|
||||
bind: this.sinon.stub().returns('component.updateFormatters')
|
||||
},
|
||||
getTimeformat: function() {
|
||||
mockThis.stream.steps.push('component.getTimeformat');
|
||||
}
|
||||
}
|
||||
};
|
||||
this.sinon.stub(window.Stream.prototype.ready, 'bind').returns('ready');
|
||||
var method = LockScreenClockWidgetTick.prototype.start;
|
||||
method.call(mockThis);
|
||||
assert.include(mockThis.stream.steps, 'component.updateFormatters',
|
||||
`it doesn't check out the timeformat`);
|
||||
assert.include(mockThis.stream.steps, 'component.updateClock',
|
||||
`it doesn't schedule to update the clock`);
|
||||
assert.include(mockThis.stream.steps, 'ready',
|
||||
`it doesn't schedule to become ready`);
|
||||
});
|
||||
|
||||
test(`when restart it should call the restart method`,
|
||||
function() {
|
||||
var mockThis = {
|
||||
configs: {},
|
||||
handleSourceEvent: function() {},
|
||||
component: {
|
||||
_previousState: { configs: { name: 'LockScreenClockWidgetSuspend' }},
|
||||
},
|
||||
restart: this.sinon.stub()
|
||||
};
|
||||
var method = LockScreenClockWidgetTick.prototype.start;
|
||||
method.call(mockThis);
|
||||
assert.isTrue(mockThis.restart.called,
|
||||
`it doesn't call the restart method`);
|
||||
});
|
||||
|
||||
test(`when stop it should stop things`, function() {
|
||||
var mockThis = {
|
||||
stream: new window.Stream(),
|
||||
_minuteSource: {
|
||||
stop: {
|
||||
bind: this.sinon.stub().returns(`bound stop called`)
|
||||
}}
|
||||
};
|
||||
this.sinon.stub(mockThis.stream, 'stop').returns({
|
||||
next: function(cb) {
|
||||
assert.equal(cb, `bound stop called`,
|
||||
`it doesn't stop the source when the state is stopping`);
|
||||
}
|
||||
});
|
||||
var method = LockScreenClockWidgetTick.prototype.stop;
|
||||
method.call(mockThis);
|
||||
});
|
||||
|
||||
test(`when events it would call the corresponding functions`, function() {
|
||||
var mockThis = {
|
||||
component: {
|
||||
updateClock: this.sinon.stub(),
|
||||
updateFormatters: this.sinon.stub(),
|
||||
},
|
||||
transferToSuspend: this.sinon.stub()
|
||||
};
|
||||
var method = LockScreenClockWidgetTick.prototype.handleSourceEvent;
|
||||
|
||||
method.call(mockThis, {'type': 'ftudone'});
|
||||
assert.isTrue(mockThis.component.updateClock.called,
|
||||
`when 'ftudone' it doesn't update the clock`);
|
||||
mockThis.component.updateClock = this.sinon.stub();
|
||||
|
||||
method.call(mockThis, {'type': 'moztimechange'});
|
||||
assert.isTrue(mockThis.component.updateClock.called,
|
||||
`when 'moztimechange' it doesn't update the clock`);
|
||||
mockThis.component.updateClock = this.sinon.stub();
|
||||
|
||||
method.call(mockThis, {'type': 'lockscreen-notification-clock-tick'});
|
||||
assert.isTrue(mockThis.component.updateClock.called,
|
||||
`when 'lockscreen-notification-clock-tick' it doesn't update the clock`);
|
||||
mockThis.component.updateClock = this.sinon.stub();
|
||||
|
||||
method.call(mockThis, {'type': 'screenchange',
|
||||
'detail': {screenEnabled: false} });
|
||||
assert.isTrue(mockThis.transferToSuspend.called,
|
||||
`when 'screenchange' & not screenEnabled it doesn't transfer to suspend`);
|
||||
mockThis.transferToSuspend = this.sinon.stub();
|
||||
|
||||
method.call(mockThis, {'type': 'screenchange',
|
||||
'detail': {screenEnabled: true} });
|
||||
assert.isFalse(mockThis.transferToSuspend.called,
|
||||
`when 'screenchange' & screenEnabled it still transfer to suspend`);
|
||||
mockThis.transferToSuspend = this.sinon.stub();
|
||||
});
|
||||
|
||||
test(`it would call the component's method to transfer to suspend`,
|
||||
function() {
|
||||
window.LockScreenClockWidgetSuspend = {
|
||||
name: 'LockScreenClockWidgetSuspend'
|
||||
};
|
||||
var mockThis = {
|
||||
component: {
|
||||
transferTo: this.sinon.stub()
|
||||
}
|
||||
};
|
||||
var method = LockScreenClockWidgetTick.prototype.transferToSuspend;
|
||||
method.call(mockThis);
|
||||
assert.isTrue(mockThis.component.transferTo.calledWithMatch(function(clz) {
|
||||
return 'LockScreenClockWidgetSuspend' === clz.name;
|
||||
}));
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue