提交 19bf4d48 编写于 作者: 1 100pah

test: add test facility.

上级 1b43577c
......@@ -169,7 +169,7 @@
var stack = ctx.stack();
for (var i = 0; i < stack.length; i++) {
var line = stack[i];
content.push(JSON.stringify(line), '\n');
content.push(JSON.stringify(line), ',\n');
}
});
contentAraa.style.display = 'block';
......@@ -602,6 +602,44 @@
console.log(elsStr);
};
// opt: {record: JSON, width: number, height: number}
testHelper.reproduceCanteen = function (opt) {
var canvas = document.createElement('canvas');
canvas.style.width = opt.width + 'px';
canvas.style.height = opt.height + 'px';
var dpr = Math.max(window.devicePixelRatio || 1, 1);
canvas.width = opt.width * dpr;
canvas.height = opt.height * dpr;
var ctx = canvas.getContext('2d');
var record = opt.record;
for (var i = 0; i < record.length; i++) {
var line = record[i];
if (line.attr) {
if (!line.hasOwnProperty('val')) {
alertIllegal(line);
}
ctx[line.attr] = line.val;
}
else if (line.method) {
if (!line.hasOwnProperty('arguments')) {
alertIllegal(line);
}
ctx[line.method].apply(ctx, line.arguments);
}
else {
alertIllegal(line);
}
}
function alertIllegal(line) {
throw new Error('Illegal line: ' + JSON.stringify(line));
}
document.body.appendChild(canvas);
};
function createDataTableHTML(data, opt) {
var sourceFormat = detectSourceFormat(data);
var dataTableLimit = opt.dataTableLimit || DEFAULT_DATA_TABLE_LIMIT;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册