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
14
gaia/tv_apps/fling-player/test/marionette/.jshintrc
Executable file
14
gaia/tv_apps/fling-player/test/marionette/.jshintrc
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"extends": "../../../../.jshintrc",
|
||||
"node": true,
|
||||
"predef": [
|
||||
"suite",
|
||||
"test",
|
||||
"setup",
|
||||
"teardown",
|
||||
"suiteSetup",
|
||||
"suiteTeardown",
|
||||
"marionette",
|
||||
"marionetteScriptFinished"
|
||||
]
|
||||
}
|
||||
18
gaia/tv_apps/fling-player/test/unit/.jshintrc
Executable file
18
gaia/tv_apps/fling-player/test/unit/.jshintrc
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"extends": "../../../../.jshintrc",
|
||||
"predef": [
|
||||
"assert",
|
||||
"suite",
|
||||
"test",
|
||||
"setup",
|
||||
"teardown",
|
||||
"suiteSetup",
|
||||
"suiteTeardown",
|
||||
"require",
|
||||
"requireApp",
|
||||
"sinon",
|
||||
"mocha",
|
||||
"loadBodyHTML"
|
||||
]
|
||||
}
|
||||
|
||||
135
gaia/tv_apps/fling-player/test/unit/casting_message_test.js
Executable file
135
gaia/tv_apps/fling-player/test/unit/casting_message_test.js
Executable file
|
|
@ -0,0 +1,135 @@
|
|||
/* global castingMessage */
|
||||
'use strict';
|
||||
|
||||
requireApp('fling-player/js/master_debug.js');
|
||||
requireApp('fling-player/js/casting_message.js');
|
||||
|
||||
suite('fling-player/castingMessage', function() {
|
||||
|
||||
var validMsg;
|
||||
|
||||
setup(function () {
|
||||
validMsg = {
|
||||
ack : {
|
||||
type : 'ack',
|
||||
seq : 1
|
||||
},
|
||||
statusBuffering : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'buffering'
|
||||
},
|
||||
statusLoaded : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'loaded'
|
||||
},
|
||||
statusBuffered : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'buffered'
|
||||
},
|
||||
statusPlaying : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'playing'
|
||||
},
|
||||
statusSeeked : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'seeked'
|
||||
},
|
||||
statusStopped : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'stopped'
|
||||
},
|
||||
statusError : {
|
||||
type : 'status',
|
||||
seq : 1,
|
||||
time : 168,
|
||||
status : 'error',
|
||||
error : '404'
|
||||
},
|
||||
load : {
|
||||
type : 'load',
|
||||
seq : 1,
|
||||
url : 'http://foo.com/bar.ogg'
|
||||
},
|
||||
play : {
|
||||
type : 'play',
|
||||
seq : 1
|
||||
},
|
||||
pause : {
|
||||
type : 'pause',
|
||||
seq : 1
|
||||
},
|
||||
seek : {
|
||||
type : 'seek',
|
||||
seq : 1,
|
||||
time : 168
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
suite('Sanitize messages', function () {
|
||||
|
||||
var result;
|
||||
|
||||
test('should sanitize valid message', function () {
|
||||
for (var m in validMsg) {
|
||||
result = castingMessage.sanitizeMsg(validMsg[m]);
|
||||
assert.isObject(result, `sanitizing ${m} message fails`);
|
||||
}
|
||||
});
|
||||
|
||||
test('should sanitize invalid message', function () {
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
|
||||
suite('Parse message', function () {
|
||||
|
||||
var txt, result;
|
||||
|
||||
test('should parse one message', function () {
|
||||
for (var m in validMsg) {
|
||||
txt = JSON.stringify(validMsg[m]);
|
||||
result = castingMessage.parse(txt);
|
||||
assert.isTrue(result instanceof Array);
|
||||
assert.equal(result.length, 1, 'should only be one message');
|
||||
assert.equal(JSON.stringify(result), `[${txt}]`);
|
||||
}
|
||||
});
|
||||
|
||||
test('should parse multiple messages', function () {
|
||||
|
||||
var msgs = [validMsg.play, validMsg.load];
|
||||
|
||||
txt = JSON.stringify(msgs[0]) + JSON.stringify(msgs[1]);
|
||||
|
||||
result = castingMessage.parse(txt);
|
||||
assert.isTrue(result instanceof Array);
|
||||
assert.equal(result.length, 2, 'should be two messages');
|
||||
assert.equal(JSON.stringify(result), JSON.stringify(msgs));
|
||||
});
|
||||
});
|
||||
|
||||
suite('Stringify message', function () {
|
||||
|
||||
var result;
|
||||
|
||||
test('should stringify valid message', function () {
|
||||
for (var m in validMsg) {
|
||||
result = castingMessage.stringify(validMsg[m]);
|
||||
assert.equal(result, JSON.stringify(validMsg[m]));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
116
gaia/tv_apps/fling-player/test/unit/master_debug_test.js
Executable file
116
gaia/tv_apps/fling-player/test/unit/master_debug_test.js
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
/* global mDBG */
|
||||
'use strict';
|
||||
|
||||
requireApp('fling-player/js/master_debug.js');
|
||||
|
||||
suite('fling-player/MasterDebug', function() {
|
||||
|
||||
var exp, mockWindow;
|
||||
|
||||
setup(function () {
|
||||
mockWindow = {};
|
||||
mockWindow.log = mockWindow.warn = mockWindow.error = function () {};
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
exp = undefined;
|
||||
});
|
||||
|
||||
test('should turn off debug mode before push to moz upstream', function () {
|
||||
assert.isFalse(mDBG.isDBG(),
|
||||
'Please turn off debug mode before push to moz upstream'
|
||||
);
|
||||
});
|
||||
|
||||
test('should set debug flag', function () {
|
||||
|
||||
exp = true;
|
||||
mDBG.setDBG(exp);
|
||||
assert.equal(mDBG.isDBG(), exp);
|
||||
|
||||
exp = false;
|
||||
mDBG.setDBG(exp);
|
||||
assert.equal(mDBG.isDBG(), exp);
|
||||
});
|
||||
|
||||
suite('behavior in the debug mode', function () {
|
||||
|
||||
var a = 'a';
|
||||
var b = 'b';
|
||||
|
||||
setup(function () {
|
||||
exp = sinon.mock(console);
|
||||
mDBG.setDBG(true);
|
||||
});
|
||||
|
||||
test('should log in the debug mode', function () {
|
||||
exp.expects('log').once().withExactArgs(a, b);
|
||||
mDBG.log(a, b);
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should warn in the debug mode', function () {
|
||||
exp.expects('warn').once().withExactArgs(a, b);
|
||||
mDBG.warn(a, b);
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should error in the debug mode', function () {
|
||||
exp.expects('error').once().withExactArgs(a, b);
|
||||
mDBG.error(a, b);
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should test behavior in the debug mode', function () {
|
||||
|
||||
var obj = {
|
||||
testSomething : function () {}
|
||||
};
|
||||
|
||||
exp = sinon.mock(obj);
|
||||
|
||||
exp.expects('testSomething').once();
|
||||
mDBG.test(obj.testSomething.bind(obj));
|
||||
exp.verify();
|
||||
});
|
||||
});
|
||||
|
||||
suite('behavior not in the debug mode', function () {
|
||||
|
||||
setup(function () {
|
||||
exp = sinon.mock(console);
|
||||
mDBG.setDBG(false);
|
||||
});
|
||||
|
||||
test('should not log not in the debug mode', function () {
|
||||
exp.expects('log').never();
|
||||
mDBG.log('test');
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should not warn not in the debug mode', function () {
|
||||
exp.expects('warn').never();
|
||||
mDBG.warn('test');
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should not error not in the debug mode', function () {
|
||||
exp.expects('error').never();
|
||||
mDBG.error('test');
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should not test behavior not in the debug mode', function () {
|
||||
|
||||
var obj = {
|
||||
testSomething : function () {}
|
||||
};
|
||||
|
||||
exp = sinon.mock(obj);
|
||||
|
||||
exp.expects('testSomething').never();
|
||||
mDBG.test(obj.testSomething.bind(obj));
|
||||
exp.verify();
|
||||
});
|
||||
});
|
||||
});
|
||||
80
gaia/tv_apps/fling-player/test/unit/mock_video_element.js
Executable file
80
gaia/tv_apps/fling-player/test/unit/mock_video_element.js
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* This mock is for the case that just want a simple video element for testing.
|
||||
* Also, see Bug 1199985, because a real HTMLVideoElement cannot play video
|
||||
* on TV gecko, we can use it for a temp subtitude for test case that needs
|
||||
* a HTMLVideoElement.
|
||||
*/
|
||||
(function(exports) {
|
||||
'use strict';
|
||||
|
||||
function MockVideoElement(config = {}) {
|
||||
var self = this;
|
||||
this.src = config.src || '';
|
||||
this.ended = config.ended || false;
|
||||
this.paused = config.paused || true;
|
||||
this.hidden = config.hidden || false;
|
||||
this.duration = config.duration || 0;
|
||||
this.currentTime = config.currentTime || 0;
|
||||
this.buffered = {
|
||||
length : 1,
|
||||
start : function () {
|
||||
return 0;
|
||||
},
|
||||
end : function () {
|
||||
return Math.max(self.currentTime + 10, self.duration);
|
||||
}
|
||||
};
|
||||
|
||||
this._events = {};
|
||||
}
|
||||
|
||||
var proto = MockVideoElement.prototype;
|
||||
|
||||
proto.fireEvent = function (e) {
|
||||
|
||||
var listeners = this._events[e.type];
|
||||
if (listeners) {
|
||||
|
||||
listeners.forEach((listener) => {
|
||||
if (typeof listener == 'function') {
|
||||
listener.call(this, e);
|
||||
} else {
|
||||
listener.handleEvent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
proto.addEventListener = function (type, listener) {
|
||||
|
||||
var listeners = this._events[type];
|
||||
if (!listeners) {
|
||||
this._events[type] = listeners = [];
|
||||
}
|
||||
|
||||
listeners.push(listener);
|
||||
};
|
||||
|
||||
proto.removeAttribute = function (attr) {
|
||||
this[attr] = '';
|
||||
};
|
||||
|
||||
proto.load = function () {
|
||||
this.paused = false;
|
||||
this.currentTime = 0;
|
||||
this.fireEvent(new Event('loadedmetadata'));
|
||||
};
|
||||
|
||||
proto.play = function () {
|
||||
this.paused = false;
|
||||
this.fireEvent(new Event('playing'));
|
||||
};
|
||||
|
||||
proto.pause = function () {
|
||||
this.paused = true;
|
||||
this.fireEvent(new Event('pause'));
|
||||
};
|
||||
|
||||
exports.MockVideoElement = MockVideoElement;
|
||||
|
||||
})(window);
|
||||
218
gaia/tv_apps/fling-player/test/unit/video_player_test.js
Executable file
218
gaia/tv_apps/fling-player/test/unit/video_player_test.js
Executable file
|
|
@ -0,0 +1,218 @@
|
|||
/* global VideoPlayer, MockVideoElement */
|
||||
'use strict';
|
||||
|
||||
requireApp('fling-player/test/unit/mock_video_element.js');
|
||||
requireApp('fling-player/js/video_player.js');
|
||||
|
||||
suite('fling-player/VideoPlayer', function() {
|
||||
|
||||
var player, video;
|
||||
|
||||
var videoURL =
|
||||
'app://fling-player.gaiamobile.org/test_media/Movies/elephants-dream.webm';
|
||||
|
||||
setup(function () {
|
||||
video = new MockVideoElement();
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
});
|
||||
|
||||
teardown(function () {
|
||||
player = video = undefined;
|
||||
});
|
||||
|
||||
test('should return video element', function () {
|
||||
assert.equal(player.getVideo(), video);
|
||||
});
|
||||
|
||||
test('should return video duration in rounded sec', function () {
|
||||
|
||||
video.duration = NaN;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedDuration(), 0);
|
||||
|
||||
video.duration = 100;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedDuration(), Math.round(video.duration));
|
||||
|
||||
video.duration = 100.01;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedDuration(), Math.round(video.duration));
|
||||
|
||||
video.duration = 100.55;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedDuration(), Math.round(video.duration));
|
||||
});
|
||||
|
||||
test('should return current video time in rounded sec', function () {
|
||||
|
||||
video.currentTime = NaN;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedCurrentTime(), 0);
|
||||
|
||||
video.currentTime = 100;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedCurrentTime(), Math.round(video.currentTime));
|
||||
|
||||
video.currentTime = 100.01;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedCurrentTime(), Math.round(video.currentTime));
|
||||
|
||||
video.currentTime = 100.55;
|
||||
player = new VideoPlayer(video);
|
||||
player.init();
|
||||
assert.equal(player.getRoundedCurrentTime(), Math.round(video.currentTime));
|
||||
});
|
||||
|
||||
test('should show video element', function () {
|
||||
video.hidden = true;
|
||||
player.show();
|
||||
assert.isFalse(video.hidden);
|
||||
});
|
||||
|
||||
test('should hide video element', function () {
|
||||
video.hidden = false;
|
||||
player.hide();
|
||||
assert.isTrue(video.hidden);
|
||||
});
|
||||
|
||||
test('should load video src url', function () {
|
||||
player.load(videoURL);
|
||||
assert.equal(video.src, videoURL);
|
||||
});
|
||||
|
||||
test('should release video src url', function () {
|
||||
video.src = videoURL;
|
||||
player.release();
|
||||
assert.equal(video.src, '');
|
||||
});
|
||||
|
||||
test('should play', function () {
|
||||
var exp = sinon.mock(video);
|
||||
exp.expects('play').once();
|
||||
player.play();
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should pause', function () {
|
||||
var exp = sinon.mock(video);
|
||||
exp.expects('pause').once();
|
||||
player.pause();
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should seek with loading metadata', function () {
|
||||
var exp = video.currentTime + 10;
|
||||
video.src = videoURL;
|
||||
video.load();
|
||||
player.seek(exp);
|
||||
assert.equal(video.currentTime, exp);
|
||||
});
|
||||
|
||||
test('should not seek without loading metadata', function () {
|
||||
var origin = video.currentTime;
|
||||
player.seek(origin + 10);
|
||||
assert.equal(video.currentTime, origin);
|
||||
});
|
||||
|
||||
suite('Event handling', function () {
|
||||
|
||||
var exp;
|
||||
|
||||
setup(function () {
|
||||
exp = sinon.mock(player);
|
||||
});
|
||||
|
||||
test('should handle the loadedmetadata event', function () {
|
||||
var t = video.currentTime + 10;
|
||||
exp.expects('seek').once().withExactArgs(t);
|
||||
player.handleEvent({ type : 'loadedmetadata' });
|
||||
player.seek(t);
|
||||
exp.verify();
|
||||
});
|
||||
|
||||
test('should handle the playing event', function () {
|
||||
exp.expects('show').once();
|
||||
player.handleEvent({ type : 'playing' });
|
||||
exp.verify();
|
||||
});
|
||||
});
|
||||
|
||||
suite('Time parsing', function () {
|
||||
|
||||
var act, exp = {};
|
||||
|
||||
var toSec = (t) => {
|
||||
return t.hh * 3600 + t.mm * 60 + t.ss;
|
||||
};
|
||||
|
||||
test('should parse hh well', function () {
|
||||
|
||||
exp.hh = 99;
|
||||
exp.mm = 0;
|
||||
exp.ss = 0;
|
||||
|
||||
act = player.parseTime(toSec(exp));
|
||||
assert.equal(act.hh, exp.hh);
|
||||
assert.equal(act.mm, exp.mm);
|
||||
assert.equal(act.ss, exp.ss);
|
||||
});
|
||||
|
||||
test('should parse mm well', function () {
|
||||
|
||||
exp.hh = 0;
|
||||
exp.mm = 59;
|
||||
exp.ss = 0;
|
||||
|
||||
act = player.parseTime(toSec(exp));
|
||||
assert.equal(act.hh, exp.hh);
|
||||
assert.equal(act.mm, exp.mm);
|
||||
assert.equal(act.ss, exp.ss);
|
||||
});
|
||||
|
||||
test('should parse ss well', function () {
|
||||
|
||||
exp.hh = 0;
|
||||
exp.mm = 0;
|
||||
exp.ss = 59;
|
||||
|
||||
act = player.parseTime(toSec(exp));
|
||||
assert.equal(act.hh, exp.hh);
|
||||
assert.equal(act.mm, exp.mm);
|
||||
assert.equal(act.ss, exp.ss);
|
||||
});
|
||||
|
||||
test('should parse hh, mm and ss well', function () {
|
||||
|
||||
exp.hh = 39;
|
||||
exp.mm = 28;
|
||||
exp.ss = 17;
|
||||
|
||||
act = player.parseTime(toSec(exp));
|
||||
assert.equal(act.hh, exp.hh);
|
||||
assert.equal(act.mm, exp.mm);
|
||||
assert.equal(act.ss, exp.ss);
|
||||
});
|
||||
|
||||
test('should parse zero sec well', function () {
|
||||
act = player.parseTime(0);
|
||||
assert.equal(act.hh, 0);
|
||||
assert.equal(act.mm, 0);
|
||||
assert.equal(act.ss, 0);
|
||||
});
|
||||
|
||||
test('should parse negative time well', function () {
|
||||
act = player.parseTime(-1234567890);
|
||||
assert.equal(act.hh, 0);
|
||||
assert.equal(act.mm, 0);
|
||||
assert.equal(act.ss, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue