2011-05-07 17:25:34 +00:00
|
|
|
Ox.load('UI', {
|
|
|
|
debug: true,
|
|
|
|
theme: 'classic'
|
|
|
|
}, function() {
|
2011-05-09 08:54:52 +00:00
|
|
|
Ox.load('Geo', function() {
|
|
|
|
var $div = $('<div>')
|
|
|
|
.css({
|
|
|
|
width: window.innerWidth,
|
|
|
|
height: window.innerHeight,
|
|
|
|
overflowY: 'scroll'
|
|
|
|
})
|
|
|
|
.appendTo(Ox.UI.$body),
|
|
|
|
colors = [
|
|
|
|
[[255, 64, 64], [224, 32, 32]],
|
|
|
|
[[64, 192, 64], [32, 160, 32]]
|
|
|
|
],
|
|
|
|
counter = 0,
|
|
|
|
files = [
|
|
|
|
Ox.PATH + 'Ox.js',
|
|
|
|
Ox.PATH + 'Ox.Geo/Ox.Geo.js'
|
|
|
|
],
|
|
|
|
tests = [];
|
|
|
|
files.forEach(function(file) {
|
|
|
|
Ox.test(file, function(fileTests) {
|
|
|
|
tests = Ox.merge(tests, fileTests);
|
|
|
|
if (++counter == files.length) {
|
|
|
|
renderTests();
|
|
|
|
}
|
|
|
|
});
|
2011-05-07 17:25:34 +00:00
|
|
|
});
|
2011-05-09 08:54:52 +00:00
|
|
|
function renderTests() {
|
|
|
|
var total = tests.length,
|
2011-05-07 17:25:34 +00:00
|
|
|
succeeded = tests.filter(function(test) {
|
|
|
|
return test.success;
|
|
|
|
}).length,
|
|
|
|
failed = total - succeeded,
|
2011-05-09 08:54:52 +00:00
|
|
|
names = Ox.unique(tests.map(function(test) {
|
|
|
|
return test.name;
|
|
|
|
})).sort();
|
|
|
|
testsByName = {};
|
|
|
|
tests.forEach(function(test) {
|
|
|
|
if (!(test.name in testsByName)) {
|
|
|
|
testsByName[test.name] = [];
|
|
|
|
}
|
|
|
|
testsByName[test.name].push(test);
|
|
|
|
});
|
2011-05-07 17:25:34 +00:00
|
|
|
getBar(total == succeeded)
|
|
|
|
.html(
|
2011-05-09 08:54:52 +00:00
|
|
|
'<b>' + total + ' tests, ' +
|
2011-05-07 17:25:34 +00:00
|
|
|
succeeded + ' succeeded, ' + failed + ' failed</b>'
|
|
|
|
)
|
2011-05-09 08:54:52 +00:00
|
|
|
.appendTo($div);
|
|
|
|
names.forEach(function(name) {
|
|
|
|
var tests = testsByName[name],
|
|
|
|
total = tests.length,
|
|
|
|
succeeded = tests.filter(function(test) {
|
|
|
|
return test.success;
|
|
|
|
}).length,
|
|
|
|
failed = total - succeeded,
|
|
|
|
classname = name.replace('.', '');
|
|
|
|
getBar(total == succeeded)
|
2011-05-07 17:25:34 +00:00
|
|
|
.html(
|
2011-05-09 08:54:52 +00:00
|
|
|
'<b>' + name + '</b> — ' + total +
|
|
|
|
' test' + (total == 1 ? '' : 's') + ', ' +
|
|
|
|
succeeded + ' succeeded, ' + failed + ' failed</b>'
|
2011-05-07 17:25:34 +00:00
|
|
|
)
|
2011-05-09 08:54:52 +00:00
|
|
|
.click(function() {
|
|
|
|
$('.' + classname).toggle();
|
|
|
|
})
|
|
|
|
.appendTo($div);
|
|
|
|
tests.forEach(function(test) {
|
|
|
|
getBar(test.success, true)
|
|
|
|
.addClass(classname)
|
|
|
|
.html(
|
|
|
|
Ox.repeat(' ', 4) +
|
|
|
|
'<b>> ' + Ox.encodeHTML(test.statement) + ' </b> ==> ' +
|
|
|
|
(test.success ? '' : Ox.encodeHTML(test.actual) + ' !=> ') +
|
|
|
|
Ox.encodeHTML(test.expected)
|
|
|
|
)
|
|
|
|
.hide()
|
|
|
|
.appendTo($div);
|
|
|
|
});
|
2011-05-07 17:25:34 +00:00
|
|
|
});
|
2011-05-09 08:54:52 +00:00
|
|
|
}
|
|
|
|
function getBar(success, darker) {
|
|
|
|
var $div = $('<div>')
|
|
|
|
.css({
|
|
|
|
width: window.innerWidth - Ox.UI.SCROLLBAR_SIZE,
|
|
|
|
height: '15px',
|
|
|
|
padding: '4px 8px 4px 8px',
|
|
|
|
fontFamily: 'Menlo, Monaco, Courier',
|
|
|
|
fontSize: '12px',
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
MozUserSelect: 'text',
|
|
|
|
WebkitUserSelect: 'text'
|
|
|
|
});
|
|
|
|
['moz', 'webkit'].forEach(function(browser) {
|
|
|
|
$div.css({
|
|
|
|
background: '-' + browser + '-linear-gradient(top, rgb(' +
|
|
|
|
getColor(success, 0) + '), rgb(' +
|
|
|
|
getColor(success, 1) + '))'
|
|
|
|
});
|
2011-05-07 17:25:34 +00:00
|
|
|
});
|
2011-05-09 08:54:52 +00:00
|
|
|
function getColor(success, i) {
|
|
|
|
return colors[+success][i].map(function(color) {
|
|
|
|
return color - (darker || 0) * 32;
|
|
|
|
}).join(', ')
|
|
|
|
}
|
|
|
|
return $div;
|
2011-05-07 17:25:34 +00:00
|
|
|
}
|
2011-05-09 08:54:52 +00:00
|
|
|
});
|
|
|
|
});
|