pandora/static/js/tests.js

59 lines
1.9 KiB
JavaScript
Raw Normal View History

2012-05-28 21:53:56 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
'use strict';
pandora.tests = function() {
var tests = [];
pandora.api.find({
2012-05-29 10:11:14 +00:00
query: {conditions: [{key: 'rendered', value: true, operator: '='}], operator: '&'},
2012-05-28 21:53:56 +00:00
sort: [{key: 'random', operator:'+'}],
2012-05-29 10:11:14 +00:00
keys: ['id', 'duration'],
2012-05-28 21:53:56 +00:00
range: [0, 10]
}, function(result) {
2012-05-29 10:11:14 +00:00
var item = result.data.items.filter(function(item) { return item.duration > 300; })[0],
2012-05-28 21:53:56 +00:00
position = 60;
pandora.UI.set('videoPoints.' + item.id, {
annotation: '',
'in': position,
out: position,
position: position
});
pandora.UI.set({item: item.id, itemView: 'player'});
test('set item', pandora.user.ui.item, item.id);
startPlayback();
function startPlayback() {
2012-06-10 18:31:02 +00:00
if (pandora.$ui.player) {
2012-05-28 21:53:56 +00:00
pandora.$ui.player.options({paused: false});
setTimeout(function() {
pandora.$ui.player.options({paused: true});
test('video position increased after playback', pandora.user.ui.videoPoints[item.id].position > position, true);
results();
}, 5000);
} else {
setTimeout(startPlayback, 500);
}
}
});
function test(title, actual, expected) {
tests.push({
actual: actual,
expected: expected,
passed: Ox.isEqual(actual, expected),
title: title
})
}
function results() {
var passed = tests.filter(function(test) {
return test.passed;
}).length,
failed = tests.length - passed;
Ox.print(JSON.stringify({
tests: tests.length,
passed: passed,
failed: failed,
results: tests
}, null, ' '));
}
}