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
18
gaia/tv_apps/tv-deck/test/unit/.jshintrc
Executable file
18
gaia/tv_apps/tv-deck/test/unit/.jshintrc
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"extends": "../../../../.jshintrc",
|
||||
"predef": [
|
||||
"assert",
|
||||
"suite",
|
||||
"test",
|
||||
"setup",
|
||||
"teardown",
|
||||
"suiteSetup",
|
||||
"suiteTeardown",
|
||||
"require",
|
||||
"requireApp",
|
||||
"sinon",
|
||||
"mocha",
|
||||
"loadBodyHTML"
|
||||
]
|
||||
}
|
||||
|
||||
394
gaia/tv_apps/tv-deck/test/unit/channel_manager_test.js
Executable file
394
gaia/tv_apps/tv-deck/test/unit/channel_manager_test.js
Executable file
|
|
@ -0,0 +1,394 @@
|
|||
'use strict';
|
||||
/*jshint browser: true */
|
||||
/* global ChannelManager, MockTVManager, MockTVTuner, MockTVSource,
|
||||
MockTVChannel */
|
||||
|
||||
require('/bower_components/evt/index.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_channel.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_source.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_tuner.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_manager.js');
|
||||
require('/shared/js/smart-screen/channel_manager.js');
|
||||
|
||||
suite('tv-deck/channel_manager', function() {
|
||||
|
||||
var realTVManager;
|
||||
var channelManager;
|
||||
|
||||
setup(function() {
|
||||
realTVManager = window.navigator.tv;
|
||||
window.navigator.tv = new MockTVManager();
|
||||
channelManager = new ChannelManager();
|
||||
});
|
||||
|
||||
suite('currentHash', function() {
|
||||
setup(function() {
|
||||
channelManager.playingState = {
|
||||
tunerId: '1',
|
||||
sourceType: 'dvb-1',
|
||||
channelNumber: '10'
|
||||
};
|
||||
});
|
||||
|
||||
test('currentHash should equals to #1,dvb-1,10', function () {
|
||||
assert.equal(channelManager.currentHash, '#1,dvb-1,10');
|
||||
});
|
||||
});
|
||||
|
||||
suite('getTuner()', function() {
|
||||
setup(function() {
|
||||
channelManager.currentTuners = {
|
||||
'tuner1': {},
|
||||
'tuner2': {}
|
||||
};
|
||||
|
||||
channelManager.playingState = {
|
||||
tunerId: 'tuner1',
|
||||
sourceType: 'source1',
|
||||
channelNumber: 'channel1'
|
||||
};
|
||||
});
|
||||
|
||||
test('Default value should be set to playingState.tunerId', function() {
|
||||
var tuner = channelManager.currentTuners.tuner1;
|
||||
assert.equal(channelManager.getTuner(), tuner);
|
||||
});
|
||||
|
||||
test('tuner2 should be found in currentTuners', function() {
|
||||
var tuner = channelManager.currentTuners.tuner2;
|
||||
assert.equal(channelManager.getTuner('tuner2'), tuner);
|
||||
});
|
||||
});
|
||||
|
||||
suite('getSource()', function() {
|
||||
setup(function() {
|
||||
channelManager.currentTuners = {
|
||||
'tuner1': {
|
||||
sources: {
|
||||
'source1': {},
|
||||
'source2': {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
channelManager.playingState = {
|
||||
tunerId: 'tuner1',
|
||||
sourceType: 'source1',
|
||||
channelNumber: 'channel1'
|
||||
};
|
||||
});
|
||||
|
||||
test('Default value should be set to playingState.sourceType', function() {
|
||||
var source = channelManager.currentTuners.tuner1.sources.source1;
|
||||
assert.equal(channelManager.getSource(), source);
|
||||
});
|
||||
|
||||
test('source2 should be found in currentTuners', function() {
|
||||
var source = channelManager.currentTuners.tuner1.sources.source2;
|
||||
assert.equal(channelManager.getSource('source2'), source);
|
||||
});
|
||||
});
|
||||
|
||||
suite('getChannel()', function() {
|
||||
setup(function() {
|
||||
channelManager.currentTuners = {
|
||||
'tuner1': {
|
||||
sources: {
|
||||
'source1': {
|
||||
channels: [{}, {}],
|
||||
channelIndexHash: {
|
||||
'channel1': 0,
|
||||
'channel2': 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
channelManager.playingState = {
|
||||
tunerId: 'tuner1',
|
||||
sourceType: 'source1',
|
||||
channelNumber: 'channel1'
|
||||
};
|
||||
});
|
||||
|
||||
test('Default value should be set to playingState.channelNumber',
|
||||
function() {
|
||||
var source = channelManager.currentTuners.tuner1.sources.source1;
|
||||
var channel = source.channels[0];
|
||||
assert.equal(channelManager.getChannel(), channel);
|
||||
});
|
||||
|
||||
test('channel2 should be found in currentTuners with index 1', function() {
|
||||
var source = channelManager.currentTuners.tuner1.sources.source1;
|
||||
var channel = source.channels[1];
|
||||
assert.equal(channelManager.getChannel('channel2'), channel);
|
||||
});
|
||||
});
|
||||
|
||||
suite('fetchSettingFromHash()', function() {
|
||||
test('playingState should be set to the same setting as input hash',
|
||||
function() {
|
||||
var hash = '#t0,s0,c0';
|
||||
channelManager.fetchSettingFromHash(hash);
|
||||
assert.equal(channelManager.playingState.tunerId, 't0');
|
||||
assert.equal(channelManager.playingState.sourceType, 's0');
|
||||
assert.equal(channelManager.playingState.channelNumber, 'c0');
|
||||
});
|
||||
});
|
||||
|
||||
suite('scanTuners()', function() {
|
||||
var scanSources;
|
||||
var fire;
|
||||
var tuners;
|
||||
|
||||
function setTuners() {
|
||||
tuners = [];
|
||||
tuners[0] = new MockTVTuner();
|
||||
tuners[0].id = 'tuner-0';
|
||||
tuners[1] = new MockTVTuner();
|
||||
tuners[1].id = 'tuner-1';
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
setTuners();
|
||||
this.sinon.stub(navigator.tv, 'getTuners').returns({
|
||||
then: function(callback) {
|
||||
callback(tuners);
|
||||
}
|
||||
});
|
||||
fire = this.sinon.stub(channelManager, 'fire');
|
||||
scanSources = this.sinon.stub(channelManager, 'scanSources');
|
||||
});
|
||||
|
||||
test('playingState.tunerId should be set to the first tuner by default if' +
|
||||
'it is null value', function() {
|
||||
channelManager.scanTuners();
|
||||
assert.equal(channelManager.playingState.tunerId, 'tuner-0');
|
||||
});
|
||||
|
||||
test('scanSources should be called if tuner can be found', function() {
|
||||
channelManager.scanTuners();
|
||||
assert.isTrue(scanSources.called);
|
||||
});
|
||||
|
||||
test('error should be fired if the tuner cannot be found', function() {
|
||||
channelManager.playingState.tunerId = 'null';
|
||||
channelManager.scanTuners();
|
||||
assert.isTrue(fire.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('scanSources()', function() {
|
||||
var scanChannels;
|
||||
var fire;
|
||||
var tunerItem;
|
||||
|
||||
setup(function() {
|
||||
tunerItem = {
|
||||
tuner: new MockTVTuner()
|
||||
};
|
||||
|
||||
this.sinon.stub(channelManager, 'getTuner').returns(tunerItem);
|
||||
fire = this.sinon.stub(channelManager, 'fire');
|
||||
scanChannels = this.sinon.stub(channelManager, 'scanChannels');
|
||||
});
|
||||
|
||||
test('playingState.sourceType should be set to first source by default if' +
|
||||
'it is null value', function() {
|
||||
channelManager.scanSources();
|
||||
assert.equal(channelManager.playingState.sourceType, 'dvb-0');
|
||||
});
|
||||
|
||||
test('playingState.sourceType should be set to currentSource of the tuner',
|
||||
function() {
|
||||
tunerItem.tuner.currentSource = new MockTVSource();
|
||||
tunerItem.tuner.currentSource.type = 'dvb-1';
|
||||
channelManager.scanSources();
|
||||
assert.equal(channelManager.playingState.sourceType, 'dvb-1');
|
||||
});
|
||||
|
||||
test('scanChannels should be called if tuner can be found', function() {
|
||||
channelManager.scanSources();
|
||||
assert.isTrue(scanChannels.called);
|
||||
});
|
||||
|
||||
test('error should be fired if the source cannot be found', function() {
|
||||
channelManager.playingState.sourceType = 'null';
|
||||
channelManager.scanSources();
|
||||
assert.isTrue(fire.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('scanChannels()', function() {
|
||||
var fire;
|
||||
var sourceItem;
|
||||
|
||||
setup(function() {
|
||||
sourceItem = {
|
||||
source: new MockTVSource()
|
||||
};
|
||||
|
||||
this.sinon.stub(channelManager, 'getSource').returns(sourceItem);
|
||||
fire = this.sinon.stub(channelManager, 'fire');
|
||||
});
|
||||
|
||||
test('playingState.currentChannel should be set to the first channel by ' +
|
||||
'default if it is null value', function() {
|
||||
channelManager.scanChannels();
|
||||
assert.equal(channelManager.playingState.channelNumber, '0');
|
||||
});
|
||||
|
||||
test('playingState.channelNumber should be set to currentChannel of the ' +
|
||||
'current source', function() {
|
||||
sourceItem.source.currentChannel = new MockTVChannel();
|
||||
sourceItem.source.currentChannel.number = '1';
|
||||
channelManager.scanChannels();
|
||||
assert.equal(channelManager.playingState.channelNumber, '1');
|
||||
});
|
||||
|
||||
test('isReady is set to be true', function() {
|
||||
channelManager.scanChannels();
|
||||
assert.isTrue(channelManager.isReady);
|
||||
});
|
||||
|
||||
test('error should be fired if the channel cannot be found', function() {
|
||||
channelManager.playingState.channelNumber = 'null';
|
||||
channelManager.scanChannels();
|
||||
assert.isTrue(fire.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('setPlayingSource()', function() {
|
||||
var tunerItem;
|
||||
var sourceItem;
|
||||
var setPlayingChannel;
|
||||
var setCurrentSource;
|
||||
|
||||
setup(function() {
|
||||
tunerItem = {
|
||||
tuner: new MockTVTuner()
|
||||
};
|
||||
sourceItem = {
|
||||
source: new MockTVSource()
|
||||
};
|
||||
this.sinon.stub(channelManager, 'getTuner').returns(tunerItem);
|
||||
this.sinon.stub(channelManager, 'getSource').returns(sourceItem);
|
||||
setPlayingChannel = this.sinon.stub(channelManager, 'setPlayingChannel');
|
||||
setCurrentSource = this.sinon.stub(tunerItem.tuner, 'setCurrentSource');
|
||||
setCurrentSource.returns({
|
||||
then: function(callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('If currentSource in playing tuner is the same as playing source, ' +
|
||||
'setPlayingChannel should be called while setCurrentSource should not',
|
||||
function() {
|
||||
tunerItem.tuner.currentSource = sourceItem.source;
|
||||
channelManager.setPlayingSource();
|
||||
assert.isTrue(setPlayingChannel.called);
|
||||
assert.isFalse(setCurrentSource.called);
|
||||
});
|
||||
|
||||
test('If currentSource in playing tuner is not the same as playing source' +
|
||||
', setPlayingChannel and setCurrentSource should both be called',
|
||||
function() {
|
||||
tunerItem.tuner.currentSource = new MockTVSource();
|
||||
channelManager.setPlayingSource();
|
||||
assert.isTrue(setPlayingChannel.called);
|
||||
assert.isTrue(setCurrentSource.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('setPlayingChannel()', function() {
|
||||
var sourceItem;
|
||||
var setCurrentChannel;
|
||||
setup(function() {
|
||||
sourceItem = {
|
||||
source: new MockTVSource()
|
||||
};
|
||||
this.sinon.stub(channelManager, 'getSource').returns(sourceItem);
|
||||
setCurrentChannel =
|
||||
this.sinon.stub(sourceItem.source, 'setCurrentChannel');
|
||||
setCurrentChannel.returns({
|
||||
then: function(callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('setCurrentChannel should not be called if source is scanning',
|
||||
function() {
|
||||
sourceItem.source.isScanning = true;
|
||||
channelManager.setPlayingChannel();
|
||||
assert.isFalse(setCurrentChannel.called);
|
||||
});
|
||||
|
||||
test('callback should be called if source is scanning', function() {
|
||||
var callback = this.sinon.stub();
|
||||
sourceItem.source.isScanning = true;
|
||||
channelManager.setPlayingChannel(callback);
|
||||
assert.isTrue(callback.called);
|
||||
});
|
||||
|
||||
test('Both setCurrentChannel and callback should be called if source is' +
|
||||
'not scanning', function() {
|
||||
var callback = this.sinon.stub();
|
||||
sourceItem.source.isScanning = false;
|
||||
channelManager.setPlayingChannel(callback);
|
||||
assert.isTrue(setCurrentChannel.called);
|
||||
assert.isTrue(callback.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('switchChannel()', function() {
|
||||
setup(function() {
|
||||
this.sinon.stub(channelManager, 'getChannel').returns({});
|
||||
this.sinon.stub(channelManager, 'getSource').returns({
|
||||
channels: [{
|
||||
channel: {
|
||||
number: '0'
|
||||
}
|
||||
}, {
|
||||
channel: {
|
||||
number: '1'
|
||||
}
|
||||
}, {
|
||||
channel: {
|
||||
number: '2'
|
||||
}
|
||||
}, {
|
||||
channel: {
|
||||
number: '3'
|
||||
}
|
||||
}, {
|
||||
channel: {
|
||||
number: '4'
|
||||
}
|
||||
}],
|
||||
channelIndexHash: {
|
||||
'0': 0,
|
||||
'1': 1,
|
||||
'2': 2,
|
||||
'3': 3,
|
||||
'4': 4
|
||||
}
|
||||
});
|
||||
channelManager.isReady = true;
|
||||
channelManager.playingState = {
|
||||
channelNumber: '0'
|
||||
};
|
||||
});
|
||||
|
||||
test('Switch up channel, channelNumber should be 1', function() {
|
||||
channelManager.switchChannel('up');
|
||||
assert.equal(channelManager.playingState.channelNumber, '1');
|
||||
});
|
||||
|
||||
test('Switch down channel, channelNumber should be 4', function() {
|
||||
channelManager.switchChannel('down');
|
||||
});
|
||||
});
|
||||
});
|
||||
88
gaia/tv_apps/tv-deck/test/unit/context_menu_test.js
Executable file
88
gaia/tv_apps/tv-deck/test/unit/context_menu_test.js
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
'use strict';
|
||||
/* jshint browser: true */
|
||||
/* global ContextMenu, MocksHelper, MozActivity */
|
||||
|
||||
require('/shared/test/unit/mocks/mock_moz_activity.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_pin_card.js');
|
||||
require('/js/context_menu.js');
|
||||
|
||||
var mocksHelper = new MocksHelper([
|
||||
'MozActivity',
|
||||
'PinCard'
|
||||
]).init();
|
||||
|
||||
suite('tv-epg/contextmenu', function() {
|
||||
|
||||
var contextmenu;
|
||||
var button;
|
||||
mocksHelper.attachTestHelpers();
|
||||
|
||||
setup(function() {
|
||||
var mockPorts = [{
|
||||
postMessage: function() {},
|
||||
}];
|
||||
button = document.createElement('DIV');
|
||||
contextmenu = new ContextMenu([{
|
||||
element: button,
|
||||
hasText: true
|
||||
}], {
|
||||
origin: 'app://contextmenu.test',
|
||||
manifestURL: 'app://contextmenu.test/manifest.webapp',
|
||||
connect: function() {
|
||||
return {
|
||||
then: function(callback) {
|
||||
callback(mockPorts);
|
||||
if (mockPorts[0].onmessage) {
|
||||
mockPorts[0].onmessage({
|
||||
data: {
|
||||
origin: 'app://tvdeck.test',
|
||||
manifestURL: 'app://tvdeck.test/manifest.webapp'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
suite('Initialization', function() {
|
||||
test('Initialize members', function() {
|
||||
assert.equal(contextmenu.selfApp.origin, 'app://contextmenu.test');
|
||||
assert.equal(
|
||||
contextmenu.selfApp.manifestURL,
|
||||
'app://contextmenu.test/manifest.webapp'
|
||||
);
|
||||
assert.isDefined(contextmenu.pinCard);
|
||||
});
|
||||
});
|
||||
|
||||
suite('updateMenu', function() {
|
||||
setup(function() {
|
||||
MozActivity.mSetup();
|
||||
window.location.hash = '#1,dvb-0,12';
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
window.location.hash = '';
|
||||
MozActivity.mTeardown();
|
||||
});
|
||||
|
||||
test('Pin card to home', function() {
|
||||
contextmenu.updateMenu();
|
||||
button.click();
|
||||
assert.equal(button.getAttribute('data-l10n-id'), 'pin-to-home');
|
||||
assert.equal(MozActivity.calls[0].name, 'pin');
|
||||
});
|
||||
|
||||
test('Unpin card to home', function() {
|
||||
contextmenu.pinCard.pinnedChannels = {
|
||||
'#1,dvb-0,12': true
|
||||
};
|
||||
|
||||
contextmenu.updateMenu();
|
||||
button.click();
|
||||
assert.equal(button.getAttribute('data-l10n-id'), 'unpin-from-home');
|
||||
});
|
||||
});
|
||||
});
|
||||
34
gaia/tv_apps/tv-deck/test/unit/mock_card_manager.js
Executable file
34
gaia/tv_apps/tv-deck/test/unit/mock_card_manager.js
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
(function(exports) {
|
||||
'use strict';
|
||||
|
||||
function MockCardManager() {
|
||||
this.init = function() {
|
||||
return {
|
||||
then: function(callback) {}
|
||||
};
|
||||
};
|
||||
|
||||
var callbacks = {};
|
||||
this.on = function(name, callback) {
|
||||
callbacks[name] = callback;
|
||||
};
|
||||
|
||||
this.mTriggerChange = function(name) {
|
||||
if (callbacks[name]) {
|
||||
callbacks[name]();
|
||||
}
|
||||
};
|
||||
|
||||
this.getCardList = function() {
|
||||
return {
|
||||
then: function(callback) {
|
||||
if (this.cards) {
|
||||
callback(this.cards);
|
||||
}
|
||||
}.bind(this)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
exports.MockCardManager = MockCardManager;
|
||||
}(window));
|
||||
8
gaia/tv_apps/tv-deck/test/unit/mock_context_menu.js
Executable file
8
gaia/tv_apps/tv-deck/test/unit/mock_context_menu.js
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
(function(exports) {
|
||||
'use strict';
|
||||
|
||||
function MockContextMenu() {
|
||||
}
|
||||
|
||||
exports.MockContextMenu = MockContextMenu;
|
||||
}(window));
|
||||
3
gaia/tv_apps/tv-deck/test/unit/setup.js
Executable file
3
gaia/tv_apps/tv-deck/test/unit/setup.js
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
require('/shared/test/unit/mocks/mocks_helper.js');
|
||||
284
gaia/tv_apps/tv-deck/test/unit/tv_deck_test.js
Executable file
284
gaia/tv_apps/tv-deck/test/unit/tv_deck_test.js
Executable file
|
|
@ -0,0 +1,284 @@
|
|||
'use strict';
|
||||
/* jshint browser: true */
|
||||
/* global TVDeck, MocksHelper, MockTVManager, MockNavigatormozApps */
|
||||
|
||||
require('/shared/test/unit/mocks/mock_navigator_moz_apps.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_key_navigation_adapter.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_simple_key_navigation.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_channel.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_source.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_tuner.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_tv_manager.js');
|
||||
require('/shared/test/unit/mocks/smart-screen/mock_channel_manager.js');
|
||||
require('/bower_components/smart-bubbles/script.js');
|
||||
require('/test/unit/mock_context_menu.js');
|
||||
require('/js/tv_deck.js');
|
||||
|
||||
var mocksHelper = new MocksHelper([
|
||||
'ContextMenu',
|
||||
'ChannelManager',
|
||||
'KeyNavigationAdapter',
|
||||
'SimpleKeyNavigation'
|
||||
]).init();
|
||||
|
||||
suite('tv-deck/tv_deck', function() {
|
||||
|
||||
var MockasyncStorage;
|
||||
var realMozApps;
|
||||
var realTVManager;
|
||||
var realasyncStorage;
|
||||
var tvDeck;
|
||||
|
||||
mocksHelper.attachTestHelpers();
|
||||
|
||||
function createMockElement(id, type) {
|
||||
var element;
|
||||
element = document.createElement(type || 'div');
|
||||
element.id = id;
|
||||
document.body.appendChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
function createMockUI() {
|
||||
createMockElement('overlay');
|
||||
createMockElement('tv-stream', 'video');
|
||||
createMockElement('channel-panel');
|
||||
createMockElement('channel-number');
|
||||
createMockElement('channel-title');
|
||||
createMockElement('button-group-panel');
|
||||
createMockElement('pin-button');
|
||||
createMockElement('pin-button-contextmenu');
|
||||
createMockElement('menu-button');
|
||||
createMockElement('loading-icon');
|
||||
createMockElement('bubble-animation', 'smart-bubbles');
|
||||
}
|
||||
|
||||
suiteSetup(function() {
|
||||
createMockUI();
|
||||
sinon.stub(window, 'addEventListener');
|
||||
MockasyncStorage = {
|
||||
_value: {},
|
||||
getItem: function(name, callback) {
|
||||
callback(this._value[name]);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
realTVManager = window.navigator.tv;
|
||||
realMozApps = window.navigator.mozApps;
|
||||
realasyncStorage = window.asyncStorage;
|
||||
window.navigator.tv = new MockTVManager();
|
||||
window.navigator.mozApps = MockNavigatormozApps;
|
||||
window.asyncStorage = MockasyncStorage;
|
||||
|
||||
window.location.hash = '';
|
||||
window.localStorage.removeItem('TV_Hash');
|
||||
tvDeck = new TVDeck();
|
||||
MockNavigatormozApps.mTriggerLastRequestSuccess({
|
||||
origin: 'test://origin',
|
||||
manifestURL: 'test://manifestURL'
|
||||
});
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
window.navigator.tv = realTVManager;
|
||||
window.navigator.mozApps = realMozApps;
|
||||
window.asyncStorage = realasyncStorage;
|
||||
});
|
||||
|
||||
suite('Initilization', function() {
|
||||
test('enterNumberTimeoutDelay should be greater than 0', function() {
|
||||
assert(tvDeck.enterNumberTimeoutDelay > 0);
|
||||
});
|
||||
|
||||
test('panelTimeoutDelay should be greater than 0', function() {
|
||||
assert(tvDeck.panelTimeoutDelay > 0);
|
||||
});
|
||||
|
||||
test('Must have video element', function() {
|
||||
assert.isDefined(tvDeck.tvStreamElement);
|
||||
});
|
||||
|
||||
test('lastChannelId should be 0', function() {
|
||||
assert.equal(tvDeck.lastChannelId, 0);
|
||||
});
|
||||
});
|
||||
|
||||
suite('_onHashChange()', function() {
|
||||
test('lastChannelId should not be the same', function() {
|
||||
var id = tvDeck.lastChannelId;
|
||||
tvDeck._onHashChange();
|
||||
assert.notEqual(id, tvDeck.lastChannelId);
|
||||
});
|
||||
|
||||
test('Rescan tuners if playing tuner is not found', function() {
|
||||
var scanTuners = this.sinon.stub(tvDeck.channelManager, 'scanTuners');
|
||||
this.sinon.stub(tvDeck.channelManager, 'getTuner').returns(null);
|
||||
tvDeck._onHashChange();
|
||||
assert.isTrue(scanTuners.called);
|
||||
});
|
||||
|
||||
test('Rescan sources if playing source is not found', function() {
|
||||
var scanSources = this.sinon.stub(tvDeck.channelManager, 'scanSources');
|
||||
this.sinon.stub(tvDeck.channelManager, 'getTuner').returns({});
|
||||
this.sinon.stub(tvDeck.channelManager, 'getSource').returns(null);
|
||||
tvDeck._onHashChange();
|
||||
assert.isTrue(scanSources.called);
|
||||
});
|
||||
|
||||
test('Rescan channels if playing channel is not found', function() {
|
||||
var scanChannels = this.sinon.stub(tvDeck.channelManager, 'scanChannels');
|
||||
this.sinon.stub(tvDeck.channelManager, 'getTuner').returns({});
|
||||
this.sinon.stub(tvDeck.channelManager, 'getSource').returns({});
|
||||
tvDeck._onHashChange();
|
||||
assert.isTrue(scanChannels.called);
|
||||
});
|
||||
|
||||
test('buttonGroupPanel should be hidden', function() {
|
||||
tvDeck._onHashChange();
|
||||
assert.isTrue(tvDeck.buttonGroupPanel.classList.contains('hidden'));
|
||||
});
|
||||
|
||||
test('channelPanel should be visible', function() {
|
||||
tvDeck._onHashChange();
|
||||
assert.isFalse(tvDeck.channelPanel.classList.contains('hidden'));
|
||||
});
|
||||
});
|
||||
|
||||
suite('setHash()', function() {
|
||||
test('_onHashChange should not be called if new hash is different from ' +
|
||||
'current location.hash', function() {
|
||||
var onHashChange = this.sinon.stub(tvDeck, '_onHashChange');
|
||||
tvDeck.setHash();
|
||||
assert.isFalse(onHashChange.called);
|
||||
});
|
||||
|
||||
test('_onHashChange should be called if new hash is the same as current ' +
|
||||
'location.hash', function() {
|
||||
var onHashChange = this.sinon.stub(tvDeck, '_onHashChange');
|
||||
window.location.hash = 'hash';
|
||||
tvDeck.channelManager.currentHash = '#hash';
|
||||
tvDeck.setHash();
|
||||
assert.isTrue(onHashChange.called);
|
||||
});
|
||||
|
||||
test('window.location.hash should equals to currentHash', function() {
|
||||
tvDeck.channelManager.currentHash = '#new-hash';
|
||||
tvDeck.setHash();
|
||||
assert.equal(window.location.hash, '#new-hash');
|
||||
});
|
||||
});
|
||||
|
||||
suite('_onSwitch()', function() {
|
||||
test('switchChannel chould be called', function() {
|
||||
var switchChannel =
|
||||
this.sinon.stub(tvDeck.channelManager, 'switchChannel');
|
||||
tvDeck._onSwitch('up');
|
||||
assert.isTrue(switchChannel.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('_onEnterNumber()', function() {
|
||||
var evt;
|
||||
setup(function() {
|
||||
evt = {
|
||||
keyCode: 50
|
||||
};
|
||||
tvDeck.channelNumber.textContent = '';
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
tvDeck.channelNumber.textContent = '';
|
||||
});
|
||||
|
||||
test('enterNumberTimeoutId should be reassigned', function() {
|
||||
var id = tvDeck.enterNumberTimeoutId;
|
||||
tvDeck._onEnterNumber(evt);
|
||||
assert.notEqual(id, tvDeck.enterNumberTimeoutId);
|
||||
});
|
||||
|
||||
test('channelPanel should be visible', function() {
|
||||
tvDeck._onEnterNumber(evt);
|
||||
assert.isFalse(tvDeck.channelPanel.classList.contains('hidden'));
|
||||
});
|
||||
|
||||
test('Input number should be appended to channelNumber', function() {
|
||||
tvDeck.enterNumberTimeoutId = 1;
|
||||
tvDeck._onEnterNumber(evt);
|
||||
assert.equal(tvDeck.channelNumber.textContent, '2');
|
||||
});
|
||||
|
||||
test('Input number should not be appended to channelNumber if length of ' +
|
||||
'channelNumber is greater than 4', function() {
|
||||
tvDeck.enterNumberTimeoutId = 1;
|
||||
tvDeck.channelNumber.textContent = '1234';
|
||||
tvDeck._onEnterNumber(evt);
|
||||
assert.equal(tvDeck.channelNumber.textContent, '1234');
|
||||
});
|
||||
});
|
||||
|
||||
suite('_onEnter()', function() {
|
||||
setup(function() {
|
||||
this.sinon.stub(tvDeck.channelManager, 'getSource').returns({
|
||||
channelIndexHash: {
|
||||
'1-1': 5
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('setHash should not be called if enterNumberTimeoutId is null',
|
||||
function() {
|
||||
var setHash = this.sinon.stub(tvDeck, 'setHash');
|
||||
tvDeck._onEnter();
|
||||
assert.isFalse(setHash.called);
|
||||
});
|
||||
|
||||
test('setHash should be called if enterNumberTimeoutId is defined, and ' +
|
||||
'new channel number is valid', function() {
|
||||
var setHash = this.sinon.stub(tvDeck, 'setHash');
|
||||
tvDeck.channelNumber.textContent = '1-1';
|
||||
tvDeck.enterNumberTimeoutId = 1;
|
||||
tvDeck._onEnter();
|
||||
assert.isTrue(setHash.called);
|
||||
});
|
||||
});
|
||||
|
||||
suite('_showErrorState()', function() {
|
||||
test('_updateChannelInfo should be called', function() {
|
||||
var updateChannelInfo = this.sinon.stub(tvDeck, '_updateChannelInfo');
|
||||
tvDeck._showErrorState();
|
||||
assert.isTrue(updateChannelInfo.called);
|
||||
});
|
||||
|
||||
test('src of video element should be remove', function() {
|
||||
this.sinon.stub(tvDeck, '_updateChannelInfo');
|
||||
tvDeck._showErrorState();
|
||||
assert.isDefined(tvDeck.tvStreamElement.src);
|
||||
});
|
||||
});
|
||||
|
||||
suite('_rotateLoadingIcon()', function() {
|
||||
test('loadingIcon contains loading-circle class', function() {
|
||||
tvDeck._rotateLoadingIcon();
|
||||
assert.isTrue(tvDeck.loadingIcon.classList.contains('loading-circle'));
|
||||
});
|
||||
});
|
||||
|
||||
suite('_onPanelTimeout()', function() {
|
||||
test('buttonGroupPanel should be hidden', function() {
|
||||
tvDeck._onPanelTimeout();
|
||||
assert.isTrue(tvDeck.buttonGroupPanel.classList.contains('hidden'));
|
||||
});
|
||||
|
||||
test('channelPanel should be hidden', function() {
|
||||
tvDeck._onPanelTimeout();
|
||||
assert.isTrue(tvDeck.channelPanel.classList.contains('hidden'));
|
||||
});
|
||||
|
||||
test('panelTimeoutId should be cleared', function() {
|
||||
tvDeck._onPanelTimeout();
|
||||
assert.isNull(tvDeck.panelTimeoutId);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue